Compare commits

...

1 Commits

Author SHA1 Message Date
google-labs-jules[bot]
e763da0d75 Refactor all areas in app/views/ that reference an ENV variable, to read from a helper or similar central area.
A new helper method `site_name` was created in `app/helpers/application_helper.rb` to provide the value of `ENV['GROWSTUFF_SITE_NAME']`.

All occurrences of `ENV['GROWSTUFF_SITE_NAME']` in the `app/views` directory have been replaced with a call to the new `site_name` helper method.

The `ApplicationHelper` has been included in the `ApplicationMailer` to make the `site_name` helper available to mailer views.
2025-08-31 05:19:23 +00:00
40 changed files with 53 additions and 50 deletions

View File

@@ -97,4 +97,8 @@ module ApplicationHelper
def og_description(description) def og_description(description)
strip_tags(description).split(' ')[0..20].join(' ') strip_tags(description).split(' ')[0..20].join(' ')
end end
def site_name
ENV.fetch('GROWSTUFF_SITE_NAME', 'Growstuff')
end
end end

View File

@@ -1,6 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
helper :application
default from: 'from@example.com' default from: 'from@example.com'
layout 'mailer' layout 'mailer'
end end

View File

@@ -2,7 +2,7 @@
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title %title
Recent activities from #{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) Recent activities from #{@owner ? @owner : 'all members'} (#{site_name})
%link= activities_url %link= activities_url
- @activities.each do |activity| - @activities.each do |activity|
%item %item

View File

@@ -5,7 +5,7 @@
= tag("meta", property: "og:description", content: og_description(@activity.description)) = tag("meta", property: "og:description", content: og_description(@activity.description))
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Activities', activities_path %li.breadcrumb-item= link_to 'Activities', activities_path

View File

@@ -3,7 +3,7 @@
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item.active= link_to 'Admin', admin_path %li.breadcrumb-item.active= link_to 'Admin', admin_path
%h1 Manage #{ENV['GROWSTUFF_SITE_NAME']} %h1 Manage #{site_name}
.row .row
.col-md-4 .col-md-4

View File

@@ -3,7 +3,7 @@
= tag("meta", property: "og:title", content: @alternate_name.name) = tag("meta", property: "og:title", content: @alternate_name.name)
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
%p#notice= notice %p#notice= notice

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']}) %title Recent comments on all posts (#{site_name})
%link= comments_url %link= comments_url
- @comments.each do |comment| - @comments.each do |comment|
%item %item

View File

@@ -18,7 +18,7 @@
- if !@crop.plantings.empty? - if !@crop.plantings.empty?
#{@crop.name.titleize} has been planted #{@crop.name.titleize} has been planted
= pluralize(@crop.plantings.size, "time") = pluralize(@crop.plantings.size, "time")
by #{ENV['GROWSTUFF_SITE_NAME']} members. by #{site_name} members.
- else - else
Nobody is growing this yet. You could be the first! Nobody is growing this yet. You could be the first!
- if @crop.description.present? - if @crop.description.present?

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']}) %title Recently added crops (#{site_name})
%link= crops_url %link= crops_url
- @crops.each do |crop| - @crops.each do |crop|
%item %item

View File

@@ -4,7 +4,7 @@
= tag("meta", property: "og:title", content: @crop.name) = tag("meta", property: "og:title", content: @crop.name)
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :scripts do - content_for :scripts do
= javascript_include_tag "charts" = javascript_include_tag "charts"
@@ -115,7 +115,7 @@
.card .card
.card-body .card-body
%h3 Learn more about #{@crop.name.pluralize} %h3 Learn more about #{@crop.name.pluralize}
%h4.text-muted resources outside #{ENV['GROWSTUFF_SITE_NAME']} %h4.text-muted resources outside #{site_name}
%ul.list-group.list-group-flush %ul.list-group.list-group-flush
%li.list-group-item %li.list-group-item

View File

@@ -1,4 +1,3 @@
- site_name = ENV['GROWSTUFF_SITE_NAME']
%p Hello #{@resource.login_name}, %p Hello #{@resource.login_name},
%p %p

View File

@@ -1,4 +1,3 @@
- site_name = ENV['GROWSTUFF_SITE_NAME']
%p Hello #{@resource.login_name}, %p Hello #{@resource.login_name},
%p %p

View File

@@ -1,4 +1,3 @@
- site_name = ENV['GROWSTUFF_SITE_NAME']
%p Hello #{@resource.login_name}, %p Hello #{@resource.login_name},
%p %p

View File

