<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement.Project" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document.CrossWireDocument" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.Segment" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.SegmentReading" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.SegmentReadingWitness" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.SegmentReading.ReadingWord" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.WitnessReading" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.Convert" %> <%@ page import="org.crosswire.utils.Utils" %> <%@ page import="org.crosswire.data.DataObject" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="java.io.File" %> <%@ page import="java.nio.charset.Charset" %> <%@ page import="java.io.InputStream" %> <%@ page import="java.io.InputStreamReader" %> <%@ page import="java.io.BufferedReader" %> <%@ page import="java.io.IOException" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashSet" %> <%@ page import="java.util.Set" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Vector" %> <%@ page import="java.util.UUID" %> <%@ page import="java.util.Collections" %> <%@ page import="java.util.Arrays" %> <%@ page import="org.apache.log4j.Logger" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.xml.XMLDataElement" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%@ page import="javax.validation.constraints.NotNull" %> <%@ page import="javax.validation.constraints.Pattern" %> <%! static Map styles = new HashMap() {{ put("Traditional", "traditional.css"); put("Minimal Witnesses", "minimal_wits.css"); put("Minimal", "minimal.css"); put("Verbose", "verbose.css"); }}; static Map superscripts = new HashMap() {{ put('ᵐ', 'm'); put('ˢ', 's'); put('ᶜ', 'C'); put('ⱽ', 'V'); put('ᵛ', 'v'); put('ᶠ', 'f'); put('ᵀ', 'T'); put('ᴬ', 'A'); put('ᴹ', 'M'); put('¹', '1'); put('²', '2'); put('³', '3'); put('ᵃ', 'a'); put('ᵇ', 'b'); put('ᶜ', 'c'); put('ᶢ', 'g'); }}; @Description(value = "Retrieve variant apparatus data", name = "variant/apparatus/get") public static class MyParameters extends Parameters { protected ProjectManagement.Project project = null; protected String styleFile = null; @NotNull @Description(value = "which range of apparatus to obtain", example = "Acts.4.5") public String indexContent = null; @Description(value = "limit results to a specific segmentGroupID; -1 = all", defaultValue = "-1", example = "3") public Integer segmentGroupID = null; @Description(value = "Project Name from which data should be retrieved (i.e., lookup the project segmentGroupID by project name)", example = "ECM Matthew") public String projectName; @Description(value = "augment results with segments from another group", example = "7") public Integer augmentGroupID = null; @Description(value = "include a baseline edition with apparatus", example = "ECM") public String includeBaseline = null; @Description(value = "use baseline module for any necessary computation but don't inclue in the output", example = "ECM") public String baseline = null; @Description(value = "include a style with output", example = "Minimal") public String style = null; @Description(value = "focus and highlight a segment", example = "2-4") public String segment = null; @Description(value = "highlight a witness", example = "10047") public Integer highlightDocID = null; @Description(value = "whether or not to turn on introduction slots, e.g., Matt.1.0, Matt.Inscriptio, Matt.Subscriptio", defaultValue = "true", example = "false") public Boolean intros = true; @Description(value = "whether or not to group all witnesses added from the {augmentGroupID} into their own section at the end of the witness list", defaultValue = "false", example = "true") public Boolean groupAugmentedWitnesses = false; @Description(value = "whether or not to break out sublabel readings into their own readings. Experimental", defaultValue = "true", example = "false") public Boolean breakoutSublabelReadings = true; @Description(value = "a projectID which should be queried to retrieve and display work progress for each segment", example = "1") public Integer includeProjectStatus = null; @Description(value = "include only witnesses from a project specified by projectID", example = "1") public Integer includeOnlyProjectWitnesses = null; @Description(value = "separation string to use between witness sigla", defaultValue = ". ", example = ", ") public String witnessDelimiter = ". "; @Description(value = "add extra detail if desired", defaultValue = "complete", example = "extra") public String detail = "complete"; @Description(value = "convert 'a' readings to positive apparatus", defaultValue = "false", example = "true") public Boolean positiveConversion = false; @Description(value = "cleanup hands display: remove additional hands if they agree with original; add * to original if corrector reads differently", defaultValue = "false", example = "true") public Boolean cleanHands = false; @Description(value = "collapse Byz witnesses according to INTF rules", defaultValue = "false", example = "true") public Boolean collapseByz = false; @Description(value = "collapse A witnesses according to INTF rules", defaultValue = "false", example = "true") public Boolean collapseA = false; @Description(value = "build lac reading if it is missing", defaultValue = "true", example = "false") public Boolean buildLac = true; @Description(value = "build A reading if it is missing and includeBaseline is provided", defaultValue = "true", example = "false") public Boolean buildA = true; @Description(value = "pull app from docID", example = "CrossWire:LXXGoeApp") public String docID = null; @Description(value = "summarize fully lacunose witnesses across either entire verse, or entire indexContent range (verse|range|false). Show it in a summary at the beginning instead of in each apparatus segment", defaultValue = "range", example = "verse") public String summarizeFullyLacWits = "range"; @Description(value = "include citation evidence", defaultValue = "false", example = "true") public Boolean includeCitations = false; @Pattern(regexp = "^(html|xml|json|icml)?$", message = "Valid response formats: html\", \"xml\", \"json\", or \"icml\"") @Description(value = "specify the result format: html, xml, json, icml", defaultValue = "xml", example = "html") public String format = "xml"; @Override protected void customValidation() { projectName = Transcription.assureUnicode(projectName); project = segmentGroupID != null ? ProjectManagement.getProject(segmentGroupID) : projectName != null ? ProjectManagement.getProject(projectName) : null; if (segmentGroupID == null && project != null) segmentGroupID = project.getProjectID(); if (baseline == null && includeBaseline != null) baseline = includeBaseline; if (style != null) { styleFile = styles.get(style); if (styleFile == null) { addError(-5, "not a valid {style}"); } } } } public static String loadModuleText(String moduleName, String key, boolean strip) { return loadModuleText(moduleName, key, (strip ? "strip" : "tei"), strip, null); } public static String loadModuleText(String moduleName, String key, String format, boolean toLower, String extraOptions) { Document doc = null; String t = null; // see if we've been given a docID int docID = -1; try { docID = Integer.parseInt(moduleName); } catch(Exception e) {} if (docID > -1) { doc = Document.getDocument(docID); } if (doc == null && !moduleName.startsWith("crosswire:") && !moduleName.startsWith("CrossWire:")) { doc = Document.getDocumentByPrimaryName(moduleName); } if (doc == null) { doc = new CrossWireDocument(moduleName, format, toLower, extraOptions); } if (doc != null) { String v11n = doc.getV11n(); VerseKey vk = new VerseKey(); vk.setIntros(true); if (v11n != null) vk.setVersificationSystem(v11n); vk.setText(key); int verseHash = vk.getHashNumber(); t = doc.getTranscriptionVerse(verseHash); } return t; } public static WitnessReading loadModuleReading(String moduleName, String key, boolean supplied, boolean unclear, boolean punct, boolean accents) { String t = loadModuleText(moduleName, key, true); if (t != null) { t = t.replaceAll("]*>", ""); t = t.replaceAll("", ""); t = t.replaceAll("]*>", ""); t = t.replaceAll("", ""); t = t.replaceAll("", ""); t = t.replaceAll("", ""); t = t.toLowerCase(); } //System.out.println("loadModuleReading: " + t); WitnessReading retVal = null; try { Vector wits = Convert.getTEITranscriptionText(t, supplied, unclear, punct, accents); retVal = (wits.size() > 0) ? wits.get(0) : new WitnessReading("", t); } catch (Exception e) { logger.error("Error looking up module: " + moduleName, e); retVal = new WitnessReading("", t); } retVal.setDocumentName(moduleName); return retVal; } static Logger logger = Logger.getLogger("apparatus/get"); static HashMap specialFonts = new HashMap(); static Set rightJustify = new HashSet(); static { specialFonts.put("bo", "Antinoou, AntinoouWeb"); specialFonts.put("sa", "Antinoou, AntinoouWeb"); specialFonts.put("fa", "Antinoou, AntinoouWeb"); specialFonts.put("mae", "Antinoou, AntinoouWeb"); specialFonts.put("ly", "Antinoou, AntinoouWeb"); specialFonts.put("cw", "Antinoou, AntinoouWeb"); // specialFonts.put("ar", "Arabic, ArabicWeb"); // specialFonts.put("arb", "Arabic, ArabicWeb"); specialFonts.put("syc", "Estrangelo Edessa, EstreWeb"); specialFonts.put("chu", "BukyvedeWeb"); rightJustify.add("syc"); rightJustify.add("he"); rightJustify.add("hbo"); rightJustify.add("arb"); rightJustify.add("ar"); } public static Thread startSlurpStreamThreaded(final InputStream is, final StringBuffer outBuf) { Thread t = new Thread() { InputStream myIS = is; StringBuffer myOutBuf = outBuf; public void run() { try { InputStreamReader isr = new InputStreamReader(myIS); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) myOutBuf.append(line + "\n"); } catch (IOException ioe) { ioe.printStackTrace(); } } }; t.start(); return t; } public static int runCommand(String command[], StringBuffer result, StringBuffer error, String toStdIn, Logger logger) { int retVal = -1; try { File cwd = new File("/home/ntvmr/ecm-app"); String cmd = ""; for (String s: command) { cmd += " [" + s + "]"; } //logger.info("executing from cwd ("+cwd.getAbsolutePath()+"):" + cmd); java.lang.Process p = Runtime.getRuntime().exec(command, new String[] { "HOME=/home/ntvmr" }, cwd); p.getOutputStream().write(toStdIn.getBytes(Charset.forName("UTF-8"))); Thread o = startSlurpStreamThreaded(p.getInputStream(), result); Thread e = startSlurpStreamThreaded(p.getErrorStream(), error); p.getOutputStream().close(); retVal = p.waitFor(); o.join(); e.join(); if (error.length() > 0) { logger.warn("error: " + error.toString()); } } catch (Exception e) {e.printStackTrace();} //logger.debug("returned: " + retVal + "; stdout: " + result); return retVal; } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); int detail = Segment.parseDetail(params.detail, Segment.DETAIL_COMPLETE); String uuid = UUID.randomUUID().toString(); String format = request.getParameter("format"); boolean intros = true; if ("false".equals(request.getParameter("intros"))) intros = false; if (params.indexContent != null && params.indexContent.length() > 0) { String defaultFontSpec = Utils.getSysConfig(session).getProperty("DefaultFontSpec", "GentiumPlus"); String lang = ""; String v11n = null; // fix this soon VerseKey vk = new VerseKey(); vk.setIntros(true); if (v11n != null) vk.setVersificationSystem(v11n); ListKey verses = vk.ParseVerseList(params.indexContent, "Mat.1.1", true); Object outputToSerialize = null; //params.getLogger().info("apparatus/get for " + verses.getText()); if ("icml".equals(format)) { response.setContentType("application/x-indesign"); response.setHeader("Content-Disposition", "attachment; filename=apparatus-"+((VerseKey)verses.getElement(0)).getOSISRef()+".icml"); String args[] = new String[] { "cat", "header.icml" }; String toStdIn = ""; StringBuffer resultBuf = new StringBuffer(); StringBuffer errorBuf = new StringBuffer(); runCommand(args, resultBuf, errorBuf, toStdIn, params.getLogger()); out.print(resultBuf.toString()); } else if ("html".equals(format)) { %> <% if (params.styleFile != null) { %> <% } } boolean firstVerse = true; List fullyLacWits = new ArrayList(); int verseCount = 0; for (verses.setPosition(VerseKey.TOP); verses.popError() == 0; verses.increment()) { ++verseCount; } StringBuffer retVal = new StringBuffer(); if (verseCount > 1 && "range".equals(params.summarizeFullyLacWits)) { List segments = Apparatus.getSegments(verses.getRangeText(), params.segmentGroupID, null, null, params.includeOnlyProjectWitnesses); fullyLacWits = Apparatus.extractFullyLacWits(segments); Collections.sort(fullyLacWits); if ("html".equals(params.format)) { %>
Fully non-extant witnesses: <% boolean first = true; for (SegmentReadingWitness srw : fullyLacWits) { if (!first) out.print(params.witnessDelimiter); out.print(srw.getWitnessText().replaceAll("_", " ")); first = false; } %>
<% } else if ("icml".equals(params.format)) { %> RightAlign . 31.181102362204726 RightAlign . 39.68503937007874 LeftAlign . 48.188976377952756 11 Helvetica Fully non-extant witnesses:
<% boolean first = true; for (SegmentReadingWitness srw : fullyLacWits) { %> 11 Helvetica <%="" + (!first ? params.witnessDelimiter : "") + srw.getWitnessText() %> <% first = false; } } %> 11 Helvetica
<% } for (verses.setPosition(VerseKey.TOP); verses.popError() == 0; verses.increment()) { try { //params.getLogger().info("apparatus/get: processing verse: " + verses.getText()); List segments = Apparatus.getSegments(verses.getText(), params.segmentGroupID, null, null, params.includeOnlyProjectWitnesses); //params.getLogger().info("processing verse: " + verses.getText() + "; getSegments returned: " + segments); if (params.augmentGroupID != null) { List augments = Apparatus.getSegments(verses.getText(), params.augmentGroupID); Apparatus.augmentSegments(segments, augments); } if (params.positiveConversion) { // Acts: 327 TODO: This needs to be dynamic. Maybe "ECMActs" doc group name // Apparatus.buildPositiveApparatus(segments, 327); } Collections.sort(segments); //params.getLogger().info("processing verse: " + verses.getText() + "; segments sort returned;"); WitnessReading baselineReading = null; if (params.baseline != null) { baselineReading = loadModuleReading(params.baseline, verses.getText(), true, true, true, true); } //params.getLogger().info("processing verse: " + verses.getText() + "; addMissingReadings start."); Apparatus.addMissingReadings(segments, params.buildA && baselineReading != null ? baselineReading.getTokens() : null, params.buildLac, params.segmentGroupID); //params.getLogger().info("processing verse: " + verses.getText() + "; addMissingReadings returned."); Apparatus.addOverlappingArrows(segments); if (!"false".equals(params.summarizeFullyLacWits)) { if ("verse".equals(params.summarizeFullyLacWits)) { fullyLacWits = Apparatus.extractFullyLacWits(segments); params.getLogger().info("Pulling fully lac witnesses by *verse*, count: " + fullyLacWits.size()); Collections.sort(fullyLacWits); } else if ("range".equals(params.summarizeFullyLacWits)) { Apparatus.extractFullyLacWits(segments, null, fullyLacWits); } } //params.getLogger().info("processing verse: " + verses.getText() + "; addOverlappingArrows returned."); if (params.cleanHands) { for (Segment s: segments) { s.cleanHands(); } } if (params.collapseA) { for (Segment s: segments) { s.designateDotDotDot(); } } if (params.collapseByz) { for (Segment s: segments) { s.designateByz(); } } ArrayList baselineReadingWords = new ArrayList(); // HTML and ICML output =============================================================== if ("html".equals(format) || "icml".equals(params.format)) { if (!firstVerse) { if ("icml".equals(params.format)) { out.println("
"); } else { out.print("
"); } } if ("icml".equals(params.format)) { %> RightAlign . 31.181102362204726 RightAlign . 39.68503937007874 LeftAlign . 48.188976377952756 11 Helvetica <%="" + ((VerseKey)verses.getElement(0)).getChapter() + ","+((VerseKey)verses.getElement(0)).getVerse()%>
RightAlign . 31.181102362204726 RightAlign . 39.68503937007874 LeftAlign . 48.188976377952756 <% } else { if (verseCount > 1) { out.print("

"); out.print(verses.getText()); out.print("

"); } } if ("html".equals(params.format)) { %>
<% } if (params.includeBaseline != null && baselineReading != null) { if ("html".equals(params.format)) { %>
<% } String tokens[] = baselineReading.getTokens(); for (int i = 0; i < tokens.length; ++i) { baselineReadingWords.add(new ReadingWord(tokens[i])); if ("html".equals(params.format)) { %> <%=tokens[i]%> <% } } if ("html".equals(params.format)) { %>
<% } } if ("html".equals(params.format)) { %>
<% } String appAttrib = ""; if (segments.size() > 0) { List segIDs = segments.get(0).getSegmentGroups(); if (segIDs.size() > 0) { Project p = ProjectManagement.getProject(segIDs.get(0)); if (p != null) { appAttrib = p.getApparatusAttribution(); } } } if (appAttrib == null || appAttrib.length() < 1) { if (verses.getText().startsWith("Acts")) { Project p = ProjectManagement.getProject(88); if (p != null) { appAttrib = p.getApparatusAttribution(); } } if (verses.getText().startsWith("Mark")) { Project p = ProjectManagement.getProject(54); if (p != null) { appAttrib = p.getApparatusAttribution(); } } } if (appAttrib != null && appAttrib.length() > 0) { if ("html".equals(params.format)) { %>

<%= appAttrib %>

<% } } if (params.docID != null) { String app = loadModuleText(params.docID, params.indexContent, "tei", false, "footnotes=On"); logger.info("Directly from Crosswire: " + app); StringBuffer allApps = new StringBuffer(app); String t = Transcription.popElement(allApps, "app"); if (t == null) t = allApps.toString(); out.print("
"); while (t != null) { String nextT = Transcription.popElement(allApps, "app"); StringBuffer allReadings = new StringBuffer(t); out.print("
"); String l = Transcription.popElement(allReadings, "lem"); if (l != null) { out.print("
"); out.print(l); out.print("
"); } // out.print("
    "); String r = Transcription.popElement(allReadings, "rdg"); while (r != null) { String nextR = Transcription.popElement(allReadings, "rdg"); out.print("
    "); out.print(r); out.print("
    "); r = nextR; } // out.print("
"); out.print("
\n"); t = nextT; } out.print("
"); return; } else { if ("html".equals(params.format)) { if ("verse".equals(params.summarizeFullyLacWits)) { %>
Fully non-extant witnesses: <% if (fullyLacWits != null) { boolean first = true; for (SegmentReadingWitness srw : fullyLacWits) { if (!first) out.print(params.witnessDelimiter); out.print(srw.getWitnessText().replaceAll("_", " ")); first = false; } } %>
<% } %> <% } for (Segment s : segments) { // be sure to do these for the other output formats!!! if (params.cleanHands) s.cleanHands(); if (params.collapseA) s.designateDotDotDot(); if (params.collapseByz) s.designateByz(); String cd = s.getContextDescription().replaceAll("[^0-9\\-]", ""); String words[] = cd.split("-"); String firstLabel = ""; boolean firstReading = true; int readNo = 0; SegmentReading srs[] = s.getSegmentReadings(); Arrays.sort(srs); int nonLacCount = 0; int nonLacNonSubCount = 0; for (SegmentReading sr : srs) { if (!"zz".equals(sr.getReadingName()) && (!"zu".equals(sr.getReadingName())) && (!"zw".equals(sr.getReadingName())) && (!"zv".equals(sr.getReadingName()))) { ++nonLacCount; ++nonLacNonSubCount; List subLabels = sr.getSubLabels(); nonLacCount += subLabels.size(); } } try { int start = Integer.parseInt(words[0]); words[0] = Integer.toString(Integer.parseInt(words[0])/2-1); if (words.length > 1) words[1] = Integer.toString(Integer.parseInt(words[1])/2-1); if (start % 2 != 0) { if (words.length < 2) { words = new String[] { words[0], words[0] }; words[1] = Integer.toString(Integer.parseInt(words[1])+1); } } if (srs.length > 0) firstLabel = srs[0].getReadingName(); } catch (Exception e) {} String projectStatus = ""; // we need to check if we're the right projects status, but for now, just show any project status if (params.includeProjectStatus != null) { String comment = s.getStatusComment(); String statusText = "Unassigned"; switch (s.getStatus()) { case 0: statusText = "Assigned"; break; case 1: statusText = "Reviewed"; break; case 2: statusText = "Of Interested"; break; case 4: statusText = "Problematic"; break; case 3: statusText = "Complete"; break; } if (comment != null && comment.trim().length() > 0) { comment = statusText + " \n" + comment; } else comment = statusText; projectStatus = "title=\""+comment+"\" data-segID=\""+s.getSegmentID()+"\" data-projectStatus=\""+s.getStatus()+"\" data-statusComment=\""+HTTPUtils.canonize(s.getStatusComment())+"\""; } // we want to include the segment always if we're HTML because we just display:none; on them and have the data if we want to extend the UI with hover help boolean showSegment = (nonLacCount != 1 || params.style == null || "html".equals(params.format) || !params.style.startsWith("Minimal")); //params.getLogger().info("segment: " + s.getContextDescription() + "nonLacCount: " + nonLacCount + "; nonLacNonSubCount: " + nonLacNonSubCount); if ("Minimal".equals(params.style) && "icml".equals(params.format)) { if (nonLacNonSubCount == 1) showSegment = false; } if (showSegment) { if ("html".equals(params.format)) { %> id="segment_<%=words[0]+(words.length > 1?"-"+words[1]:"")%>" <%=projectStatus %> data-nonLacCount="<%=nonLacCount%>" data-label="<%=firstLabel%>" data-wordsegs="<%=cd%>" class="appSegment segmentHead baseTextWord_<%=words[0]+(words.length > 1?"-"+words[1]:"")%>"> <% } else if ("icml".equals(params.format)) { %> 11 Helvetica <%=s.getContextDescription()%> <% } for (SegmentReading sr : srs) { List subLabels = sr.getSubLabels(); // add our base reading (no sublabel) subLabels.add(0, ""); for (String subLabel : subLabels) { String displayLabel = sr.getReadingDisplay()+subLabel; if ("Minimal".equals(params.style) && "icml".equals(params.format)) { if ("a".equals(sr.getReadingName()) || "zz".equals(sr.getReadingName()) || "zv".equals(sr.getReadingName()) || "zu".equals(sr.getReadingName()) || "zw".equals(sr.getReadingName()) ) { continue; } } ++readNo; // TODO: do we need this: if (sr.getWitnessesText(false, subLabel, params.witnessDelimiter).trim().length() == 0) continue; //params.getLogger().info("segmentReadingsCount ("+cd+"): " + srs.length + "; nonLacCount: " + nonLacCount + "; processing reading: " + sr.getReadingName() + "; subLabel: " + subLabel); if (!firstReading) { if ("html".equals(params.format)) { %> 1?"-"+words[1]:"")%>" data-label="<%=sr.getReadingName()%>" <% if (subLabel != null && subLabel.trim().length() > 0) { %> data-sublabel="<%=subLabel%>" <% } %> data-nonLacCount="<%=nonLacCount%>" > <% } } else out.println(""); String reading = sr.getReading(subLabel).trim(); //params.getLogger().info("sr("+subLabel+"): " + sr.toString()); String subtext = subLabel.length() > 0 ? "" : sr.getReadingSubtext(); String supportingReading = sr.getSupportingReading(); if (supportingReading != null) { supportingReading = supportingReading.trim(); if (supportingReading.length() == 0) supportingReading = null; } if ("html".equals(params.format)) { %> <% } else if ("icml".equals(params.format)) { %> 11 <%=("zw".equals(sr.getReadingName()) ? "Times New Roman" : "Helvetica") %> <%=((!firstReading) ? " ":"")+displayLabel%> <% } if ("html".equals(params.format)) { %> <% if (params.includeProjectStatus != null) { %>
" : "> "%> <% } %>
<% } else if ("icml".equals(params.format)) { if (!"Minimal".equals(params.style)) { String allWitnesses = primaryWitnesses+augmentedWitnesses; allWitnesses = allWitnesses.replaceAll("]*>", ""); allWitnesses = allWitnesses.replaceAll("", ""); allWitnesses = allWitnesses.replaceAll("
[^>]*
", ""); List witnessSegments = new ArrayList(); boolean superscript = false; int lastStart = 0; %> 11 Helvetica <% for (int i = 0; i < allWitnesses.length(); ++i) { if (superscripts.containsKey(allWitnesses.charAt(i)) && superscript == false) { String witText = allWitnesses.substring(lastStart, i); try { witText = witText.replaceAll("([^:])(L|K|S|CPA):", "11Helvetica$1$2:11Helvetica"); witText = witText.replaceAll("^(L|K|S|CPA):", "11Helvetica$1:11Helvetica"); witText = witText.replaceAll("Byz", "11HelveticaByz11Helvetica"); } catch (Exception e) { e.printStackTrace(); } %> 11 Helvetica <%=witText%> <% superscript = true; lastStart = i; } else if (!superscripts.containsKey(allWitnesses.charAt(i)) && superscript == true) { String superUnicodeToNormal = ""; for (Character c : allWitnesses.substring(lastStart, i).toCharArray()) { superUnicodeToNormal += superscripts.get(c); } %> 11 Helvetica <%=superUnicodeToNormal%> <% lastStart = i; superscript = false; } } String witText = allWitnesses.substring(lastStart); try { witText = witText.replaceAll("([^:])(L|K|S|CPA):", "11Helvetica$1$2:11Helvetica"); witText = witText.replaceAll("^(L|K|S|CPA):", "11Helvetica$1:11Helvetica"); witText = witText.replaceAll("Byz", "11HelveticaByz11Helvetica"); } catch (Exception e) { e.printStackTrace(); } %> 11 Helvetica <%=witText%> <% } %> 11 Helvetica
<% } firstReading = false; } } if ("icml".equals(params.format)) { } } } //params.getLogger().info("processing verse: " + verses.getText() + "; segments to html returned;"); if ("html".equals(params.format)) { %>
<%=s.getContextDescription()%>
<%=displayLabel%>" data-segmentid="<%=s.getSegmentID()%>" data-label="<%=sr.getReadingName()%>" data-wordsegs="<%=cd%>" data-segmentreadingid="<%=sr.getSegmentReadingID()%>" <% if (subLabel != null && subLabel.trim().length() > 0) { %> data-sublabel="<%=subLabel%>" <% } %> ><%= reading %> <% } else if ("icml".equals(params.format)) { %> " AppliedLanguage="$ID/Greek"> 11 <%=("zw".equals(sr.getReadingName()) ? "Helvetica":"SymbolGreekTU")%> <%= reading %> <% } if ("html".equals(params.format)) { %> <%=subtext != null && subtext.length() > 0 ? " " + subtext.trim() : ""%> <%=reading.length() > 0 ? "    " : ""%> <% } else if ("icml".equals(params.format) && (subtext != null && subtext.length() > 0)) { %> 11 Helvetica <%=subtext.trim()%> <% } //params.getLogger().info("segmentReadingWitnesses: " + sr.getWitnesses()); String primaryWitnesses = sr.getWitnessesText("html".equals(params.format), subLabel, params.witnessDelimiter, params.groupAugmentedWitnesses && params.augmentGroupID != null ? params.augmentGroupID * -1 : null, true, (!"false".equals(params.summarizeFullyLacWits))); String extEvidenceOut = ""; if ("html".equals(params.format)) { extEvidenceOut += " 0) { extEvidenceOut += " data-sublabel=\""+subLabel + "\""; } extEvidenceOut += " data-wordsegs=\""+cd+"\" class=\"extEvidence\" id=\"extEv"+readNo+"\""; extEvidenceOut += ">"; } if (params.includeCitations) { String url = "http://intf.uni-muenster.de/apparat/webservice/api.php"; url += "?book=" + ((VerseKey)verses.getElement(0)).getBook(); url += "&chapter=" + ((VerseKey)verses.getElement(0)).getChapter(); url += "&verse=" + ((VerseKey)verses.getElement(0)).getVerse(); url += "&segment="+ s.getContextDescription(); url += "&labez="+ sr.getReadingName(); if (subLabel != null && subLabel.trim().length() > 0) { url += "&labezsuf="+ subLabel; } String t = ""; try { String fathersResponse = HTTPUtils.postURL(url, null).toString(); //params.getLogger().info("url: " + url + "; response: " + fathersResponse); if (fathersResponse.indexOf("author") > -1) { XMLBlock f = XMLBlock.createXMLBlock(fathersResponse); XMLBlock address = f.getBlock("address"); if (address != null) { int extOffset = primaryWitnesses.indexOf(Apparatus.SegmentReading.afterSecondaryText); String beforeExtEvidence = extOffset > 0 ? primaryWitnesses.substring(0, extOffset) : ""; beforeExtEvidence = beforeExtEvidence.replace(Apparatus.SegmentReading.afterPrimaryText, ""); //params.getLogger().info("S: " + s.getContextDescription() + "; BEFORE EXTERNAL EVIDENCE: *" + beforeExtEvidence + "*; witnessDelimiter: *" + params.witnessDelimiter + "*"); boolean needPrecedingComma = (!beforeExtEvidence.endsWith(params.witnessDelimiter) && beforeExtEvidence.length() > 0); for (XMLDataElement e : address.getElements("author")) { if (t.length() > 0 || needPrecedingComma) t += params.witnessDelimiter; if ("html".equals(params.format)) { t += ""; } t += e.getText(); if ("html".equals(params.format)) { t += ""; } } if (!needPrecedingComma) t += params.witnessDelimiter; } } } catch(Exception e) {} extEvidenceOut += t; } if ("html".equals(params.format)) { extEvidenceOut += ""; } //params.getLogger().info("primaryWitnesses: " + primaryWitnesses + "; extEvidenceOut: " + extEvidenceOut); primaryWitnesses = primaryWitnesses.replaceAll(Apparatus.SegmentReading.afterSecondaryText, extEvidenceOut); //params.getLogger().info("primaryWitnesses after replace: " + primaryWitnesses); // group augmented witnesses String augmentedWitnesses = ""; String underMentionedWitnesses = ""; if (sr.underMentions != null) underMentionedWitnesses = sr.getWitnessesText("a", sr.underMentions, "html".equals(params.format), subLabel, params.witnessDelimiter, params.augmentGroupID, false, (!"false".equals(params.summarizeFullyLacWits))); if (params.groupAugmentedWitnesses && params.augmentGroupID != null) { augmentedWitnesses = sr.getWitnessesText("html".equals(params.format), subLabel, params.witnessDelimiter, params.augmentGroupID, false, (!"false".equals(params.summarizeFullyLacWits))); if (primaryWitnesses.length() > 0 && augmentedWitnesses.length() > 0) { String aw = augmentedWitnesses; augmentedWitnesses = ""; if ("html".equals(params.format)) { augmentedWitnesses += ""; } augmentedWitnesses += params.witnessDelimiter; if ("html".equals(params.format)) { augmentedWitnesses += ""; } augmentedWitnesses += aw; } } if ("html".equals(params.format)) { %> <%=primaryWitnesses%> <% if (supportingReading != null) { %>
<%=supportingReading%>
<% } if (params.groupAugmentedWitnesses && params.augmentGroupID != null) { %> <%=augmentedWitnesses%> <% } if (underMentionedWitnesses.length() > 0) { %> <% } %>
<% } if (params.includeBaseline != null && baselineReading != null) { %>




<% } if ("html".equals(params.format)) { %>
<% } } } else if ("latex".equals(format)) { } else { VerseKey verse = (VerseKey) verses.getElement(); retVal.append(""); if (!"false".equals(params.summarizeFullyLacWits)) { retVal.append(""); if (fullyLacWits != null) { for (SegmentReadingWitness srw : fullyLacWits) { retVal.append(srw.toFormattedXML()); } } retVal.append(""); // show fully lac wits } if (baselineReading != null) { } for (Segment s : segments) { // these should match EXACTLY to the above for (Segment ...) loop for HTML output if (params.cleanHands) s.cleanHands(); if (params.collapseA) s.designateDotDotDot(); if (params.collapseByz) s.designateByz(); s.setBreakoutReadingSublabels(params.breakoutSublabelReadings); retVal.append(s.toFormattedXML(detail | (params.includeProjectStatus != null ? Segment.DETAIL_INCLUDE_STATUS : 0))); } retVal.append(""); } firstVerse = false; if ("icml".equals(params.format)) { %>
<% } } catch (Exception e) { e.printStackTrace(); } } if ("html".equals(format)) { if (verseCount == 1) { %> <% } } else if ("icml".equals(params.format)) { String args[] = new String[] { "cat", "footer.icml" }; String toStdIn = ""; StringBuffer resultBuf = new StringBuffer(); StringBuffer errorBuf = new StringBuffer(); runCommand(args, resultBuf, errorBuf, toStdIn, params.getLogger()); out.print(resultBuf.toString()); } else { if (verseCount > 1) { retVal.insert(0,""); retVal.append(""); } outputToSerialize = XMLBlock.createXMLBlock(retVal.toString()); // out.print(retVal.toString()); Serializer.output(response, out, params, outputToSerialize); } return; } else ((Parameters)params).format = "html"; Serializer.reportErrors(request, response, out, params, true); %>