diff --git a/Dockerfile b/Dockerfile index 43cae04..9f587ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update -yqq && \ apt-get install -yqq --no-install-recommends \ - sqlite3 nodejs npm sassc yarn libvips fish ranger && \ + sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc && \ apt-get clean && \ npm install tabby-agent && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ @@ -108,7 +108,7 @@ RUN \ ${NAME} && \ apt-get update -yqq && \ apt-get install -yqq --no-install-recommends \ - sqlite3 libvips && \ + sqlite3 libvips pandoc && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ truncate -s 0 /var/log/*log && \ diff --git a/Gemfile b/Gemfile index 49fa037..95e2e4e 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ gem 'caxlsx' gem 'caxlsx_rails' gem 'image_processing', '~> 1.2' gem 'pagy', '~> 9.0' +gem 'pandoc-ruby' gem 'prawn-markup' gem 'prawn-rails' gem 'sablon' diff --git a/Gemfile.lock b/Gemfile.lock index cdc7a37..ee0de82 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,6 +179,7 @@ GEM nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) pagy (9.0.2) + pandoc-ruby (2.1.10) parallel (1.25.1) parser (3.3.4.0) ast (~> 2.4.1) @@ -356,6 +357,7 @@ DEPENDENCIES jbuilder jsbundling-rails pagy (~> 9.0) + pandoc-ruby prawn-markup prawn-rails puma (>= 5.0) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 341f183..dfe6847 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -15,6 +15,21 @@ class ReportsController < ApplicationController response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}") render end + format.xml do + response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'html')}") + render formats: [:odt], layout: false + end + format.rtf do + html = render_to_string(template: 'reports/show', formats: [:odt], + layout: false) + rtf = "{\\rtf1\n#{PandocRuby.html(html).to_rtf}}" + send_data rtf, filename: filename(@report, extension: 'rtf') + end + format.odt do + html = render_to_string(layout: false) + odt = PandocRuby.html(html).to_odt + send_data odt, filename: filename(@report, extension: 'odt') + end format.docx do template = Sablon.template(Rails.root.join('lib/templates/docx/report.docx')) context = { diff --git a/app/views/elements/_element.odt.erb b/app/views/elements/_element.odt.erb new file mode 100644 index 0000000..bf1ae9e --- /dev/null +++ b/app/views/elements/_element.odt.erb @@ -0,0 +1,13 @@ +
<%= Check.count %> <%= link_to Check.model_name.human(count: Check.count), :checks %>
++ +<%= Link.count %> +<%= link_to Link.model_name.human(count: Link.count), :links %> +
+ +<%= link_to "Backup herunterladen", admin_backup_url, class: "btn btn-secondary", data: { turbo_prefetch: false, frame: "_top", turbo: false } %>
\ No newline at end of file diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index ad8b9ae..d6bd395 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -35,6 +35,17 @@ <%= link_to report_path(@report, format: :xlsx), class: "btn btn-primary", target: "_blank" do %> XLSX <% end %> + <%= link_to report_path(@report, format: :rtf), class: "btn btn-primary", target: "_blank" do %> + RTF + <% end %> + <%= link_to report_path(@report, format: :xml), class: "btn btn-primary", target: "_blank" do %> + HTML + <% end %> + <%= link_to report_path(@report, format: :odt), class: "btn btn-primary", target: "_blank" do %> + ODT + <% end %> + ++ Erstellt am <%= l(@report.created_at, format: :short) %>, + zuletzt bearbeitet am <%= l(@report.updated_at, format: :short) %> +
+ + <% if @report.comment_html %> +