[sword-devel] htmlhref filters

Terry Biggs sword-devel@crosswire.org
Tue, 10 Feb 2004 12:21:07 -0500


--=-i29jilXjqQ4N3lV5IaTn
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Troy and Joachim,

Could you guys look at these these diff and see if they cause you any
grief.

Let me know if it's ok to commit or not.

Thanks
Terry 
-- 

--=-i29jilXjqQ4N3lV5IaTn
Content-Disposition: attachment; filename=gbfhtmlhref.diff
Content-Type: text/x-patch; name=gbfhtmlhref.diff; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: gbfhtmlhref.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/gbfhtmlhref.cpp,v
retrieving revision 1.27
diff -u -r1.27 gbfhtmlhref.cpp
--- gbfhtmlhref.cpp	31 Jan 2004 00:09:31 -0000	1.27
+++ gbfhtmlhref.cpp	10 Feb 2004 17:09:33 -0000
@@ -24,6 +24,12 @@
 
 SWORD_NAMESPACE_START
 
+GBFHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+	if (module) {
+		version = module->Name();
+	}	
+}
+
 GBFHTMLHREF::GBFHTMLHREF() {
 	setTokenStart("<");
 	setTokenEnd(">");
@@ -143,9 +149,9 @@
 			}
 		}
 		
-		else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
-			buf += " <small><em>&lt;<a href=\"type=Strongs value=";
-			for (tok = token+1; *tok; tok++)
+		else if (!strncmp(token, "WG", 2)) { // strong's numbers
+			buf += " <small><em>&lt;<a href=\"strongs://Greek/";
+			for (tok = token+2; *tok; tok++)
 				//if(token[i] != '\"')
 					buf += *tok;
 			buf += "\">";
@@ -154,10 +160,36 @@
 					buf += *tok;
 			buf += "</a>&gt;</em></small>";
 		}
-
-		else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
-			buf += " <small><em>(<a href=\"type=Strongs value=";
+		
+		else if (!strncmp(token, "WH", 2)) { // strong's numbers
+			buf += " <small><em>&lt;<a href=\"strongs://Hebrew/";
+			for (tok = token+2; *tok; tok++)
+				//if(token[i] != '\"')
+					buf += *tok;
+			buf += "\">";
 			for (tok = token + 2; *tok; tok++)
+				//if(token[i] != '\"')
+					buf += *tok;
+			buf += "</a>&gt;</em></small>";
+		}
+
+		else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense
+			
+			buf += " <small><em>(<a href=\"strongs://Greek/";
+			for (tok = token + 3; *tok; tok++)
+				if(*tok != '\"')
+					buf += *tok;
+			buf += "\">";
+			for (tok = token + 3; *tok; tok++)
+				if(*tok != '\"')
+					buf += *tok;
+			buf += "</a>)</em></small>";
+		}
+
+		else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense
+			
+			buf += " <small><em>(<a href=\"strongs://Hebrew/";
+			for (tok = token + 3; *tok; tok++)
 				if(*tok != '\"')
 					buf += *tok;
 			buf += "\">";
@@ -168,7 +200,7 @@
 		}
 
 		else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
-			buf += " <small><em>(<a href=\"type=morph class=none value=";
+			buf += " <small><em>(<a href=\"morph:///";
 			for (tok = token + 2; *tok; tok++)
 				if(*tok != '\"')
 					buf += *tok;
@@ -203,7 +235,7 @@
 			if (vkey) {
 				// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
 				//char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
-				buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), 'n', footnoteNumber.c_str(), 'n');
+				buf.appendFormatted("<a href=\"noteID://%s/%s/%c/%s\"><small><sup>*%c</sup></small></a> ", u->version.c_str(), vkey->getText(), 'n', footnoteNumber.c_str(), 'n');
 			}
 			u->suspendTextPassThru = true;
 		}

--=-i29jilXjqQ4N3lV5IaTn
Content-Disposition: attachment; filename=osishtmlhref.diff
Content-Type: text/x-patch; name=osishtmlhref.diff; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: osishtmlhref.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/osishtmlhref.cpp,v
retrieving revision 1.21
diff -u -r1.21 osishtmlhref.cpp
--- osishtmlhref.cpp	24 Jan 2004 18:42:40 -0000	1.21
+++ osishtmlhref.cpp	10 Feb 2004 17:11:57 -0000
@@ -25,6 +25,8 @@
 
 OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
 	osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
+	if (module) 
+		version = module->Name();
 }
 
 
@@ -95,12 +97,17 @@
 						if (i < 0) i = 0;	// to handle our -1 condition
 						val = strchr(attrib, ':');
 						val = (val) ? (val + 1) : attrib;
+						SWBuf gh;
+						if(*val == 'G')
+							gh = "Greek";
+						if(*val == 'H')
+							gh = "Hebrew";
 						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=\"type=Strongs value=%s\">%s</a>&gt;</em></small> ", val, val2);
