Actions
Patch #29649
openRake task to export wiki to HTML/PDF
Status:
New
Priority:
Normal
Assignee:
-
Category:
Wiki
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
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.
Files
Updated by Karel Pičman almost 6 years 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.
Updated by Karel Pičman about 3 years ago
For Redmine >= 4.2 no modification needed and the original solution works well.
Updated by Karel Pičman about 2 years ago
- File 0002-Add-a-rake-task-to-dump-whole-wikis.patch 0002-Add-a-rake-task-to-dump-whole-wikis.patch added
Patch upgraded for Redmine 5.0.
Updated by Karel Pičman about 2 years ago
- File 0003-Add-a-rake-task-to-dump-whole-wikis.patch 0003-Add-a-rake-task-to-dump-whole-wikis.patch added
A small improvement.
Actions