Skip to content

Commit

Permalink
Merge branch 'development' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
benwbrum committed Sep 14, 2021
2 parents fc25752 + 3d6078c commit eeb9901
Show file tree
Hide file tree
Showing 104 changed files with 26,115 additions and 30,927 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,5 @@ gem 'rack-mini-profiler'
gem 'stackprof'

gem 'intercom', '~> 3.9.0'

gem 'open3'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ GEM
omniauth-saml (1.10.3)
omniauth (~> 1.3, >= 1.3.2)
ruby-saml (~> 1.9)
open3 (0.1.1)
orm_adapter (0.5.0)
parser (3.0.1.1)
ast (~> 2.4.1)
Expand Down Expand Up @@ -558,6 +559,7 @@ DEPENDENCIES
omniauth-google-oauth2
omniauth-multi-provider (~> 0.2.1)
omniauth-saml
open3
pry
pry-awesome_print
pry-byebug
Expand Down
17 changes: 8 additions & 9 deletions app/assets/javascripts/transcribe.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ function startDictation(target){
recognizing = true;
button = target;
var form = $(button.form);
var voiceData = form.find('#dictation_text');
var voiceData = form.find('textarea');
voiceSpan = form.find('.voice-info');
if (voiceSpan.hasClass('voice-error')){
voiceSpan.removeClass('voice-error');
}
var initialText = '';
var initialText

// if (voiceData.text() != '') {
// initialText = voiceData.text() + '\n';
// } else {
// initialText = '';
// }
if (voiceData.text() != '') {
initialText = voiceData.text() + '\n';
} else {
initialText = '';
}
var final_transcript = initialText;
var interim_transcript = initialText;

Expand All @@ -79,7 +79,6 @@ function startDictation(target){
}
}
voiceData.text(final_transcript);
myCodeMirror.replaceSelection(final_transcript);
};
}

Expand Down Expand Up @@ -115,4 +114,4 @@ function checkForUnsaved(inputs, msg, e){
};
};
});
}
}
7 changes: 5 additions & 2 deletions app/assets/stylesheets/components/shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,12 @@
/* hide and position tooltip */
/* top: -0.5em; */
color: white;
font-size: 150%;
font-size: 100%;
color: #FFF;
padding: 10px;
text-align: left;
max-width: 400px;
max-width: 800px;
width: 20em;
line-height: 1.2;
position: relative;
border-radius: 5px;
Expand Down Expand Up @@ -898,10 +899,12 @@ button, .button, .dropdown dd a {
.remove {
top: 50%;
right: 0;
border: 0;
width: 1em;
height: 1em;
display: none;
font-size: 20px;
box-shadow: none;
position: absolute;
margin-top: -0.5em;
border-radius: 50%;
Expand Down
51 changes: 51 additions & 0 deletions app/assets/stylesheets/sections/article.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,56 @@
}
}

.cm-editor {
min-width: 0;
min-height: 0;
display: flex;
flex: 1 1 auto;
flex-direction: column;

.CodeMirror {
display: flex;
flex: 1 1 auto;
flex-direction: column;
font-family: $fontFamily;
height: auto !important;

&-buttonsPanel:not(:empty) {
top: 74px;
z-index: 1;
display: flex;
flex-wrap: wrap;
position: sticky;
padding-bottom: 5px;
background-color: $bodyBg;

[data-layout-mode='ttb'] & {
padding-top: 8px;
top: calc(74px + (100vh - 74px - 3rem) / 2);
}

button {
padding: 0 4px;
font-size: 13px;
box-shadow: none;
margin: 0 3px 3px 0;
line-height: 1.75em;
font-family: monospace;
}
}

&-wrap {
z-index: 0;
border: 1px solid $inputBorderColor;
}

&-scroll {
flex-grow: 1;
}
}
}


.article-duplicates {
margin: 1em 0;
overflow: auto;
Expand Down Expand Up @@ -99,6 +149,7 @@

.article-editarea {
height: 100%;
min-height: 15em;
overflow: hidden;
background: #FFF;
box-sizing: border-box;
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/bulk_export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def bulk_export_params
:table_csv_work,
:table_csv_collection,
:work_metadata_csv,
:facing_edition_work)
:facing_edition_work,
:text_docx_work,
:text_pdf_work,
:static)
end
end
62 changes: 46 additions & 16 deletions app/controllers/collection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class CollectionController < ApplicationController

