<%@ page language="java" contentType="text/html;charset=utf-8" %> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.sword.orb.*" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="java.net.URLEncoder" %> <% final int VERSEKEY_TESTAMENT = 0; final int VERSEKEY_BOOK = 1; final int VERSEKEY_CHAPTER = 2; final int VERSEKEY_VERSE = 3; final int VERSEKEY_CHAPTERMAX = 4; final int VERSEKEY_VERSEMAX = 5; final int VERSEKEY_BOOKNAME = 6; final int VERSEKEY_OSISREF = 7; final int VERSEKEY_SHORTTEXT = 8; final int VERSEKEY_BOOKABBREV = 9; SWMgr mgr = SwordOrb.getSWMgrInstance(request); SWModule book = null; String modName = request.getParameter("mod"); String ks = request.getParameter("key"); boolean includeRenderHeader = "true".equals(request.getParameter("includeRenderHeader")); if (ks != null && !"betacode".equals(modName)) { ks = new String(ks.getBytes("iso8859-1"), "UTF-8"); } //System.out.println("****"); //System.out.println("ks: " + ks); // if (ks != null) ks = new String(ks.getBytes("iso8859-1"), "UTF-8"); String fn = request.getParameter("fn"); String format = request.getParameter("format"); boolean pages = "true".equals(request.getParameter("pages")); String footnotes = request.getParameter("footnotes"); footnotes = (!"On".equals(footnotes)) ? "Off" : "On"; mgr.setGlobalOption("Footnotes", footnotes); mgr.setGlobalOption("Cross-references", "Off"); //System.out.println("****"); String inTestament = null; String inBook = null; String inChapter = null; String inVerse = null; if ("plain".equals(format)) { mgr.setGlobalOption("Strong's Numbers", "Off"); mgr.setGlobalOption("Morphological Tags", "Off"); } if ("tei".equals(format) && "LXXCATSS".equals(modName)) { mgr.setGlobalOption("Greek Accents", "Off"); } String mods[] = new String[0]; if (modName != null) { mods = modName.split("\\|"); } if (ks != null) { String parts[] = ks.split("\\|"); for (int i = 0; i < parts.length; i++) { if (i < mods.length) modName = mods[i]; String key = parts[i]; if ("betacode".equals(modName)) { // key = new String(key.getBytes("iso8859-1"), "UTF-8"); } if (i > 0) out.print("
__________________

"); // hack until LXXM morph is cleaned up ----- if ("Packard".equals(modName)) { while (key.indexOf(" ") > -1) key = key.replaceAll(" ", " "); } // end of LXXM Packard hack ---------------- if ("ls".equals(modName)) { SWModule greekLemma = mgr.getModuleByName("GreekStrongToLem"); greekLemma.setKeyText(key); key = greekLemma.getRawEntry(); modName = "betacode"; } // ------ betacode lookup from perseus ------------------------------------------------ if ("betacode".equals(modName)) { //System.out.println("Perseus Lookup: " + key); String ls = org.crosswire.swordweb.PerseusUtils.getLiddellScottDef(key); //System.out.println("Perseus returned: " + ls); if (ls.length() > 0) { %> <%= ls %>
from Liddell and Scott, An Intermediate Greek-English Lexicon
Courtesy of Perseus Digital Library
<% } else { %>

<%= key %>

<% } } // ------ Textual Evidence Lookup from INTF --------------------------------------------- else if ("TC".equals(modName)) { String srcMod = request.getParameter("srcMod"); String activeKey = (String)session.getAttribute("ActiveKey"); if (srcMod != null) { book = mgr.getModuleByName(srcMod); } //System.out.println("book:" + book+ ";key="+key+"activeKey:"+activeKey); if ((key != null) && (book != null) && activeKey != null) { try { Integer.parseInt(key); // assert we have only an int and need to get our book and chapter from session String activeChapter = activeKey.substring(0, activeKey.indexOf(":")); activeKey = activeChapter+"."+key; } catch (Exception e) { activeKey = key; } // not an error, just hopefully have entire versekey already String vk[] = book.parseKeyList(activeKey); activeKey=vk[0]; StringBuffer vmrResponse = HTTPUtils.postURL("https://ntvmr.uni-muenster.de/community/vmr/api/metadata/liste/search/", "biblicalContent="+activeKey+"&detail=page&limit=40"); //System.out.println("**** response: " + vmrResponse); XMLBlock manuscripts = new XMLBlock(vmrResponse.toString()); %>

Some Manuscript Witnesses for <%=vk[0]%>

