kaminari-core 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.md +31 -0
  4. data/app/views/kaminari/_first_page.html.erb +11 -0
  5. data/app/views/kaminari/_first_page.html.haml +9 -0
  6. data/app/views/kaminari/_first_page.html.slim +10 -0
  7. data/app/views/kaminari/_gap.html.erb +8 -0
  8. data/app/views/kaminari/_gap.html.haml +8 -0
  9. data/app/views/kaminari/_gap.html.slim +9 -0
  10. data/app/views/kaminari/_last_page.html.erb +11 -0
  11. data/app/views/kaminari/_last_page.html.haml +9 -0
  12. data/app/views/kaminari/_last_page.html.slim +10 -0
  13. data/app/views/kaminari/_next_page.html.erb +11 -0
  14. data/app/views/kaminari/_next_page.html.haml +9 -0
  15. data/app/views/kaminari/_next_page.html.slim +10 -0
  16. data/app/views/kaminari/_page.html.erb +12 -0
  17. data/app/views/kaminari/_page.html.haml +10 -0
  18. data/app/views/kaminari/_page.html.slim +11 -0
  19. data/app/views/kaminari/_paginator.html.erb +25 -0
  20. data/app/views/kaminari/_paginator.html.haml +18 -0
  21. data/app/views/kaminari/_paginator.html.slim +19 -0
  22. data/app/views/kaminari/_prev_page.html.erb +11 -0
  23. data/app/views/kaminari/_prev_page.html.haml +9 -0
  24. data/app/views/kaminari/_prev_page.html.slim +10 -0
  25. data/config/locales/kaminari.yml +23 -0
  26. data/kaminari-core.gemspec +23 -0
  27. data/lib/generators/kaminari/config_generator.rb +18 -0
  28. data/lib/generators/kaminari/templates/kaminari_config.rb +12 -0
  29. data/lib/generators/kaminari/views_generator.rb +134 -0
  30. data/lib/kaminari/config.rb +28 -0
  31. data/lib/kaminari/core.rb +23 -0
  32. data/lib/kaminari/core/version.rb +6 -0
  33. data/lib/kaminari/engine.rb +5 -0
  34. data/lib/kaminari/exceptions.rb +4 -0
  35. data/lib/kaminari/helpers/helper_methods.rb +169 -0
  36. data/lib/kaminari/helpers/paginator.rb +189 -0
  37. data/lib/kaminari/helpers/tags.rb +137 -0
  38. data/lib/kaminari/models/array_extension.rb +72 -0
  39. data/lib/kaminari/models/configuration_methods.rb +57 -0
  40. data/lib/kaminari/models/page_scope_methods.rb +80 -0
  41. data/lib/kaminari/railtie.rb +8 -0
  42. metadata +113 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ad3d5396adc51998d690a560dea4308037faee3
