diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:43:13 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:48:28 +0200 |
| commit | 95e5fe8b8fb1e16c71ffbed6681ab8b2203249d4 (patch) | |
| tree | 0f6dc99d031a499befbbcbb301b7fd1a62af125b /app | |
| parent | 28399cd9a549cc4edf8c557883c940532821c28d (diff) | |
| download | operum-95e5fe8b8fb1e16c71ffbed6681ab8b2203249d4.tar.gz operum-95e5fe8b8fb1e16c71ffbed6681ab8b2203249d4.zip | |
Add subtitles to pages
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/exports_controller.rb | 1 | ||||
| -rw-r--r-- | app/controllers/searches_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/shared_searches_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/tags_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/things_controller.rb | 2 | ||||
| -rw-r--r-- | app/helpers/layout_helper.rb | 14 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 2 |
7 files changed, 25 insertions, 1 deletions
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb index 812cf39..4b809c9 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -36,6 +36,7 @@ class ExportsController < ApplicationController else Search.find(params[:search_id]) end + @subtitle = @search.name end def set_results diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index 376455c..a01fd59 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -14,6 +14,7 @@ class SearchesController < ApplicationController def new @search = Search.new + @subtitle = I18n.t('searches.title') end def edit; end @@ -52,6 +53,7 @@ class SearchesController < ApplicationController def set_search @search = Search.find(params[:id]) + @subtitle = @search.name end def search_params diff --git a/app/controllers/shared_searches_controller.rb b/app/controllers/shared_searches_controller.rb index ca65539..ffdd56e 100644 --- a/app/controllers/shared_searches_controller.rb +++ b/app/controllers/shared_searches_controller.rb @@ -6,10 +6,12 @@ class SharedSearchesController < ApplicationController def index @searches = Search.order(:name) @saved_searches = @searches.where(shared: true) + @subtitle = I18n.t('searches.shared.title') end def show @search = Search.where(shared: true).find(params[:search_id]) + @subtitle = @search.name @results = @search.results.values.flatten end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index c5ca6a8..c56b9f9 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -5,10 +5,12 @@ class TagsController < ApplicationController def index @tags = Tag.order(:name) + @subtitle = I18n.t('tags.title') end def new @tag = Tag.new + @subtitle = I18n.t('tags.title') end def edit; end @@ -59,6 +61,7 @@ class TagsController < ApplicationController def search @search = Search.new(name: 'temporary', body: "tag:\"#{@tag.name}\"") + @subtitle = "#{I18n.t('tags.searching-by')} '#{@tag.name}'" render 'searches/show' end diff --git a/app/controllers/things_controller.rb b/app/controllers/things_controller.rb index e994a3d..f9e7674 100644 --- a/app/controllers/things_controller.rb +++ b/app/controllers/things_controller.rb @@ -9,6 +9,7 @@ class ThingsController < ApplicationController def new @thing = Thing.new + @subtitle = I18n.t('activerecord.models.thing') end def edit; end @@ -59,6 +60,7 @@ class ThingsController < ApplicationController def set_thing @thing = Thing.find(params[:id]) + @subtitle = @thing.title end def thing_params diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb new file mode 100644 index 0000000..03917d5 --- /dev/null +++ b/app/helpers/layout_helper.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module LayoutHelper + # Returns a strign containing the string to be used for the <title> HTML tag. + def page_title + title = ENV.fetch('OPERUM_BASE_TITLE', 'Operum') + + if @subtitle + "#{@subtitle} - #{title}" + else + title + end + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 422270d..8a46e3f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ <!DOCTYPE html> <html lang="<%= I18n.default_locale %>"> <head> - <title><%= ENV.fetch('OPERUM_BASE_TITLE', 'Operum') %></title> + <title><%= page_title %></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="author" content="Miquel Sabaté Solà"> |
