Re: [greenstone-users] Referencing & querying the search engine

From schild
DateMon, 27 Jun 2005 20:36:15 +0200
Subject Re: [greenstone-users] Referencing & querying the search engine
In-Reply-To (200506260835-j5Q8ZF40032437-dbmail-mx1-orcon-net-nz)
I did the same thing as you want to do. I simply replaced the html document link with the record link and changed the format statement of  of DocumentText in the collect.cfg file to be:

format DocumentText "

<center>

<table width=537 border=4 cellpadding=5 cellspacing=0>

 

<tr>

{If}{[dc.Description],

<td align=right valign=top width=15%><b>Document <br/>Description:</b></td>

<td align=left valign=bottom width=80%>[dc.Description]</td>,

<td align=right valign=top width=15%></td><td align=left valign=bottom></td>}

 

{If}{[ImageHTML],

<td valign=top rowspan=16 align=center>

<font face=Arial, Helvetica, sans-serif size=1> Click photo to see larger image </font><br> [ImageHTML]</td>}

</tr>

 

{If}{[dc.Creator],

<tr>

<td align=right valign=top><b>Authors:</b></td>

<td align=left valign=bottom>_JavaScriptMacroBegin_(ExtractAuthors) '/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-K+Rajasekharan--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=q;[sibling(All:' | '):dc.Creator];[sibling(All:'_'):dc.Creator]' _JavaScriptMacroEnd_</td>

</tr>}

 

{If}{[dc.Subject],

<tr><td align=right valign=top><b>Subjects:</b></td>

<td align=left valign=bottom width=70%>_JavaScriptMacroBegin_(ExtractSubjects) '/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-K+Rajasekharan--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=q;[sibling(All:' #|# '):dc.Subject];[sibling(All:',###'):dc.Subject]' _JavaScriptMacroEnd_

</td></tr>}

 

{If}{[dc.Date^Published],

<tr>

<td align=right valign=top><b>Publication Date:</b></td>

<td align=left valign=bottom>[dc.Date^Published]</td>

</tr>}

 

{If}{[dc.Date^Created],

<tr>

<td align=right valign=top><b>Creation Date:</b></td>

<td align=left valign=bottom>[dc.Date^Created]</td>

</tr>}

 

{If}{[dc.Type],

<tr>

<td align=right valign=top><b>Document type:</b></td>

<td align=left valign=bottom> [dc.Type]</td>

</tr>}

 

{If}{[dc.Format],

<tr>

<td align=right valign=top><b>Document Format:</b></td>

<td align=left valign=bottom> [dc.Format]</td>

</tr>}

 

{If}{[dc.Language],

<tr>

<td align=right valign=top><b>Language:</b></td>

<td align=left valign=bottom>[dc.Language]</td>

</tr>}

 

{If}{[dc.Title],

<tr>

<td align=right valign=top><b>Referenced by:</b></td>

<td align=left valign=bottom width=70%>_JavaScriptMacroBegin_(RemoveKomma) '<a href=/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-K+Rajasekharan--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=q&r=1&hs=1&k=0&s=0&fqv=', '[dc.Title]', '&fqf=DE&t=1&fqs=0&fqk=0&fqc=and&fqa=0> Search for related documents</a> ' _JavaScriptMacroEnd_ </td>

</tr>}

 

{If}{[dc.Relation^References],

<tr>

<td align=right valign=top><b>References:</b></td>

<td align=left valign=bottom width=70%>_JavaScriptMacroBegin_(ExtractReferences) '/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-K+Rajasekharan--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=q|[sibling(All:' #;# '):dc.Relation]|[sibling(All:'###'):dc.Relation]' _JavaScriptMacroEnd_</td>

</tr>}

 

{If}{[dc.Rights],

<tr>

<td align=right valign=top><b>Access rights:</b></td>

<td align=left valign=bottom>[dc.Rights]</td>

</tr>}

 

{If}{[dc.Source],

<tr>

<td align=right valign=top><b>Source file name:</b></td>

<td align=left valign=bottom>[dc.Source]</td>

</tr>}

 

