From 489f6d7c0fd143c63aa07f61bcd412f8fd947d31 Mon Sep 17 00:00:00 2001 From: benjamin wil Date: Thu, 30 Dec 2021 16:07:54 -0800 Subject: [PATCH] Internationalize `Views::Overview` templates --- lib/gollum/locales/en.yml | 7 +++++++ lib/gollum/templates/overview.mustache | 25 +++++++++++++++++++------ lib/gollum/views/overview.rb | 20 ++++++++++---------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/lib/gollum/locales/en.yml b/lib/gollum/locales/en.yml index afc826e1..416200e9 100644 --- a/lib/gollum/locales/en.yml +++ b/lib/gollum/locales/en.yml @@ -23,3 +23,10 @@ en: title: Latest Changes (Globally) precious/views/layout: title: Home + precious/views/overview: + back_to_top: Back to Top + delete_confirmation: "Are you sure you want to delete %{name}?" + no_pages_in: There are no pages in + on: "on" + title: "Overview of %{ref}" + diff --git a/lib/gollum/templates/overview.mustache b/lib/gollum/templates/overview.mustache index f714621d..d840e0ca 100644 --- a/lib/gollum/templates/overview.mustache +++ b/lib/gollum/templates/overview.mustache @@ -21,25 +21,38 @@ {{{icon}}} {{name}} {{#allow_editing}} - {{#is_file}}{{/is_file}} - {{/allow_editing}} + {{#is_file}} + + {{/is_file}} + {{/allow_editing}} {{/files_folders}} - - + + {{/has_results}} {{#no_results}}

- There are no pages in {{current_path}} on {{ref}}. + {{t.no_pages_in}} + {{current_path}} + {{t.on}} + {{ref}}.

{{/no_results}} diff --git a/lib/gollum/views/overview.rb b/lib/gollum/views/overview.rb index 0c651296..d0e798a4 100644 --- a/lib/gollum/views/overview.rb +++ b/lib/gollum/views/overview.rb @@ -3,11 +3,11 @@ require 'pathname' module Precious module Views class Overview < Layout - attr_reader :results, :ref, :allow_editing, :newable + attr_reader :name, :results, :ref, :allow_editing, :newable HIDDEN_PATHS = ['.gitkeep'] def title - "Overview of #{@ref}" + t[:title] end # def editable @@ -38,21 +38,21 @@ module Precious end end - + def files_folders if has_results files_and_folders = [] - + @results.each do |result| result_path = result.url_path - result_path = result_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil? + result_path = result_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil? if result_path.include?('/') # result contains a folder folder_name = result_path.split('/').first folder_path = @path ? "#{@path}/#{folder_name}" : folder_name folder_url = "#{overview_path}/#{folder_path}/" files_and_folders << {name: folder_name, icon: rocticon('file-directory'), type: 'dir', url: folder_url, is_file: false} - elsif !HIDDEN_PATHS.include?(result_path) + elsif !HIDDEN_PATHS.include?(result_path) file_url = page_route(result.escaped_url_path) files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, file_path: result.escaped_url_path, is_file: true} end @@ -61,7 +61,7 @@ module Precious files_and_folders.uniq{|f| f[:name]}.sort_by!{|f| [f[:type], f[:name]]} end end - + def has_results !@results.empty? @@ -70,12 +70,12 @@ module Precious def no_results @results.empty? end - + def latest_changes true end - - + + end end end