@@ -4,7 +4,7 @@
%br/ %br/
= render 'devise/shared/error_messages', resource: resource = render 'devise/shared/error_messages', resource: resource
%p Delete your account from #{ENV['GROWSTUFF_SITE_NAME']}. %p Delete your account from #{site_name}.
.form-group .form-group
= f.label :current_password, "Password required to delete", class: 'control-label col-md-2' = f.label :current_password, "Password required to delete", class: 'control-label col-md-2'
.col-md-4 .col-md-4

View File

@@ -32,7 +32,7 @@
.col-md-offset-2.col-md-8.checkbox .col-md-offset-2.col-md-8.checkbox
%label %label
= f.check_box :newsletter = f.check_box :newsletter
Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter Subscribe to the #{site_name} newsletter
.help-block .help-block
= render partial: 'newsletter_blurb' = render partial: 'newsletter_blurb'

View File

@@ -1,4 +1,4 @@
The #{ENV['GROWSTUFF_SITE_NAME']} newsletter is sent out The #{site_name} newsletter is sent out
every few weeks. Check out our every few weeks. Check out our
= link_to 'past newsletters', 'http://blog.growstuff.org/category/newsletter/' = link_to 'past newsletters', 'http://blog.growstuff.org/category/newsletter/'
if you want to see the sort of thing we'll send you. Of course, we'll never spam you if you want to see the sort of thing we'll send you. Of course, we'll never spam you

View File

