[sword-cvs] sword/src/modules/filters osiswebif.cpp,NONE,1.1 Makefile.am,1.23,1.24 gbfwebif.cpp,1.6,1.7 osishtmlhref.cpp,1.17,1.18 swbasicfilter.cpp,1.32,1.33

sword@www.crosswire.org sword@www.crosswire.org
Thu, 23 Oct 2003 19:43:48 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv15097/src/modules/filters

Modified Files:
	Makefile.am gbfwebif.cpp osishtmlhref.cpp swbasicfilter.cpp 
Added Files:
	osiswebif.cpp 
Log Message:


--- NEW FILE: osiswebif.cpp ---
/***************************************************************************
                          OSISWEBIF.cpp  -   OSIS to HTML filter with hrefs 
			        for strongs and morph tags
                             -------------------
    begin                    : 2003-10-23
    copyright            : 2003 by CrossWire Bible Society
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <stdlib.h>
#include <osiswebif.h>
#include <utilxml.h>
#include <versekey.h>
#include <swmodule.h>
#include <ctype.h>


SWORD_NAMESPACE_START



bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
	if (!substituteToken(buf, token)) {
		MyUserData *u = (MyUserData *)userData;
		XMLTag tag(token);

		// <w> tag
		if (!strcmp(tag.getName(), "w")) {

			// start <w> tag
			if ((!tag.isEmpty()) && (!tag.isEndTag())) {
				u->w = token;
			}

			// end or empty <w> tag
			else {
				bool endTag = tag.isEndTag();
				SWBuf lastText;
				bool show = true;	// to handle unplaced article in kjv2003-- temporary till combined

				if (endTag) {
					tag = u->w.c_str();
					lastText = u->lastTextNode.c_str();
				}
				else lastText = "stuff";

				const char *attrib;
				const char *val;
				if (attrib = tag.getAttribute("xlit")) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					buf.appendFormatted(" %s", val);
				}
				if (attrib = tag.getAttribute("gloss")) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					buf.appendFormatted(" %s", val);
				}
				if (attrib = tag.getAttribute("lemma")) {
					int count = tag.getAttributePartCount("lemma");
					int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
					do {
						attrib = tag.getAttribute("lemma", i);
						if (i < 0) i = 0;	// to handle our -1 condition
						val = strchr(attrib, ':');
						val = (val) ? (val + 1) : attrib;
						const char *val2 = val;
						if ((strchr("GH", *val)) && (isdigit(val[1])))
							val2++;
						if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
							show = false;
						else	buf.appendFormatted(" <small><em>&lt;<a href=\"%s?key=%s\">%s</a>&gt;</em></small> ", passageStudyURL.c_str(), encodeURL(val2).c_str(), val2);
					} while (++i < count);
				}
				if ((attrib = tag.getAttribute("morph")) && (show)) {
					SWBuf savelemma = tag.getAttribute("savlm");
					if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
						show = false;
					if (show) {
						int count = tag.getAttributePartCount("morph");
						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
						do {
							attrib = tag.getAttribute("morph", i);
							if (i < 0) i = 0;	// to handle our -1 condition
							val = strchr(attrib, ':');
							val = (val) ? (val + 1) : attrib;
							const char *val2 = val;
							if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
								val2+=2;
							buf.appendFormatted(" <small><em>(<a href=\"%s?key=%s\">%s</a>)</em></small> ", passageStudyURL.c_str(), encodeURL(val2).c_str(), val2);
						} while (++i < count);
					}
				}
				if (attrib = tag.getAttribute("POS")) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					buf.appendFormatted(" %s", val);
				}

				/*if (endTag)
					buf += "}";*/
			}
		}

		// <q> quote
		else if (!strcmp(tag.getName(), "q")) {
			SWBuf type = tag.getAttribute("type");
			SWBuf who = tag.getAttribute("who");
			const char *lev = tag.getAttribute("level");
			int level = (lev) ? atoi(lev) : 1;
			
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				/*buf += "{";*/

				//alternate " and '
				if (u->osisQToTick)
					buf += (level % 2) ? '\"' : '\'';
				
				if (who == "Jesus") {
					buf += "<span class=\"wordsOfJesus\"> ";
				}
			}
			else if (tag.isEndTag()) {
				//alternate " and '
				if (u->osisQToTick)
					buf += (level % 2) ? '\"' : '\'';
				buf += "</span>";
			}
			else {	// empty quote marker
				//alternate " and '
				if (u->osisQToTick)
					buf += (level % 2) ? '\"' : '\'';
			}
		}

		// <transChange>
		else if (!strcmp(tag.getName(), "transChange")) {
			SWBuf type = tag.getAttribute("type");
			
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {

// just do all transChange tags this way for now
				if ((type == "added") || (type == "supplied"))
					buf += "<i>";
				else if (type == "tenseChange")
					buf += "*";
			}
			else if (tag.isEndTag()) {
				if ((type == "added") || (type == "supplied"))
					buf += "</i>";
			}
			else {	// empty transChange marker?
			}
		}
		else {
			return OSISHTMLHREF::handleToken(buf, token, userData);
		}
	}
	return true;
}


