Use default_url_options to generate absolute URLs
In the dev seeds, we were using `Setting["url"]/proposals`, but we can use `proposals_url` instead, similar to what we do in the rest of the application. We can do a similar thing in the sitemap. This way the sitemap will also work on installations who haven't manually set the "url" setting. Since we aren't using `Setting["url"]` anywhere anymore, we're removing it. This setting was mainly redundant, since we already had the `server_name` in the secrets. Furthermore, `server_name` is automatically configured when running the installer, while `Setting["url"]` had to be manually set in the admin section the application was installed. Note we're using `ActionMailer::Base` setting to generate URLs. Sounds a bit strange, but it's a standard way Rails provides to generate URLs outside the context of a request.
This commit is contained in:
@@ -159,7 +159,6 @@ class Setting < ApplicationRecord
|
|||||||
"twitter_handle": nil,
|
"twitter_handle": nil,
|
||||||
"twitter_hashtag": nil,
|
"twitter_hashtag": nil,
|
||||||
"youtube_handle": nil,
|
"youtube_handle": nil,
|
||||||
"url": "http://example.com", # Public-facing URL of the app.
|
|
||||||
# CONSUL installation's organization name
|
# CONSUL installation's organization name
|
||||||
"org_name": "CONSUL",
|
"org_name": "CONSUL",
|
||||||
"meta_title": nil,
|
"meta_title": nil,
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ en:
|
|||||||
telegram_handle_description: "If filled in it will appear in the footer"
|
telegram_handle_description: "If filled in it will appear in the footer"
|
||||||
instagram_handle: "Instagram handle"
|
instagram_handle: "Instagram handle"
|
||||||
instagram_handle_description: "If filled in it will appear in the footer"
|
instagram_handle_description: "If filled in it will appear in the footer"
|
||||||
url: "Main URL"
|
|
||||||
url_description: "Main URL of your website"
|
|
||||||
org_name: "Site name"
|
org_name: "Site name"
|
||||||
org_name_description: "This name will appear on mailers subject, help pages..."
|
org_name_description: "This name will appear on mailers subject, help pages..."
|
||||||
related_content_score_threshold: "Related content score threshold"
|
related_content_score_threshold: "Related content score threshold"
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ es:
|
|||||||
telegram_handle_description: "Si está rellenado aparecerá en el pie de página"
|
telegram_handle_description: "Si está rellenado aparecerá en el pie de página"
|
||||||
instagram_handle: "Usuario de Instagram"
|
instagram_handle: "Usuario de Instagram"
|
||||||
instagram_handle_description: "Si está rellenado aparecerá en el pie de página"
|
instagram_handle_description: "Si está rellenado aparecerá en el pie de página"
|
||||||
url: "URL general de la web"
|
|
||||||
url_description: "URL principal de tu web"
|
|
||||||
org_name: "Nombre del sitio"
|
org_name: "Nombre del sitio"
|
||||||
org_name_description: "Este nombre aparecerá en el asunto de emails, páginas de ayuda..."
|
org_name_description: "Este nombre aparecerá en el asunto de emails, páginas de ayuda..."
|
||||||
related_content_score_threshold: "Umbral de puntuación de contenido relacionado"
|
related_content_score_threshold: "Umbral de puntuación de contenido relacionado"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, ex
|
|||||||
|
|
||||||
# default host
|
# default host
|
||||||
SitemapGenerator::Sitemap.verbose = false if Rails.env.test?
|
SitemapGenerator::Sitemap.verbose = false if Rails.env.test?
|
||||||
SitemapGenerator::Sitemap.default_host = Setting["url"]
|
SitemapGenerator::Sitemap.default_host = root_url(ActionMailer::Base.default_url_options)
|
||||||
|
|
||||||
# sitemap generator
|
# sitemap generator
|
||||||
SitemapGenerator::Sitemap.create do
|
SitemapGenerator::Sitemap.create do
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ section "Creating Admin Notifications & Templates" do
|
|||||||
%i[title body].index_with do |attribute|
|
%i[title body].index_with do |attribute|
|
||||||
-> { I18n.t("seeds.admin_notifications.proposal.#{attribute}") }
|
-> { I18n.t("seeds.admin_notifications.proposal.#{attribute}") }
|
||||||
end
|
end
|
||||||
).merge(link: "#{Setting["url"]}/proposals", segment_recipient: "administrators")
|
).merge(
|
||||||
|
link: Rails.application.routes.url_helpers.proposals_url(ActionMailer::Base.default_url_options),
|
||||||
|
segment_recipient: "administrators"
|
||||||
|
)
|
||||||
).deliver
|
).deliver
|
||||||
|
|
||||||
AdminNotification.create!(
|
AdminNotification.create!(
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ section "Creating Settings" do
|
|||||||
"telegram_handle": "CONSUL",
|
"telegram_handle": "CONSUL",
|
||||||
"twitter_handle": "@consul_dev",
|
"twitter_handle": "@consul_dev",
|
||||||
"twitter_hashtag": "#consul_dev",
|
"twitter_hashtag": "#consul_dev",
|
||||||
"url": "http://localhost:3000",
|
|
||||||
"votes_for_proposal_success": "100",
|
"votes_for_proposal_success": "100",
|
||||||
"youtube_handle": "CONSUL"
|
"youtube_handle": "CONSUL"
|
||||||
}.each do |name, value|
|
}.each do |name, value|
|
||||||
|
|||||||
Reference in New Issue
Block a user