4
+ data.tar.gz: 1efdb607e00f8b4a27350074a7b4ff77dfb06dc9
5
+ SHA512:
6
+ metadata.gz: cd23e9feaac1566b0a99c3bcb469a19d1d07134d77fe44b28ca2e3ae938909774bb12f191b98b62344981751e09db04771bbb4c01026a42fb9ddf450885a8171
7
+ data.tar.gz: 14f300e09667f82e8001460febb946dd8a9037f7aa8e7cea28603fa1d6602eaa0ce6095f37ae8273a83aa86cee1aa8e67c49404bdecd6f38a43ccee9095fe8b1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Akira Matsuda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Kaminari::Core
2
+
3
+ Kaminari core libraries.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'kaminari-core'
12
+ ```
13
+
14
+ And bundle.
15
+
16
+
17
+ ## Usage
18
+
19
+ This gem is basically an internal gem that will be automatically bundled from kaminari gem or kaminari adapter gems.
20
+
21
+ See [Kaminari README](https://github.com/amatsuda/kaminari/blob/master/README.md) for the documentation.
22
+
23
+
24
+ ## Contributing
25
+
26
+ Pull requests are welcome on GitHub at https://github.com/amatsuda/kaminari.
27
+
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ <%# Link to the "First" page
2
+ - available local variables
3
+ url: url to the first page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <span class="first">
10
+ <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "First" page
2
+ -# available local variables
3
+ -# url: url to the first page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.first
9
+ = link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote
@@ -0,0 +1,10 @@
1
+ / Link to the "First" page
2
+ - available local variables
3
+ url : url to the first page
4
+ current_page : a page object for the currently displayed page
5
+ total_pages : total number of pages
6
+ per_page : number of items to fetch per page
7
+ remote : data-remote
8
+ span.first
9
+ == link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote
10
+ '
@@ -0,0 +1,8 @@
1
+ <%# Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ total_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ -%>
8
+ <span class="page gap"><%= t('views.pagination.truncate').html_safe %></span>
@@ -0,0 +1,8 @@
1
+ -# Non-link tag that stands for skipped pages...
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ %span.page.gap
8
+ = t('views.pagination.truncate').html_safe
@@ -0,0 +1,9 @@
1
+ / Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page : a page object for the currently displayed page
4
+ total_pages : total number of pages
5
+ per_page : number of items to fetch per page
6
+ remote : data-remote
7
+ span.page.gap
8
+ == t('views.pagination.truncate').html_safe
9
+ '
@@ -0,0 +1,11 @@
1
+ <%# Link to the "Last" page
2
+ - available local variables
3
+ url: url to the last page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <span class="last">
10
+ <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "Last" page
2
+ -# available local variables
3
+ -# url: url to the last page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.last
9
+ = link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote
@@ -0,0 +1,10 @@
1
+ / Link to the "Last" page
2
+ - available local variables
3
+ url : url to the last page
4
+ current_page : a page object for the currently displayed page
5
+ total_pages : total number of pages
6
+ per_page : number of items to fetch per page
7
+ remote : data-remote
8
+ span.last
9
+ == link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote
10
+ '
@@ -0,0 +1,11 @@
1
+ <%# Link to the "Next" page
2
+ - available local variables
3
+ url: url to the next page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <span class="next">
10
+ <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "Next" page
2
+ -# available local variables
3
+ -# url: url to the next page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.next
9
+ = link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote
@@ -0,0 +1,10 @@
1
+ / Link to the "Next" page
2
+ - available local variables
3
+ url : url to the next page
4
+ current_page : a page object for the currently displayed page
5
+ total_pages : total number of pages
6
+ per_page : number of items to fetch per page
7
+ remote : data-remote
8
+ span.next
9
+ == link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote
10
+ '
@@ -0,0 +1,12 @@
1
+ <%# Link showing page number
2
+ - available local variables
3
+ page: a page object for "this" page
4
+ url: url to this page
5
+ current_page: a page object for the currently displayed page
6
+ total_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
9
+ -%>
10
+ <span class="page<%= ' current' if page.current? %>">
11
+ <%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %>
12
+ </span>
@@ -0,0 +1,10 @@
1
+ -# Link showing page number
2
+ -# available local variables
3
+ -# page: a page object for "this" page
4
+ -# url: url to this page
5
+ -# current_page: a page object for the currently displayed page
6
+ -# total_pages: total number of pages
7
+ -# per_page: number of items to fetch per page
8
+ -# remote: data-remote
9
+ %span{class: "page#{' current' if page.current?}"}
10
+ = link_to_unless page.current?, page, url, {remote: remote, rel: page.rel}
@@ -0,0 +1,11 @@
1
+ / Link showing page number
2
+ - available local variables
3
+ page : a page object for "this" page
4
+ url : url to this page
5
+ current_page : a page object for the currently displayed page
6
+ total_pages : total number of pages
7
+ per_page : number of items to fetch per page
8
+ remote : data-remote
9
+ span class="page#{' current' if page.current?}"
10
+ == link_to_unless page.current?, page, url, {remote: remote, rel: page.rel}
11
+ '
@@ -0,0 +1,25 @@
1
+ <%# The container tag
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ total_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ paginator: the paginator that renders the pagination tags inside
8
+ -%>
9
+ <%= paginator.render do -%>
10
+ <nav class="pagination">
11
+ <%= first_page_tag unless current_page.first? %>
12
+ <%= prev_page_tag unless current_page.first? %>
13
+ <% each_page do |page| -%>
14
+ <% if page.display_tag? -%>
15
+ <%= page_tag page %>
16
+ <% elsif !page.was_truncated? -%>
17
+ <%= gap_tag %>
18
+ <% end -%>
19
+ <% end -%>
20
+ <% unless current_page.out_of_range? %>
21
+ <%= next_page_tag unless current_page.last? %>
22
+ <%= last_page_tag unless current_page.last? %>
23
+ <% end %>
24
+ </nav>
25
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ -# The container tag
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ -# paginator: the paginator that renders the pagination tags inside
8
+ = paginator.render do
9
+ %nav.pagination
10
+ = first_page_tag unless current_page.first?
11
+ = prev_page_tag unless current_page.first?
12
+ - each_page do |page|
13
+ - if page.display_tag?
14
+ = page_tag page
15
+ - elsif !page.was_truncated?
16
+ = gap_tag
17
+ = next_page_tag unless current_page.last?
18
+ = last_page_tag unless current_page.last?
@@ -0,0 +1,19 @@
1
+ / The container tag
2
+ - available local variables
3
+ current_page : a page object for the currently displayed page
4
+ total_pages : total number of pages
5
+ per_page : number of items to fetch per page
6
+ remote : data-remote
7
+ paginator : the paginator that renders the pagination tags inside
8
+
9
+ == paginator.render do
10
+ nav.pagination
11
+ == first_page_tag unless current_page.first?
12
+ == prev_page_tag unless current_page.first?
13
+ - each_page do |page|
14
+ - if page.display_tag?
15
+ == page_tag page
16
+ - elsif !page.was_truncated?
17
+ == gap_tag
18
+ == next_page_tag unless current_page.last?
19
+ == last_page_tag unless current_page.last?
@@ -0,0 +1,11 @@
1
+ <%# Link to the "Previous" page
2
+ - available local variables
3
+ url: url to the previous page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <span class="prev">
10
+ <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
11
+ </span>
@@ -0,0 +1,9 @@
1
+ -# Link to the "Previous" page
2
+ -# available local variables
3
+ -# url: url to the previous page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.prev
9
+ = link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote
@@ -0,0 +1,10 @@
1
+ / Link to the "Previous" page
2
+ - available local variables
3
+ url : url to the previous page
4
+ current_page : a page object for the currently displayed page
5
+ total_pages : total number of pages
6
+ per_page : number of items to fetch per page
7
+ remote : data-remote
8
+ span.prev
9
+ == link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote
10
+ '
@@ -0,0 +1,23 @@
1
+ # Sample localization file for Kaminari. You can override these values in your app's locales file if you want.
2
+
3
+ en:
4
+ views:
5
+ pagination:
6
+ first: "&laquo; First"
7
+ last: "Last &raquo;"
8
+ previous: "&lsaquo; Prev"
9
+ next: "Next &rsaquo;"
10
+ truncate: "&hellip;"
11
+ helpers:
12
+ page_entries_info:
13
+ entry:
14
+ zero: "entries"
15
+ one: "entry"
16
+ other: "entries"
17
+ one_page:
18
+ display_entries:
19
+ zero: "No %{entry_name} found"
20
+ one: "Displaying <b>1</b> %{entry_name}"
21
+ other: "Displaying <b>all %{count}</b> %{entry_name}"
22
+ more_pages:
23
+ display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'kaminari/core/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "kaminari-core"
9
+ spec.version = Kaminari::Core::VERSION
10
+ spec.authors = ["Akira Matsuda"]
11
+ spec.email = ["ronnie@dio.jp"]
12
+
13
+ spec.summary = "Kaminari's core pagination library"
14
+ spec.description = 'kaminari-core includes pagination logic independent from ORMs and view libraries'
15
+ spec.homepage = 'https://github.com/amatsuda/kaminari'
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", ">= 1.13"
22
+ spec.add_development_dependency "rake", ">= 10.0"
23
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module Kaminari
3
+ module Generators
4
+ # rails g kaminari:config
5
+ class ConfigGenerator < Rails::Generators::Base # :nodoc:
6
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
7
+
8
+ desc <<DESC
9
+ Description:
10
+ Copies Kaminari configuration file to your application's initializer directory.
11
+ DESC
12
+
13
+ def copy_config_file
14
+ template 'kaminari_config.rb', 'config/initializers/kaminari_config.rb'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ Kaminari.configure do |config|
3
+ # config.default_per_page = 25
4
+ # config.max_per_page = nil
5
+ # config.window = 4
6
+ # config.outer_window = 0
7
+ # config.left = 0
8
+ # config.right = 0
9
+ # config.page_method_name = :page
10
+ # config.param_name = :page
11
+ # config.params_on_first_page = false
12
+ end
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+ module Kaminari
3
+ module Generators
4
+ # rails g kaminari:views THEME
5
+ class ViewsGenerator < Rails::Generators::NamedBase # :nodoc:
6
+ source_root File.expand_path('../../../../app/views/kaminari', __FILE__)
7
+
8
+ class_option :template_engine, type: :string, aliases: '-e', desc: 'Template engine for the views. Available options are "erb", "haml", and "slim".'
9
+ class_option :views_prefix, type: :string, desc: 'Prefix for path to put views in.'
10
+
11
+ def self.banner #:nodoc:
12
+ <<-BANNER.chomp
13
+ rails g kaminari:views THEME [options]
14
+
15
+ Copies all paginator partial templates to your application.
16
+ You can choose a template THEME by specifying one from the list below:
17
+
18
+ - default
19
+ The default one.
20
+ This one is used internally while you don't override the partials.
21
+ #{themes.map {|t| " - #{t.name}\n#{t.description}"}.join("\n")}
22
+ BANNER
23
+ end
24
+
25
+ desc ''
26
+ def copy_or_fetch #:nodoc:
27
+ return copy_default_views if file_name == 'default'
28
+
29
+ if (theme = self.class.themes.detect {|t| t.name == file_name})
30
+ if download_templates(theme).empty?
31
+ say "template_engine: #{template_engine} is not available for theme: #{file_name}"
32
+ end
33
+ else
34
+ say "no such theme: #{file_name}\n available themes: #{self.class.themes.map(&:name).join ', '}"
35
+ end
36
+ end
37
+
38
+ private
39
+ def self.themes
40
+ @themes ||= GitHubApiHelper.get_files_in_master.group_by {|fn, _| fn[0...(fn.index('/') || 0)]}.delete_if {|fn, _| fn.blank?}.map do |name, files|
41
+ Theme.new name, files
42
+ end
43
+ rescue SocketError
44
+ []
45
+ end
46
+
47
+ def download_templates(theme)
48
+ theme.templates_for(template_engine).each do |template|
49
+ say " downloading #{template.name} from kaminari_themes..."
50
+ create_file view_path_for(template.name), GitHubApiHelper.get_content_for("#{theme.name}/#{template.name}")
51
+ end
52
+ end
53
+
54
+ def copy_default_views
55
+ filename_pattern = File.join self.class.source_root, "*.html.#{template_engine}"
56
+ Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
57
+ copy_file f, view_path_for(f)
58
+ end
59
+ end
60
+
61
+ def view_path_for(file)
62
+ ['app', 'views', views_prefix, 'kaminari', File.basename(file)].compact.join('/')
63
+ end
64
+
65
+ def views_prefix
66
+ options[:views_prefix].try(:to_s)
67
+ end
68
+
69
+ def template_engine
70
+ engine = options[:template_engine].try(:to_s).try(:downcase)
71
+
72
+ if engine == 'haml' || engine == 'slim'
73
+ ActiveSupport::Deprecation.warn 'The -e option is deprecated and will be removed in the near future. Please use the html2slim gem or the html2haml gem ' \
74
+ 'to convert erb templates manually.'
75
+ end
76
+
77
+ engine || 'erb'
78
+ end
79
+ end
80
+
81
+ Template = Struct.new(:name, :sha) do
82
+ def description?
83
+ name == 'DESCRIPTION'
84
+ end
85
+
86
+ def view?
87
+ name =~ /^app\/views\//
88
+ end
89
+
90
+ def engine #:nodoc:
91
+ File.extname(name).sub(/^\./, '')
92
+ end
93
+ end
94
+
95
+ class Theme
96
+ attr_accessor :name
97
+ def initialize(name, templates) #:nodoc:
98
+ @name, @templates = name, templates.map {|fn, sha| Template.new fn.sub(/^#{name}\//, ''), sha}
99
+ end
100
+
101
+ def description #:nodoc:
102
+ file = @templates.detect(&:description?)
103
+ return "#{' ' * 12}#{name}" unless file
104
+ GitHubApiHelper.get_content_for("#{@name}/#{file.name}").chomp.gsub(/^/, ' ' * 12)
105
+ end
106
+
107
+ def templates_for(template_engine) #:nodoc:
108
+ @templates.select {|t| t.engine == template_engine }
109
+ end
110
+ end
111
+
112
+ module GitHubApiHelper
113
+ def get_files_in_master
114
+ master_tree_sha = open('https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master') do |json|
115
+ ActiveSupport::JSON.decode(json.read)['object']['sha']
116
+ end
117
+ open('https://api.github.com/repos/amatsuda/kaminari_themes/git/trees/' + master_tree_sha + '?recursive=1') do |json|
118
+ blobs = ActiveSupport::JSON.decode(json.read)['tree'].find_all {|i| i['type'] == 'blob' }
119
+ blobs.map do |blob|
120
+ [blob['path'], blob['sha']]
121
+ end
122
+ end
123
+ end
124
+ module_function :get_files_in_master
125
+
126
+ def get_content_for(path)
127
+ open('https://api.github.com/repos/amatsuda/kaminari_themes/contents/' + path) do |json|
128
+ Base64.decode64(ActiveSupport::JSON.decode(json.read)['content'])
129
+ end
130
+ end
131
+ module_function :get_content_for
132
+ end
133
+ end
134
+ end