Skip to content

Commit

Permalink
Merge pull request #3693 from benwbrum/3692-respect-metadata-exclusion
Browse files Browse the repository at this point in the history
Fixes #3692 by respecting print configuration in facing edition view
  • Loading branch information
saracarl authored Jul 6, 2023
2 parents 988d922 + 5609a44 commit 13817d6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions app/controllers/concerns/export_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def add_readme_to_zip(work:, out:, by_work:, original_filenames:)
out.write file.read
end

def export_printable_to_zip(work, edition, output_format, out, by_work, original_filenames, preserve_lb)
def export_printable_to_zip(work, edition, output_format, out, by_work, original_filenames, preserve_lb, include_metadata, include_contributors)
return if work.pages.count == 0

dirname = path_from_work(work)
Expand All @@ -40,12 +40,12 @@ def export_printable_to_zip(work, edition, output_format, out, by_work, original
path = File.join dirname, 'printable', "text_only.#{output_format}"
end

tempfile = export_printable(work, edition, output_format, preserve_lb)
tempfile = export_printable(work, edition, output_format, preserve_lb, include_metadata, include_contributors)
out.put_next_entry(path)
out.write(IO.read(tempfile))
end

def export_printable(work, edition, format, preserve_lb)
def export_printable(work, edition, format, preserve_lb, include_metadata, include_contributors)
# render to a string
rendered_markdown =
ApplicationController.new.render_to_string(
Expand All @@ -56,7 +56,9 @@ def export_printable(work, edition, format, preserve_lb)
:work => work,
:edition_type => edition,
:output_type => format,
:preserve_linebreaks => preserve_lb
:preserve_linebreaks => preserve_lb,
:include_metadata => include_metadata,
:include_contributors => include_contributors
}
)

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def show
end

def printable
output_file = export_printable(@work, params[:edition], params[:format], false)
output_file = export_printable(@work, params[:edition], params[:format], false, true, true)

if params[:format] == 'pdf'
content_type = "application/pdf"
Expand Down
10 changes: 6 additions & 4 deletions app/helpers/export_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,22 @@ def write_work_exports(works, out, export_user, bulk_export)
end

preserve_lb = bulk_export.report_arguments['preserve_linebreaks']
include_metadata = bulk_export.report_arguments['include_metadata'] != '0'
include_contributors = bulk_export.report_arguments['include_contributors'] != '0'
if bulk_export.facing_edition_work
export_printable_to_zip(work, 'facing', 'pdf', out, by_work, original_filenames, preserve_lb)
export_printable_to_zip(work, 'facing', 'pdf', out, by_work, original_filenames, preserve_lb, include_metadata, include_contributors)
end

if bulk_export.text_pdf_work
export_printable_to_zip(work, 'text', 'pdf', out, by_work, original_filenames, preserve_lb)
export_printable_to_zip(work, 'text', 'pdf', out, by_work, original_filenames, preserve_lb, include_metadata, include_contributors)
end

if bulk_export.text_only_pdf_work
export_printable_to_zip(work, 'text_only', 'pdf', out, by_work, original_filenames, preserve_lb)
export_printable_to_zip(work, 'text_only', 'pdf', out, by_work, original_filenames, preserve_lb, include_metadata, include_contributors)
end

if bulk_export.text_docx_work
export_printable_to_zip(work, 'text', 'doc', out, by_work, original_filenames, preserve_lb)
export_printable_to_zip(work, 'text', 'doc', out, by_work, original_filenames, preserve_lb, include_metadata, include_contributors)
end

# Page-specific exports
Expand Down
10 changes: 7 additions & 3 deletions app/views/export/facing_edition.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@


\newpage

<% if @include_metadata %>
### Metadata
<p>
<%= t('.export_metadata', work: @work.title, collection: @work.collection.title, time: Time.now) %>
<%= t('export.facing_edition.export_metadata', work: @work.title, collection: @work.collection.title, time: Time.now) %>
</p>

<%
Expand All @@ -17,6 +19,8 @@
\newpage
<% end %>

<% end %>

<% @work.pages.includes(:notes, :ia_leaf, :sc_canvas).each do |page| %>

<% if @edition_type == 'facing'%>
Expand All @@ -41,10 +45,10 @@

<% end %>

<% unless @edition_type == 'text_only'%>
<% if @edition_type != 'text_only' && @include_contributors %>

\newpage
<%= t('.contributions_message') %>
<%= t('export.facing_edition.contributions_message') %>

<% contributor_ids = @work.deeds.group(:user_id).count.sort{|a,b| b[1] <=> a[1]}.map{|e| e[0]} %>
<% contributor_names = [] %>
Expand Down

0 comments on commit 13817d6

Please sign in to comment.