leaf 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,18 @@
1
1
  = Leaf
2
2
 
3
- A _really_ simple pagination library, heavily based on the agnostic branch
4
- of {will_paginate}[http://github.com/mislav/will_paginate/tree/agnostic]
3
+ A _really_ simple pagination library
4
+
5
+ == Installation
6
+
7
+ The recommended way is that you get the gem
8
+
9
+ gem install leaf
10
+
11
+ == Example usage
12
+
13
+ == Authors and credits
14
+
15
+ Leaf is heavily based on the agnostic branch of
16
+ {will_paginate}[http://github.com/mislav/will_paginate/tree/agnostic].
17
+ will_paginate was originally written by PJ Hyett, who later handed over
18
+ development to Mislav Marohnić. (The library was completely rewritten since then.)
data/Rakefile CHANGED
@@ -11,10 +11,10 @@ desc 'Generate RDoc documentation for the leaf gem.'
11
11
  Rake::RDocTask.new(:rdoc) do |rdoc|
12
12
  rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE').
13
13
  include('lib/**/*.rb').
14
- exclude('lib/will_paginate/finders/sequel.rb').
15
- exclude('lib/will_paginate/view_helpers/sinatra.rb').
16
- exclude('lib/will_paginate/core_ext.rb').
17
- exclude('lib/will_paginate/version.rb')
14
+ exclude('lib/leaf/finders/sequel.rb').
15
+ exclude('lib/leaf/view_helpers/sinatra.rb').
16
+ exclude('lib/leaf/core_ext.rb').
17
+ exclude('lib/leaf/version.rb')
18
18
 
19
19
  rdoc.main = "README.rdoc" # page to start on
20
20
  rdoc.title = "leaf documentation"
@@ -5,6 +5,11 @@
5
5
  # Leaf::Collection.
6
6
  #
7
7
  # Happy paginating!
8
- module Leaf
9
- require 'leaf/view_helpers/sinatra'
8
+ module Leaf
9
+ require 'leaf/version'
10
+
11
+ # Load the helpers for sinatra
12
+ if defined?(Sinatra)
13
+ require 'leaf/view_helpers/sinatra'
14
+ end
10
15
  end
@@ -1,5 +1,6 @@
1
1
  require 'sequel'
2
2
  require 'sequel/extensions/pagination'
3
+ require 'leaf/core_ext'
3
4
 
4
5
  existing_methods = Sequel::Dataset::Pagination.instance_methods
5
6
 
@@ -1,9 +1,9 @@
1
1
  module Leaf
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 2
6
-
4
+ MINOR = 1
5
+ TINY = 0
6
+
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
  end
@@ -1,6 +1,12 @@
1
+ require 'i18n'
1
2
  require 'leaf/core_ext'
2
3
  require 'leaf/view_helpers'
3
4
 
5
+ # REPLACE WITH REAL CODE :)
6
+ ['sv', 'en'].each do |locale|
7
+ I18n.load_path << "locales/#{locale}.yml"
8
+ end
9
+
4
10
  module Leaf
5
11
  module ViewHelpers
6
12
  # = The main view helpers module
@@ -104,16 +110,18 @@ module Leaf
104
110
 
105
111
  if collection.total_pages < 2
106
112
  case collection.size
107
- when 0; "No #{plural_name} found"
108
- when 1; "Displaying #{b}1#{eb} #{entry_name}"
109
- else; "Displaying #{b}all #{collection.size}#{eb} #{plural_name}"
113
+ when 0; I18n::t('leaf.page_entries_info.one_page.nothing', :plural_name => plural_name)
114
+ when 1; I18n::t('leaf.page_entries_info.one_page.one', :b => b, :eb => eb, :entry_name => entry_name)
115
+ else; I18n::t('leaf.page_entries_info.one_page.many', :b => b, :collection_size => collection.size, :eb => eb, :plural_name => plural_name)
110
116
  end
111
117
  else
112
- %{Displaying #{plural_name} #{b}%d#{sp}-#{sp}%d#{eb} of #{b}%d#{eb} in total} % [
113
- collection.offset + 1,
114
- collection.offset + collection.length,
115
- collection.total_entries
116
- ]
118
+ I18n::t('leaf.page_entries_info.default',
119
+ :plural_name => plural_name,
120
+ :b => b, :sp => sp, :eb => eb,
121
+ :from_number => (collection.offset + 1),
122
+ :to_number => (collection.offset + collection.length),
123
+ :total_entries => collection.total_entries
124
+ )
117
125
  end
118
126
  end
119
127
  end
@@ -13,7 +13,7 @@ Leaf::ViewHelpers::LinkRenderer.class_eval do
13
13
  url.gsub(/page=[0-9]+/, "page=#{page}")
14
14
  else
15
15
  (url =~ /\?/) ? url + "&page=#{page}" : url + "?page=#{page}"
16
- end
16
+ end
17
17
  end
18
18
  end
19
19
  end
@@ -0,0 +1,11 @@
1
+ # English
2
+ en:
3
+ leaf:
4
+ next_label: "Next &#8594;"
5
+ previous_label: "&#8592; Previous"
6
+ page_entries_info:
7
+ one_page:
8
+ nothing: "No %{plural_name} found"
9
+ one: "Displaying %{b}1%{eb} %{entry_name}"
10
+ many: "Displaying %{b}all %{collection_size}%{eb} %{plural_name}"
11
+ default: "Displaying %{plural_name} %{b}%{from_number}%{sp}-%{sp}%{to_number}%{eb} of %{b}%{total_entries}%{eb} in total"
@@ -0,0 +1,11 @@
1
+ # Swedish
2
+ sv:
3
+ leaf:
4
+ next_label: "Nästa &#8594;"
5
+ previous_label: "&#8592; Föregående"
6
+ page_entries_info:
7
+ one_page:
8
+ nothing: "Hittade inga %{plural_name}"
9
+ one: "Visar %{b}1%{eb} %{entry_name}"
10
+ many: "Visar %{b}alla %{collection_size}%{eb} %{plural_name}"
11
+ default: "Visar %{plural_name} %{b}%{from_number}%{sp}-%{sp}%{to_number}%{eb} av totalt %{b}%{total_entries}%{eb}"
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Hellberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-24 00:00:00 +02:00
18
+ date: 2010-06-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,22 @@ dependencies:
34
34
  version: 1.2.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: i18n
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 0
48
+ - 4
49
+ - 0
50
+ version: 0.4.0
51
+ type: :runtime
52
+ version_requirements: *id002
37
53
  description: A really simple pagination library for Sinatra
38
54
  email: peter@c7.se
39
55
  executables: []
@@ -57,6 +73,8 @@ files:
57
73
  - lib/leaf/view_helpers/sinatra.rb
58
74
  - lib/leaf/view_helpers.rb
59
75
  - lib/leaf.rb
76
+ - locales/en.yml
77
+ - locales/sv.yml
60
78
  - MIT-LICENSE
61
79
  - Rakefile
62
80
  - README.rdoc