<% for (XMLBlock m : manuscripts.getBlocks("manuscript")) { for (XMLBlock p : m.getBlock("pages").getBlocks("page")) { String thumbURL = null; String imageURL = null; String transURL = null; XMLBlock block = p.getBlock("images"); if (block != null) { block = block.getBlock("image"); if (block != null) { thumbURL = block.getAttribute("thumbURL"); imageURL = block.getAttribute("webFriendlyURL"); } } block = p.getBlock("transcriptions"); if (block != null) { block = block.getBlock("transcription"); if (block != null) { transURL = block.getAttribute("uri"); } } String mssURL = "//ntvmr.uni-muenster.de/manuscript-workspace?docID=" + m.getAttribute("docID")+"&pageID="+p.getAttribute("pageID"); %> <% } } %>
MsCenturyFolioContent 
<%=m.getAttribute("gaNum")%> <%=m.getValue("originYear")%> <%=p.getAttribute("folio")%> <% if (transURL != null) { %> <% } %> <%=p.getAttribute("biblicalContent")%> <% if (transURL != null) { %> <% } %> <% if (imageURL != null) { %> <% } if (thumbURL != null) { %> <% } if (imageURL != null) { %> <% } %>

This dataset is by no means exhaustive and is growing rapidly. Check back soon for more results.

