GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/zmack/mephisto.git
Switch to will_paginate plugin [Mislav]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2902 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Thu Jun 14 08:11:24 -0700 2007
commit  ac57a508d1ccbd05cdd1737eeab79148f05136a3
tree    8ef5bf9fe6ed3c62437d3ab2a7045b44c683ead4
parent  687ced52aa5d8484fe6f2ecf0cc253a619e9d704
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Switch to will_paginate plugin [Mislav]
0
+
0
 * unit test fixes for those not using mysql or psql [Mislav]
0
 
0
 * add comment moderation links to the overview [court3nay]
...
14
15
16
17
18
19
20
 
 
21
22
23
...
14
15
16
 
 
 
 
17
18
19
20
21
0
@@ -14,10 +14,8 @@ class Admin::ArticlesController < Admin::BaseController
0
   before_filter :load_sections, :only => [:new, :edit]
0
 
0
   def index
0
- @article_pages = Paginator.new self, site.articles.count(:all, article_options), 30, params[:page]
0
- @articles = site.articles.find(:all, article_options(:order => 'contents.published_at DESC', :select => 'contents.*',
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset))
0
+ @articles = site.articles.paginate(article_options(:order => 'contents.published_at DESC', :select => 'contents.*',
0
+ :page => params[:page], :per_page => params[:per_page]))
0
     
0
     @comments = @site.unapproved_comments.count :all, :group => :article, :order => '1 desc'
0
     @sections = site.sections.find(:all)
...
85
86
87
88
 
 
89
90
91
 
 
92
93
94
95
 
96
97
98
...
85
86
87
 
88
89
90
 
 
91
92
93
94
95
 
96
97
98
99
0
@@ -85,14 +85,15 @@ class Admin::AssetsController < Admin::BaseController
0
 
0
     def search_assets(limit)
0
       @types = params[:filter].blank? ? [] : params[:filter].keys
0
- @asset_pages = Paginator.new self, count_by_conditions, limit, params[:page]
0
+ options = search_options.merge(:per_page => limit, :page => params[:page], :total_entries => count_by_conditions)
0
+
0
       @assets = @types.any? ?
0
- site.assets.find_all_by_content_types(@types, :all, search_options) :
0
- site.assets.find(:all, search_options)
0
+ site.assets.paginate_by_content_types(@types, :all, options) :
0
+ site.assets.paginate(options)
0
     end
0
 
0
     def search_options
0
- search_conditions.merge(:order => 'created_at desc', :limit => @asset_pages.items_per_page, :offset => @asset_pages.current.offset)
0
+ search_conditions.merge(:order => 'created_at desc')
0
     end
0
 
0
     def search_conditions
...
3
4
5
6
7
8
9
 
 
 
10
11
12
...
25
26
27
28
29
 
...
3
4
5
 
 
 
 
6
7
8
9
10
11
...
24
25
26
 
27
28
0
@@ -3,10 +3,9 @@ class Admin::CachedPagesController < Admin::BaseController
0
 
0
   def index
0
     CachedPage.with_current_scope do
0
- @cached_page_pages = Paginator.new self, site.cached_pages.count, 30, params[:page]
0
- offset = (((params[:page] || 1).to_i - 1) * @cached_page_pages.items_per_page)
0
- @cached_pages = site.cached_pages.find(:all, :order => 'updated_at', :limit => @cached_page_pages.items_per_page, :offset => offset,
0
- :conditions => (params[:query] && ['url LIKE ?', ["#{params[:query]}%"]]))
0
+ @cached_pages = site.cached_pages.paginate(:order => 'updated_at',
0
+ :conditions => (params[:query] && ['url LIKE ?', ["#{params[:query]}%"]]),
0
+ :page => params[:page])
0
     end
0
   end
0
   alias_method :query, :index
0
@@ -25,4 +24,4 @@ class Admin::CachedPagesController < Admin::BaseController
0
   
0
   protected
0
     alias authorized? admin?
0
-end
0
\ No newline at end of file
0
+end
...
83
84
85
86
87
88
89
90
91
92
93
 
 
 
 
94
95
96
97
 
 
98
99
 
100
101
102
...
83
84
85
 
86
 
 
 
 
 
 
87
88
89
90
91
92
 
 
93
94
95
 
96
97
98
99
0
@@ -83,20 +83,17 @@ class MephistoController < ApplicationController
0
       if @section
0
         conditions.first << ' AND (assigned_sections.section_id = :section)'
0
         conditions.last[:section] = @section.id
0
- joins = "INNER JOIN assigned_sections ON assigned_sections.article_id = contents.id"
0
       end
0
- search_count = site.articles.count(:all, :conditions => conditions, :joins => joins)
0
- @article_pages = Paginator.new self, search_count, site.articles_per_page, params[:page]
0
- @articles = site.articles.find(:all, :conditions => conditions, :order => 'published_at DESC',
0
- :include => [:user, :sections],
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset)
0
+
0
+ @articles = site.articles.paginate(:conditions => conditions, :order => 'published_at DESC',
0
+ :include => [:user, :sections],
0
+ :per_page => site.articles_per_page, :page => params[:page])
0
       
0
       render_liquid_template_for(:search, 'articles' => @articles,
0
- 'previous_page' => paged_search_url_for(@article_pages.current.previous),
0
- 'next_page' => paged_search_url_for(@article_pages.current.next),
0
+ 'previous_page' => paged_search_url_for(@articles.previous_page),
0
+ 'next_page' => paged_search_url_for(@articles.next_page),
0
                                           'search_string' => CGI::escapeHTML(params[:q]),
0
- 'search_count' => search_count,
0
+ 'search_count' => @articles.total_entries,
0
                                           'section' => @section)