SWORD_NAMESPACE_END


Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Makefile.am	27 Jul 2003 00:21:39 -0000	1.23
+++ Makefile.am	24 Oct 2003 02:43:46 -0000	1.24
@@ -41,6 +41,7 @@
 libsword_la_SOURCES += $(filtersdir)/osisheadings.cpp
 libsword_la_SOURCES += $(filtersdir)/osisfootnotes.cpp 
 libsword_la_SOURCES += $(filtersdir)/osishtmlhref.cpp
+libsword_la_SOURCES += $(filtersdir)/osiswebif.cpp
 libsword_la_SOURCES += $(filtersdir)/osismorph.cpp
 libsword_la_SOURCES += $(filtersdir)/osisstrongs.cpp
 libsword_la_SOURCES += $(filtersdir)/osisplain.cpp

Index: gbfwebif.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbfwebif.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gbfwebif.cpp	12 Aug 2003 05:36:30 -0000	1.6
+++ gbfwebif.cpp	24 Oct 2003 02:43:46 -0000	1.7
@@ -23,6 +23,8 @@
 
 GBFWEBIF::GBFWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.jsp") {
 //all is done in GBFHTMLHREF since it inherits form this class
+	addTokenSubstitute("FR", "<span class=\"wordsOfJesus\">"); // words of Jesus begin
+	addTokenSubstitute("Fr", "</span>");
 }
 
 bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {

Index: osishtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osishtmlhref.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- osishtmlhref.cpp	22 Oct 2003 03:10:46 -0000	1.17
+++ osishtmlhref.cpp	24 Oct 2003 02:43:46 -0000	1.18
@@ -300,7 +300,7 @@
 			strcat(filepath, src);
 
 // we do this because BibleCS looks for this EXACT format for an image tag
-			buf+="<figure src=\"";
+			buf+="<image src=\"";
 			buf+=filepath;
 			buf+="\" />";
 /*

Index: swbasicfilter.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/swbasicfilter.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- swbasicfilter.cpp	12 Aug 2003 05:36:30 -0000	1.32
+++ swbasicfilter.cpp	24 Oct 2003 02:43:46 -0000	1.33
@@ -94,10 +94,10 @@
 	if (!tokenCaseSensitive) {
 		stdstr(&buf, findString);
 		toupperstr(buf);
-		tokenSubMap.insert(DualStringMap::value_type(buf, replaceString));
+		tokenSubMap[buf] = replaceString;
 		delete [] buf;
 	}
-	else tokenSubMap.insert(DualStringMap::value_type(findString, replaceString));
+	else tokenSubMap[findString] = replaceString;
 }