{If}{[dc.Date^Submission],

<tr>

<td align=right valign=top><b>Available since:</b></td>

<td align=left valign=bottom>_JavaScriptMacroBegin_(reformatDate)'[dc.Date^Submission]'_JavaScriptMacroEnd_</td>

</tr>}

 

{If}{[dc.BibTex],

<tr>

<td align=right valign=top><b>BibTeX:</b></td>

<td align=left valign=bottom>[dc.BibTex]</td>

</tr>}

</font>

</table>"

As you see, there are serveral JavaScript macros that I wrote, which must be placed in the correct package (Document) in the macro. I just paste the latest version of these macros to the end of this mail. They work for me, see if that solves your problem...

Regards,

Axel Schild


package document

###document display
[c=yourCollection] {<img src= "/gsdl/collect/hyconexa/images/IconHelp.gif">}

###HTML-Page Header
_textheader_ [c=yourCollection] {

GSDL Error
<center>
<table width=537><tr><td align=right>
</td></tr></table>
</center>
}
_textheader_ [v=1] {
GSDL Error
_javalinks_
}

### Self-made Javascript functions
{

function ExtractAuthors(AuthorString) {
   
    var hrefString;
       var hrefString_All;
       var linkString_without_highlight;
       var linkString_without_Komma;
    var linkString;
    var textString;
    var stringArray;
    var resolver_FormQueryField;
    var resolver_PlainQueryField;
    var i;
    var j;
      
       if (AuthorString != "") {
          stringArray = AuthorString.split(";");
          resolver_FormQueryField = stringArray[0]+"&r=1&hs=1&k=0&s=0&fqv=";
          resolver_PlainQueryField = stringArray[0]+"&r=1&hs=1&k=0&s=0&q=";
          linkString = stringArray[1].split(" | ");
          textString = stringArray[2].split("_");
          hrefString = '<ul>';
          for (i = 0; i < linkString.length ;i++) {
            linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
            linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
            linkString_without_Komma = escape(encode_utf8(linkString_without_highlight.split('%2c').join('+')));

                    hrefString = hrefString + "<li><a href=" + resolver_FormQueryField + linkString_without_Komma + "&fqf=DR&t=1&fqs=0&fqk=0&fqc=and&fqa=0>" + textString[i] + "</a><br/>";
                }
          
        if(linkString.length>1) {
                  hrefString_All = ""
                  for (i = 0; i < (linkString.length-1) ;i++) {
                linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
                linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
                linkString_without_Komma = escape(encode_utf8(linkString_without_highlight.split('%2c').join('+')));
              
                hrefString_All = hrefString_All + "["+ linkString_without_Komma +"]:DR" + "+%7c+";
                        }
       
            linkString_without_highlight = linkString[linkString.length-1].split('<span style="background: #FFFF77">').join('');
            linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
            linkString_without_Komma = escape(encode_utf8(linkString_without_highlight.split('%2c').join('+')));
       
            hrefString = hrefString + "<li><a href=" + resolver_PlainQueryField + hrefString_All + "[" + linkString_without_Komma + "]:DR" + "&fqf=DR&t=1&fqa=1>" + "All authors" + "</a>";
               }
         hrefString = hrefString + "</ul>";
          document.write(hrefString);
        }
    }


function ExtractSubjects(SubString) {
 
  var hrefString;
  var intermediateSubString;
  var hrefString_All;
  var linkString_without_highlight;
  var linkString_without_Komma;
  var componentsOfClassification;
  var i;
  var j;
  var linkString;
  var textString;
  var stringArray;
  var resolver_FormQueryField;
  var resolver_PlainQueryField;

  if(SubString != "") {
      stringArray = SubString.split(";");
    resolver_FormQueryField = stringArray[0]+"&r=1&hs=1&k=0&s=0&fqv=";
      resolver_PlainQueryField = stringArray[0]+"&r=1&hs=1&k=0&s=0&q=";
      linkString = stringArray[1].split(" #|# ");
      textString = stringArray[2].split("###");
      hrefString = '<ul>';
    hrefString_All = ""

      for (i = 0; i < linkString.length ;i++) {
          linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
        linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
        linkString_without_Komma = escape(encode_utf8(linkString_without_highlight.split('%2c').join('+')));
       
            componentsOfClassification = linkString_without_Komma.split("%7c");
                intermediateSubString = "("+ RemoveParenthesis(componentsOfClassification[0]);
                for(j = 1; j < componentsOfClassification.length; j++) {
                    intermediateSubString = intermediateSubString + ")+%26+(" + RemoveParenthesis(componentsOfClassification[j]);
                    }
               hrefString = hrefString + "<li><a href=" + resolver_FormQueryField + intermediateSubString + ")&fqf=DC&t=1&fqs=0&fqk=0&fqc=and&fqa=0>" + textString[i] + "</a><br/>";
              }
    
       if(0) {           
              for (i = 0; i < (linkString.length) ;i++) {
                  linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
            linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
            linkString_without_Komma = escape(encode_utf8(linkString_without_highlight.split('%2c').join('+')));
           
            componentsOfClassification = linkString_without_Komma.split("%7c");
                    intermediateSubString = "(" + RemoveParenthesis(componentsOfClassification[0]);
                     for(j = 1;j < componentsOfClassification.length; j++) {
                        intermediateSubString = intermediateSubString + RemoveParenthesis(componentsOfClassification[j]) + "+";
                            }
                   if(i < (linkString.length-1)) {
                        hrefString_All = hrefString_All + "["+ intermediateSubString +"]:DC" + "+%7c+";
                           }
                   else {
                        hrefString_All = hrefString_All + "["+ intermediateSubString +"]:DC";
                        }
            }
                hrefString = hrefString + "<li><a href=" + resolver_PlainQueryField + hrefString_All + "&fqf=DC&t=1&fqa=1>" + "All subjects" + "</a>";
           }
    }
  hrefString = hrefString + "</ul>";
  document.write(hrefString);
  }


function ExtractKeywords(KeyString) {
 
  var hrefString;
  var resolver_FormQueryField;
  var linkString_without_highlight;
  var linkString_without_Komma;
  var componentsOfClassification;
  var i;
  var linkString;
  var textString;
  var stringArray;
  var resolver_FormQueryField;
 
  if (KeyString != "") {
      stringArray = KeyString.split(";");
      resolver_FormQueryField = stringArray[0]+"&q=";
     linkString = stringArray[1].split("+%3b+");
      textString = stringArray[2].split("###");
     
      hrefString = "";
      for (i = 0; i < linkString.length ;i++) {
          linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
        linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
        linkString_without_Komma = linkString_without_highlight.split('%2c').join('+');
       
                hrefString = hrefString + "<a href=" + resolver_FormQueryField + linkString_without_Komma+ "&h=ddc&t=0>" + textString[i] + "</a><br/>";
            }
      if(linkString.length > 1) {
          linkString_without_highlight = stringArray[1].split('<span style="background: #FFFF77">').join('');
        linkString_without_highlight = linkString_without_highlight.split('</span>').join('');
        linkString_without_Komma = linkString_without_highlight.split('%2c').join('+');
            hrefString = hrefString + "<a href=" + resolver_FormQueryField + linkString_without_Komma + "&h=ddc&t=0>" + "All keywords" + "</a><br/>";
           }
      document.write(hrefString);
    }
  } 


function ExtractReferences(RefString) {
 
  var hrefString;
  var resolver_FormQueryField;
  var linkString;
  var textString;
  var linkString_without_highlight;
  var linkString_without_Komma;
  var refStringFirstPart;
  var refStringSecPart;
  var refStringAuthor;
  var intermediateAuthorString;
  var i;
  var j;
  
  if (RefString != "") {
      stringArray = RefString.split("|");
      resolver_FormQueryField = stringArray[0]+"&r=1&hs=1&k=0&s=0&q=";
      linkString = stringArray[1].split(" #;# ");
      textString = stringArray[2].split("###");
      hrefString = "";
      for (i = 0; i < linkString.length ;i++) {
          linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join('');
        linkString_without_highlight = escape(encode_utf8(linkString_without_highlight.split('</span>').join('')));
       
                refStringFirstPart = linkString_without_highlight.split("%3a+");
                refStringSecPart = refStringFirstPart[1].split("%3b+");
        refStringSecPart = refStringSecPart[0].split('%2c').join('+');
                refStringAuthor = refStringFirstPart[0].split("%2c+");
                intermediateAuthorString = ""
                for (j = 0; j < (refStringAuthor.length-1) ;j++) {
                   intermediateAuthorString = intermediateAuthorString + "["+ refStringAuthor[j] +"]:DR" + "+%26+";
                    }
                hrefString = hrefString + "<a href=" + resolver_FormQueryField + intermediateAuthorString + "[" + refStringAuthor[refStringAuthor.length-1] + "]:DR" + "+%26+" + "[" + refStringSecPart + "]:DT" + "&fqf=DR&t=1&fqa=1>" + textString[i] + "</a><br/><br/>";
            }
      document.write(hrefString);
    }
  }


function RemoveKomma(TestStringPart1, TestStringPart2, TestStringPart3) {
 
  var string_without_Komma;
 
  if (TestStringPart2 != "") {
    TestStringPart2 = escape(encode_utf8(TestStringPart2));
    string_without_Komma = TestStringPart2.split('%2c').join('+');
    }
  document.write(TestStringPart1+string_without_Komma+TestStringPart3);
  }


function RemoveParenthesis(TestString) {

  if (TestString != "") {
    TestString = TestString.split('%29').join('+');
    TestString = TestString.split('%28').join('+');
    }
  return TestString;
}


function showAuthors(MainAuthor, moreAuthors) {
   
    var authorString = "";
       var authorString_without_highlight;
       var stringArray;
    var i;
      
       if (moreAuthors != "") {
          stringArray = moreAuthors.split(";");
            for (i = 0; i < stringArray.length ;i++) {
            authorString_without_highlight = stringArray[i].split('<span style="background: #FFFF77">').join('');
            authorString_without_highlight = authorString_without_highlight.split('</span>').join('');
           
            if(authorString_without_highlight != MainAuthor) {
                if(authorString != "")
                    authorString = authorString + ", " + stringArray[i];
                else
                    authorString = stringArray[i];
                }
                }
        }
        document.write(authorString);
    }

function reformatDate(dateString) {
    var month = dateString.substring(4,6);
    var day = dateString.substring(6,8);
    var reformatedString;

    switch (month){
      case "01":
           month = ",&nbsp;January";
          break;
    case "02":
           month = ",&nbsp;February";
           break;
    case "03":
           month = ",&nbsp;March";
           break;
    case "04":
           month = ",&nbsp;April";
           break;
    case "05":
           month = ",&nbsp;May";
           break;
    case "06":
           month = ",&nbsp;June";
           break;
    case "07":
           month = ",&nbsp;July";
           break;
    case "08":
           month = ",&nbsp;August";
           break;
    case "09":
           month = ",&nbsp;september";
           break;
    case "10":
           month = ",&nbsp;October";
           break;
    case "11":
           month = ",&nbsp;November";
           break;
    case "12":
           month = ",&nbsp;December";
           break;
         }
    switch (day){
    case "":
           day = '';
          break;
      case "01":
           day = '&nbsp;'+day+"st";
          break;
    case "02":
           day = '&nbsp;'+day+"nd";
           break;
    case "03":
           day = '&nbsp;'+day+"rd";
           break;
      case "21":
           day = '&nbsp;'+day+"st";
          break;
    case "22":
           day = '&nbsp;'+day+"nd";
           break;
    case "23":
           day = '&nbsp;'+day+"rd";
           break;
      case "31":
           day = '&nbsp;'+day+"st";
          break;
         default:
           day = '&nbsp;'+day+"th";
           break;
    }

    reformatedString = dateString.substring(0,4)+month+day;
    document.write(reformatedString);
    }

   function decode_utf8(utftext) {
       var plaintext = ""; var i=0; var c=c1=c2=0;
            while(i<utftext.length)    {
             c = utftext.charCodeAt(i);
                 if (c<128) {
                     plaintext += String.fromCharCode(c);
                     i++;
            }
                    else if((c>191) && (c<224)) {
                     c2 = utftext.charCodeAt(i+1);
                     plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
                     i+=2;
            }
                 else {
                     c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
                     plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
                     i+=3;
            }
                 }
             return plaintext;
         }


   function encode_utf8(rohtext) {
       rohtext = rohtext.replace(/\r\n/g,"\n");
         var utftext = "";
         for(var n=0; n<rohtext.length; n++) {
             var c=rohtext.charCodeAt(n);
                 if (c<128)
                     utftext += String.fromCharCode(c);
                 else if((c>127) && (c<2048)) {
                     utftext += String.fromCharCode((c>>6)|192);
                     utftext += String.fromCharCode((c&63)|128);
            }
                 else {
                     utftext += String.fromCharCode((c>>12)|224);
                     utftext += String.fromCharCode(((c>>6)&63)|128);
                     utftext += String.fromCharCode((c&63)|128);
            }
                 }
             return utftext;
         }

}


