From 0f992c4198e51b41721bfca7497879ab2f6fc1b9 Mon Sep 17 00:00:00 2001 From: Terence Goh Nai Jiu Date: Thu, 21 Apr 2011 11:46:49 -0700 Subject: [PATCH] Adding Slim view support --- app/views/kaminari/_first_page.html.slim | 9 +++++++++ app/views/kaminari/_gap.html.slim | 8 ++++++++ app/views/kaminari/_last_page.html.slim | 9 +++++++++ app/views/kaminari/_next_page.html.slim | 9 +++++++++ app/views/kaminari/_page.html.slim | 10 ++++++++++ app/views/kaminari/_paginator.html.slim | 19 +++++++++++++++++++ app/views/kaminari/_prev_page.html.slim | 9 +++++++++ 7 files changed, 73 insertions(+) create mode 100644 app/views/kaminari/_first_page.html.slim create mode 100644 app/views/kaminari/_gap.html.slim create mode 100644 app/views/kaminari/_last_page.html.slim create mode 100644 app/views/kaminari/_next_page.html.slim create mode 100644 app/views/kaminari/_page.html.slim create mode 100644 app/views/kaminari/_paginator.html.slim create mode 100644 app/views/kaminari/_prev_page.html.slim diff --git a/app/views/kaminari/_first_page.html.slim b/app/views/kaminari/_first_page.html.slim new file mode 100644 index 0000000..41e94ca --- /dev/null +++ b/app/views/kaminari/_first_page.html.slim @@ -0,0 +1,9 @@ +/ Link to the "First" page + - available local variables + url : url to the first page + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span.first + == link_to_unless(current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote) diff --git a/app/views/kaminari/_gap.html.slim b/app/views/kaminari/_gap.html.slim new file mode 100644 index 0000000..36dda5d --- /dev/null +++ b/app/views/kaminari/_gap.html.slim @@ -0,0 +1,8 @@ +/ Non-link tag that stands for skipped pages... + - available local variables + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span.page.gap + == raw(t 'views.pagination.truncate') diff --git a/app/views/kaminari/_last_page.html.slim b/app/views/kaminari/_last_page.html.slim new file mode 100644 index 0000000..211b239 --- /dev/null +++ b/app/views/kaminari/_last_page.html.slim @@ -0,0 +1,9 @@ +/ Link to the "Last" page + - available local variables + url : url to the last page + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span.last + == link_to_unless(current_page.last?, raw(t 'views.pagination.last'), url, { :remote => remote }) diff --git a/app/views/kaminari/_next_page.html.slim b/app/views/kaminari/_next_page.html.slim new file mode 100644 index 0000000..0a86d06 --- /dev/null +++ b/app/views/kaminari/_next_page.html.slim @@ -0,0 +1,9 @@ +/ Link to the "Next" page + - available local variables + url : url to the next page + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span.next + == link_to_unless(current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote) diff --git a/app/views/kaminari/_page.html.slim b/app/views/kaminari/_page.html.slim new file mode 100644 index 0000000..be02257 --- /dev/null +++ b/app/views/kaminari/_page.html.slim @@ -0,0 +1,10 @@ +/ Link showing page number + - available local variables + page : a page object for "this" page + url : url to this page + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span class="page#{' current' if page.current?}" + == link_to_unless(page.current?, page, url, { :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil }) diff --git a/app/views/kaminari/_paginator.html.slim b/app/views/kaminari/_paginator.html.slim new file mode 100644 index 0000000..7981f34 --- /dev/null +++ b/app/views/kaminari/_paginator.html.slim @@ -0,0 +1,19 @@ +/ The container tag + - available local variables + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote + paginator : the paginator that renders the pagination tags inside + +== paginator.render do + div.nav.pagination + == first_page_tag unless current_page.first? + == prev_page_tag unless current_page.first? + - each_page do |page| + - if page.left_outer? || page.right_outer? || page.inside_window? + == page_tag page + - elsif !page.was_truncated? + == gap_tag + == next_page_tag unless current_page.last? + == last_page_tag unless current_page.last? diff --git a/app/views/kaminari/_prev_page.html.slim b/app/views/kaminari/_prev_page.html.slim new file mode 100644 index 0000000..d955471 --- /dev/null +++ b/app/views/kaminari/_prev_page.html.slim @@ -0,0 +1,9 @@ +/ Link to the "Previous" page + - available local variables + url : url to the previous page + current_page : a page object for the currently displayed page + num_pages : total number of pages + per_page : number of items to fetch per page + remote : data-remote +span.prev + == link_to_unless(current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote)