Patch #29649

Rake task to export wiki to HTML/PDF

Added by Lorenz Schori 9 months ago. Updated 7 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Wiki
Target version:-

Description

As a system administrator I want to automatically export and archive a wiki on a regular basis such that critical information is still accessible to my team if redmine goes down.

The attached patch adds two rake tasks redmine:wikidump:html and redmine:wikidump:pdf which can be called from a cron job / systemd timer.

0001-Add-a-rake-task-to-dump-whole-wikis.patch Magnifier (3.47 KB) Lorenz Schori, 2018-09-20 13:00

History

#1 Updated by Holger Just 9 months ago

  • Tracker changed from Feature to Patch

#2 Updated by Karel Pičman 7 months ago

I've just tested it and had to fix the following error:

# rake redmine:wikidump:html project=lbcfree RAILS_ENV="production" 
rake aborted!
ActionView::Template::Error: In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers`.
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/abstract_controller/url_for.rb:13:in `_routes'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/url_for.rb:175:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/routing_url_for.rb:131:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:241:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:218:in `call'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:345:in `block (2 levels) in define_url_helper'
/opt/redmine-3.4/app/helpers/application_helper.rb:56:in `link_to_user'
/opt/redmine-3.4/app/helpers/application_helper.rb:988:in `block in parse_redmine_links'
/opt/redmine-3.4/app/helpers/application_helper.rb:845:in `gsub!'
/opt/redmine-3.4/app/helpers/application_helper.rb:845:in `parse_redmine_links'
/opt/redmine-3.4/app/helpers/application_helper.rb:666:in `block (2 levels) in textilizable'
/opt/redmine-3.4/app/helpers/application_helper.rb:665:in `each'
/opt/redmine-3.4/app/helpers/application_helper.rb:665:in `block in textilizable'
/opt/redmine-3.4/app/helpers/application_helper.rb:686:in `parse_non_pre_blocks'
/opt/redmine-3.4/app/helpers/application_helper.rb:664:in `textilizable'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:30:in `block in _app_views_wiki_export_multiple_html_erb__625170301977414803_47188578157680'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:27:in `each'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:27:in `_app_views_wiki_export_multiple_html_erb__625170301977414803_47188578157680'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:145:in `block in render'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:166:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:333:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:143:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `block in instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:52:in `render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:14:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/renderer.rb:46:in `render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/renderer.rb:27:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/helpers/rendering_helper.rb:32:in `render'
/opt/redmine-3.4/lib/tasks/wikidump.rake:44:in `block in export_wiki'
/opt/redmine-3.4/lib/tasks/wikidump.rake:43:in `open'
/opt/redmine-3.4/lib/tasks/wikidump.rake:43:in `export_wiki'
/opt/redmine-3.4/lib/tasks/wikidump.rake:81:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers`.
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/abstract_controller/url_for.rb:13:in `_routes'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/url_for.rb:175:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/routing_url_for.rb:131:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:241:in `optimize_routes_generation?'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:218:in `call'
/var/lib/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:345:in `block (2 levels) in define_url_helper'
/opt/redmine-3.4/app/helpers/application_helper.rb:56:in `link_to_user'
/opt/redmine-3.4/app/helpers/application_helper.rb:988:in `block in parse_redmine_links'
/opt/redmine-3.4/app/helpers/application_helper.rb:845:in `gsub!'
/opt/redmine-3.4/app/helpers/application_helper.rb:845:in `parse_redmine_links'
/opt/redmine-3.4/app/helpers/application_helper.rb:666:in `block (2 levels) in textilizable'
/opt/redmine-3.4/app/helpers/application_helper.rb:665:in `each'
/opt/redmine-3.4/app/helpers/application_helper.rb:665:in `block in textilizable'
/opt/redmine-3.4/app/helpers/application_helper.rb:686:in `parse_non_pre_blocks'
/opt/redmine-3.4/app/helpers/application_helper.rb:664:in `textilizable'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:30:in `block in _app_views_wiki_export_multiple_html_erb__625170301977414803_47188578157680'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:27:in `each'
/opt/redmine-3.4/app/views/wiki/export_multiple.html.erb:27:in `_app_views_wiki_export_multiple_html_erb__625170301977414803_47188578157680'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:145:in `block in render'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:166:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:333:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/template.rb:143:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `block in instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:52:in `render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/template_renderer.rb:14:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/renderer.rb:46:in `render_template'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/renderer/renderer.rb:27:in `render'
/var/lib/gems/2.3.0/gems/actionview-4.2.8/lib/action_view/helpers/rendering_helper.rb:32:in `render'
/opt/redmine-3.4/lib/tasks/wikidump.rake:44:in `block in export_wiki'
/opt/redmine-3.4/lib/tasks/wikidump.rake:43:in `open'
/opt/redmine-3.4/lib/tasks/wikidump.rake:43:in `export_wiki'
/opt/redmine-3.4/lib/tasks/wikidump.rake:81:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => redmine:wikidump:html
(See full trace by running task with --trace)

by adding the following line as recommended in the error:

...
18 namespace :redmine do
19   namespace :wikidump do
20 ++  include Rails.application.routes.url_helpers
21     def export_wiki(project, template, path)
22       pages = project.wiki.pages.
...

Then it worked.

Also available in: Atom PDF