[sword-svn] r220 - in trunk: . WEB-INF/lib src
src/org/crosswire/swordweb
scribe at crosswire.org
scribe at crosswire.org
Wed Oct 12 01:24:23 MST 2005
Author: scribe
Date: 2005-10-12 01:24:22 -0700 (Wed, 12 Oct 2005)
New Revision: 220
Added:
trunk/WEB-INF/lib/greekconverter.jar
trunk/src/org/crosswire/swordweb/PerseusUtils.java
Modified:
trunk/blues.css
trunk/bookdisplay.jsp
trunk/fetchdata.jsp
trunk/parchment.css
trunk/print.css
trunk/sandy.css
trunk/src/Makefile
trunk/swordweb.js
trunk/wash.css
Log:
Added LXX support and Perseus lookup
Added: trunk/WEB-INF/lib/greekconverter.jar
===================================================================
(Binary files differ)
Property changes on: trunk/WEB-INF/lib/greekconverter.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/blues.css
===================================================================
--- trunk/blues.css 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/blues.css 2005-10-12 08:24:22 UTC (rev 220)
@@ -422,7 +422,7 @@
position:absolute;
left:50px;
top:50px;
- width:200px;
+ width:275px;
background-color: #fff3cf;
margin-left : 0;
overflow: visible;
Modified: trunk/bookdisplay.jsp
===================================================================
--- trunk/bookdisplay.jsp 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/bookdisplay.jsp 2005-10-12 08:24:22 UTC (rev 220)
@@ -8,7 +8,20 @@
String currentJumpNode = null;
boolean forceOpen = false;
+ boolean strongs = "on".equals((String) session.getAttribute("strongs"));
+ String buf = request.getParameter("strongs");
+ strongs = (buf != null) ? "on".equalsIgnoreCase(buf) : strongs;
+ session.setAttribute("strongs", (strongs)?"on":"off");
+ boolean morph = "on".equals((String) session.getAttribute("morph"));
+ buf = request.getParameter("morph");
+ morph = (buf != null) ? "on".equalsIgnoreCase(buf) : morph;
+ session.setAttribute("morph", (morph)?"on":"off");
+
+ String showStrong = request.getParameter("showStrong");
+ String showMorph = request.getParameter("showMorph");
+
+
session.setAttribute("lastModType", "GBS");
String gbsBook = (String)request.getParameter("mod");
if (gbsBook != null) {
@@ -148,10 +161,12 @@
<td><div <%= rtol ? "dir=\"rtl\"" : "" %> class="<%= (k.equals(gbsEntry)) ? "currentverse" : "verse" %>">
- <%
+<%
String lang = module.getConfigEntry("Lang");
// <div xml:lang="<%= (lang.equals("")) ? "en" : lang
- %>
+ mgr.setGlobalOption("Strong's Numbers", (strongs)?"On":"Off");
+ mgr.setGlobalOption("Morphological Tags", (morph)?"On":"Off");
+%>
<%= new String(module.getRenderText().getBytes("iso8859-1"), "UTF-8") %>
<%
// </div>
Modified: trunk/fetchdata.jsp
===================================================================
--- trunk/fetchdata.jsp 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/fetchdata.jsp 2005-10-12 08:24:22 UTC (rev 220)
@@ -2,21 +2,46 @@
language="java"
contentType="text/html;charset=utf-8"
%>
-
<%@ page import="org.crosswire.sword.orb.*" %>
+<%
-<%
SWMgr mgr = SwordOrb.getSWMgrInstance(session);
SWModule book = null;
String key = request.getParameter("key");
String modName = request.getParameter("mod");
- if (modName != null) {
- book = mgr.getModuleByName(modName);
+
+ // hack until LXXM morph is cleaned up -----
+ if ("Packard".equals(modName)) {
+ while (key.indexOf(" ") > -1) key = key.replaceAll(" ", " ");
}
- if ((key != null) && (book != null)) {
- book.setKeyText(key);
+ // end of LXXM Packard hack ----------------
+
+ if (!"betacode".equals(modName)) {
+ if (modName != null) {
+ book = mgr.getModuleByName(modName);
+ }
+ if ((key != null) && (book != null)) {
+ book.setKeyText(key);
%>
- <%= new String(book.getRenderText().getBytes("iso8859-1"), "UTF-8") %>
+ <%= new String(book.getRenderText().getBytes("iso8859-1"), "UTF-8") %>
<%
+ }
}
+ // betacode lookup from perseus
+ else {
+ key = new String(key.getBytes("iso8859-1"), "UTF-8");
+ String ls = org.crosswire.swordweb.PerseusUtils.getLiddellScottDef(key);
+ if (ls.length() > 15+key.length()) {
%>
+ <%= ls %>
+<div class="copyLine">from Liddell and Scott, <i>An Intermediate Greek-English Lexicon</i><br/>
+Courtesy of <a href="http://www.perseus.tufts.edu">Perseus Digital Library</a></div>
+<%
+ }
+ else {
+%>
+ <%= key %>
+<%
+ }
+ }
+%>
Modified: trunk/parchment.css
===================================================================
(Binary files differ)
Modified: trunk/print.css
===================================================================
--- trunk/print.css 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/print.css 2005-10-12 08:24:22 UTC (rev 220)
@@ -91,7 +91,7 @@
position:absolute;
left:50px;
top:50px;
- width:200px;
+ width:275px;
background-color: #fff3cf;
margin-left : 0;
overflow: visible;
Modified: trunk/sandy.css
===================================================================
--- trunk/sandy.css 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/sandy.css 2005-10-12 08:24:22 UTC (rev 220)
@@ -643,7 +643,7 @@
margin-left : 0;
left:50px;
top:50px;
- width:200px;
+ width:275px;
visibility: hidden;
background-color: #fff3cf;
overflow: visible;
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/src/Makefile 2005-10-12 08:24:22 UTC (rev 220)
@@ -1,11 +1,9 @@
TOMCAT_HOME=/usr/local/tomcat
-#TOMCAT_HOME=/usr/share/tomcat5
instdir=..
all: ../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class
- javac -Xlint -Xlint:unchecked:deprecation -classpath ../WEB-INF/classes/ -d ../WEB-INF/classes/ ./org/crosswire/swordweb/*.java
-
+
../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class: org/crosswire/web/i18n/TranslateTag.java
- javac -classpath ${TOMCAT_HOME}/common/lib/jsp-api.jar:${TOMCAT_HOME}/common/lib/servlet-api.jar -d ../WEB-INF/classes -sourcepath . ./org/crosswire/web/i18n/*.java ./org/crosswire/web/util/*.java
+ javac -classpath ${TOMCAT_HOME}/common/lib/jsp-api.jar:${TOMCAT_HOME}/common/lib/servlet-api.jar:../WEB-INF/classes:../WEB-INF/lib/greekconverter.jar -d ../WEB-INF/classes -sourcepath . ./org/crosswire/web/i18n/*.java ./org/crosswire/web/util/*.java ./org/crosswire/swordweb/*.java
clean:
rm -rf ../WEB-INF/classes/org/crosswire/web/*
Added: trunk/src/org/crosswire/swordweb/PerseusUtils.java
===================================================================
--- trunk/src/org/crosswire/swordweb/PerseusUtils.java 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/src/org/crosswire/swordweb/PerseusUtils.java 2005-10-12 08:24:22 UTC (rev 220)
@@ -0,0 +1,187 @@
+package org.crosswire.swordweb;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+import org.xml.sax.InputSource;
+import java.net.URL;
+import javax.xml.xpath.XPathConstants;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList;
+import java.net.*;
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.w3c.dom.*;
+import java.io.*;
+import greekconverter.UnicodeToBetacode;
+import greekconverter.BetacodeToUnicode;
+
+public class PerseusUtils {
+ public static String getLiddellScottDef(String lemma) {
+ UnicodeToBetacode bc = new UnicodeToBetacode();
+ String retVal = "<h2>"+lemma+"</h2>";
+ lemma = bc.convertString(lemma).toLowerCase();
+ // Perseus wants final sigma to be "s"
+ if (lemma.endsWith("j")) lemma = lemma.substring(0, lemma.length()-1) + "s";
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ String expression = "//entry/sense";
+ URL url = null;
+ try {
+ url = new URL("http://www.perseus.tufts.edu/hopper/xmlchunk.jsp?doc=Perseus%3Atext%3A1999.04.0058%3Aentry%3D"+URLEncoder.encode(lemma));
+ InputSource inputSource = new InputSource(url.openStream());
+ DTMNodeList nodes = (DTMNodeList)xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ retVal += outputSenseNode(n);
+ }
+ } catch (Exception ex) { ex.printStackTrace(); }
+ return retVal;
+ }
+
+ static String outputSenseNode(Node sense) {
+ String retVal = "<p>";
+ Node n = sense.getAttributes().getNamedItem("n");
+ if (n != null) retVal += "<span class=\"sameLemma\">"+n.getNodeValue()+"</span>. ";
+ NodeList children = sense.getChildNodes();
+ StringBuffer out = new StringBuffer();
+ for (int i = 0; i < children.getLength(); i++) {
+ print(children.item(i), out);
+ }
+ retVal += out.toString();
+ retVal += "</p>";
+ return retVal;
+ }
+
+
+
+ /** Prints the specified node, recursively. */
+ static public void print(Node node, StringBuffer out) {
+
+ // is there anything to do?
+ if ( node == null ) {
+ return;
+ }
+
+ int type = node.getNodeType();
+ switch (type) {
+ // print document
+ case Node.DOCUMENT_NODE: {
+ print(((Document)node).getDocumentElement(), out);
+ break;
+ }
+
+ // print element with attributes
+ case Node.ELEMENT_NODE: {
+ out.append('<');
+ out.append(node.getNodeName());
+ NamedNodeMap attrs = node.getAttributes();
+ for ( int i = 0; i < attrs.getLength(); i++ ) {
+ Node attr = attrs.item(i);
+ out.append(' ');
+ out.append(attr.getNodeName());
+ out.append("=\"");
+ out.append(normalize(attr.getNodeValue()));
+ out.append('"');
+ }
+ out.append('>');
+ NodeList children = node.getChildNodes();
+ if ( children != null ) {
+ int len = children.getLength();
+ for ( int i = 0; i < len; i++ ) {
+ print(children.item(i), out);
+ }
+ }
+ break;
+ }
+
+ // handle entity reference nodes
+ case Node.ENTITY_REFERENCE_NODE: {
+ NodeList children = node.getChildNodes();
+ if ( children != null ) {
+ int len = children.getLength();
+ for ( int i = 0; i < len; i++ ) {
+ print(children.item(i), out);
+ }
+ }
+ break;
+ }
+
+ // print cdata sections
+ case Node.CDATA_SECTION_NODE: {
+ out.append(normalize(node.getNodeValue()));
+ break;
+ }
+
+ // print text
+ case Node.TEXT_NODE: {
+ String txt = node.getNodeValue();
+ Node l = node.getParentNode().getAttributes().getNamedItem("lang");
+ if ((l != null) && ("greek".equals(l.getNodeValue()))) {
+ txt = (new BetacodeToUnicode().convertString(txt));
+ }
+ out.append(normalize(txt));
+ break;
+ }
+
+ // print processing instruction
+ case Node.PROCESSING_INSTRUCTION_NODE: {
+ out.append("<?");
+ out.append(node.getNodeName());
+ String data = node.getNodeValue();
+ if ( data != null && data.length() > 0 ) {
+ out.append(' ');
+ out.append(data);
+ }
+ out.append("?>");
+ break;
+ }
+ }
+
+ if ( type == Node.ELEMENT_NODE ) {
+ out.append("</");
+ out.append(node.getNodeName());
+ out.append('>');
+ }
+} // print(Node)
+
+ static String normalize(String s) {
+ StringBuffer str = new StringBuffer();
+
+ int len = (s != null) ? s.length() : 0;
+ for ( int i = 0; i < len; i++ ) {
+ char ch = s.charAt(i);
+ switch ( ch ) {
+ case '<': {
+ str.append("<");
+ break;
+ }
+ case '>': {
+ str.append(">");
+ break;
+ }
+ case '&': {
+ str.append("&");
+ break;
+ }
+ case '"': {
+ str.append(""");
+ break;
+ }
+ case '\r':
+ case '\n': {
+ str.append("&#");
+ str.append(Integer.toString(ch));
+ str.append(';');
+ break;
+ }
+ default: {
+ str.append(ch);
+ }
+ }
+ }
+
+ return (str.toString());
+
+} // normalize(String):String
+
+
+}
+
Modified: trunk/swordweb.js
===================================================================
--- trunk/swordweb.js 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/swordweb.js 2005-10-12 08:24:22 UTC (rev 220)
@@ -115,6 +115,22 @@
var curspans = new Array();
+function pe(extratext) {
+ b=document.getElementById("onlywlayer");
+ if (b!=null) {
+ c=document.getElementById("dm");
+ if (c!=null) {
+ xmlhttp.open("GET", "fetchdata.jsp?mod=Packard&key="+extratext,true);
+ xmlhttp.onreadystatechange=function() {
+ if (xmlhttp.readyState==4) {
+ c.innerHTML="<br/>"+extratext+"<br/>"+xmlhttp.responseText;
+ }
+ }
+ xmlhttp.send(null);
+ }
+ }
+}
+
function pd(extratext) {
b=document.getElementById("onlywlayer");
if (b!=null) {
@@ -154,7 +170,10 @@
xmlhttp.open("GET", "fetchdata.jsp?mod="+mod+"&key="+key,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
- b.innerHTML=xmlhttp.responseText + "<br/>"+"<div id=\"dm\"><a href=\"#\" onclick=\"pd('"+extratext+"');return false;\">"+extratext+"</a></div>";
+ if (mod != "betacode")
+ b.innerHTML=xmlhttp.responseText + "<br/>"+"<div id=\"dm\"><a href=\"#\" onclick=\"pd('"+extratext+"');return false;\">"+extratext+"</a></div>";
+ else
+ b.innerHTML=xmlhttp.responseText + "<br/>"+"<div id=\"dm\"><a href=\"#\" onclick=\"pe('"+extratext+"');return false;\">"+extratext+"</a></div>";
showhide("onlywlayer", "visible");
lastword = wordnum;
}
Modified: trunk/wash.css
===================================================================
--- trunk/wash.css 2005-10-08 18:38:15 UTC (rev 219)
+++ trunk/wash.css 2005-10-12 08:24:22 UTC (rev 220)
@@ -830,7 +830,7 @@
position:absolute;
left:50px;
top:50px;
- width:200px;
+ width:275px;
background-color: #EEEEEE;
margin-left : 0;
overflow: visible;
@@ -865,3 +865,6 @@
span.sameLemma { /* The other words with the same lemma on the page */
font-weight : bold;
}
+.word-layer.span.sameLemma { /* The other words with the same lemma on the page */
+ font-weight : bold;
+}
More information about the sword-cvs
mailing list