Commit 872482678be0eef25191e118b8300112735f0023

Authored by Marin Jankovski
1 parent 415c0f4b

Speed up loading and add pagination to wiki pages page.

app/controllers/projects/wikis_controller.rb
@@ -7,7 +7,7 @@ class Projects::WikisController < Projects::ApplicationController @@ -7,7 +7,7 @@ class Projects::WikisController < Projects::ApplicationController
7 before_filter :load_project_wiki 7 before_filter :load_project_wiki
8 8
9 def pages 9 def pages
10 - @wiki_pages = @project_wiki.pages 10 + @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(30)
11 end 11 end
12 12
13 def show 13 def show
app/models/wiki_page.rb
@@ -57,12 +57,16 @@ class WikiPage @@ -57,12 +57,16 @@ class WikiPage
57 57
58 # The raw content of this page. 58 # The raw content of this page.
59 def content 59 def content
60 - @attributes[:content] 60 + @attributes[:content] ||= if @page
  61 + @page.raw_data
  62 + end
61 end 63 end
62 64
63 # The processed/formatted content of this page. 65 # The processed/formatted content of this page.
64 def formatted_content 66 def formatted_content
65 - @attributes[:formatted_content] 67 + @attributes[:formatted_content] ||= if @page
  68 + @page.formatted_data
  69 + end
66 end 70 end
67 71
68 # The markup format for the page. 72 # The markup format for the page.
@@ -163,8 +167,6 @@ class WikiPage @@ -163,8 +167,6 @@ class WikiPage
163 def set_attributes 167 def set_attributes
164 attributes[:slug] = @page.escaped_url_path 168 attributes[:slug] = @page.escaped_url_path
165 attributes[:title] = @page.title 169 attributes[:title] = @page.title
166 - attributes[:content] = @page.raw_data  
167 - attributes[:formatted_content] = @page.formatted_data  
168 attributes[:format] = @page.format 170 attributes[:format] = @page.format
169 end 171 end
170 172
app/views/projects/wikis/pages.html.haml
@@ -9,3 +9,4 @@ @@ -9,3 +9,4 @@
9 %small (#{wiki_page.format}) 9 %small (#{wiki_page.format})
10 .pull-right 10 .pull-right
11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} 11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)}
  12 += paginate @wiki_pages, theme: 'gitlab'