Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

added a print menu item to the context menu of a wiki page

Sven R. Kunze93bdcb537b6d
diff --git a/app/views/wiki/show.html.erb b/app/views/wiki/show.html.erb
index d8646c0cc61..22415b81ee1 100644
--- a/app/views/wiki/show.html.erb
+++ b/app/views/wiki/show.html.erb
@@ -39,6 +39,11 @@ See COPYRIGHT and LICENSE files for more details.
<% @formatted_text = format_text (@content || @page.content), :text, attachments: @page.attachments %>
<% description strip_tags(@formatted_text) %>
+<% content_for :header_tags do %>
+ <meta name="required_script" content="print_handler" />
+<% end %>
+
+
<%= toolbar title: title, html: {class: '-with-dropdown'} do %>
<% if @editable %>
<% if User.current.allowed_to? :edit_wiki_pages, @project %>
@@ -97,6 +102,11 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<%= li_unless_nil(link_to_if_authorized(t(:label_history), {action: 'history', id: @page}, class: 'icon-context icon-activity-history')) %>
<%= li_unless_nil(link_to_if_authorized(t(:button_manage_menu_entry), {controller: '/wiki_menu_items', action: 'edit', project_id: @project.identifier, id: @page}, class: 'icon-context icon-settings')) %>
+ <li>
+ <a class="icon-context icon-print op-wiki-context-print" title="<%= t('wiki.print_hint') %>">
+ <%= t(:button_print) %>
+ </a>
+ </li>
<% if User.current.allowed_to?(:export_wiki_pages, @project) %>
<section data-augmented-model-wrapper
data-modal-class-name="wiki-export---modal">
diff --git a/config/locales/en.yml b/config/locales/en.yml
index dd98447abbb..154ab74c327 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -390,6 +390,7 @@ en:
wiki:
page_not_editable_index: The requested page does not (yet) exist. You have been redirected to the index of all wiki pages.
no_results_title_text: There are currently no wiki pages.
+ print_hint: This will print the content of this wiki page without any navigation bars.
index:
no_results_content_text: Add a new wiki page
diff --git a/frontend/src/app/core/augmenting/dynamic-scripts/print_handler.js b/frontend/src/app/core/augmenting/dynamic-scripts/print_handler.js
new file mode 100644
index 00000000000..8f06cee0df0
--- /dev/null
+++ b/frontend/src/app/core/augmenting/dynamic-scripts/print_handler.js
@@ -0,0 +1,7 @@
+// we cannot just use print as the handler
+function print_wiki_handler() {
+ print();
+}
+
+jQuery(document.body).on('click', '.op-wiki-context-print', print_wiki_handler);
+