Daniel Mulholland schrieb:

Hi all,

 

Thanks for those who have answered my questions – very helpful and deeply appreciated. I’m quite impressed with how quickly a collection can be built up in Greenstone, kudos to all you people up there at Waikato university!

 

I have a few more questions, which I can’t seem to resolve.

 

(1) I’d like to organize my collection, so the user can see record information either before they look at the record or as a separate link. At present, the only way I can think of to show the information is to edit the DocumentText or DocumentHeader fields so the information is given either at the top or bottom. Is it (easily) possible to make this a separate page?

 

(2) As part of the above, I’d like to have the author name as a link to a query which gives all titles by that author.

 

I thought I could do that like this (a section from my DocumentHeader)

 

{If}{[ref.Author], <tr>

<td align=right valign=top width=120><b>Author:</b></td>

<td align=left valign=bottom width=325><a href=/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-help-K+Rajasekharan--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=q&q=[cgisafe:ref.Author]&h=Author>[ref.Author]</a></td>

<td align=left valign=bottom width=325>[ref.Author]</td>,

<td align=right valign=top width=120></td>

<td align=left valign=bottom></td>}

 

Unfortunately this doesn’t work, it just brings up the search page without doing anything else. I had a look at Katherine’s example of how to do a httpquery in the archives (https://list.scms.waikato.ac.nz/mailman/htdig/greenstone-users/2004-July/001283.html) and this wouldn’t work for me either. Any ideas?

 

(3) As part of my metadata, I would like to include links to other documents in the collection, by their title. So I’d have a field called references and use an expression similar to the above (if I could get it to work) which I would like to automatically search for that title, and if it brings back a unique record to pull it up directly. Is there any more direct way to refer to other documents or would this be the way to go?

 

(4) I store the author’s name in a single field as LastName, FirstName. How can I extract that and organize it as I like. Sometimes I’d like to write something like “[Title] by [FirstName] [LastName]”. At present, I have two fields for author, one being FirstName LastName, the other being LastName, FirstName which seems a poor solution.

 

Cheers,


Daniel


_______________________________________________ greenstone-users mailing list greenstone-users@list.scms.waikato.ac.nz https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users


-- 
----------------------------------------------

Dipl.-Ing. Axel Schild
Automatisierungstechnik und Prozessinformatik
Ruhr-Universitaet Bochum IC-3/140
D-44780 Bochum, Germany

Tel: +49 234 32 25203
Fax: +49 234 32 14101
E-mail: schild@atp.rub.de