Sha256: 7fb737fadf97722e85b5646e9705a713cfa9cc12bce1a4857517fbef416e35c5
Contents?: true
Size: 1.16 KB
Versions: 14
Compression:
Stored size: 1.16 KB
Contents
# -*- coding: utf-8 -*- # # @file # @brief パッケージ一覧 # @author ongaeshi # @date 2012/05/25 require 'milkode/cdweb/lib/database' module Milkode class PackageList VIEW_NUM = 7 ADD_NUM = 5 UPDATE_NUM = 5 FAV_NUM = 7 def initialize(grndb) @grndb = grndb end # topページへの表示数の調整は結構大切 # view .. 7 # add .. 5 # update .. 5 # fav .. 5 # def top_view grndb_list("viewtime", VIEW_NUM) end def top_add grndb_list("addtime", ADD_NUM) end def top_update grndb_list("updatetime", UPDATE_NUM) end def top_fav a = @grndb.packages.favs.map{|r| r.name} top_list(a[0...FAV_NUM], 'favtime') end def grndb_list(column_name, num) a = @grndb.packages.sort(column_name).map {|r| r.name} top_list(a[0...num], column_name) end def top_list(list, column_name) list = list.map {|v| " <li><a href=\"/home/#{v}\">#{v}</a></li>" }.join("\n") <<EOF <ul class="unstyled_margin"> #{list} <li><a href=\"/home?sort=#{column_name}">next >></a></li> </ul> EOF end end end
Version data entries
14 entries across 14 versions & 1 rubygems