0
       @skip_caching = true
0
     end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
20
21
22
23
24
 
...
1
 
 
 
 
 
 
 
 
 
 
2
3
4
...
10
11
12
 
13
14
0
@@ -1,14 +1,4 @@
0
 module Admin::CachedPagesHelper
0
- def pagination_remote_links(paginator, options={}, html_options={})
0
- name = options[:name] || ActionController::Pagination::DEFAULT_OPTIONS[:name]
0
- params = (options[:params] || ActionController::Pagination::DEFAULT_OPTIONS[:params]).clone
0
-
0
- pagination_links_each(paginator, options) do |n|
0
- params[name] = n
0
- link_to n.to_s, :page => n
0
- end
0
- end
0
-
0
   def display_cached_page_date(page)
0
     if Date.today == page.updated_at.to_date
0
       if page.updated_at > Time.now - 4.hours
0
@@ -20,4 +10,4 @@ module Admin::CachedPagesHelper
0
       page.updated_at.strftime("%b %d, %Y")
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
52
53
54
 
 
 
 
 
 
 
 
 
 
55
56
57
0
@@ -52,16 +52,6 @@ module ApplicationHelper
0
     end
0
   end
0
 
0
- def pagination_remote_links(paginator, options={}, html_options={})
0
- name = options[:name] || ActionController::Pagination::DEFAULT_OPTIONS[:name]
0
- params = (options[:params] || ActionController::Pagination::DEFAULT_OPTIONS[:params]).clone
0
-
0
- pagination_links_each(paginator, options) do |n|
0
- params[name] = n
0
- link_to_function n.to_s, "window.spotlight.search('#{n}')"
0
- end
0
- end
0
-
0
   def comment_expiration_options
0
     [['Are not allowed', -1],
0
      ['Never expire', 0],
...
37
38
39
 
 
 
 
 
40
41
42
...
54
55
56
57
58
59
60
61
 
 
62
63
64
65
66
...
37
38
39
40
41
42
43
44
45
46
47
...
59
60
61
 
62
 
 
 
63
64
65
 
66
67
68
0
@@ -37,6 +37,11 @@
0
 <% end %>
0
 
0
 <% if @articles.any? %>
0
+
0
+<% content_tag :p, :class => 'total' do %>
0
+ Total: <%= content_tag :strong, @articles.total_entries %> articles.
0
+<% end %>
0
+
0
 <!-- begin article list -->
0
 <table id="article-list" cellspacing="0" cellpadding="0">
0
   <thead>
0
@@ -54,13 +59,10 @@
0
 </table>
0
 <!-- /end article list -->
0
 
0
-
0
 <!-- begin pagination -->
0
-<div id="pagination">
0
-<% if @article_pages.page_count > 1 -%>
0
-Pages: <strong><%= pagination_links @article_pages, :params => { :action => 'index' } %></strong>
0
+<% if @articles.page_count > 1 -%>
0
+ <%= will_paginate @articles, :id => 'pagination' %>
0
 <% end -%>
0
-</div>
0
 <!-- /end pagination -->
0
 
0
 <% else %>
...
27
28
29
30
31
32
33
34
35
 
 
 
...
27
28
29
 
 
 
 
 
30
31
32
33
0
@@ -27,8 +27,6 @@
0
     <div class="empty" style="margin: 20px;">You have no files of this type or have yet to upload any files. <%= link_to 'Upload one now &raquo;', :action => 'new' %></div>
0
   <% end %>
0
 
0
-<% if @asset_pages.page_count > 1 %>
0
- <div id="pagination">
0
- Pages: <strong><%= pagination_remote_links @asset_pages, :params => { :action => 'index' } %></strong>
0
- </div>
0
-<% end %>
0
\ No newline at end of file
0
+<% if @assets.page_count > 1 %>
0
+ <%= will_paginate @assets, :id => 'pagination' %>
0
+<% end %>
...
2
3
4
5
 
6
7
8
...
113
114
115
 
 
 
 
 
 
 
 
 
116
117
118
...
2
3
4
 
5
6
7
8
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
0
@@ -2,7 +2,7 @@
0
 # migrations feature of ActiveRecord to incrementally modify your database, and
0
 # then regenerate this schema definition.
0
 
0
-ActiveRecord::Schema.define(:version => 71) do
0
+ActiveRecord::Schema.define(:version => 68) do
0
 
0
   create_table "assets", :force => true do |t|
0
     t.column "content_type", :string
0
@@ -113,6 +113,15 @@ ActiveRecord::Schema.define(:version => 71) do
0
     t.column "site_id", :integer
0
   end
0
 
0
+ create_table "feedbacks", :force => true do |t|
0
+ t.column "site_id", :integer
0
+ t.column "name", :string
0
+ t.column "email", :string
0
+ t.column "body", :text
0
+ t.column "key", :string
0
+ t.column "created_at", :datetime
0
+ end
0
+
0
   create_table "memberships", :force => true do |t|
0
     t.column "site_id", :integer
0
     t.column "user_id", :integer
...
1199
1200
1201
 
 
 
 
 
 
 
 
1202
1203
1204
...
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
0
@@ -1199,6 +1199,14 @@ li.event-article { background-image: url(/images/mephisto/icons/articleb.gif);
0
   text-align: center;
0
   border-top: 1px solid #ccc;
0
   padding: 10px 0;
0
+ font-weight:bold;
0
+}
0
+
0
+#main p.total {
0
+ margin:-0.3em 0 1.2em 0;
0
+ padding: 0.3em 3em;
0
+ background: #eee;
0
+ text-align:center;
0
 }
0
 
0
 

Comments

    No one has commented yet.