[sword-svn] r413 - in trunk/webapp: . examples

scribe at crosswire.org scribe at crosswire.org
Sat Apr 5 12:59:50 MST 2014


Author: scribe
Date: 2014-04-05 12:59:49 -0700 (Sat, 05 Apr 2014)
New Revision: 413

Modified:
   trunk/webapp/examples/parsevs.jsp
   trunk/webapp/fetchdata.jsp
   trunk/webapp/simplegadget.jsp
   trunk/webapp/simplelookup.jsp
Log:
updated to use defines for versekey magic numbers to make the code more easily readable.  Need to add these to the bindings for others to use or add getVerseKey which returns a nice structure, like we did in the javascript bindings
updated to handle special fonts



Modified: trunk/webapp/examples/parsevs.jsp
===================================================================
--- trunk/webapp/examples/parsevs.jsp	2013-11-02 22:07:20 UTC (rev 412)
+++ trunk/webapp/examples/parsevs.jsp	2014-04-05 19:59:49 UTC (rev 413)
@@ -9,6 +9,9 @@
 <%
 	SWMgr mgr = SwordOrb.getSWMgrInstance(request);
 
+	SWModule mod = mgr.getModuleByName("KJV");
+
+	
 String util = "/usr/bin/vs2osisref";
 String util2 = "/usr/bin/parsekey";
 String vs = request.getParameter("vs");
@@ -56,6 +59,15 @@
 <br/><h3>OSIS Reference:</h3><br/>
 <%
 	result = runCommand(new String[] {util, vs, context, locale}, out, true, true);
+%>
+<br/><h3>KJV.parseKeyList:</h3><br/>
+<%
+	String[] keys = mod.parseKeyList(vs);
+	for (String k : keys) {
+%>
+	<%= k %><br/>
+<%
+	}
 }
 %>
 

Modified: trunk/webapp/fetchdata.jsp
===================================================================
--- trunk/webapp/fetchdata.jsp	2013-11-02 22:07:20 UTC (rev 412)
+++ trunk/webapp/fetchdata.jsp	2014-04-05 19:59:49 UTC (rev 413)
@@ -9,6 +9,15 @@
 <%@ 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;
+
 	SWMgr mgr = SwordOrb.getSWMgrInstance(request);
 	SWModule book = null;
 	String ks = request.getParameter("key");
@@ -18,6 +27,11 @@
 	mgr.setGlobalOption("Footnotes", "Off");
 	mgr.setGlobalOption("Cross-references", "Off");
 
+	if ("plain".equals(format)) {
+		mgr.setGlobalOption("Strong's Numbers", "Off");
+		mgr.setGlobalOption("Morphological Tags", "Off");
+	}
+
 	String mods[] = new String[0];
 	if (modName != null) {
 		mods = modName.split("\\|");
@@ -180,14 +194,20 @@
 					
 					if ("tei".equals(format) && keyList.length > 0) {
 						book.setKeyText(keyList[0]);
+						response.setContentType("text/xml");
 %>
 <TEI>
-<div type="book" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[1])) %>" part="<%= ("1".equals(book.getKeyChildren()[2]))&&("1".equals(book.getKeyChildren()[3]))?"I":"Y"%>">
-<div type="chapter" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[1])) %>K<%= book.getKeyChildren()[2] %>" part="<%= ("1".equals(book.getKeyChildren()[3]))?"I":"Y"%>" >
+<div type="book" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[VERSEKEY_BOOK])) %>" part="<%= ("1".equals(book.getKeyChildren()[VERSEKEY_CHAPTER]))&&("1".equals(book.getKeyChildren()[VERSEKEY_VERSE]))?"I":"Y"%>">
+<div type="chapter" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[VERSEKEY_BOOK])) %>K<%= book.getKeyChildren()[VERSEKEY_CHAPTER] %>" part="<%= ("1".equals(book.getKeyChildren()[VERSEKEY_VERSE]))?"I":"Y"%>" >
 <%
 					}
 					for (int k = 0; k < keyList.length; ++k) {
 						String k1 = keyList[k];
+						// kludge for verse 0 which comes out to e.g., "Rev.2"
+						if (k1.split("\\.").length == 2) {
+							k1 = "=" + k1 + ".0";
+							continue;	// just skip chapter headings
+						}
 						book.setKeyText(k1);
 						if (("StrongsGreek".equals(modName)) && ("3588".equals(k1))) {
 							out.print("with Greek Article");
@@ -220,21 +240,26 @@
 						}
 						else {
 							if ("raw".equals(format) || "tei".equals(format)) {
+/*
+%>
+<milestone k="<%=k%>" key="<%=k1%>" keyText="<%=book.getKeyText()%>"/>
+<%
+*/
 
 								// ----- header for trier tinymce editor ------
 								if ("tei".equals(format)) {
-									if (k > 0 && "1".equals(book.getKeyChildren()[3])) {
-										if ("1".equals(book.getKeyChildren()[2])) {
+									if (k > 0 && "1".equals(book.getKeyChildren()[VERSEKEY_VERSE])) {
+										if ("1".equals(book.getKeyChildren()[VERSEKEY_CHAPTER])) {
 %>
-<div type="book" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[1])) %>">
+<div type="book" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[VERSEKEY_BOOK])) %>">
 <%
 										}
 %>
-<div type="chapter" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[1])) %>K<%= book.getKeyChildren()[2] %>">
+<div type="chapter" n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[VERSEKEY_BOOK])) %>K<%= book.getKeyChildren()[VERSEKEY_CHAPTER] %>">
 <%
 									}
 %>
