Commit 872482678be0eef25191e118b8300112735f0023
1 parent
415c0f4b
Exists in
spb-stable
and in
3 other branches
Speed up loading and add pagination to 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
| ... | ... | @@ -57,12 +57,16 @@ class WikiPage |
| 57 | 57 | |
| 58 | 58 | # The raw content of this page. |
| 59 | 59 | def content |
| 60 | - @attributes[:content] | |
| 60 | + @attributes[:content] ||= if @page | |
| 61 | + @page.raw_data | |
| 62 | + end | |
| 61 | 63 | end |
| 62 | 64 | |
| 63 | 65 | # The processed/formatted content of this page. |
| 64 | 66 | def formatted_content |
| 65 | - @attributes[:formatted_content] | |
| 67 | + @attributes[:formatted_content] ||= if @page | |
| 68 | + @page.formatted_data | |
| 69 | + end | |
| 66 | 70 | end |
| 67 | 71 | |
| 68 | 72 | # The markup format for the page. |
| ... | ... | @@ -163,8 +167,6 @@ class WikiPage |
| 163 | 167 | def set_attributes |
| 164 | 168 | attributes[:slug] = @page.escaped_url_path |
| 165 | 169 | attributes[:title] = @page.title |
| 166 | - attributes[:content] = @page.raw_data | |
| 167 | - attributes[:formatted_content] = @page.formatted_data | |
| 168 | 170 | attributes[:format] = @page.format |
| 169 | 171 | end |
| 170 | 172 | ... | ... |
app/views/projects/wikis/pages.html.haml