Courtesy of Institut für Neutestamentliche Textforschung
<% } } // normal SWORD mod lookup else { if (modName != null) { book = mgr.getModuleByName(modName); } if ((key != null) && (book != null)) { if ("RenderHeader".equals(key)) { out.print(book.getRenderHeader()); return; } if (includeRenderHeader) { %> <% } String keyList[] = SwordOrb.BIBLES.equals(book.getCategory())?book.parseKeyList(key) : new String[] { key }; //System.out.println(key); //System.out.println(keyList[0]); if ("json".equals(format)) { response.setContentType("application/json"); out.print("{ \"result\": [ "); } if ("raw".equals(format)) { response.setContentType("text/plain"); } if ("tei".equals(format)) { response.setContentType("text/xml"); %> <% if (keyList.length > 0) { book.setKeyText(keyList[0]); } else { %>
<% } } // shift subscriptio to the end boolean lastInscriptio = false; String subscriptio = null; if (keyList.length > 0 && SwordOrb.BIBLES.equals(book.getCategory())) { String curBook = ""; //System.out.println("***** cleaning up in/subsriptios"); for (int k = 0; k < keyList.length; ++k) { String keyParts[] = keyList[k].split("\\."); String thisBook = keyParts[0]; //System.out.println("Key: " + keyList[k] + "; thisBook: " + thisBook + "; keyParts.length: " + keyParts.length + "; lastInscription: " + lastInscriptio); if (subscriptio != null && thisBook != curBook) { keyList[k-1] = subscriptio; subscriptio = null; curBook = thisBook; } if (keyParts.length == 2 && "1".equals(keyParts[1])) { //System.out.println("Scriptio found ("+k+"): " + keyList[k]); if (lastInscriptio) keyList[k] = null; else subscriptio = keyList[k]; } lastInscriptio = (keyParts.length == 1); if (subscriptio != null && k < keyList.length-1) { keyList[k] = keyList[k+1]; } curBook = thisBook; /* shift first to end String start = keyList[0]; System.arraycopy(keyList, 1, keyList, 0, keyList.length - 1); keyList[keyList.length - 1] = start; */ } if (subscriptio != null) keyList[keyList.length-1] = subscriptio; //System.out.println("===== finished cleaning up in/subsriptios"); } String lastBook = ""; String lastChapter = ""; String lastShownPBN = ""; for (int k = 0; k < keyList.length; ++k) { String k1 = keyList[k]; if (k1 == null) continue; // kludge for verse 0 which comes out to e.g., "Rev.2" if (k1.split("\\.").length == 2 && SwordOrb.BIBLES.equals(book.getCategory())) { // magic '=' prefix turns on intros k1 = "=" + k1 + ".0"; // continue; // just skip chapter headings } else if (k1.split("\\.").length == 1 && SwordOrb.BIBLES.equals(book.getCategory())) { k1 = "=" + k1 + ".0.0"; // continue; // just skip chapter headings } //System.out.println("key: " + k1); book.setKeyText(k1); String keyChildren[] = book.getKeyChildren(); String nowTestament = keyChildren.length > VERSEKEY_TESTAMENT ? keyChildren[VERSEKEY_TESTAMENT] : ""; String nowBook = keyChildren.length > VERSEKEY_BOOK ? keyChildren[VERSEKEY_BOOK] : ""; String nowChapter = keyChildren.length > VERSEKEY_CHAPTER ? keyChildren[VERSEKEY_CHAPTER] : ""; String nowVerse = keyChildren.length > VERSEKEY_VERSE ? keyChildren[VERSEKEY_VERSE] : ""; String nowBookAbbrev = keyChildren.length > VERSEKEY_BOOKABBREV ? keyChildren[VERSEKEY_BOOKABBREV] : ""; String nowBookName = keyChildren.length > VERSEKEY_BOOKNAME ? keyChildren[VERSEKEY_BOOKNAME] : ""; String nowOSISRef = keyChildren.length > VERSEKEY_OSISREF ? keyChildren[VERSEKEY_OSISREF] : ""; boolean hasEntry = book.getRawEntry().length() > 0; // skip empty incipits and explicits if (nowVerse.equals("0") && !hasEntry) { continue; } //System.out.println("book key: " + book.getKeyText()); if (("StrongsGreek".equals(modName)) && ("3588".equals(k1))) { out.print("with Greek Article"); } else if (fn != null) { try { String[] type = book.getEntryAttribute("Footnote", fn, "type", false); if ((type.length > 0) && type[0].equalsIgnoreCase("crossReference")) { String[] attr = book.getEntryAttribute("Footnote", fn, "refList", false); if (attr.length > 0) { String[] keys = book.parseKeyList(attr[0]); if (keys.length > 0) { out.print("
"); for (int j = 0; j < keys.length; j++) { book.setKeyText(keys[j]); out.print("
" + book.getKeyText() + "
" + book.getRenderText()+"
\n"); } out.print("
"); } } } else { String[] attr = book.getEntryAttribute("Footnote", fn, "body", true); if (attr.length > 0) { out.print(attr[0]); } } } catch (Exception e) { e.printStackTrace(); } } else { if ("raw".equals(format) || "tei".equals(format)) { // ----- header for trier tinymce editor ------ if ("tei".equals(format)) { if (inChapter != null && (!nowChapter.equals(inChapter) || !nowBook.equals(inBook) || nowVerse.equals("0"))) { if (!"0".equals(inChapter)) { %>
<% } } if (inBook != null && !nowBook.equals(inBook)) { %>
<% } if (!nowBook.equals(inBook)) { if (pages) { int t = Integer.parseInt(nowTestament); int b = Integer.parseInt(nowBook); int c = Integer.parseInt(nowChapter); if (b == 0) b = 1; if (c == 0) c = 1; String n = String.format("%d%03d%03d000", t, b, c); if (!n.equals(lastShownPBN)) { %> " osisID="<%=nowBookAbbrev + "." + c%>" pageID="<%=n%>" type="chapter"/> <% lastShownPBN = n; } } %>
" osisID="<%=nowBookAbbrev%>"> <% } if (!nowChapter.equals(inChapter) || !nowBook.equals(inBook) || nowVerse.equals("0")) { if (!nowVerse.equals("0")) { int t = Integer.parseInt(nowTestament); int b = Integer.parseInt(nowBook); int c = Integer.parseInt(nowChapter); if (b == 0) b = 1; if (c == 0) c = 1; if (pages) { String n = String.format("%d%03d%03d000", t, b, c); if (!n.equals(lastShownPBN)) { %> " osisID="<%=nowBookAbbrev + "." + c%>" pageID="<%=n%>" type="chapter"/> <% lastShownPBN = n; } } %>
K<%= nowChapter %>" osisID="<%=nowBookAbbrev + "." + c%>"> <% } } inChapter = nowChapter; inBook = nowBook; if (nowVerse.equals("0")) { inChapter = "0"; if (nowChapter.equals("0")) { %>
incipit" osisID="<%=nowOSISRef%>"><% } else if (nowChapter.equals("1")) { %>
explicit" osisID="<%=nowOSISRef%>"><% } } else { %> K<%= nowChapter %>V<%= nowVerse %>" osisID="<%=nowOSISRef%>"> <% } } // -------------------------------------------- if (!"raw".equals(format) && ("WHNU".equals(modName) || "WLC".equals(modName) || "LXX".equals(modName) || "Vulgate".equals(modName))) { %> <%= book.getStripText() %> <% } else if ("LXXCATSS".equals(modName) || "Aleppo".equals(modName)) { String raw = book.getStripText(); raw = mgr.filterText("OSISPlain", raw); // raw = mgr.filterText("UTF8GreekAccents", raw); while (raw.indexOf("\n") > -1) raw = raw.replaceAll("\n", " "); while (raw.indexOf("\r") > -1) raw = raw.replaceAll("\r", " "); while (raw.indexOf(" ") > -1) raw = raw.replaceAll(" ", " "); out.print(raw); } else if (!"raw".equals(format) && "ThML".equals(book.getConfigEntry("SourceType"))) { mgr.setGlobalOption("Strong's Numbers", "Off"); mgr.setGlobalOption("Morphological Tags", "Off"); book.getRenderText(); String raw = book.getRenderText(); // raw = mgr.filterText("ThMLPlain", raw); %> <%= raw %> <% } else if ("tei".equals(format)) { String t = book.getRawEntry(); t = t.replaceAll("x-preverse\"/", "x-preverse\""); if ("Off".equals(footnotes)) { t = t.replaceAll("]*[^/]>.*", ""); t = t.replaceAll("]*/>", ""); t = t.replaceAll("]*>", ""); t = t.replaceAll("]*>", ""); t = t.replaceAll("", ""); t = t.replaceAll("", ""); t = t.replaceAll("]*>", ""); t = t.replaceAll("", ""); t = t.replaceAll("]*>", ""); t = t.replaceAll("", ""); t = t.replaceAll("([>:;,'ʼ˙··.\u2014\u2027])", "$1"); // if we're adding our own chapter markers, then remove any tags in the text if (pages) { t = t.replaceAll("]*/>", ""); } } %> <%= t %> <% } else { %> <%= book.getRawEntry() %> <% } // ----- header for trier tinymce editor ------ if ("tei".equals(format)) { if (nowVerse.equals("0")) { if (nowChapter.equals("0") || nowChapter.equals("1")) { %>
<% } } else { %>
<% } } // -------------------------------------------- } else { // ----- header for trier tinymce editor ------ if ("basetext".equals(format)) { %> "> <%= nowChapter %> <% %> <%= nowVerse %> <% } if ("strip".equals(format)) { mgr.setGlobalOption("Greek Accents", "Off"); String raw = book.getStripText(); raw = raw.replaceAll("\\*", " "); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); // apparatus tags. TODO: we need to add this to a filter proper rather than do this here raw = raw.replaceAll("[⸆¹⸆²⸆⸇᾿˸¹˸²˸³˸·¹²⟦–ʹ°¹°²⸋¹⸋²⸋⸌¹⸌°*\\[\\];⸀¹⸀²⸀³⸁⸀◆⟧⸂¹⸂²⸄⸂⸅⸃⸉¹⸈⸉⸊]", ""); %> <%= raw %> <% } else if ("plain".equals(format)) { String raw = book.getRawEntry(); // assume our modules are OSIS for now (should change output format of mgr or have a second mgr for this one. // // TODO: this doesn't work, but should. Find out why this crashes // raw = mgr.filterText("Strong's Numbers", raw); // raw = mgr.filterText("Morphological Tags", raw); // raw = mgr.filterText("OSISPlain", raw); raw = raw.replaceAll("\\([^)]*\\)", ""); raw = raw.replaceAll("\\<[^>]*\\>", ""); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); raw = raw.replaceAll(" ", " "); %> <%= raw %> <% } else { // -------------------------------------------- String suggest = ""; StringBuffer verseText = new StringBuffer(); if (book.getKeyChildren().length > VERSEKEY_BOOKABBREV) { suggest = book.getKeyChildren()[VERSEKEY_VERSE]; if (!lastChapter.equals(book.getKeyChildren()[VERSEKEY_CHAPTER]) || !lastBook.equals(book.getKeyChildren()[VERSEKEY_BOOKABBREV])) suggest = book.getKeyChildren()[VERSEKEY_CHAPTER] + ":" + suggest; if (!lastBook.equals(book.getKeyChildren()[VERSEKEY_BOOKABBREV])) suggest = book.getKeyChildren()[VERSEKEY_BOOKABBREV] + " " + suggest; verseText.append(""); } else { verseText.append(""); } verseText.append(book.getRenderText()); if ("json".equals(format)) { if (k > 0) out.print(", "); out.print("{ \"verse\": \"" + book.getKeyText() + "\", \"text\": \"" + jsonEscape(verseText.toString()) + "\" }"); } else out.print(verseText.toString()); } } } if (book.getKeyChildren().length > VERSEKEY_BOOKABBREV && !"0".equals(book.getKeyChildren()[VERSEKEY_VERSE])) { lastBook = book.getKeyChildren()[VERSEKEY_BOOKABBREV]; lastChapter = book.getKeyChildren()[VERSEKEY_CHAPTER]; } } if ("tei".equals(format)) { //System.out.println("inchapter: " + inChapter); if (!"0".equals(inChapter)) { %>
<% } %>
<% } else if ("json".equals(format)) { out.print(" ] }"); } } } } } else { response.setContentType("text/xml"); %> <% ModInfo[] modInfo = mgr.getModInfoList(); for (int i = 0; i < modInfo.length; i++) { SWModule b = mgr.getModuleByName(modInfo[i].name); String dist = b.getConfigEntry("DistributionLicense"); if ("".equals(dist)) dist=""; %> <%= HTTPUtils.canonize(b.getDescription()) %> <% } %> <% } %> <%! private static String jsonEscape(String raw) { String escaped = raw; escaped = escaped.replace("\\", "\\\\"); escaped = escaped.replace("\"", "\\\""); escaped = escaped.replace("\b", "\\b"); escaped = escaped.replace("\f", "\\f"); escaped = escaped.replace("\n", "\\n"); escaped = escaped.replace("\r", "\\r"); escaped = escaped.replace("\t", "\\t"); return escaped; } %>