feedcellar-web 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/NEWS.md +9 -0
- data/lib/feedcellar/web/app.rb +18 -10
- data/lib/feedcellar/web/version.rb +1 -1
- data/lib/feedcellar/web/views/_feeds.haml +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3dadd52a9a10e3c7b3747a538a9367314c58826
|
4
|
+
data.tar.gz: 6c416a0f26fd62050dd4049294677381a5f12dc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a7ef8200c6558470a1f08f46c3ebb7368e19538243c9be273a2bac49cff85063acec29d26b484715d131d43fde84f30c56c4e9d7399245e6540d2e50647380b
|
7
|
+
data.tar.gz: 3574831e84ee5e026f42623e3629bce9ad4811243ade5595cd26cf050ed7866f1ddf7b033d1d8bf11469cdd2c21f1babe8e262cd77d01cc5e77e8ec4543d9d03
|
data/Gemfile.lock
CHANGED
data/NEWS.md
CHANGED
data/lib/feedcellar/web/app.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# class Feedcellar::Web::App
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
3
|
+
# Copyright (C) 2014-2016 Masafumi Yokoyama <myokoym@gmail.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -26,6 +26,16 @@ require "kaminari/sinatra"
|
|
26
26
|
|
27
27
|
module Feedcellar
|
28
28
|
module Web
|
29
|
+
module PaginationProxy
|
30
|
+
def limit_value
|
31
|
+
page_size
|
32
|
+
end
|
33
|
+
|
34
|
+
def total_pages
|
35
|
+
n_pages
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
29
39
|
class App < Sinatra::Base
|
30
40
|
helpers Kaminari::Helpers::SinatraHelpers
|
31
41
|
register Sinatra::CrossOrigin
|
@@ -67,11 +77,13 @@ module Feedcellar
|
|
67
77
|
options[:year] = params[:year].to_i if params[:year]
|
68
78
|
options[:month] = params[:month].to_i if params[:month]
|
69
79
|
@feeds = search(words, options)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
page = (params[:page] || 1).to_i
|
81
|
+
size = (params[:n_per_page] || 50).to_i
|
82
|
+
@feeds = @feeds.paginate([["date", :desc]],
|
83
|
+
page: page,
|
84
|
+
size: size)
|
85
|
+
@feeds.extend(PaginationProxy)
|
86
|
+
@feeds
|
75
87
|
end
|
76
88
|
|
77
89
|
def search(words, options={})
|
@@ -80,10 +92,6 @@ module Feedcellar
|
|
80
92
|
GroongaSearcher.search(database, words, options)
|
81
93
|
end
|
82
94
|
|
83
|
-
def pagenate_feeds(feeds, page, n_per_page)
|
84
|
-
Kaminari.paginate_array(feeds.to_a).page(page).per(n_per_page)
|
85
|
-
end
|
86
|
-
|
87
95
|
def grouping(table)
|
88
96
|
key = "resource"
|
89
97
|
table.group(key).sort_by {|item| item.n_sub_records }.reverse
|
@@ -1,10 +1,10 @@
|
|
1
|
-
- if @
|
2
|
-
= paginate(@
|
1
|
+
- if @feeds.total_pages > 1
|
2
|
+
= paginate(@feeds)
|
3
3
|
%ul
|
4
|
-
-
|
4
|
+
- @feeds.each do |feed|
|
5
5
|
%li
|
6
6
|
%p
|
7
7
|
= feed.date.strftime("%Y-%m-%d")
|
8
8
|
= link_to("#{feed.title} - #{feed.resource.title}", feed.link)
|
9
|
-
- if @
|
10
|
-
= paginate(@
|
9
|
+
- if @feeds.total_pages > 1
|
10
|
+
= paginate(@feeds)
|