before_action :authorized?, :only => [:new, :edit, :update, :delete, :works_list]
before_action :set_collection, :only => [:show, :edit, :update, :contributors, :new_work, :works_list, :needs_transcription_pages, :needs_review_pages, :start_transcribing]
before_action :load_settings, :only => [:edit, :update, :upload]
before_action :load_settings, :only => [:edit, :update, :upload, :edit_owners, :remove_owner, :edit_collaborators, :remove_collaborator, :edit_reviewers, :remove_reviewer]

# no layout if xhr request
layout Proc.new { |controller| controller.request.xhr? ? false : nil }, :only => [:new, :create, :edit_buttons]
layout Proc.new { |controller| controller.request.xhr? ? false : nil }, :only => [:new, :create, :edit_buttons, :edit_owners, :remove_owner, :add_owner, :edit_collaborators, :remove_collaborator, :add_collaborator, :edit_reviewers, :remove_reviewer, :add_reviewer]

def authorized?
unless user_signed_in?
Expand All @@ -27,6 +27,18 @@ def authorized?
end
end

def search_users
query = "%#{params[:term]}%"
users = User.where("real_name like ? or email like ?", query, query)
render json: { results: users.map{|u| {text: "#{u.display_name} #{u.email}", id: u.id}}}
end

def reviewer_dashboard
# works which have at least one page needing review
@works = @collection.works.joins(:work_statistic).includes(:notes, :pages).where.not('work_statistics.needs_review' => 0).reorder("works.title")
end


def edit_buttons
@prefer_html = @collection.editor_buttons.where(:prefer_html => true).exists?
end
Expand Down Expand Up @@ -99,11 +111,19 @@ def search
def load_settings
@main_owner = @collection.owner
@owners = [@main_owner] + @collection.owners
@nonowners = User.order(:display_name) - @owners
@nonowners.each { |user| user.display_name = user.login if user.display_name.empty? }
@works_not_in_collection = current_user.owner_works - @collection.works
@collaborators = @collection.collaborators
@noncollaborators = User.order(:display_name) - @collaborators - @collection.owners
@reviewers = @collection.reviewers
if User.count > 100
@nonowners = []
@noncollaborators = []
@nonreviewers = []
else
@nonowners = User.order(:display_name) - @owners
@nonowners.each { |user| user.display_name = user.login if user.display_name.empty? }
@noncollaborators = User.order(:display_name) - @collaborators - @collection.owners
@nonreviewers = User.order(:display_name) - @reviewers - @collection.owners
end
end

def show
Expand Down Expand Up @@ -176,12 +196,6 @@ def show
end
end

def owners
@main_owner = @collection.owner
@owners = @collection.owners + [@main_owner]
@nonowners = User.all - @owners
end

def add_owner
@user.owner = true
@user.account_type = "Staff"
Expand All @@ -192,12 +206,12 @@ def add_owner
if @user.notification.add_as_owner
send_email(@user, @collection)
end
redirect_to action: 'edit', collection_id: @collection.id
redirect_to collection_edit_owners_path(@collection)
end

def remove_owner
@collection.owners.delete(@user)
redirect_to action: 'edit', collection_id: @collection.id
redirect_to collection_edit_owners_path(@collection)
end

def add_collaborator
Expand All @@ -206,12 +220,25 @@ def add_collaborator
if @user.notification.add_as_collaborator
send_email(@user, @collection)
end
redirect_to action: 'edit', collection_id: @collection.id
redirect_to collection_edit_collaborators_path(@collection)
end

def remove_collaborator
@collection.collaborators.delete(@user)
redirect_to action: 'edit', collection_id: @collection.id
redirect_to collection_edit_collaborators_path(@collection)
end

def add_reviewer
@collection.reviewers << @user
if @user.notification.add_as_collaborator
send_email(@user, @collection)
end
redirect_to collection_edit_reviewers_path(@collection)
end

def remove_reviewer
@collection.reviewers.delete(@user)
redirect_to collection_edit_reviewers_path(@collection)
end

def send_email(user, collection)
Expand Down Expand Up @@ -305,6 +332,9 @@ def edit
int = array[@lang_index].size.times.select {|i| array[@lang_index][i].include?(lang)}[0]
#transform to integer and subtract 2 because of how the array is nested
@dialect_index = !int.nil? ? int-2 : nil
if @collection.field_based && !@collection.transcription_fields.present?
flash.now[:info] = t('.alert')
end
end

def update
Expand Down Expand Up @@ -610,6 +640,6 @@ def set_collection_for_work(collection, work)
end

def collection_params
params.require(:collection).permit(:title, :slug, :intro_block, :footer_block, :transcription_conventions, :help, :link_help, :subjects_disabled, :review_workflow, :hide_completed, :text_language, :default_orientation, :voice_recognition, :picture, :user_download)
params.require(:collection).permit(:title, :slug, :intro_block, :footer_block, :transcription_conventions, :help, :link_help, :subjects_disabled, :review_type, :hide_completed, :text_language, :default_orientation, :voice_recognition, :picture, :user_download)
end
end
27 changes: 21 additions & 6 deletions app/controllers/concerns/export_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module ExportService
include AbstractXmlHelper
include StaticSiteExporter

def add_readme_to_zip(dirname:, out:)
readme = "#{Rails.root}/doc/zip/README"
Expand All @@ -10,14 +11,19 @@ def add_readme_to_zip(dirname:, out:)
end

def export_printable_to_zip(work, edition, output_format, dirname, out)
path = File.join dirname, 'printable', "facing_edition.pdf"
case edition
when "facing"
path = File.join dirname, 'printable', "facing_edition.pdf"
when "text"
path = File.join dirname, 'printable', "text.#{output_format}"
end

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

def export_printable(work, edition, format)

# render to a string
rendered_markdown =
ApplicationController.new.render_to_string(
Expand Down Expand Up @@ -51,14 +57,17 @@ def export_printable(work, edition, format)

# run pandoc against the temp directory
log_file = File.join(temp_dir, "#{file_stub}.log")
cmd = "pandoc -o #{output_file} #{md_file} --pdf-engine=xelatex --verbose > #{log_file} 2>&1"
print cmd
cmd = "pandoc --from markdown+superscript -o #{output_file} #{md_file} --pdf-engine=xelatex --verbose > #{log_file} 2>&1"
puts cmd
logger.info(cmd)
system(cmd)
puts File.read(log_file)

output_file
end



def export_work_metadata_csv(dirname:, out:, collection:)
path = "work_metadata.csv"
out.put_next_entry(path)
Expand Down Expand Up @@ -136,6 +145,9 @@ def export_plaintext_transcript_pages(name:, dirname:, out:, page:)
out.put_next_entry path
out.write page.emended_transcription_plaintext
end
when "searchable"
out.put_next_entry path
out.write page.search_text
end
end

Expand Down Expand Up @@ -230,6 +242,7 @@ def export_html_full_pages(dirname:, out:, page:)
out.write page_view
end


private

def spreadsheet_heading_to_indexable(field_id, column_label)
Expand All @@ -248,6 +261,7 @@ def get_headings(collection, ids)
cell_headings = orphan_cell_headings + markdown_cell_headings

@raw_headings = (field_headings + cell_headings + renamed_cell_headings).uniq
@indexable_headings = @raw_headings.map { |e| e.is_a?(String) ? e.downcase : e }
@headings = []

@page_metadata_headings = collection.page_metadata_fields
Expand Down Expand Up @@ -486,8 +500,9 @@ def index_for_cell(cell)
index = (@raw_headings.index(cell.transcription_field_id))
end
end
index = (@raw_headings.index(cell.header)) unless index
index = (@raw_headings.index(cell.header.strip)) unless index
index = (@indexable_headings.index(cell.header)) unless index
index = (@indexable_headings.index(cell.header.downcase)) unless index
index = (@indexable_headings.index(cell.header.strip.downcase)) unless index

index
end
Expand Down
Loading

0 comments on commit eeb9901

Please sign in to comment.