Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use xslt override to include html tags with title #30

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions scripts/overrides/tei_to_es.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class TeiToEs < XmlToEs

def preprocessing
@year = date[/^\d{4}/] if date
xslt_location = "../whitman-scripts/scripts/archive-wide/internal_xslt.xslt"
@xslt = Nokogiri::XSLT(File.read(xslt_location))
end

def override_xpaths
Expand Down Expand Up @@ -220,6 +222,36 @@ def fig_location
images
end

def title
title_set = get_elements(@xpaths["title"])
#turn nodeset into document so xslt scripts can be run
title_xml = Nokogiri::XML::Document.new
title_root = title_xml.create_element('root')

title_set.each do |node|
title_root.add_child(node.clone)
end

title_xml.add_child(title_root)
#run xslt script to transform it into valid html whose markup will display on front end
@xslt.transform(title_xml)
end

def title_sort
#need to override Datura because of the xslt transformation of title
if title
if title.class == Nokogiri::XML::Document
title_text = get_text(title)
if title_text
Datura::Helpers.normalize_name(title_text)
end
else
#normal behavior for poems, clusters, etc.
Datura::Helpers.normalize_name(title)
end
end
end

private

def get_iiif_issue_dir(issue)
Expand Down