-<ab n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[1])) %>K<%= book.getKeyChildren()[2] %>V<%= book.getKeyChildren()[3] %>">
+<ab n="B<%= String.format("%02d", Integer.parseInt(book.getKeyChildren()[VERSEKEY_BOOK])) %>K<%= book.getKeyChildren()[VERSEKEY_CHAPTER] %>V<%= book.getKeyChildren()[VERSEKEY_VERSE] %>">
 <%
 								}
 								// --------------------------------------------
@@ -247,13 +272,13 @@
 </ab>
 <%
 									// if last verse of chapter
-									if (k < keyList.length-1 && book.getKeyChildren()[5].equals(book.getKeyChildren()[3])) {
+									if (k < keyList.length-1 && book.getKeyChildren()[VERSEKEY_VERSEMAX].equals(book.getKeyChildren()[VERSEKEY_VERSE])) {
 System.out.println("ending chapter");
 %>
 </div>
 <%
 										// if last chapter of book
-										if (k < keyList.length-1 && book.getKeyChildren()[4].equals(book.getKeyChildren()[2])) {
+										if (k < keyList.length-1 && book.getKeyChildren()[VERSEKEY_CHAPTERMAX].equals(book.getKeyChildren()[VERSEKEY_CHAPTER])) {
 System.out.println("ending book");
 %>
 </div>
@@ -269,10 +294,10 @@
 								// ----- header for trier tinymce editor ------
 								if ("basetext".equals(format)) {
 %>
-<span class="chapter_number" part="<%=("1".equals(book.getKeyChildren()[3]))?"I":"Y"%>"> <%= book.getKeyChildren()[2]%></span>
+<span class="chapter_number" part="<%=("1".equals(book.getKeyChildren()[VERSEKEY_VERSE]))?"I":"Y"%>"> <%= book.getKeyChildren()[VERSEKEY_CHAPTER]%></span>
 <%
 %>
-<span class="verse_number"> <%= book.getKeyChildren()[3]%></span>
+<span class="verse_number"> <%= book.getKeyChildren()[VERSEKEY_VERSE]%></span>
 <%
 								}
 								if ("strip".equals(format)) {
@@ -283,8 +308,9 @@
 								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.
+									raw = mgr.filterText("OSISPlain", raw);
 %>
-<%= mgr.filterText("OSISPlain", raw) %>
+<%= raw %>
 <%
 								}
 								else {

Modified: trunk/webapp/simplegadget.jsp
===================================================================
--- trunk/webapp/simplegadget.jsp	2013-11-02 22:07:20 UTC (rev 412)
+++ trunk/webapp/simplegadget.jsp	2014-04-05 19:59:49 UTC (rev 413)
@@ -54,6 +54,7 @@
 	}
 %>
 </UserPref>
+<UserPref name="autoSelectMod" datatype="bool" display_name="Auto Select Bible from Last Manuscript Language" default_value="false" />
 <Content type="html">
 <![CDATA[
 <head>
@@ -64,6 +65,16 @@
 	
 
 <script type="text/javascript">
+
+var specialModules = {
+     bo  : "SahidicBible",
+     sa  : "SahidicBible",
+     fa  : "SahidicBible",
+     mae : "SahidicBible",
+     ly  : "SahidicBible",
+     cw  : "SahidicBible"
+};
+
         $(document).ready(function() {
 
 		$( "#tabs" ).tabs();
@@ -116,6 +127,8 @@
 <script>
 
 var swordModule = "WHNU";
+var chosenModule = swordModule;
+var autoSelectMod = false;
 var MARGIN = 8;
 var preferredHeight = -1;
 
@@ -237,6 +250,7 @@
 	var mod = getURLParams()['mod'];
 	if (mod != null) {
 		swordModule = mod;
+		chosenModule = mod;
 	}
 	var key = getURLParams()['key'];
 	if (key != null) {
@@ -245,6 +259,11 @@
 }
 
 function page_select_callback(topic, data, subscriberData) {
+	if (autoSelectMod) {
+		if (data.lang in specialModules)
+			swordModule = specialModules[data.lang];
+		else swordModule = chosenModule;
+	}
 	if (data.bibcont != null && data.bibcont.length > 0) {
 		lookup(data.bibcont);
 	}
@@ -310,6 +329,8 @@
 function loaded() {
 	var prefs = new gadgets.Prefs();
 	swordModule = prefs.getString('swordModule');
+	autoSelectMod = prefs.getBool('autoSelectMod');
+	chosenModule = swordModule;
      preferredHeight = parseInt(prefs.getString('height'));
      if (gadgets.util.hasFeature('dynamic-height')) gadgets.window.adjustHeight(preferredHeight == -1 ? 500 : preferredHeight);
      $('#searchContent').css('overflow', (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) ? 'visible' : 'auto');

Modified: trunk/webapp/simplelookup.jsp
===================================================================
--- trunk/webapp/simplelookup.jsp	2013-11-02 22:07:20 UTC (rev 412)
+++ trunk/webapp/simplelookup.jsp	2014-04-05 19:59:49 UTC (rev 413)
@@ -39,15 +39,17 @@
 	buf = request.getParameter("morph");
 	boolean morph =  "on".equalsIgnoreCase(buf);
 
-	activeModule.setKeyText(activeKey);
+	activeModule.setKeyText("="+activeKey);
 	activeKey = activeModule.getKeyText(); 	// be sure it is formatted nicely
+	String book = activeModule.getKeyChildren()[6];
+	int chapter = Integer.parseInt(activeModule.getKeyChildren()[2]);
+	int verse = Integer.parseInt(activeModule.getKeyChildren()[3]);
 %>
 <%= activeKey %>%%%
 		<div>
 
 		<%
 			if ((activeModule.getCategory().equals("Cults / Unorthodox / Questionable Material")) || (activeModule.getCategory().equals(SwordOrb.BIBLES))) {
-				String chapterPrefix = activeKey.substring(0, activeKey.indexOf(":"));
 				int activeVerse = Integer.parseInt(activeKey.substring(activeKey.indexOf(":")+1));
 				int anchorVerse = (activeVerse > 2)?activeVerse - 2: -1;
 				boolean first = true;
@@ -56,11 +58,11 @@
 				
 				String lastEusNum = "";
 				String myEusNum = "";
-				for (activeModule.setKeyText("="+chapterPrefix + ":0"); (activeModule.error() == (char)0); activeModule.next()) {
+				for (activeModule.setKeyText("="+book+"."+chapter+"."+"0"); (activeModule.error() == (char)0); activeModule.next()) {
+					if (chapter == 0) chapter = 1;
 					String keyText = activeModule.getKeyText();
 					String keyProps[] = activeModule.getKeyChildren();
 					// book and chapter intros
-					// TODO: change 'chapterPrefix' to use keyProps so we can support book intros (e.g. Jn.0.0)
 					boolean intro = (keyProps[2].equals("0") || keyProps[3].equals("0"));
 					if (eusVs != null) {
 						myEusNum = "";
@@ -82,8 +84,9 @@
 			<%
 						first = false;
 					}
-					int curVerse = Integer.parseInt(keyText.substring(keyText.indexOf(":")+1));
-					if (!chapterPrefix.equals(keyText.substring(0, keyText.indexOf(":")))) {
+					int curVerse = Integer.parseInt(keyProps[3]);
+					int curChapter = Integer.parseInt(keyProps[2]);
+					if (!book.equals(keyProps[6]) || curChapter > chapter) {
 						break;
 					}
 					mgr.setGlobalOption("Strong's Numbers",




More information about the sword-cvs mailing list