Files
gollum/lib/gollum/views/layout.rb
T
benjamin wil 738d6f6ec4 Start localizing the views (#1797)
* Internationalize `Views::Compare` templates

* Internationalize `Views::Error` templates

* Internationalize `Views::History` templates

* Internationalize `Views::LatestChanges` templates

* Internationalize `Views::Layout` templates

* Internationalize `Views::Overview` templates

* Internationalize `Views::Search` templates

* Reset I18n load path after I18n helper tests

* Create locale helper for global translations

There are some translation strings we should use across multiple views.
Instead of duplicating the translations, we can use a different locale
helper method, `#tt`, to get a hash of all available translations.

Then, in a partial view like `pagination.mustache`, we can render
translations regardless of what the current view class is.

This commit adds the necessary helper, tests, and uses the new method to
render translations on the `pagination.mustache` template, which is used
by many other view classes (latest changes, history, and search).
2022-07-30 17:01:05 -07:00

94 lines
1.5 KiB
Ruby

require 'cgi'
module Precious
module Views
class Layout < Mustache
include Rack::Utils
include Sprockets::Helpers
include Precious::Views::AppHelpers
include Precious::Views::LocaleHelpers
include Precious::Views::SprocketsHelpers
include Precious::Views::RouteHelpers
include Precious::Views::OcticonHelpers
alias_method :h, :escape_html
attr_reader :name, :path
def escaped_name
CGI.escape(@name)
end
def title
t[:title]
end
def has_path
!@path.nil?
end
def base_url
@base_url
end
def custom_path
@base_url
end
def custom_css
clean_url(custom_path, "custom.css")
end
def custom_js
clean_url(custom_path, "custom.js")
end
def mathjax_config_path
page_route(@mathjax_config)
end
def mathjax_js
"#{page_route('gollum/assets/mathjax/MathJax.js')}?config=TeX-AMS-MML_HTMLorMML"
end
def css # custom css
@css
end
def js # custom js
@js
end
def critic_markup
@critic_markup
end
def per_page_uploads
@per_page_uploads
end
def show_local_time
@show_local_time ? 'true' : 'false'
end
# Navigation bar
def search
false
end
def history
false
end
def overview
false
end
def latest_changes
false
end
end
end
end