Skip to content

Commit

Permalink
export: add readme code
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoviola committed Feb 4, 2020
1 parent 7f6f7e5 commit 9c05722
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/concerns/export_service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
module ExportService
def add_readme_to_zip(dirname:, out:)
readme = "#{Rails.root}/doc/zip/README"
file = File.open(readme, "r")
path = File.join dirname, 'README.txt'
out.put_next_entry path
out.write file.read
end

def export_plaintext_transcript(name:, dirname:, out:)
path = File.join dirname, 'plaintext', "#{name}_transcript.txt"

Expand Down
3 changes: 3 additions & 0 deletions app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def export_work
respond_to do |format|
format.zip do
buffer = Zip::OutputStream.write_buffer do |out|
add_readme_to_zip(dirname: dirname, out: out)

%w(verbatim emended searchable).each do |format|
export_plaintext_transcript(name: format, dirname: dirname, out: out)
end
Expand Down Expand Up @@ -146,6 +148,7 @@ def export_all_works
@works.each do |work|
@work = work
dirname = work.slug.truncate(200, omission: "")
add_readme_to_zip(dirname: dirname, out: out)

%w(verbatim expanded searchable).each do |format|
export_plaintext_transcript(name: format, dirname: dirname, out: out)
Expand Down
10 changes: 10 additions & 0 deletions doc/zip/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTML:

full -- full text of the transcription or translation, with versions, contributors, and comments.
text -- just the full text of the transcription or translation.

Text:

verbatim -- full text of the transcription, with versions, contributors and comments.
searchable -- links removed and line breaks removed so searches can span line breaks.
expanded -- expanded transcripts and translations replace the verbatim linked subjects with the canonical name of the subject to make it suitable for text analysis.

0 comments on commit 9c05722

Please sign in to comment.