Changeset 8411
- Timestamp:
- 03/26/08 23:15:09 (5 years ago)
- Location:
- lang/ruby/fastladder_mobile/trunk/app
- Files:
-
- 1 added
- 3 modified
-
controllers/mobile_controller.rb (modified) (4 diffs)
-
views/mobile/_item.rhtml (modified) (1 diff)
-
views/mobile/_subs.rhtml (added)
-
views/mobile/index.rhtml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/fastladder_mobile/trunk/app/controllers/mobile_controller.rb
r7589 r8411 2 2 verify :session => :member, :redirect_to => "/mobile/login", :except => :login 3 3 after_filter OutputCompressionFilter 4 5 # 一度に表示するフィード/記事の上限に関する設定 6 MAX_FEED_COUNT = 20 # フィードの件数 7 # 合計の件数とサイズは越えた時点でループを止めるため設定値=上限ではない 8 MAX_TOTAL_ITEM_COUNT = 20 # 記事の件数の合計、0なら無制限 9 MAX_TOTAL_ITEM_SIZE = 30000 # 記事本文のHTMLとしての文字数の合計、0なら無制限 4 10 5 11 def login … … 21 27 22 28 def index 23 conditions = ["has_unread = ?", true] 24 @subs = member.subscriptions.find(:first, :conditions => conditions, 25 :order => "subscriptions.rate DESC, subscriptions.id ASC", 26 :include => [:folder, { :feed => :crawl_status }]) 27 @items = get_items @subs 29 feed_count = 0 30 item_count = 0 31 item_size = 0 32 @subs = get_unread_subs 33 @items = Array.new 34 35 if @subs.size > 0 36 for feed in @subs 37 items = get_items(feed) 38 item_count += items.length 39 item_size += items.inject(0) {|t, i| t + i.body.size } 40 @items << items 41 feed_count += 1 42 43 if item_count >= MAX_TOTAL_ITEM_COUNT || 44 item_size >= MAX_TOTAL_ITEM_SIZE 45 break 46 end 47 end 48 else 49 render :text => "No unread feeds." 50 return 51 end 52 53 if @subs.size > feed_count 54 @subs = @subs.slice(0, feed_count) 55 end 56 @dbg = {:f => feed_count, :i => item_count, :s => item_size } 28 57 end 29 58 … … 31 60 # set pins 32 61 if params[:pins] 33 params[:pins].each { | p|62 params[:pins].each { |p| 34 63 a = p.split("##") 35 64 set_pin(a[0], a[1]) 36 65 } 37 66 end 67 38 68 # set readed 39 touch params[:subs_id] 69 if params[:subs_ids] 70 params[:subs_ids].each { |id| 71 touch id 72 } 73 end 74 40 75 # redirect or end 41 76 if params[:next_feed] … … 59 94 60 95 private 96 def get_unread_subs 97 conditions = ["has_unread = ?", true] 98 limit = MAX_FEED_COUNT >= 1 ? MAX_FEED_COUNT : 0 99 return member.subscriptions.find(:all, :conditions => conditions, 100 :order => "subscriptions.rate DESC, subscriptions.id ASC", 101 :include => [:folder, { :feed => :crawl_status }], 102 :limit => limit) 103 end 104 61 105 def get_items(subs) 62 106 conditions = subs.viewed_on ? ["stored_on >= ?", subs.viewed_on] : nil 63 items = subs.feed.items.find(:all, :conditions => conditions, :order => "created_on DESC, id DESC", :limit => MAX_UNREAD_COUNT) 64 result = { 65 :subscribe_id => @id, 66 :channel => subs.feed, 67 :items => items, 68 } 69 if items.length > 0 70 result[:last_stored_on] = items.max { |a, b| a.stored_on <=> b.stored_on }.stored_on 71 end 72 result[:ignore_notify] = 1 if subs.ignore_notify 73 return result 107 return subs.feed.items.find(:all, :conditions => conditions, :order => "created_on DESC, id DESC", :limit => MAX_UNREAD_COUNT) 74 108 end 75 109 -
lang/ruby/fastladder_mobile/trunk/app/views/mobile/_item.rhtml
r7412 r8411 8 8 <tr> 9 9 <td> 10 <label for="chk_<%= item_counter %>">11 <input id="chk_<%= item_counter %>" type="checkbox" name="pins[]" value="<%=h item.link + "##" + item.title%>">10 <label for="chk_<%= subs_id %>-<%= item_counter %>"> 11 <input id="chk_<%= subs_id %>-<%= item_counter %>" type="checkbox" name="pins[]" value="<%=h item.link + "##" + item.title%>"> 12 12 Pin 13 13 </label> -
lang/ruby/fastladder_mobile/trunk/app/views/mobile/index.rhtml
r7412 r8411 1 1 <% form_tag('/mobile/next', :method => :post) do %> 2 <div class="title">3 <h1><%= link_to @subs.feed.title, @subs.feed.link %></h1>4 <p>5 <%= @items[:items].size %> new item(s).6 Rate : <%= @subs.rate %>7 <%= submit_tag 'Go Next Feed', {:id => "next_feed", :name => "next_feed"}%>8 <%= submit_tag 'Send Pin Only', {:id => "send_pin", :name => "send_pin"}%>9 </p>10 </div>11 2 12 <%= render(:partial => "item", :collection => @items[:items]) %> 13 <%= hidden_field_tag 'subs_id', @subs.id %> 3 <% @subs.each_index {|i| %> 4 <%= render(:partial => "subs", :object => @subs[i], :locals => {:item_count => @items[i].length}) %> 5 6 <%= render(:partial => "item", :collection => @items[i], :locals => {:subs_id => @subs[i].id}) %> 7 <% } %> 14 8 15 9 <div class="navi"> 16 <%= submit_tag 'Go Next Feed', {:id => "next_feed", :name => "next_feed"}%> 17 <%= submit_tag 'Send Pin Only', {:id => "send_pin", :name => "send_pin"}%> 10 <%= submit_tag 'Next Feed', {:id => "next_feed", :name => "next_feed"}%> 11 <%= submit_tag 'Pin Only', {:id => "send_pin", :name => "send_pin"}%> 12 <br> 13 Feeds:<%= @dbg[:f] %> 14 Items:<%= @dbg[:i] %> 15 Size:<%= @dbg[:s] %> 18 16 </div> 19 17 <% end %>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)