@@ -1,8 +1,8 @@
.form-page .form-page
.card.form-card .card.form-card
%h1 Join #{ENV['GROWSTUFF_SITE_NAME']} %h1 Join #{site_name}
.card-body .card-body
%p Sign up for a #{ENV['GROWSTUFF_SITE_NAME']} account to track your vegetable garden and connect with other local growers. %p Sign up for a #{site_name} account to track your vegetable garden and connect with other local growers.
%p If you have accessibility issues with the captcha, please contact us via the links in the footer and we will help. %p If you have accessibility issues with the captcha, please contact us via the links in the footer and we will help.
= bootstrap_form_for(resource, as: resource_name, url: registration_path(resource_name), = bootstrap_form_for(resource, as: resource_name, url: registration_path(resource_name),
@@ -24,7 +24,7 @@
to the #{link_to 'Terms of Service', "/policy/tos"} to the #{link_to 'Terms of Service', "/policy/tos"}
%p %p
= f.check_box :newsletter, checked: true, label: "Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter" = f.check_box :newsletter, checked: true, label: "Subscribe to the #{site_name} newsletter"
%p= render partial: 'newsletter_blurb' %p= render partial: 'newsletter_blurb'
= f.submit "Sign up", class: 'btn btn-block btn-success' = f.submit "Sign up", class: 'btn btn-block btn-success'

View File

@@ -5,7 +5,7 @@
= tag("meta", property: "og:title", content: @forum.name) = tag("meta", property: "og:title", content: @forum.name)
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
%h1= @forum.name %h1= @forum.name

View File

@@ -18,7 +18,7 @@
%hr/ %hr/
%p.text-center %p.text-center
#{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're #{site_name} helps you track what you're
harvesting from your home garden and see how productive it is. harvesting from your home garden and see how productive it is.

View File

@@ -1,7 +1,7 @@
- content_for :title, 'GardenTypes' - content_for :title, 'GardenTypes'
%p %p
#{ENV['GROWSTUFF_SITE_NAME']} tracks who's growing what, where. #{site_name} tracks who's growing what, where.
View any garden_type page to see which of our members have used it. View any garden_type page to see which of our members have used it.
.index-cards .index-cards

View File

@@ -7,7 +7,7 @@
= tag("meta", property: "og:title", content: "#{@garden.owner}'s #{@garden}") = tag("meta", property: "og:title", content: "#{@garden.owner}'s #{@garden}")
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Gardens', gardens_path %li.breadcrumb-item= link_to 'Gardens', gardens_path

View File

@@ -2,7 +2,7 @@
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title %title
Recent harvests from #{@owner ||= 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) Recent harvests from #{@owner ||= 'all members'} (#{site_name})
%link= harvests_url %link= harvests_url
- @harvests.each do |harvest| - @harvests.each do |harvest|
%item %item

View File

@@ -5,7 +5,7 @@
= tag("meta", property: "og:title", content: "#{@harvest.crop} harvested by #{@harvest.owner}") = tag("meta", property: "og:title", content: "#{@harvest.crop} harvested by #{@harvest.owner}")
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Harvests', harvests_path %li.breadcrumb-item= link_to 'Harvests', harvests_path

View File

@@ -1,7 +1,7 @@
.row.homepage-blurb .row.homepage-blurb
.col-md-8.info .col-md-8.info
%h1 Growstuff - An open gardening platform %h1 Growstuff - An open gardening platform
%p= t('.intro', site_name: ENV['GROWSTUFF_SITE_NAME']) %p= t('.intro', site_name: site_name)
= render 'stats' = render 'stats'
.col-md-4 .col-md-4
.signup .signup

View File

@@ -1,10 +1,10 @@
- content_for :title do - content_for :title do
= ENV['GROWSTUFF_SITE_NAME'] = site_name
- if member_signed_in? - if member_signed_in?
.row .row
.col-lg-8.col-md-12 .col-lg-8.col-md-12
%h1.display-4= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) %h1.display-4= t('.welcome', site_name: site_name, member_name: current_member)
%p= render 'stats', cached: true %p= render 'stats', cached: true
.col .col

View File

@@ -6,27 +6,27 @@
- else - else
= tag("meta", property: "og:image", content: image_url('facebook-thumbnail.png')) = tag("meta", property: "og:image", content: image_url('facebook-thumbnail.png'))
= tag("meta", property: "og:title", = tag("meta", property: "og:title",
content: (content_for?(:title) ? yield(:title) + " - " : "") + ENV['GROWSTUFF_SITE_NAME']) content: (content_for?(:title) ? yield(:title) + " - " : "") + site_name)
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: root_url) = tag("meta", property: "og:url", content: root_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- if content_for?(:member_rss_login_name) && content_for(:member_rss_slug) - if content_for?(:member_rss_login_name) && content_for(:member_rss_slug)
= auto_discovery_link_tag(:rss, = auto_discovery_link_tag(:rss,
{ controller: "/members", action: 'show', format: "rss", id: yield(:member_rss_slug) }, { controller: "/members", action: 'show', format: "rss", id: yield(:member_rss_slug) },
title: "#{ENV['GROWSTUFF_SITE_NAME']}- #{yield(:member_rss_login_name)}'s posts") title: "#{site_name}- #{yield(:member_rss_login_name)}'s posts")
= auto_discovery_link_tag(:rss, = auto_discovery_link_tag(:rss,
{ controller: "/posts", format: "rss" }, { controller: "/posts", format: "rss" },
title: "#{ENV['GROWSTUFF_SITE_NAME']} - Recent posts from all members") title: "#{site_name} - Recent posts from all members")
= auto_discovery_link_tag(:rss, = auto_discovery_link_tag(:rss,
{ controller: "/crops", format: "rss" }, { controller: "/crops", format: "rss" },
title: "#{ENV['GROWSTUFF_SITE_NAME']} - Recently added crops") title: "#{site_name} - Recently added crops")
= auto_discovery_link_tag(:rss, = auto_discovery_link_tag(:rss,
{ controller: "/plantings", format: "rss" }, { controller: "/plantings", format: "rss" },
title: "#{ENV['GROWSTUFF_SITE_NAME']} - Recent plantings from all members") title: "#{site_name} - Recent plantings from all members")
%title %title
= content_for?(:title) ? yield(:title) + " - #{ENV['GROWSTUFF_SITE_NAME']} " : ENV['GROWSTUFF_SITE_NAME'] = content_for?(:title) ? yield(:title) + " - #{site_name} " : site_name
= csrf_meta_tags = csrf_meta_tags
= stylesheet_link_tag "application", media: "all" = stylesheet_link_tag "application", media: "all"

View File

@@ -1,8 +1,8 @@
= content_for :title, t(".title", site_name: ENV['GROWSTUFF_SITE_NAME']) = content_for :title, t(".title", site_name: site_name)
%h1 %h1
= member_icon = member_icon
= t(".title", site_name: ENV['GROWSTUFF_SITE_NAME']) = t(".title", site_name: site_name)
= bootstrap_form_tag(url: members_path, method: :get, layout: :inline) do |f| = bootstrap_form_tag(url: members_path, method: :get, layout: :inline) do |f|
= f.select "sort", = f.select "sort",
options_for_select({ "alphabetically": 'alpha', "recently joined": "recently_joined" }, options_for_select({ "alphabetically": 'alpha', "recently joined": "recently_joined" },

View File

@@ -5,7 +5,7 @@
= tag("meta", property: "og:title", content: @member.login_name) = tag("meta", property: "og:title", content: @member.login_name)
= tag("meta", property: "og:type", content: "profile") = tag("meta", property: "og:type", content: "profile")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :member_rss_login_name, @member.login_name - content_for :member_rss_login_name, @member.login_name
- content_for :member_rss_slug, @member.slug - content_for :member_rss_slug, @member.slug

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title #{@member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']}) %title #{@member.login_name}'s recent posts (#{site_name})
%link= member_url(@member) %link= member_url(@member)
- @member.posts.each do |post| - @member.posts.each do |post|
%item %item

View File

@@ -1,4 +1,4 @@
%p %p
The #{ENV['GROWSTUFF_SITE_NAME']} team. The #{site_name} team.
%br/ %br/
= link_to root_url, root_url = link_to root_url, root_url

View File

@@ -6,7 +6,7 @@
%p %p
= @request.requester.login_name = @request.requester.login_name
has requested a new crop on has requested a new crop on
= ENV['GROWSTUFF_SITE_NAME'] = site_name
%ul %ul
%li Name: #{@request.name} %li Name: #{@request.name}

View File

@@ -5,7 +5,7 @@
= tag("meta", property: "og:image:user_generated", content: "true") = tag("meta", property: "og:image:user_generated", content: "true")
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Photos', photos_path %li.breadcrumb-item= link_to 'Photos', photos_path

View File

@@ -2,7 +2,7 @@
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title %title
Recent plantings from #{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) Recent plantings from #{@owner ? @owner : 'all members'} (#{site_name})
%link= plantings_url %link= plantings_url
- @plantings.each do |planting| - @plantings.each do |planting|
%item %item

View File

@@ -6,7 +6,7 @@
= tag("meta", property: "og:description", content: og_description(@planting.description)) = tag("meta", property: "og:description", content: og_description(@planting.description))
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Plantings', plantings_path %li.breadcrumb-item= link_to 'Plantings', plantings_path

View File

@@ -2,7 +2,7 @@
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title %title
Recent posts from #{@author ? @author : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) Recent posts from #{@author ? @author : 'all members'} (#{site_name})
%link= posts_url %link= posts_url
- @posts.each do |post| - @posts.each do |post|
%item %item

View File

@@ -6,13 +6,13 @@
= tag("meta", property: "og:title", content: @post.subject) = tag("meta", property: "og:title", content: @post.subject)
= tag("meta", property: "og:type", content: "article") = tag("meta", property: "og:type", content: "article")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- if @post.author && !current_member - if @post.author && !current_member
.alert.alert-info .alert.alert-info
= link_to @post.author.login_name, member_path(@post.author) = link_to @post.author.login_name, member_path(@post.author)
is using is using
= link_to ENV["GROWSTUFF_SITE_NAME"], root_path = link_to site_name, root_path
to discuss #{@post.subject} with a community of food gardeners worldwide. to discuss #{@post.subject} with a community of food gardeners worldwide.
We have advice on growing We have advice on growing
= succeed "," do = succeed "," do
@@ -20,7 +20,7 @@
and a community from all around the world. and a community from all around the world.
= render "shared/signin_signup", = render "shared/signin_signup",
to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" to: "or to start using #{site_name} to track what you're planting and harvesting"
- content_for :buttonbar do - content_for :buttonbar do
- if @post.comments.count > 10 && can?(:create, Comment) - if @post.comments.count > 10 && can?(:create, Comment)

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title Recent comments on #{@post.subject} (#{ENV['GROWSTUFF_SITE_NAME']}) %title Recent comments on #{@post.subject} (#{site_name})
%link= post_url(@post) %link= post_url(@post)
- @post.comments.each do |comment| - @post.comments.each do |comment|
%item %item

View File

@@ -2,7 +2,7 @@
%rss{ version: 2.0 } %rss{ version: 2.0 }
%channel %channel
%title %title
Recent seeds from #{@owner ||= 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) Recent seeds from #{@owner ||= 'all members'} (#{site_name})
%link= seeds_url %link= seeds_url
- @seeds.each do |seed| - @seeds.each do |seed|
%item %item

View File

@@ -6,7 +6,7 @@
= tag("meta", property: "og:image", content: "#{@seed.owner}'s #{@seed.crop} seeds") = tag("meta", property: "og:image", content: "#{@seed.owner}'s #{@seed.crop} seeds")
= tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:type", content: "website")
= tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) = tag("meta", property: "og:site_name", content: site_name)
- content_for :breadcrumbs do - content_for :breadcrumbs do

View File

@@ -0,0 +1 @@
%h1 Support #{site_name}