diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
commit | 71a39f4652cd51df814c930dd268f3c9ad2aee86 (patch) | |
tree | 5994350a603908c4e4d660bc9d72c4ec43dd648e /src/modules/filters/teihtmlhref.cpp | |
parent | 03134fa5f6f25d92724ce4c183f9bbe12a9e37dc (diff) |
Imported Upstream version 1.6.0+dfsg
Diffstat (limited to 'src/modules/filters/teihtmlhref.cpp')
-rw-r--r-- | src/modules/filters/teihtmlhref.cpp | 100 |
1 files changed, 84 insertions, 16 deletions
diff --git a/src/modules/filters/teihtmlhref.cpp b/src/modules/filters/teihtmlhref.cpp index 1d213f4..7e27667 100644 --- a/src/modules/filters/teihtmlhref.cpp +++ b/src/modules/filters/teihtmlhref.cpp @@ -1,18 +1,24 @@ /*************************************************************************** - teirtf.cpp - TEI to HTMLHREF filter - ------------------- - begin : 2006-07-03 - copyright : 2006 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. * - * * - ***************************************************************************/ + * teirtf.cpp - TEI to HTMLHREF filter + * ------------------- + * begin : 2006-07-03 + * copyright : 2006 by CrossWire Bible Society + * + * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org) + * CrossWire Bible Society + * P. O. Box 2528 + * Tempe, AZ 85280-2528 + * + * 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 version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ #include <stdlib.h> #include <ctype.h> @@ -20,6 +26,7 @@ #include <utilxml.h> #include <swmodule.h> #include <url.h> +#include <iostream> SWORD_NAMESPACE_START @@ -137,8 +144,8 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || - !strcmp(tag.getName(), "pron") || - !strcmp(tag.getName(), "def")) { + !strcmp(tag.getName(), "pron") /*|| + !strcmp(tag.getName(), "def")*/) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { buf += "<i>"; } @@ -172,6 +179,67 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData !strcmp(tag.getName(), "usg")) { // do nothing here } + else if (!strcmp(tag.getName(), "ref")) { + if (!tag.isEndTag()) { + u->suspendTextPassThru = true; + SWBuf target; + SWBuf work; + SWBuf ref; + + int was_osisref = false; + if(tag.getAttribute("osisRef")) + { + target += tag.getAttribute("osisRef"); + was_osisref=true; + } + else if(tag.getAttribute("target")) + target += tag.getAttribute("target"); + + if(target.size()) + { + const char* the_ref = strchr(target, ':'); + + if(!the_ref) { + // No work + ref = target; + } + else { + // Compensate for starting : + ref = the_ref + 1; + + int size = target.size() - ref.size() - 1; + work.setSize(size); + strncpy(work.getRawData(), target, size); + } + + if(was_osisref) + { + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">", + (ref) ? URL::encode(ref.c_str()).c_str() : "", + (work.size()) ? URL::encode(work.c_str()).c_str() : ""); + } + else + { + // Dictionary link, or something + buf.appendFormatted("<a href=\"sword://%s/%s\">", + (work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(), + (ref) ? URL::encode(ref.c_str()).c_str() : "" + ); + } + } + else + { + //std::cout << "TARGET WASN'T\n"; + } + + } + else { + buf += u->lastTextNode.c_str(); + buf += "</a>"; + + u->suspendTextPassThru = false; + } + } // <note> tag else if (!strcmp(tag.getName(), "note")) { |