Method: Milkode#packages

Defined in:
lib/milkode/cdweb/lib/command.rb

#packages(params, before, suburl, locale) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/milkode/cdweb/lib/command.rb', line 109

def packages(params, before, suburl, locale)
  @setting = WebSetting.new
  @title = "Package List"
  @path = ""
  packages = Database.instance.packages(params["sort"])
  @total_records = packages.size
  @locale = locale

  @sort_change_content =
    [
     sort_change_content(params["sort"], I18n.t(:name, locale: @locale)),
     '|',
     sort_change_content(params["sort"], I18n.t(:recently_viewed, locale: @locale), 'viewtime'),
     '|',
     sort_change_content(params["sort"], I18n.t(:added, locale: @locale), 'addtime'),
     '|',
     sort_change_content(params["sort"], I18n.t(:updated, locale: @locale), 'updatetime'),
     '|',
     sort_change_content(params["sort"], I18n.t(:favorite, locale: @locale), 'favtime'),
    ].join("\n")

  @record_content = packages.map do |v|
    "<dt class='result-file'>#{file_or_dirimg(false, suburl)}<a href='#{Mkurl.new(suburl + '/home/' + v, params).inherit_query_shead}'>#{File.basename v}</a></dt>"
  end.join
  @elapsed = Time.now - before
  haml :packages
end