Created
March 19, 2012 23:41
-
-
Save leucos/2128499 to your computer and use it in GitHub Desktop.
Diff that adds pagination to the todolist app example in Ramaze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/examples/app/todolist/controller/init.rb b/examples/app/todolist/controller/init.rb | |
index d5aaa92..3c74fec 100644 | |
--- a/examples/app/todolist/controller/init.rb | |
+++ b/examples/app/todolist/controller/init.rb | |
@@ -2,6 +2,12 @@ module TodoList | |
class Controller < Ramaze::Controller | |
layout :default | |
engine :Etanni | |
+ helper :paginate | |
+ | |
+ trait :paginate => { | |
+ :var => 'page', | |
+ :limit => 4 | |
+ } | |
map '/', :todolist | |
app.location = '/' | |
diff --git a/examples/app/todolist/controller/task.rb b/examples/app/todolist/controller/task.rb | |
index 7ae2ebc..0170067 100644 | |
--- a/examples/app/todolist/controller/task.rb | |
+++ b/examples/app/todolist/controller/task.rb | |
@@ -3,7 +3,7 @@ module TodoList | |
map '/' | |
def index | |
- @tasks = Task.all | |
+ @tasks = paginate(Task) | |
@title = request[:title] | |
end | |
diff --git a/examples/app/todolist/model/init.rb b/examples/app/todolist/model/init.rb | |
index 434c436..f1595e9 100644 | |
--- a/examples/app/todolist/model/init.rb | |
+++ b/examples/app/todolist/model/init.rb | |
@@ -1,6 +1,7 @@ | |
module TodoList | |
# yeah, we're lazy | |
Sequel::Model.plugin(:schema) | |
+ Sequel.extension(:pagination) | |
# Uncomment the line for the DB you want to use. | |
diff --git a/examples/app/todolist/view/index.xhtml b/examples/app/todolist/view/index.xhtml | |
index bc1dbaf..7ca5b1d 100644 | |
--- a/examples/app/todolist/view/index.xhtml | |
+++ b/examples/app/todolist/view/index.xhtml | |
@@ -26,4 +26,6 @@ | |
</tr> | |
<?r end ?> | |
</table> | |
+ <center>#{@tasks.navigation}</center> | |
<?r end ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment