Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
benwbrum committed Jul 27, 2020
2 parents f8b4237 + 99a8b03 commit 61a86f0
Show file tree
Hide file tree
Showing 29 changed files with 143 additions and 73 deletions.
6 changes: 0 additions & 6 deletions app/controllers/application_controller.rb
Expand Up @@ -157,12 +157,6 @@ def bad_record_id
return
end


def pontiiif_server
Rails.application.config.respond_to?(:pontiiif_server) && Rails.application.config.pontiiif_server
end


def update_omeka_urls
if @work && @work.omeka_item && @work.omeka_item.needs_refresh?
@work.omeka_item.refresh_urls
Expand Down
14 changes: 9 additions & 5 deletions app/controllers/export_controller.rb
Expand Up @@ -33,6 +33,9 @@ def tei
@user_contributions =
User.find_by_sql("SELECT user_id user_id,
users.real_name real_name,
users.display_name display_name,
users.guest guest,
users.login login,
count(*) edit_count,
min(page_versions.created_on) first_edit,
max(page_versions.created_on) last_edit
Expand All @@ -49,12 +52,13 @@ def tei
@work_versions = PageVersion.joins(:page).where(['pages.work_id = ?', @work.id]).order("work_version DESC").includes(:page).all

@all_articles = @work.articles

@person_articles = @all_articles.joins(:categories).where(categories: {title: 'People'})
@place_articles = @all_articles.joins(:categories).where(categories: {title: 'Places'})
@other_articles = @all_articles.joins(:categories).where.not(categories: {title: 'People'})
.where.not(categories: {title: 'Places'})

person_category = @collection.categories.where(title: 'People').first
@person_articles = @all_articles.joins(:categories).where("articles_categories.category_id in (?)", person_category.descendants.map {|c| c.id}+[person_category.id])
place_category = @collection.categories.where(title: 'Places').first
@place_articles = @all_articles.joins(:categories).where("articles_categories.category_id in (?)", place_category.descendants.map {|c| c.id}+[place_category.id])

@other_articles = @all_articles - (@place_articles + @person_articles)
### Catch the rendered Work for post-processing
xml = render_to_string :layout => false, :template => "export/tei.html.erb"

Expand Down
1 change: 1 addition & 0 deletions app/controllers/ia_controller.rb
Expand Up @@ -104,6 +104,7 @@ def confirm_import
#id = detail_url.split('/').last

if @detail_url =~ /https?:\/\/(www\.)?archive\.org\/.+/
@detail_url.sub!(/\/mode\/.*/, '')
@matches = IaWork.where(:detail_url => @detail_url)
if @matches.size() == 0
# nothing to do here
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/sc_collections_controller.rb
Expand Up @@ -29,12 +29,6 @@ def import_cdm
redirect_to :back
end
end
#dead code
def search_pontiiif
search_param = params[:search_param]
at_id = ScCollection.collection_at_id_from_pontiiif_search(pontiiif_server, search_param)
redirect_to :action => :explore_collection, :at_id => at_id
end

def import
at_id = params[:at_id]
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/abstract_xml_helper.rb
Expand Up @@ -51,6 +51,14 @@ def xml_to_html(xml_text, preserve_lb=true, flatten_links=false)
lb.add_attribute('class', 'line-break')

if preserve_lb
if e.attributes['break'] == "no"
sib = e.previous_sibling
if sib.kind_of? REXML::Element
sib.add_text('-')
else
sib.value=sib.value+'-'
end
end
e.replace_with(REXML::Element.new('br'))
else
if params[:action] == "read_work" || params[:action] == 'needs_review_pages'
Expand Down
1 change: 0 additions & 1 deletion app/helpers/add_work_helper.rb
Expand Up @@ -30,7 +30,6 @@ def new_upload
if @document_upload.save
if SMTP_ENABLED
begin
SystemMailer.new_upload(@document_upload).deliver!
flash[:notice] = "Document has been uploaded and will be processed shortly. We'll email you at #{@document_upload.user.email} when ready."
rescue StandardError => e
log_smtp_error(e, current_user)
Expand Down
5 changes: 0 additions & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -125,11 +125,6 @@ def work_title
end
end

#dead code
def pontiiif_server
Rails.application.config.respond_to?(:pontiiif_server) && Rails.application.config.pontiiif_server
end

def language_attrs(collection)
direction = Rtl.rtl?(collection.text_language) ? 'rtl' : 'ltr'

Expand Down
1 change: 1 addition & 0 deletions app/helpers/collection_helper.rb
Expand Up @@ -35,6 +35,7 @@ def all_complete
end

def work_stats(work)
@progress_blank = work.work_statistic.pct_blank.round
unless work.supports_translation
@progress_annotated = work.work_statistic.pct_annotated.round
@progress_review = work.work_statistic.pct_needs_review.round
Expand Down
15 changes: 15 additions & 0 deletions app/helpers/export_helper.rb
Expand Up @@ -49,6 +49,21 @@ def subject_to_tei(subject)
tei = "<category xml:id=\"S#{subject.id}\">\n"
tei << "<catDesc>\n"
tei << "<term>#{subject.title}</term>\n"
tei << '<note type="categorization">Categories:'
subject.categories.each do |category|
tei << '<ab>'
category.ancestors.reverse.each do |parent|
if parent.root?
category_class = "#category #root"
else
category_class = "#category #branch"
end
tei << "<ptr ana=\"#{category_class}\" target=\"#C#{parent.id}\">#{parent.title}</ptr> -- "
end
tei << "<ptr ana=\"#category #leaf#{' #root' if category.root?}\" target=\"#C#{category.id}\">#{category.title}</ptr>"
tei << "</ab>"
end
tei << "</note>"
tei << "<gloss>#{xml_to_export_tei(subject.xml_text,ExportContext.new, "SD#{subject.id}")}</gloss>\n" unless subject.source_text.blank?
tei << "</catDesc>\n"
tei << "</category>\n"
Expand Down
6 changes: 6 additions & 0 deletions app/models/ia_work.rb
Expand Up @@ -299,6 +299,12 @@ def files_from_loc(loc_doc)
if zips.size < 1
zips = formats.select{|e| e.inner_text=='Single Page Processed JP2 Tar'}
end
if zips.size < 1
zips = formats.select{|e| e.inner_text=="Single Page Processed JPEG Tar"}
end



zip = zips.first.parent['name']

return [scandata, djvu, zip]
Expand Down
4 changes: 3 additions & 1 deletion app/models/page.rb
Expand Up @@ -293,7 +293,9 @@ def process_fields(field_cells)
input_type = TranscriptionField.find(tc.transcription_field_id).input_type

cell_data.each do |key, value|
#tc = TableCell.new(row: 1, header: key, content: value)
if value.scan('<').count != value.scan('>').count # broken tags or actual < / > signs
value = ERB::Util.html_escape(value)
end
tc.header = key
tc.content = value
key = (input_type == "description") ? (key + " ") : (key + ": ")
Expand Down
5 changes: 0 additions & 5 deletions app/models/sc_collection.rb
Expand Up @@ -47,9 +47,4 @@ def self.collection_for_at_id(at_id)

sc_collection
end

def self.collection_at_id_from_pontiiif_search(pontiiif_server, search_param)
# http://pontiiif.brumfieldlabs.com/api/v0.0/search/Irish
pontiiif_server + 'api/v0.0/search/' + CGI.escape(search_param)
end
end
14 changes: 7 additions & 7 deletions app/views/admin/_header.html.slim
Expand Up @@ -4,6 +4,13 @@
:options => {\
:controller => 'admin',
},
},{\
:name => 'Owners',
:selected => 3,
:options => {\
:controller => 'admin',
:action => 'owner_list',
},
},{\
:name => 'Users',
:selected => 2,
Expand All @@ -18,13 +25,6 @@
:controller => 'admin',
:action => 'flag_list',
},
},{\
:name => 'Owners',
:selected => 3,
:options => {\
:controller => 'admin',
:action => 'owner_list',
},
},{\
:name => 'Uploads',
:selected => 5,
Expand Down
2 changes: 1 addition & 1 deletion app/views/article/show.html.slim
Expand Up @@ -10,7 +10,7 @@
-if user_signed_in? && !current_user.guest
i =link_to 'Edit the description in the settings tab.', collection_article_edit_path(@collection.owner, @collection, @article)

-if @article.uri
-if @article.uri && @article.uri.include?("http")
p
| See also:
a href="#{@article.uri}" target="_blank" #{@article.uri}
Expand Down
3 changes: 2 additions & 1 deletion app/views/collection/_contributors_body.html.slim
Expand Up @@ -49,9 +49,10 @@
p A detailed spreadsheet export of all collaborators is available on your owner dashboard.

h3 All Collaborator Emails
p=link_to "Find recommendations for project newsletters.", "https://content.fromthepage.com/crowdsourcing-project-newsletter/"
p#collaborators
-unless @all_collaborators.empty?
=@all_collaborators
=@all_collaborators + ", support@fromthepage.com"
-else
|No collaborators

Expand Down
13 changes: 7 additions & 6 deletions app/views/collection/show.html.slim
Expand Up @@ -14,7 +14,7 @@
h2 Works

.start_link
-if @collection.has_untranscribed_pages?
-if @collection.has_untranscribed_pages? && @collection.active?
p
-if user_signed_in?
=link_to "Start Transcribing", collection_transcribe_page_path(@collection.owner, @collection, @collection.next_untranscribed_page.work, @collection.next_untranscribed_page), class: 'button'
Expand All @@ -39,7 +39,7 @@
span.progress
-unless @collection.subjects_disabled
span(style="width:#{@progress_annotated}%")
span(style="width:#{@progress_completed - @progress_annotated}%")
span(style="width:#{@progress_completed - @progress_annotated + @progress_blank}%")
-unless @progress_review == 0
span(style="width:#{@progress_review}%")

Expand All @@ -49,7 +49,7 @@
-link
p.transcribed =link_to @link_title, collection_path(@collection.owner, @collection, works: @link_type)

-if user_signed_in? && current_user.like_owner?(@collection)
-if user_signed_in? && current_user.like_owner?(@collection) && @collection.active?
-if @collection.is_a?(Collection)
p.nodata_text = link_to 'Add a new work', new_work_collection_path(@collection.owner, @collection)

Expand Down Expand Up @@ -78,10 +78,11 @@
=search_field_tag :search, params[:search], placeholder: 'Search for works...'
=button_tag 'Search'
=label_tag 'search', "Search for works", class: 'hidden'

-if @collection.active?
=link_to "Pages That Need Transcription", collection_needs_transcription_path(@collection.owner, @collection), class: 'button review-button'

=link_to "Pages That Need Transcription", collection_needs_transcription_path(@collection.owner, @collection), class: 'button review-button'

=link_to "Pages That Need Review", collection_needs_review_path(@collection.owner, @collection), class: 'button review-button'
=link_to "Pages That Need Review", collection_needs_review_path(@collection.owner, @collection), class: 'button review-button'

h3 Recent Notes
-@collection.notes.active.limit(10).each do |note|
Expand Down
2 changes: 1 addition & 1 deletion app/views/display/_multi_page.html.slim
Expand Up @@ -23,7 +23,7 @@
-if @work
-if @total != @count
=button_to "View All Pages", {action: "read_work", work_id: @work.id, needs_review: 'none'}, class: 'review-button'
-else
-elsif @collection.active?
=button_to "Pages That Need Transcription", {action: "read_work", work_id: @work.id, needs_review: 'transcription' }, class: 'review-button'
=button_to "Pages That Need Review", {action: "read_work", work_id: @work.id, needs_review: 'review' }, class: 'review-button'
=button_to "Pages That Need Indexing", {action: "read_work", work_id: @work.id, needs_review: 'index' }, class: 'review-button' if @work.supports_indexing?
Expand Down
4 changes: 3 additions & 1 deletion app/views/display/list_pages.html.slim
Expand Up @@ -2,7 +2,7 @@

-if @work.pages.empty?
.nodata
h4.nodata_title No pages found
h4.nodata_title No pages found.
p.nodata_text =="This work does not contain any pages yet, go to #{link_to('Pages tab', { controller: 'work', action: 'pages_tab', work_id: @work.id })} to create a new page"
-else
table.datagrid.work-contents
Expand All @@ -24,3 +24,5 @@
td
-page_action(page)
=link_to @wording, @path, class: 'button small outline'

=render({ :partial => '/shared/collection_footer' })
4 changes: 3 additions & 1 deletion app/views/display/read_work.html.slim
@@ -1,3 +1,5 @@
=render({ :partial => '/shared/work_tabs', :locals => { :selected => 1, :work_id => @work }})

=render({ :partial => 'multi_page'})
=render({ :partial => 'multi_page'})

=render({ :partial => '/shared/collection_footer' })
51 changes: 46 additions & 5 deletions app/views/export/tei.html.erb
Expand Up @@ -20,18 +20,18 @@ xml:id="export">
<editionStmt>
<edition>Edition created from new transcripts of this manuscript.</edition>
<respStmt xml:id="AU<%= @work.owner.id%>">
<resp>Initial upload of this work's facsimile images and metadata to FromThePage.com for editing</resp>
<resp>Initial upload of this work's facsimile images and metadata to FromThePage for editing</resp>
<persName><%= @work.owner.real_name%></persName>
</respStmt>

<respStmt xml:id="OU<%= @collection.owner.id%>">
<resp>Adminstrator of the <%=@collection.title%> transcription project on FromThePage.com</resp>
<resp>Adminstrator of the <%=@collection.title%> transcription project on FromThePage</resp>
<persName><%= @collection.owner.real_name %></persName>
</respStmt>

<% @user_contributions.each do |user| %>
<respStmt xml:id="U<%= user[:user_id]%>">
<persName><%= user[:real_name] %></persName>
<persName><%= user[:real_name] || user.display_name %></persName>
<% if user[:edit_count] == 1 %>
<resp>
made one edit on
Expand Down Expand Up @@ -80,8 +80,27 @@ xml:id="export">
<% @person_articles.each do |person| %>
<person xml:id="S<%=person.id%>">
<persName><%= person.title %></persName>
<% if person.categories %>
<note type="categorization">
Categories:
<% person.categories.each do |category| %>
<ab>
<% category.ancestors.reverse.each do |parent| %>
<% if parent.root?
category_class = "#category #root"
else
category_class = "#category #branch"
end
%>
<ptr ana="<%= category_class %>" target="#C<%= parent.id %>"><%= parent.title %></ptr> --
<% end %>
<ptr ana="#category #leaf<%= ' #root' if category.root? %>" target="#C<%= category.id %>"><%= category.title %></ptr>
</ab>
<% end %>
</note>
<% end %>
<% unless person.source_text.blank? %>
<note>
<note type="article">
<% unless person.source_text.blank? %>
<%= raw(xml_to_export_tei(person.xml_text, @context, "S#{person.id}")) %>
<% end %>
Expand All @@ -97,13 +116,35 @@ xml:id="export">
<% @place_articles.each do |place| %>
<place xml:id="S<%=place.id%>">
<placeName><%= place.title %></placeName>
<% if place.categories %>
<note type="categorization">
Categories:
<% place.categories.each do |category| %>
<ab>
<% category.ancestors.reverse.each do |parent| %>
<% if parent.root?
category_class = "#category #root"
else
category_class = "#category #branch"
end
%>
<ptr ana="<%= category_class %>" target="#C<%= parent.id %>"><%= parent.title %></ptr> --
<% end %>
<ptr ana="#category #leaf<%= ' #root' if category.root? %>" target="#C<%= category.id %>"><%= category.title %></ptr>
</ab>
<% end %>
</note>
<% end %>
<% unless place.source_text.blank? %>
<note>
<note type="article">
<% unless place.source_text.blank? %>
<%= raw(xml_to_export_tei(place.xml_text, @context, "S#{place.id}")) %>
<% end %>
</note>
<% end %>
<% unless place.latitude.blank? %>
<geo><%= place.latitude %> <%= place.longitude %></geo>
<% end %>
</place>
<% end %>
</listPlace>
Expand Down

0 comments on commit 61a86f0

Please sign in to comment.