Internationalize Views::Overview templates

This commit is contained in:
benjamin wil
2021-12-30 16:07:54 -08:00
parent 1548034a06
commit 489f6d7c0f
3 changed files with 36 additions and 16 deletions
+7
View File
@@ -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}"
+19 -6
View File
@@ -21,25 +21,38 @@
<span class="pr-2">{{{icon}}}</span>
<span><a href="{{url}}">{{name}}</a></span>
{{#allow_editing}}
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path="{{file_path}}" data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trash{{/octicon}}</button>{{/is_file}}
{{/allow_editing}}
{{#is_file}}
<button
class="btn btn-sm float-right delete-file"
data-confirm="{{t.delete_confirmation}}"
data-file-path="{{file_path}}"
>
{{#octicon}}trash{{/octicon}}
</button>
{{/is_file}}
{{/allow_editing}}
</li>
{{/files_folders}}
</ul>
</div>
{{/has_results}}
{{#no_results}}
<p id="no-results">
There are no pages in <strong>{{current_path}}</strong> on <strong>{{ref}}</strong>.
{{t.no_pages_in}}
<strong>{{current_path}}</strong>
{{t.on}}
<strong>{{ref}}</strong>.
</p>
{{/no_results}}
</div>
<div class="pt-4" id="footer">
<a href="#">Back to Top</a>
<a href="#">
{{t.back_to_top}}
</a>
</div>
</div>
+10 -10
View File
@@ -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