@@ -181,16 +181,9 class WikiController < ApplicationController | |||
|
181 | 181 | :order => 'title' |
|
182 | 182 | @pages_by_date = @pages.group_by {|p| p.updated_on.to_date} |
|
183 | 183 | @pages_by_parent_id = @pages.group_by(&:parent_id) |
|
184 | # export wiki to a single html file | |
|
185 | 184 | when 'export' |
|
186 | if User.current.allowed_to?(:export_wiki_pages, @project) | |
|
187 | @pages = @wiki.pages.find :all, :order => 'title' | |
|
188 | export = render_to_string :action => 'export_multiple', :layout => false | |
|
189 | send_data(export, :type => 'text/html', :filename => "wiki.html") | |
|
190 | else | |
|
191 | redirect_to :action => 'index', :id => @project, :page => nil | |
|
192 | end | |
|
193 | return | |
|
185 | redirect_to :action => 'export', :id => @project # Compatibility stub while refactoring | |
|
186 | return | |
|
194 | 187 | else |
|
195 | 188 | # requested special page doesn't exist, redirect to default page |
|
196 | 189 | redirect_to :action => 'index', :id => @project, :page => nil |
@@ -198,6 +191,17 class WikiController < ApplicationController | |||
|
198 | 191 | end |
|
199 | 192 | render :action => "special_#{page_title}" |
|
200 | 193 | end |
|
194 | ||
|
195 | # Export wiki to a single html file | |
|
196 | def export | |
|
197 | if User.current.allowed_to?(:export_wiki_pages, @project) | |
|
198 | @pages = @wiki.pages.find :all, :order => 'title' | |
|
199 | export = render_to_string :action => 'export_multiple', :layout => false | |
|
200 | send_data(export, :type => 'text/html', :filename => "wiki.html") | |
|
201 | else | |
|
202 | redirect_to :action => 'index', :id => @project, :page => nil | |
|
203 | end | |
|
204 | end | |
|
201 | 205 | |
|
202 | 206 | def preview |
|
203 | 207 | page = @wiki.find_page(params[:page]) |
@@ -24,7 +24,7 | |||
|
24 | 24 | <% unless @pages.empty? %> |
|
25 | 25 | <% other_formats_links do |f| %> |
|
26 | 26 | <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> |
|
27 |
<%= f.link_to('HTML', :url => {:action |
|
|
27 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> | |
|
28 | 28 | <% end %> |
|
29 | 29 | <% end %> |
|
30 | 30 |
@@ -17,7 +17,7 | |||
|
17 | 17 | <% unless @pages.empty? %> |
|
18 | 18 | <% other_formats_links do |f| %> |
|
19 | 19 | <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> |
|
20 |
<%= f.link_to('HTML', :url => {:action |
|
|
20 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> | |
|
21 | 21 | <% end %> |
|
22 | 22 | <% end %> |
|
23 | 23 |
@@ -29,7 +29,8 ActionController::Routing::Routes.draw do |map| | |||
|
29 | 29 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
30 | 30 | map.with_options :controller => 'wiki' do |wiki_routes| |
|
31 | 31 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| |
|
32 |
wiki_views.connect 'projects/:id/wiki/ |
|
|
32 | wiki_views.connect 'projects/:id/wiki/export', :action => 'export' | |
|
33 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index/i | |
|
33 | 34 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
34 | 35 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
35 | 36 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
@@ -112,7 +112,7 Redmine::AccessControl.map do |map| | |||
|
112 | 112 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
113 | 113 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
114 | 114 | map.permission :view_wiki_pages, :wiki => [:index, :special] |
|
115 |
map.permission :export_wiki_pages, |
|
|
115 | map.permission :export_wiki_pages, :wiki => [:export] | |
|
116 | 116 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
117 | 117 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] |
|
118 | 118 | map.permission :delete_wiki_pages_attachments, {} |
@@ -256,6 +256,34 class WikiControllerTest < ActionController::TestCase | |||
|
256 | 256 | :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, |
|
257 | 257 | :content => 'Another page' } } |
|
258 | 258 | end |
|
259 | ||
|
260 | context "GET :export" do | |
|
261 | context "with an authorized user to export the wiki" do | |
|
262 | setup do | |
|
263 | @request.session[:user_id] = 2 | |
|
264 | get :export, :id => 'ecookbook' | |
|
265 | end | |
|
266 | ||
|
267 | should_respond_with :success | |
|
268 | should_assign_to :pages | |
|
269 | should_respond_with_content_type "text/html" | |
|
270 | should "export all of the wiki pages to a single html file" do | |
|
271 | assert_select "a[name=?]", "CookBook_documentation" | |
|
272 | assert_select "a[name=?]", "Another_page" | |
|
273 | assert_select "a[name=?]", "Page_with_an_inline_image" | |
|
274 | end | |
|
275 | ||
|
276 | end | |
|
277 | ||
|
278 | context "with an unauthorized user" do | |
|
279 | setup do | |
|
280 | get :export, :id => 'ecookbook' | |
|
281 | ||
|
282 | should_respond_with :redirect | |
|
283 | should_redirect_to('wiki index') { {:action => 'index', :id => @project, :page => nil} } | |
|
284 | end | |
|
285 | end | |
|
286 | end | |
|
259 | 287 | |
|
260 | 288 | def test_not_found |
|
261 | 289 | get :index, :id => 999 |
@@ -321,7 +321,7 class RoutingTest < ActionController::IntegrationTest | |||
|
321 | 321 | should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index' |
|
322 | 322 | should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index' |
|
323 | 323 | should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index' |
|
324 |
should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => ' |
|
|
324 | should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :id => '567' | |
|
325 | 325 | |
|
326 | 326 | should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
327 | 327 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' |
General Comments 0
You need to be logged in to leave comments.
Login now