Add pandoc
This commit is contained in:
parent
dec482bfba
commit
109dcd205c
11 changed files with 108 additions and 4 deletions
|
|
@ -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 && \
|
||||
|
|
|
|||
1
Gemfile
1
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'
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
13
app/views/elements/_element.odt.erb
Normal file
13
app/views/elements/_element.odt.erb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<div>
|
||||
<div>
|
||||
<h2>
|
||||
<%= element.title %>
|
||||
</h2>
|
||||
<%= element.path %>
|
||||
</div>
|
||||
<%= element.description_html %>
|
||||
|
||||
<% element.success_criteria.each do |sc| %>
|
||||
<%= render sc %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<h1>A11yDive</h1>
|
||||
<h1>a11ydive</h1>
|
||||
|
||||
<h2>Dashboard</h1>
|
||||
|
||||
|
|
@ -12,12 +12,20 @@
|
|||
<%= Checklist.count %>
|
||||
<%= link_to Checklist.model_name.human(count: Checklist.count), :checklists %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<i class="bi bi-check2"></i>
|
||||
<%= Check.count %>
|
||||
<%= link_to Check.model_name.human(count: Check.count), :checks %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<i class="bi bi-link"></i>
|
||||
<%= Link.count %>
|
||||
<%= link_to Link.model_name.human(count: Link.count), :links %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<%= link_to "Backup herunterladen", admin_backup_url, class: "btn btn-secondary", data: { turbo_prefetch: false, frame: "_top", turbo: false } %>
|
||||
</p>
|
||||
|
|
@ -35,6 +35,17 @@
|
|||
<%= link_to report_path(@report, format: :xlsx), class: "btn btn-primary", target: "_blank" do %>
|
||||
<i class="bi bi-filetype-xlsx"></i> XLSX
|
||||
<% end %>
|
||||
<%= link_to report_path(@report, format: :rtf), class: "btn btn-primary", target: "_blank" do %>
|
||||
<i class="bi bi-file-richtext"></i> RTF
|
||||
<% end %>
|
||||
<%= link_to report_path(@report, format: :xml), class: "btn btn-primary", target: "_blank" do %>
|
||||
<i class="bi bi-filetype-html"></i> HTML
|
||||
<% end %>
|
||||
<%= link_to report_path(@report, format: :odt), class: "btn btn-primary", target: "_blank" do %>
|
||||
<i class="bi bi-file-richtext"></i> ODT
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="action-row">
|
||||
<%= link_to t("scaffold.link_edit", model: @report.model_name.human), edit_report_path(@report) %>
|
||||
<%= link_to t("scaffold.link_index", model: @report.model_name.human(count: 2)), reports_path %>
|
||||
<%= button_to t("scaffold.link_destroy", model: @report.model_name.human), @report, method: :delete, class: "btn btn-outline-danger" %>
|
||||
|
|
|
|||
23
app/views/reports/show.odt.erb
Normal file
23
app/views/reports/show.odt.erb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1><%= @report.name %></h1>
|
||||
<small>
|
||||
Erstellt am <%= l(@report.created_at, format: :short) %>,
|
||||
zuletzt bearbeitet am <%= l(@report.updated_at, format: :short) %>
|
||||
</small>
|
||||
|
||||
<% if @report.comment_html %>
|
||||
<div>
|
||||
<%= @report.comment_html %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div >
|
||||
<% @report.elements.each do |element| %>
|
||||
<%= render element %>
|
||||
<% end %>
|
||||
</div>
|
||||
</body>
|
||||
</head>
|
||||
25
app/views/reports/show.rtf.erb
Normal file
25
app/views/reports/show.rtf.erb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<h1><i class="bi bi-journal-text me-2"></i><%= @report.name %></h1>
|
||||
<p class="small">
|
||||
Erstellt am <%= l(@report.created_at, format: :short) %>,
|
||||
zuletzt bearbeitet am <%= l(@report.updated_at, format: :short) %>
|
||||
</p>
|
||||
|
||||
<% if @report.comment_html %>
|
||||
<div class="mt-2 mb-4 lead">
|
||||
<%= @report.comment_html %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="border-top pt-3">
|
||||
<%= turbo_frame_tag "new_element_frame" do %>
|
||||
<%= render partial: "reports/new_element_button", locals: { report: @report } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="element_list">
|
||||
<% @report.elements.each do |element| %>
|
||||
<%= turbo_frame_tag dom_id(element, :frame) do %>
|
||||
<%= render element %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
4
app/views/success_criteria/_success_criterion.odt.erb
Normal file
4
app/views/success_criteria/_success_criterion.odt.erb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<div>
|
||||
<%= success_criterion.result %>
|
||||
</div>
|
||||
<%= success_criterion.description_html %>
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
# Add this line to config/initializers/mime_types.rb in your Rails application
|
||||
Mime::Type.register "application/vnd.openxmlformats-officedocument.wordprocessingml.document", :docx
|
||||
Mime::Type.register "application/vnd.openxmlformats-officedocument.wordprocessingml.document", :docx
|
||||
Mime::Type.register "text/richtext", :rtf
|
||||
Mime::Type.register "application/vnd.oasis.opendocument.text", :odt
|
||||
Loading…
Add table
Add a link
Reference in a new issue