From d5797f967bc8d7b8553b2e1393a03d53224dc85f Mon Sep 17 00:00:00 2001 From: John Corrigan Date: Wed, 28 Oct 2015 13:00:51 -0500 Subject: [PATCH] handle files added directly to the item list of a module fixes CNVS-23798 test plan: - Have a course with content separated into modules, including specific files. - Confirm that course is configured to sort by module (default behavior). - Export course as an ePub at `/epub_exports`. - Observe that file names are included as part of the module list. - Click the link to get to the file template. - Observe that the file can be viewed by clicking on the tile name. Change-Id: I28c6afeba668714ed284cc5437fb06d522b4f855 Reviewed-on: https://gerrit.instructure.com/65988 Tested-by: Jenkins Reviewed-by: Matt Berns Product-Review: John Corrigan QA-Review: John Corrigan --- lib/cc/exporter/epub/book.rb | 4 ++-- .../epub/converters/files_converter.rb | 2 +- .../epub/converters/media_converter.rb | 15 ++++++++++++-- .../epub/converters/object_path_converter.rb | 2 +- lib/cc/exporter/epub/exporter.rb | 8 +++++--- .../epub/templates/files_template.html.erb | 20 +++++++++++++++++++ .../module_sorting_template.html.erb | 2 +- spec/lib/cc/exporter/epub/exporter_spec.rb | 2 +- 8 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 lib/cc/exporter/epub/templates/files_template.html.erb diff --git a/lib/cc/exporter/epub/book.rb b/lib/cc/exporter/epub/book.rb index 44765edd959..ee83f0e4577 100644 --- a/lib/cc/exporter/epub/book.rb +++ b/lib/cc/exporter/epub/book.rb @@ -12,7 +12,7 @@ module CC::Exporter::Epub def add_files files.each do |file_data| File.open(file_data[:path_to_file]) do |file| - epub.add_item(file_data[:local_path], file, file_data[:migration_id], { + epub.add_item(file_data[:local_path], file, file_data[:identifier], { 'media-type' => file_data[:media_type] }) end @@ -40,7 +40,7 @@ module CC::Exporter::Epub b.set_primary_identifier(pub_id) b.language = I18n.locale b.add_title(title, nil, GEPUB::TITLE_TYPE::MAIN) do |title| - title.file_as = "#{title} Epub" + title.file_as = "#{title} ePub" title.display_seq = 1 end b.add_creator('Canvas by Instructure') do |creator| diff --git a/lib/cc/exporter/epub/converters/files_converter.rb b/lib/cc/exporter/epub/converters/files_converter.rb index 1adb50a9a22..200b8ff3de1 100644 --- a/lib/cc/exporter/epub/converters/files_converter.rb +++ b/lib/cc/exporter/epub/converters/files_converter.rb @@ -57,7 +57,7 @@ module CC::Exporter::Epub::Converters def to_h return { - migration_id: data['identifier'], + identifier: data['identifier'], local_path: local_path, file_name: File.basename(local_path), path_to_file: path_to_file, diff --git a/lib/cc/exporter/epub/converters/media_converter.rb b/lib/cc/exporter/epub/converters/media_converter.rb index 225e882bdbe..d41ab7ae1af 100644 --- a/lib/cc/exporter/epub/converters/media_converter.rb +++ b/lib/cc/exporter/epub/converters/media_converter.rb @@ -97,7 +97,12 @@ module CC::Exporter::Epub::Converters # #