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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d531f35faa53cf7b45c3d997b970b9d7cd87563b
4
- data.tar.gz: bdf08a288b49ff0b92dd470bbcbce8860df4d273
3
+ metadata.gz: f3dadd52a9a10e3c7b3747a538a9367314c58826
4
+ data.tar.gz: 6c416a0f26fd62050dd4049294677381a5f12dc7
5
5
  SHA512:
6
- metadata.gz: 99ff6ae62664253974619a70649f3ff00f1b85211223db3a8ede640c959438f41493f34ea6327ecd7164f694c312c5a869f87cf5c3fac6cc8a57777e034d33d8
7
- data.tar.gz: b3646d00a1ee0a5c8ed3c5dc4e56e7de9b16513d17c1ab80a1bb20bc8cb37bd2630c5ab443508d3f17473b4dc0ad0262f32945916191a68ae493cf382f97f022
6
+ metadata.gz: 1a7ef8200c6558470a1f08f46c3ebb7368e19538243c9be273a2bac49cff85063acec29d26b484715d131d43fde84f30c56c4e9d7399245e6540d2e50647380b
7
+ data.tar.gz: 3574831e84ee5e026f42623e3629bce9ad4811243ade5595cd26cf050ed7866f1ddf7b033d1d8bf11469cdd2c21f1babe8e262cd77d01cc5e77e8ec4543d9d03
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedcellar-web (0.4.1)
4
+ feedcellar-web (0.4.2)
5
5
  feedcellar (>= 0.6.0)
6
6
  haml
7
7
  kaminari
data/NEWS.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.4.2: 2016-02-17
4
+
5
+ ### Changes
6
+
7
+ #### Improvements
8
+
9
+ * Always paginate without "page" parameter.
10
+ * Paginate in Rroonga.
11
+
3
12
  ## 0.4.1: 2016-02-17
4
13
 
5
14
  ### Changes
@@ -1,6 +1,6 @@
1
1
  # class Feedcellar::Web::App
2
2
  #
3
- # Copyright (C) 2014-2015 Masafumi Yokoyama <myokoym@gmail.com>
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
- if @feeds and params[:page]
71
- page = params[:page]
72
- n_per_page = options[:n_per_page] || 50
73
- @paginated_feeds = pagenate_feeds(@feeds, page, n_per_page)
74
- end
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
@@ -18,6 +18,6 @@
18
18
 
19
19
  module Feedcellar
20
20
  module Web
21
- VERSION = "0.4.1"
21
+ VERSION = "0.4.2"
22
22
  end
23
23
  end
@@ -1,10 +1,10 @@
1
- - if @paginated_feeds
2
- = paginate(@paginated_feeds)
1
+ - if @feeds.total_pages > 1
2
+ = paginate(@feeds)
3
3
  %ul
4
- - (@paginated_feeds || @feeds).each do |feed|
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 @paginated_feeds
10
- = paginate(@paginated_feeds)
9
+ - if @feeds.total_pages > 1
10
+ = paginate(@feeds)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedcellar-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masafumi Yokoyama