[sword-cvs] sword/src/modules/filters thmlhtml.cpp,1.25,1.26 thmlhtmlhref.cpp,1.28,1.29 thmlmorph.cpp,1.8,1.9 thmlwebif.cpp,1.2,1.3

sword@www.crosswire.org sword@www.crosswire.org
Fri, 6 Jun 2003 13:43:00 -0700


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

Modified Files:
	thmlhtml.cpp thmlhtmlhref.cpp thmlmorph.cpp thmlwebif.cpp 
Log Message:
some more filter fixes

Index: thmlhtml.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlhtml.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** thmlhtml.cpp	6 Jun 2003 18:25:56 -0000	1.25
--- thmlhtml.cpp	6 Jun 2003 20:42:58 -0000	1.26
***************
*** 173,181 ****
  			}
  			else if (tag.getAttribute("class")) {
! 				if (!strcasecmp(tag.getAttribute("class"), "sechead")) {
  					userData["SecHead"] = "true";
  					buf += "<br /><b><i>";
  				}
! 				else if (!strcasecmp(tag.getAttribute("class"), "title")) {
  					userData["SecHead"] = "true";
  					buf += "<br /><b><i>";
--- 173,181 ----
  			}
  			else if (tag.getAttribute("class")) {
! 				if (!strcmp(tag.getAttribute("class"), "sechead")) {
  					userData["SecHead"] = "true";
  					buf += "<br /><b><i>";
  				}
! 				else if (!strcmp(tag.getAttribute("class"), "title")) {
  					userData["SecHead"] = "true";
  					buf += "<br /><b><i>";

Index: thmlhtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlhtmlhref.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** thmlhtmlhref.cpp	6 Jun 2003 18:25:56 -0000	1.28
--- thmlhtmlhref.cpp	6 Jun 2003 20:42:58 -0000	1.29
***************
*** 142,172 ****
  		XMLTag tag(token);
  		if (!strcmp(tag.getName(), "sync")) {
! 			if(strstr(token,"type=\"morph\"")){
  				buf += "<small><em> (<a href=\"";
! 			}				
! 			else
  				buf += "<small><em> &lt;<a href=\"";
! 			for (tok = token + 5; *(tok+1); tok++)
! 				if(*tok != '\"')
! 					buf += *tok;
  			buf += "\">";
! 				
!                         //scan for value and add it to the buffer
! 			for (tok = token + 5; *tok; tok++) {
! 				if (!strncmp(tok, "value=\"", 7)) {
! 					if(strstr(token,"type=\"morph\"")) 
! 						tok += 7;
! 					else
! 						tok += 8;
! 					for (;*tok != '\"'; tok++)
! 						buf += *tok;
! 					break;
! 				}
  			}
  
! 			if(strstr(token,"type=\"morph\""))
! 				buf += "</a>) </em></small>";
! 			else
  				buf += "</a>&gt; </em></small>";
  		}
  		else if (!strcmp(tag.getName(), "scripture")) {
--- 142,170 ----
  		XMLTag tag(token);
  		if (!strcmp(tag.getName(), "sync")) {
! 			if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) {
  				buf += "<small><em> (<a href=\"";
! 			}
! 			else {
  				buf += "<small><em> &lt;<a href=\"";
! 			}
! 
! 			buf += "type=";
! 			buf += tag.getAttribute("type");
! 
! 			const char* value = tag.getAttribute("value");
! 			buf += " value=";
! 			buf += value ? value : "";
  			buf += "\">";
! 
! 			//add the value
! 			if (value && tag.getAttribute("type") && strcmp(tag.getAttribute("type"), "morph")) { //not morph type
! 				value++;
  			}
+ 			buf += value;
  
! 			if(tag.getAttribute("type") && strcmp(tag.getAttribute("type"), "morph"))
  				buf += "</a>&gt; </em></small>";
+ 			else
+ 				buf += "</a>) </em></small>";
  		}
  		else if (!strcmp(tag.getName(), "scripture")) {

Index: thmlmorph.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlmorph.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** thmlmorph.cpp	6 Jun 2003 18:25:56 -0000	1.8
--- thmlmorph.cpp	6 Jun 2003 20:42:58 -0000	1.9
***************
*** 61,68 ****
--- 61,70 ----
  				  continue;
  				}
+ 
  				// if not a morph tag token, keep token in text
  				text += '<' + token + '>';
  				continue;
  			}
+ 
  			if (intoken) {
  				token += *from;

Index: thmlwebif.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlwebif.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** thmlwebif.cpp	6 Jun 2003 18:25:56 -0000	1.2
--- thmlwebif.cpp	6 Jun 2003 20:42:58 -0000	1.3
***************
*** 1,4 ****
  /***************************************************************************
!                      ThMLWEBIF.cpp  -  ThML to HTML filter with hrefs  
                               -------------------
      begin                    : 2001-09-03
--- 1,4 ----
  /***************************************************************************
!                      ThMLWEBIF.cpp  -  ThML to HTML filter with hrefs
                               -------------------
      begin                    : 2001-09-03
***************
*** 20,23 ****
--- 20,24 ----
  #include <swmodule.h>
  #include <utilweb.h>
+ #include <utilxml.h>
  
  SWORD_NAMESPACE_START
***************
*** 29,104 ****
  bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
  	const char *tok;
- 	std::string url;
  
! 	if (!substituteToken(buf, token)) {
! 	// manually process if it wasn't a simple substitution
! 		if (!strncmp(token, "sync ", 5)) {
! 			url = "";
  
! 			if(strstr(token,"type=\"morph\"")){
  				buf += "<small><em> (";
  			}
  			else {
  				buf += "<small><em> &lt;";
  			}
  
- 			for (tok = token + 5; *(tok+1); tok++) {
- 				if(*tok != '\"') {
- 					url += *tok;
- 				}
- 			}
  			buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(url).c_str() );
  
!                         //scan for value and add it to the buffer
! 			for (tok = token + 5; *tok; tok++) {
! 				if (!strncmp(tok, "value=\"", 7)) {
! 					if(strstr(token,"type=\"morph\""))
! 						tok += 7;
! 					else
! 						tok += 8;
! 					for (;*tok != '\"'; tok++)
! 						buf += *tok;
! 					break;
! 				}
  			}
! 			if(strstr(token,"type=\"morph\""))
! 				buf += "</a>) </em></small>";
! 			else
! 				buf += "</a>&gt; </em></small>";
! 		}
! 
! 		else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) {
! 			userData["inscriptRef"] = "true";
! 			url = "";
! 
! 			for (const char *tok = token + 9; *(tok+1); tok++) {
! 				if(*tok != '\"')
! 					url += *tok;
  			}
- 
- 			buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(url).c_str());
  		}
  
! 		// we've ended a scripRef
! 		else if (!strcmp(token, "/scripRef")) {
! 			if (userData["inscriptRef"] == "true") { // like  "<scripRef passage="John 3:16">John 3:16</scripRef>"
! 				userData["inscriptRef"] = "false";
! 				buf +="</a>";
  			}
  
! 			else { // like "<scripRef>John 3:16</scripRef>"
! 				url = userData["lastTextNode"].c_str();
! 
! 				buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(url).c_str() );
! 
! 				buf += userData["lastTextNode"].c_str();
! 
! 				// let's let text resume to output again
! 				userData["suspendTextPassThru"] = "false";
! 
! 				buf += "</a>";
  			}
  		}
- 
  		else {
  			return ThMLHTMLHREF::handleToken(buf,token,userData);
--- 30,91 ----
  bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
  	const char *tok;
  
! 	if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
! 		XMLTag tag(token);
! 		std::string url;
! 		if (!strcmp(tag.getName(), "sync")) {
! 			const char* value = tag.getAttribute("value");
! 			url = value;
  
! 			if(tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")){
  				buf += "<small><em> (";
  			}
  			else {
+ 				if (value) {
+ 					value++; //skip leading G, H or T
+ 					//url = value;
+ 				}
+ 
  				buf += "<small><em> &lt;";
  			}
  
  			buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(url).c_str() );
+ 			buf += value;
+ 			buf += "</a>";
  
! 			if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) {
! 				buf += ") </em></small>";
  			}
! 			else {
! 				buf += "&gt; </em></small>";
  			}
  		}
+ 		else if (!strcmp(tag.getName(), "scripRef")) {
+ 			if (tag.isEndTag()) {
+ 				if (userData["inscriptRef"] == "true") { // like  "<scripRef passage="John 3:16">John 3:16</scripRef>"
+ 					userData["inscriptRef"] = "false";
+ 					buf += "</a>";
+ 				}
+ 				else { // end of scripRef like "<scripRef>John 3:16</scripRef>"
+ 					url = userData["lastTextNode"];
+ 					buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(url).c_str());
+ 					buf += userData["lastTextNode"].c_str();
+ 					buf += "</a>";
  
! 					// let's let text resume to output again
! 					userData["suspendTextPassThru"] = "false";
! 				}
  			}
+ 			else if (tag.getAttribute("passage")) { //passage given
+ 				userData["inscriptRef"] = "true";
  
! 				buf.appendFormatted("<a href=\"%s?key=%s\">", passageStudyURL.c_str(), encodeURL(tag.getAttribute("passage")).c_str());
! 			}
! 			else { //no passage given
! 				userData["inscriptRef"] = "false";
! 				// let's stop text from going to output
! 				userData["suspendTextPassThru"] = "true";
  			}
  		}
  		else {
  			return ThMLHTMLHREF::handleToken(buf,token,userData);