Commit 2ed56ce9d445e0ab22b5c20ec0d28342396d01cf
Exists in
spb-stable
and in
3 other branches
Merge branch 'speed_up_wiki_pages' into 'master'
Speed up wiki pages page
Showing
3 changed files
with
8 additions
and
5 deletions
Show diff stats
app/controllers/projects/wikis_controller.rb
... | ... | @@ -7,7 +7,7 @@ class Projects::WikisController < Projects::ApplicationController |
7 | 7 | before_filter :load_project_wiki |
8 | 8 | |
9 | 9 | def pages |
10 | - @wiki_pages = @project_wiki.pages | |
10 | + @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(30) | |
11 | 11 | end |
12 | 12 | |
13 | 13 | def show | ... | ... |
app/models/wiki_page.rb
... | ... | @@ -61,12 +61,16 @@ class WikiPage |
61 | 61 | |
62 | 62 | # The raw content of this page. |
63 | 63 | def content |
64 | - @attributes[:content] | |
64 | + @attributes[:content] ||= if @page | |
65 | + @page.raw_data | |
66 | + end | |
65 | 67 | end |
66 | 68 | |
67 | 69 | # The processed/formatted content of this page. |
68 | 70 | def formatted_content |
69 | - @attributes[:formatted_content] | |
71 | + @attributes[:formatted_content] ||= if @page | |
72 | + @page.formatted_data | |
73 | + end | |
70 | 74 | end |
71 | 75 | |
72 | 76 | # The markup format for the page. |
... | ... | @@ -167,8 +171,6 @@ class WikiPage |
167 | 171 | def set_attributes |
168 | 172 | attributes[:slug] = @page.escaped_url_path |
169 | 173 | attributes[:title] = @page.title |
170 | - attributes[:content] = @page.raw_data | |
171 | - attributes[:formatted_content] = @page.formatted_data | |
172 | 174 | attributes[:format] = @page.format |
173 | 175 | end |
174 | 176 | ... | ... |
app/views/projects/wikis/pages.html.haml