class Servel::Index
Constants
- RENDER_CACHE
Public Class Methods
new(url_root:, url_path:, fs_path:)
click to toggle source
# File lib/servel/index.rb, line 5 def initialize(url_root:, url_path:, fs_path:) @url_root = url_root @url_path = url_path @fs_path = fs_path end
Public Instance Methods
locals()
click to toggle source
# File lib/servel/index.rb, line 19 def locals children = @fs_path.children.map { |path| Servel::EntryFactory.for(path) }.compact { url_root: @url_root, url_path: @url_path, special_entries: special_entries.to_json, directory_entries: children.select(&:directory?).to_json, file_entries: children.select(&:file?).to_json } end
render()
click to toggle source
# File lib/servel/index.rb, line 11 def render RENDER_CACHE.getset(render_cache_key) { Servel::HamlContext.render('index.haml', locals) } end
render_cache_key()
click to toggle source
# File lib/servel/index.rb, line 15 def render_cache_key @render_cache_key ||= [@fs_path.to_s, @fs_path.mtime.to_i].join("-") end
special_entries()
click to toggle source
# File lib/servel/index.rb, line 31 def special_entries list = [] list << Servel::EntryFactory.home("/") if @url_root != "" unless @url_path == "/" list << Servel::EntryFactory.top(@url_root == "" ? "/" : @url_root) list << Servel::EntryFactory.parent("../") end list end