From 0cefd5ddefdf0611b2d6abb5c7f016dd213ff8f0 Mon Sep 17 00:00:00 2001 From: "Matt (IPv4) Cowley" Date: Mon, 4 Jan 2021 15:41:56 +0000 Subject: [PATCH] Add onion location support (#207) * Add initial onion tab * Add some explaining copy * Add to generator * Add strings to language packs * Add external learn more link --- .../generators/conf/website.conf.js | 6 + .../en/templates/domain_sections/index.js | 3 +- .../en/templates/domain_sections/onion.js | 36 ++++++ .../pt-br/templates/domain_sections/index.js | 3 +- .../pt-br/templates/domain_sections/onion.js | 36 ++++++ .../zh-cn/templates/domain_sections/index.js | 3 +- .../zh-cn/templates/domain_sections/onion.js | 36 ++++++ .../zh-tw/templates/domain_sections/index.js | 3 +- .../zh-tw/templates/domain_sections/onion.js | 36 ++++++ src/nginxconfig/scss/_fields.scss | 18 +++ .../templates/domain_sections/index.js | 1 + .../templates/domain_sections/onion.vue | 112 ++++++++++++++++++ 12 files changed, 289 insertions(+), 4 deletions(-) create mode 100644 src/nginxconfig/i18n/en/templates/domain_sections/onion.js create mode 100644 src/nginxconfig/i18n/pt-br/templates/domain_sections/onion.js create mode 100644 src/nginxconfig/i18n/zh-cn/templates/domain_sections/onion.js create mode 100644 src/nginxconfig/i18n/zh-tw/templates/domain_sections/onion.js create mode 100644 src/nginxconfig/templates/domain_sections/onion.vue diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index 828b0c7..dfd7d43 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -150,6 +150,12 @@ export default (domain, domains, global) => { // HTTPS serverConfig.push(...sslConfig(domain, global)); + // Onion location + if (domain.onion.onionLocation.computed) { + serverConfig.push(['# Onion services', '']); + serverConfig.push(['add_header Onion-Location', `http://${domain.onion.onionLocation.computed}$request_uri`]); + } + // HSTS if (!commonHsts(domains) && domain.https.hsts.computed) { serverConfig.push(['# HSTS', '']); diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/index.js b/src/nginxconfig/i18n/en/templates/domain_sections/index.js index 95c3f88..5b2b817 100644 --- a/src/nginxconfig/i18n/en/templates/domain_sections/index.js +++ b/src/nginxconfig/i18n/en/templates/domain_sections/index.js @@ -33,5 +33,6 @@ import reverseProxy from './reverse_proxy'; import routing from './routing'; import server from './server'; import restrict from './restrict'; +import onion from './onion'; -export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict }; +export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion }; diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/onion.js b/src/nginxconfig/i18n/en/templates/domain_sections/onion.js new file mode 100644 index 0000000..6ada5a7 --- /dev/null +++ b/src/nginxconfig/i18n/en/templates/domain_sections/onion.js @@ -0,0 +1,36 @@ +/* +Copyright 2020 DigitalOcean + +This code is licensed under the MIT License. +You may obtain a copy of the License at +https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +const onion = 'Onion'; + +export default { + onion, + onionLocation: `${onion} location`, + provideAnOnionLocationToSetOnionLocationHeader: 'Provide an onion location address to set the Onion-Location header for your site.', + letsVisitorsKnownOnionServicesIsAvailable: 'This lets visitors know that an onion services version of your site is available for Tor browsers.', + learnMoreAboutOnionServices: 'Learn more about Onion services', + onionLocationExpectedToEndWithOnion: 'Onion location addresses normally end with `.onion`.', +}; diff --git a/src/nginxconfig/i18n/pt-br/templates/domain_sections/index.js b/src/nginxconfig/i18n/pt-br/templates/domain_sections/index.js index 95c3f88..5b2b817 100644 --- a/src/nginxconfig/i18n/pt-br/templates/domain_sections/index.js +++ b/src/nginxconfig/i18n/pt-br/templates/domain_sections/index.js @@ -33,5 +33,6 @@ import reverseProxy from './reverse_proxy'; import routing from './routing'; import server from './server'; import restrict from './restrict'; +import onion from './onion'; -export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict }; +export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion }; diff --git a/src/nginxconfig/i18n/pt-br/templates/domain_sections/onion.js b/src/nginxconfig/i18n/pt-br/templates/domain_sections/onion.js new file mode 100644 index 0000000..1d1b509 --- /dev/null +++ b/src/nginxconfig/i18n/pt-br/templates/domain_sections/onion.js @@ -0,0 +1,36 @@ +/* +Copyright 2020 DigitalOcean + +This code is licensed under the MIT License. +You may obtain a copy of the License at +https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +const onion = 'Onion'; + +export default { + onion, + onionLocation: `${onion} location`, // TODO: translate + provideAnOnionLocationToSetOnionLocationHeader: 'Provide an onion location address to set the Onion-Location header for your site.', // TODO: translate + letsVisitorsKnownOnionServicesIsAvailable: 'This lets visitors know that an onion services version of your site is available for Tor browsers.', // TODO: translate + learnMoreAboutOnionServices: 'Learn more about Onion services', // TODO: translate + onionLocationExpectedToEndWithOnion: 'Onion location addresses normally end with `.onion`.', // TODO: translate +}; diff --git a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/index.js b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/index.js index 95c3f88..5b2b817 100644 --- a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/index.js +++ b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/index.js @@ -33,5 +33,6 @@ import reverseProxy from './reverse_proxy'; import routing from './routing'; import server from './server'; import restrict from './restrict'; +import onion from './onion'; -export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict }; +export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion }; diff --git a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/onion.js b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/onion.js new file mode 100644 index 0000000..1d1b509 --- /dev/null +++ b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/onion.js @@ -0,0 +1,36 @@ +/* +Copyright 2020 DigitalOcean + +This code is licensed under the MIT License. +You may obtain a copy of the License at +https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +const onion = 'Onion'; + +export default { + onion, + onionLocation: `${onion} location`, // TODO: translate + provideAnOnionLocationToSetOnionLocationHeader: 'Provide an onion location address to set the Onion-Location header for your site.', // TODO: translate + letsVisitorsKnownOnionServicesIsAvailable: 'This lets visitors know that an onion services version of your site is available for Tor browsers.', // TODO: translate + learnMoreAboutOnionServices: 'Learn more about Onion services', // TODO: translate + onionLocationExpectedToEndWithOnion: 'Onion location addresses normally end with `.onion`.', // TODO: translate +}; diff --git a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/index.js b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/index.js index 95c3f88..5b2b817 100644 --- a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/index.js +++ b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/index.js @@ -33,5 +33,6 @@ import reverseProxy from './reverse_proxy'; import routing from './routing'; import server from './server'; import restrict from './restrict'; +import onion from './onion'; -export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict }; +export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion }; diff --git a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/onion.js b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/onion.js new file mode 100644 index 0000000..1d1b509 --- /dev/null +++ b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/onion.js @@ -0,0 +1,36 @@ +/* +Copyright 2020 DigitalOcean + +This code is licensed under the MIT License. +You may obtain a copy of the License at +https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +const onion = 'Onion'; + +export default { + onion, + onionLocation: `${onion} location`, // TODO: translate + provideAnOnionLocationToSetOnionLocationHeader: 'Provide an onion location address to set the Onion-Location header for your site.', // TODO: translate + letsVisitorsKnownOnionServicesIsAvailable: 'This lets visitors know that an onion services version of your site is available for Tor browsers.', // TODO: translate + learnMoreAboutOnionServices: 'Learn more about Onion services', // TODO: translate + onionLocationExpectedToEndWithOnion: 'Onion location addresses normally end with `.onion`.', // TODO: translate +}; diff --git a/src/nginxconfig/scss/_fields.scss b/src/nginxconfig/scss/_fields.scss index 4263a73..d3d4bb3 100644 --- a/src/nginxconfig/scss/_fields.scss +++ b/src/nginxconfig/scss/_fields.scss @@ -49,6 +49,12 @@ THE SOFTWARE. &.is-aligned-top { align-items: flex-start; + > .field-label { + &.has-margin-top { + margin-top: .75rem; + } + } + > p { @include sailec-medium; @@ -116,6 +122,18 @@ THE SOFTWARE. display: inline-block; font-size: 14px; padding: 0 .5rem; + + &.message { + padding: 0; + + .message-body { + display: inline-block; + } + } + + .fa-external-link-alt { + margin: 0 0 0 .25rem; + } } } diff --git a/src/nginxconfig/templates/domain_sections/index.js b/src/nginxconfig/templates/domain_sections/index.js index 0ca10e6..8f2269e 100644 --- a/src/nginxconfig/templates/domain_sections/index.js +++ b/src/nginxconfig/templates/domain_sections/index.js @@ -32,3 +32,4 @@ export { default as ReverseProxy } from './reverse_proxy'; export { default as Routing } from './routing'; export { default as Logging } from './logging'; export { default as Restrict } from './restrict'; +export { default as Onion } from './onion'; diff --git a/src/nginxconfig/templates/domain_sections/onion.vue b/src/nginxconfig/templates/domain_sections/onion.vue new file mode 100644 index 0000000..aaf4e30 --- /dev/null +++ b/src/nginxconfig/templates/domain_sections/onion.vue @@ -0,0 +1,112 @@ + + + + +