+						else	buf.appendFormatted(" <small><em>&lt;<a href=\"strongs://%s/%s\">%s</a>&gt;</em></small> ", (gh.length()) ? gh.c_str() : "", val2, val2);
 					} while (++i < count);
 				}
 				if ((attrib = tag.getAttribute("morph")) && (show)) {
@@ -118,7 +125,7 @@
 							const char *val2 = val;
 							if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
 								val2+=2;
-							buf.appendFormatted(" <small><em>(<a href=\"type=morph class=%s value=%s\">%s</a>)</em></small> ", tag.getAttribute("morph"), val, val2);
+							buf.appendFormatted(" <small><em>(<a href=\"morph://%s/%s\">%s</a>)</em></small> ", tag.getAttribute("morph"), val, val2);
 						} while (++i < count);
 					}
 				}
@@ -149,7 +156,7 @@
 						SWCATCH ( ... ) {	}
 						if (vkey) {
 							char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
-							buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber.c_str(), ch);
+							buf.appendFormatted("<a href=\"noteID://%s/%s/%c/%s\"><small><sup>*%c</sup></small></a> ", u->version.c_str(), vkey->getText(), ch, footnoteNumber.c_str(), ch);
 						}
 					}
 					u->suspendTextPassThru = true;

--=-i29jilXjqQ4N3lV5IaTn
Content-Disposition: attachment; filename=thmlhtmlhref.diff
Content-Type: text/x-patch; name=thmlhtmlhref.diff; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: thmlhtmlhref.cpp
===================================================================
RCS file: /cvs/core/sword/src/modules/filters/thmlhtmlhref.cpp,v
retrieving revision 1.48
diff -u -r1.48 thmlhtmlhref.cpp
--- thmlhtmlhref.cpp	24 Jan 2004 18:42:40 -0000	1.48
+++ thmlhtmlhref.cpp	10 Feb 2004 17:11:35 -0000
@@ -53,27 +53,19 @@
 		if (tag.getName() && !strcmp(tag.getName(), "sync")) {
 			SWBuf value = tag.getAttribute("value");
 			if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt;
-				buf += "<small><em>(<a href=\"";
-				buf += "type=";
-				buf += tag.getAttribute("type");
-	
-				//const char* value = tag.getAttribute("value");
-				buf += " value=";
-				buf += (value.length()) ? value.c_str() : "";
-				buf += "\">";
+				buf.appendFormatted("<small><em>(<a href=\"morph://Greek/%s\">",(value.length()) ? value.c_str() : "");
 				buf += (value.length()) ? value.c_str() : "";
 				buf += "</a>) </em></small>";
 			}
 			else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
-				buf += "<small><em>&lt;<a href=\"";
-				buf += "type=";
-				buf += tag.getAttribute("type");
-	
-				//const char* value = tag.getAttribute("value");
-				buf += " value=";
-				buf += (value.length()) ? value.c_str() : "";
-				buf += "\">";
-				value<<1;
+				if(*value == 'H') {
+					value<<1;
+					buf.appendFormatted("<small><em>&lt;<a href=\"strongs://Hebrew/%s\">",(value.length()) ? value.c_str() : "");
+				}
+				else if(*value == 'G') {
+					value<<1;
+					buf.appendFormatted("<small><em>&lt;<a href=\"strongs://Greek/%s\">",(value.length()) ? value.c_str() : "");
+				}
 				buf += (value.length()) ? value.c_str() : "";
 				buf += "</a>&gt; </em></small>";
 			}
@@ -99,7 +91,7 @@
 					if (vkey) {
 						// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
 						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
-						buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber.c_str(), ch);
+						buf.appendFormatted("<a href=\"noteID://%s/%s/%c/%s\"><small><sup>*%c</sup></small></a> ", u->version.c_str(), vkey->getText(), ch, footnoteNumber.c_str(), ch);
 					}
 					u->suspendTextPassThru = true;
 				}
@@ -110,7 +102,7 @@
 		}
 		// <scripRef> tag
 		else if (!strcmp(tag.getName(), "scripRef")) {
-			if (!tag.isEndTag()) {
+			if (!tag.isEndTag()) {					
 				if (!tag.isEmpty()) {
 					u->suspendTextPassThru = true;
 				}
@@ -120,16 +112,8 @@
 					SWBuf refList = u->startTag.getAttribute("passage");
 					if (!refList.length())
 						refList = u->lastTextNode;
-					SWBuf version = tag.getAttribute("version");
-					buf += "&nbsp<a href=\"";
-					if (version.length()) {
-						buf += "version=";
-						buf += version;
-						buf += " ";
-					}
-					buf += "passage=";
-					buf += refList.c_str();
-					buf += "\">";
+					SWBuf version = u->startTag.getAttribute("version");
+					buf.appendFormatted("&nbsp<a href=\"reference://%s/%s\">",(version.length()) ? version.c_str() : "",(refList.length()) ? refList.c_str() : "");
 					buf += u->lastTextNode.c_str();
 					buf += "</a>&nbsp";
 				}
@@ -143,7 +127,7 @@
 					SWCATCH ( ... ) {}
 					if (vkey) {
 						// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
-						buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
+						buf.appendFormatted("<a href=\"noteID://%s/%s/x/%s\"><small><sup>*x</sup></small></a> ",u->version.c_str(), vkey->getText(), footnoteNumber.c_str());
 					}
 				}
 

--=-i29jilXjqQ4N3lV5IaTn--