Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Refactoring & adding I18n #4

Closed
wants to merge 2 commits into from

2 participants

Papa Pathé SENE Abdelkader Boudih
Papa Pathé SENE

Hi Amatsuda

I refactored the code a little bit. I was using kaminari in a clients project & i needed a custom pagination view the kaminari themes was a quick solution but it lacked I18n so i added it to the project.

JUST GIVING BACK TO OPEN SOURCE

Abdelkader Boudih seuros commented on the diff
github/app/views/kaminari/_prev_page.html.haml
@@ -1,2 +1,2 @@
-~ link_to_unless current_page.first?, raw('« Newer'), url, :remote => remote do |name|
+~ link_to_unless current_page.first?, raw(t 'views.pagination.previous') , url, :remote => remote do |name|
Abdelkader Boudih Collaborator
seuros added a note

why using raw ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Abdelkader Boudih seuros closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 24, 2011
  1. Papa Pathé SENE
  2. Papa Pathé SENE

    fix in google prev page erb

    PapePathe authored
This page is out of date. Refresh to see the latest.
1  .gitignore
View
@@ -0,0 +1 @@
+*~
4 github/app/views/kaminari/_next_page.html.erb
View
@@ -1 +1,3 @@
-<%= link_to_unless current_page.last?, raw('Older &raquo;'), url, :remote => remote do |name| -%><span class="disabled"><%= name %></span><% end -%>
+<%= link_to_unless current_page.last?, raw(t 'views.pagination.next') , url, :remote => remote do |name| -%>
+ <span class="disabled"><%= name %></span>
+<% end -%>
2  github/app/views/kaminari/_next_page.html.haml
View
@@ -1,2 +1,2 @@
-~ link_to_unless current_page.last?, raw('Older &raquo;'), url, :remote => remote do |name|
+~ link_to_unless current_page.last?, raw(t 'views.pagination.next') , url, :remote => remote do |name|
~ content_tag :span, name, :class => 'disabled'
4 github/app/views/kaminari/_prev_page.html.erb
View
@@ -1 +1,3 @@
-<%= link_to_unless current_page.first?, raw('&laquo; Newer'), url, :remote => remote do |name| -%><span class="disabled"><%= name %></span><% end -%>
+<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous') , url, :remote => remote do |name| -%>
+ <span class="disabled"><%= name %></span>
+<% end -%>
2  github/app/views/kaminari/_prev_page.html.haml
View
@@ -1,2 +1,2 @@
-~ link_to_unless current_page.first?, raw('&laquo; Newer'), url, :remote => remote do |name|
+~ link_to_unless current_page.first?, raw(t 'views.pagination.previous') , url, :remote => remote do |name|
Abdelkader Boudih Collaborator
seuros added a note

why using raw ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
~ content_tag :span, name, :class => 'disabled'
5 google/app/views/kaminari/_next_page.html.erb
View
@@ -1,5 +1,8 @@
<% if current_page.last? %>
<span class="csb" style="background-position:-96px 0;width:45px"></span>
<% else %>
- <%= link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote %>
+ <%= link_to url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote do %>
+ <span class="csb ch" style="background-position:-96px 0;width:71px"></span>
+ <span style="display:block;margin-left:53px;text-decoration:underline"><%= raw(t 'views.pagination.next') %></span>
+ <% end %>
<% end %>
7 google/app/views/kaminari/_next_page.html.haml
View
@@ -1,4 +1,7 @@
- if current_page.last?
- %span.csb{:style => 'background-position:-96px 0;width:45px'}
+ %span(:class => "csb", :style => 'background-position:-96px 0;width:45px')
- else
- = link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote
+ = link_to url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote do
+ %span(:class => "csb ch", :style => "background-position:-96px 0;width:71px")
+ %span(:style => "display:block;margin-left:53px;text-decoration:underline")
+ = raw(t 'views.pagination.next')
12 google/app/views/kaminari/_page.html.erb
View
@@ -1,5 +1,13 @@
<% if page.current? %>
-<td class="cur"><span class="csb" style="background-position:-53px 0;width:20px"></span><%= page %></td>
+<td class="cur">
+ <span class="csb" style="background-position:-53px 0;width:20px"></span>
+ <%= page %>
+</td>
<% else %>
-<td><%= link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), url, :class => 'fl', :remote => remote %></td>
+<td>
+ <%= link_to url, :class => 'fl', :remote => remote do %>
+ <span class="csb ch" style="background-position:-74px 0;width:20px"></span
+ <%= page %>
+ <% end %>
+</td>
<% end %>
4 google/app/views/kaminari/_page.html.haml
View
@@ -4,4 +4,6 @@
= page
- else
%td<
- = link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), url, :class => 'fl', :remote => remote
+ = link_to url, :class => 'fl', :remote => remote do
+ %span(:class => "csb ch" :style => "background-position:-74px 0;width:20px")
+ = page
18 google/app/views/kaminari/_paginator.html.erb
View
@@ -11,9 +11,17 @@
.b {font-weight:bold}
</style>
<%= paginator.render do -%>
-<table id="nav" style="border-collapse:collapse;text-align:left;direction:ltr;margin:17px auto 0"><tbody><tr valign="top">
-<td class="b"><%= prev_page_tag -%></td>
-<% each_page.select(&:inside_window?).each do |page| %><%= page_tag page -%><% end %>
-<td class="b"><%= next_page_tag -%></td>
-</tr></tbody></table>
+<table id="nav" style="border-collapse:collapse;text-align:left;direction:ltr;margin:17px auto 0">
+ <tbody>
+ <tr valign="top">
+ <td class="b"><%= prev_page_tag -%></td>
+ <% each_page.select(&:inside_window?).each do |page| %>
+ <%= page_tag page -%>
+ <% end %>
+ <td class="b">
+ <%= next_page_tag -%>
+ </td>
+ </tr>
+ </tbody>
+</table>
<% end %>
5 google/app/views/kaminari/_prev_page.html.erb
View
@@ -1,5 +1,8 @@
<% if current_page.first? %>
<span class="csb" style="background-position:-24px 0;width:28px"></span>
<% else %>
- <%= link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote %>
+ <%= link_to url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote do %>
+ <span class="csb ch" style="background-position:0 0;float:right;width:53px"></span>
+ <span style="display:block;margin-right:35px;clear:right;text-decoration:underline"><%= raw(t 'views.pagination.previous') %></span>
+ <% end %>
<% end %>
7 google/app/views/kaminari/_prev_page.html.haml
View
@@ -1,4 +1,7 @@
- if current_page.first?
- %span.csb{:style => 'background-position:-24px 0;width:28px'}
+ %span(:class => "csb", :style => 'background-position:-24px 0;width:28px')
- else
- = link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote
+ = link_to url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote do
+ %span(:class => "csb ch" :style => "background-position:0 0;float:right;width:53px")
+ %span(:style => "display:block;margin-right:35px;clear:right;text-decoration:underline")
+ = raw(t 'views.pagination.next')
Something went wrong with that request. Please try again.