From 40f1e3a30cff1713e794cc97fe87bf245063606b Mon Sep 17 00:00:00 2001 From: Evan Travers Date: Mon, 7 Aug 2017 20:37:42 -0500 Subject: [PATCH 1/3] Add helper to simplify titles I'm headed towards simplifying the layout... and I think that the header system is the first piece that could be DRY'd up. To that end, I'm borrowing a great method for cleaning up the page titles from the blog in references, and implementing it in one place to show y'all what it could do. References: - https://coderwall.com/p/a1pj7w/rails-page-titles-with-the-right-amount-of-magic --- app/helpers/application_helper.rb | 11 +++++++++++ app/views/organizations/index.html.erb | 2 +- config/locales/en.yml | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abfd29a..f47b90d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,4 +13,15 @@ def sortable(column, title=nil) direction = (column == sort_column or join_column == sort_column) && sort_direction == "asc" ? "desc" : "asc" link_to title, params.permit!.merge({:sort => column, :direction => direction}), {:class => css_class} end + + def title + if content_for?(:title) + # allows the title to be set in the view by using t(".title") + content_for :title + else + # look up translation key based on controller path, action name and .title + # this works identical to the built-in lazy lookup + t("#{ controller_path.tr('/', '.') }.#{ action_name }.title", default: :site_name) + end + end end diff --git a/app/views/organizations/index.html.erb b/app/views/organizations/index.html.erb index 31512e3..bf54054 100644 --- a/app/views/organizations/index.html.erb +++ b/app/views/organizations/index.html.erb @@ -3,7 +3,7 @@ New Organization <% end %> -

Listing organizations

+

<%= title %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..4364905 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,4 +20,6 @@ # available at http://guides.rubyonrails.org/i18n.html. en: - hello: "Hello world" + organizations: + index: + title: "Listing Organization" From 4048d228306e67adebee64760f3781ae7fb556cf Mon Sep 17 00:00:00 2001 From: Evan Travers Date: Mon, 7 Aug 2017 20:47:22 -0500 Subject: [PATCH 2/3] Implement new title and content_for Trying to DRY up the views --- app/views/layouts/application.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5ffd154..396c16d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -71,6 +71,12 @@
+ <% if content_for? :page_header %> + + <% end %> <%= yield %>
From 11b90f3496bfededa9d771204d08a69948adfa93 Mon Sep 17 00:00:00 2001 From: Evan Travers Date: Tue, 8 Aug 2017 21:04:54 -0500 Subject: [PATCH 3/3] Move the titles to a helper By moving the titles to a i18n file, we increase the ease of translatability and renaming later if we really need it. --- app/views/check_ins/index.html.erb | 5 +- app/views/check_ins/new.html.erb | 5 +- app/views/cohorts/edit.html.erb | 5 +- app/views/cohorts/index.html.erb | 5 +- app/views/cohorts/new.html.erb | 5 +- app/views/cohorts/show.html.erb | 5 +- app/views/common_tasks/edit.html.erb | 5 +- app/views/common_tasks/index.html.erb | 5 +- app/views/common_tasks/new.html.erb | 5 +- app/views/common_tasks/show.html.erb | 5 +- app/views/communications/edit.html.erb | 5 +- app/views/communications/index.html.erb | 5 +- app/views/communications/new.html.erb | 7 +- app/views/communications/show.html.erb | 5 +- .../extracurricular_activities/edit.html.erb | 5 +- .../extracurricular_activities/index.html.erb | 5 +- .../extracurricular_activities/new.html.erb | 5 +- .../extracurricular_activities/show.html.erb | 5 +- app/views/graduating_classes/edit.html.erb | 5 +- app/views/graduating_classes/index.html.erb | 5 +- app/views/graduating_classes/show.html.erb | 5 +- app/views/identities/edit.html.erb | 5 +- app/views/identities/index.html.erb | 5 +- app/views/identities/new.html.erb | 5 +- app/views/identities/show.html.erb | 5 +- app/views/locations/edit.html.erb | 5 +- app/views/locations/index.html.erb | 5 +- app/views/locations/new.html.erb | 5 +- app/views/locations/show.html.erb | 5 +- app/views/members/edit.html.erb | 5 +- app/views/members/index.html.erb | 5 +- app/views/members/new.html.erb | 5 +- app/views/members/show.html.erb | 7 +- app/views/neighborhoods/edit.html.erb | 5 +- app/views/neighborhoods/index.html.erb | 5 +- app/views/neighborhoods/new.html.erb | 5 +- app/views/neighborhoods/show.html.erb | 5 +- app/views/network_actions/edit.html.erb | 5 +- app/views/network_actions/index.html.erb | 5 +- app/views/network_actions/new.html.erb | 5 +- app/views/network_actions/show.html.erb | 5 +- app/views/network_event_tasks/index.html.erb | 185 ++++++------ app/views/network_event_tasks/update.html.erb | 3 - app/views/network_events/edit.html.erb | 5 +- app/views/network_events/index.html.erb | 269 +++++++++--------- app/views/network_events/new.html.erb | 14 +- app/views/network_events/show.html.erb | 5 +- app/views/organizations/edit.html.erb | 5 +- app/views/organizations/index.html.erb | 5 +- app/views/organizations/new.html.erb | 5 +- app/views/organizations/show.html.erb | 5 +- app/views/programs/edit.html.erb | 5 +- app/views/programs/index.html.erb | 5 +- app/views/programs/new.html.erb | 5 +- app/views/programs/show.html.erb | 5 +- app/views/schools/edit.html.erb | 5 +- app/views/schools/index.html.erb | 5 +- app/views/schools/new.html.erb | 5 +- app/views/schools/show.html.erb | 5 +- app/views/sign_ups/index.html.erb | 7 +- app/views/sign_ups/new.html.erb | 8 +- app/views/talents/edit.html.erb | 5 +- app/views/talents/index.html.erb | 5 +- app/views/talents/new.html.erb | 5 +- app/views/talents/show.html.erb | 5 +- app/views/users/edit.html.erb | 7 +- app/views/users/index.html.erb | 4 - app/views/users/show.html.erb | 5 +- config/locales/en.yml | 150 ++++++++++ 69 files changed, 515 insertions(+), 436 deletions(-) diff --git a/app/views/check_ins/index.html.erb b/app/views/check_ins/index.html.erb index 1153df9..47b06ff 100644 --- a/app/views/check_ins/index.html.erb +++ b/app/views/check_ins/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/check_ins/new.html.erb b/app/views/check_ins/new.html.erb index 7323e57..7452d30 100644 --- a/app/views/check_ins/new.html.erb +++ b/app/views/check_ins/new.html.erb @@ -1,9 +1,8 @@ - +<% end %>
diff --git a/app/views/cohorts/edit.html.erb b/app/views/cohorts/edit.html.erb index a49d17a..39000f7 100644 --- a/app/views/cohorts/edit.html.erb +++ b/app/views/cohorts/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/cohorts/index.html.erb b/app/views/cohorts/index.html.erb index f16d88b..9911a4f 100644 --- a/app/views/cohorts/index.html.erb +++ b/app/views/cohorts/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/cohorts/new.html.erb b/app/views/cohorts/new.html.erb index ec3f74c..1136a09 100644 --- a/app/views/cohorts/new.html.erb +++ b/app/views/cohorts/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/cohorts/show.html.erb b/app/views/cohorts/show.html.erb index 07b289b..a835419 100644 --- a/app/views/cohorts/show.html.erb +++ b/app/views/cohorts/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/common_tasks/edit.html.erb b/app/views/common_tasks/edit.html.erb index a749fa2..0f74698 100644 --- a/app/views/common_tasks/edit.html.erb +++ b/app/views/common_tasks/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/common_tasks/index.html.erb b/app/views/common_tasks/index.html.erb index 4068e4f..ccb2bdc 100644 --- a/app/views/common_tasks/index.html.erb +++ b/app/views/common_tasks/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/common_tasks/new.html.erb b/app/views/common_tasks/new.html.erb index bb2368a..fc82c1e 100644 --- a/app/views/common_tasks/new.html.erb +++ b/app/views/common_tasks/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/common_tasks/show.html.erb b/app/views/common_tasks/show.html.erb index faa68a9..249557b 100644 --- a/app/views/common_tasks/show.html.erb +++ b/app/views/common_tasks/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/communications/edit.html.erb b/app/views/communications/edit.html.erb index 45b1a7e..a35b7d9 100644 --- a/app/views/communications/edit.html.erb +++ b/app/views/communications/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/communications/index.html.erb b/app/views/communications/index.html.erb index 3d5d46b..48ed052 100644 --- a/app/views/communications/index.html.erb +++ b/app/views/communications/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/communications/new.html.erb b/app/views/communications/new.html.erb index 17d8d9b..bc0ea38 100644 --- a/app/views/communications/new.html.erb +++ b/app/views/communications/new.html.erb @@ -1,10 +1,9 @@ - + <%= content_for :title, t(".title", name: @member.name) %> +<% end %> <%= render 'form' %> diff --git a/app/views/communications/show.html.erb b/app/views/communications/show.html.erb index ed133fc..429c88c 100644 --- a/app/views/communications/show.html.erb +++ b/app/views/communications/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Date:
diff --git a/app/views/extracurricular_activities/edit.html.erb b/app/views/extracurricular_activities/edit.html.erb index 15108a2..d971669 100644 --- a/app/views/extracurricular_activities/edit.html.erb +++ b/app/views/extracurricular_activities/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/extracurricular_activities/index.html.erb b/app/views/extracurricular_activities/index.html.erb index c307c6d..b7dc722 100644 --- a/app/views/extracurricular_activities/index.html.erb +++ b/app/views/extracurricular_activities/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/extracurricular_activities/new.html.erb b/app/views/extracurricular_activities/new.html.erb index 311f481..cf867d5 100644 --- a/app/views/extracurricular_activities/new.html.erb +++ b/app/views/extracurricular_activities/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/extracurricular_activities/show.html.erb b/app/views/extracurricular_activities/show.html.erb index 7c4183f..e527ba1 100644 --- a/app/views/extracurricular_activities/show.html.erb +++ b/app/views/extracurricular_activities/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/graduating_classes/edit.html.erb b/app/views/graduating_classes/edit.html.erb index 83c39d0..74a47f2 100644 --- a/app/views/graduating_classes/edit.html.erb +++ b/app/views/graduating_classes/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/graduating_classes/index.html.erb b/app/views/graduating_classes/index.html.erb index ad5aeee..2457dd9 100644 --- a/app/views/graduating_classes/index.html.erb +++ b/app/views/graduating_classes/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/graduating_classes/show.html.erb b/app/views/graduating_classes/show.html.erb index e2719c5..9cc17fb 100644 --- a/app/views/graduating_classes/show.html.erb +++ b/app/views/graduating_classes/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Year:
diff --git a/app/views/identities/edit.html.erb b/app/views/identities/edit.html.erb index 35a0977..6d22e00 100644 --- a/app/views/identities/edit.html.erb +++ b/app/views/identities/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/identities/index.html.erb b/app/views/identities/index.html.erb index 70bc9a7..1fa265b 100644 --- a/app/views/identities/index.html.erb +++ b/app/views/identities/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/identities/new.html.erb b/app/views/identities/new.html.erb index 60a345f..353c206 100644 --- a/app/views/identities/new.html.erb +++ b/app/views/identities/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/identities/show.html.erb b/app/views/identities/show.html.erb index 4383470..c3494ff 100644 --- a/app/views/identities/show.html.erb +++ b/app/views/identities/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 55fcdfb..9239bd6 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index e170487..25efcf6 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 633268a..b0ac01b 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 205d41a..119e24b 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/members/edit.html.erb b/app/views/members/edit.html.erb index 9a06b9d..d7ea70a 100644 --- a/app/views/members/edit.html.erb +++ b/app/views/members/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/members/index.html.erb b/app/views/members/index.html.erb index 6762948..244e8d3 100644 --- a/app/views/members/index.html.erb +++ b/app/views/members/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/members/new.html.erb b/app/views/members/new.html.erb index 37ea253..76f2cf9 100644 --- a/app/views/members/new.html.erb +++ b/app/views/members/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/members/show.html.erb b/app/views/members/show.html.erb index 7a9d1c4..6d460d6 100644 --- a/app/views/members/show.html.erb +++ b/app/views/members/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
First name:
@@ -182,4 +181,4 @@ <% else %> No events attended yet. -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/neighborhoods/edit.html.erb b/app/views/neighborhoods/edit.html.erb index 32797e3..f7f97e2 100644 --- a/app/views/neighborhoods/edit.html.erb +++ b/app/views/neighborhoods/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/neighborhoods/index.html.erb b/app/views/neighborhoods/index.html.erb index 82c9fb3..3cac09d 100644 --- a/app/views/neighborhoods/index.html.erb +++ b/app/views/neighborhoods/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/neighborhoods/new.html.erb b/app/views/neighborhoods/new.html.erb index 2fab0a5..776d43b 100644 --- a/app/views/neighborhoods/new.html.erb +++ b/app/views/neighborhoods/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/neighborhoods/show.html.erb b/app/views/neighborhoods/show.html.erb index 5d2e084..45beb51 100644 --- a/app/views/neighborhoods/show.html.erb +++ b/app/views/neighborhoods/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Name:
diff --git a/app/views/network_actions/edit.html.erb b/app/views/network_actions/edit.html.erb index c175862..f0a8224 100644 --- a/app/views/network_actions/edit.html.erb +++ b/app/views/network_actions/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/network_actions/index.html.erb b/app/views/network_actions/index.html.erb index 0aec3eb..950d9d1 100644 --- a/app/views/network_actions/index.html.erb +++ b/app/views/network_actions/index.html.erb @@ -1,10 +1,9 @@ - +<% end %>
diff --git a/app/views/network_actions/new.html.erb b/app/views/network_actions/new.html.erb index b1d1bf4..ec4e135 100644 --- a/app/views/network_actions/new.html.erb +++ b/app/views/network_actions/new.html.erb @@ -1,9 +1,8 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/network_actions/show.html.erb b/app/views/network_actions/show.html.erb index 433435b..1f27076 100644 --- a/app/views/network_actions/show.html.erb +++ b/app/views/network_actions/show.html.erb @@ -1,4 +1,4 @@ - +<% end %>
Event:
diff --git a/app/views/network_event_tasks/index.html.erb b/app/views/network_event_tasks/index.html.erb index 70a4d30..3d75b3f 100644 --- a/app/views/network_event_tasks/index.html.erb +++ b/app/views/network_event_tasks/index.html.erb @@ -1,104 +1,103 @@ -
@@ -153,4 +152,4 @@
<%= paginate @network_event_tasks %> -
\ No newline at end of file +
diff --git a/app/views/network_event_tasks/update.html.erb b/app/views/network_event_tasks/update.html.erb index 84e8af9..deaebcc 100644 --- a/app/views/network_event_tasks/update.html.erb +++ b/app/views/network_event_tasks/update.html.erb @@ -1,4 +1 @@ -

Find me in app/views/network_event_tasks/update.html.erb

diff --git a/app/views/network_events/edit.html.erb b/app/views/network_events/edit.html.erb index e2b8942..96b0ee0 100644 --- a/app/views/network_events/edit.html.erb +++ b/app/views/network_events/edit.html.erb @@ -1,4 +1,4 @@ - +<% end %> <%= render 'form' %> diff --git a/app/views/network_events/index.html.erb b/app/views/network_events/index.html.erb index 2d32be5..6c047fb 100644 --- a/app/views/network_events/index.html.erb +++ b/app/views/network_events/index.html.erb @@ -1,154 +1,153 @@ -