Re: [greenstone-users] More detailed info on macros

From sw64@cs.waikato.ac.nz
DateThu, 2 Nov 2006 16:14:55 +1300 (NZDT)
Subject Re: [greenstone-users] More detailed info on macros
In-Reply-To (454929D6-7020100-gmx-net)
Thanks, Jens. I have added them to the wiki.
http://greenstone.sourceforge.net/wiki/index.php/All_about_macros
Let me known if there are errors.

Regards
Shaoqun

> sw64@cs.waikato.ac.nz [01.11.2006 22:56]:
>> That would be great, thank you. How about you post them to the
>> mailing-list, and I add them to the wiki?
> well, ok, here we go (note that output might look crippled in the
> mail; '$' denotes the prompt):
>
> - first, a correction: to get really all macros, use this one:
>
> $ expand_macros.pl -s ".*"
>
> => 1892 on my "stable" system (v2.62), 1979 on my "testing" system
> (v2.71); all following output is for v2.62 (haven't upgraded my
> production system yet ;-)
>
> - get definition of function initialize() { } :
>
> $ expand_macros.pl function initialize() { }
> *** macro: query:pagescriptextra ***
>
> * query:pagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 68)
> { _formpagescriptextra_ _historypagescriptextra_ } }
>
> - get macros that are used by function initialize() { } ('-s' for
> short output, omit for display of definitions; '-d' for depth,
> increase to see more levels):
>
> $ expand_macros.pl -s -d 2 function initialize() { }
> *** macro: query:pagescriptextra ***
>
> * query:pagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 68)
> * query:formpagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 76)
> * query:formfunctions [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 178)
> * query:searchfunctions [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 478)
> * preferences:standardfunctions [v=0]
> (/usr/local/gsdl/stable/macros/pref.dm, line 82)
> * query:standardfunctions [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 143)
> * query:historypagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 101)
> * query:selectpagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 71)
> * query:dummypagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 72)
> * query:formpagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 76)
>
> - get macros that use "any" ('-r' for reverse search):
>
> $ expand_macros.pl -r
> *** macro: pagescriptextra (reverse) ***
>
> * Style:globalscripts [v=0] (/usr/local/gsdl/stable/macros/style.dm,
> line 142)
> { <script> <!-- // --> </script> } }
>
> * homepref:pagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/home.dm, line 198)
> { // preferences scripts generated from _preferences:pagescriptextra_ savedhrefs = new Object(); argk = ""; args = ""; argm = ""; argrd = ""; argo = ""; argb = ""; arghd = ""; argqb = ""; argfqn = ""; argqt= ""; argaf = ""; function initialize () { for (i = 0; i < document.links.length; i++) savedhrefs[i] = document.links[i].href; } function getargs () { return argk + args + argaf + argm + argo + argrd + arghd + argb + argqb + argfqn + argqt; } function updatehrefs () { for (i = 0; i < document.links.length; i++) document.links[i].href = savedhrefs[i] + getargs(); } function updatek (value) { if (value != 1) argk = "&k=" + value; else argk = ""; updatehrefs(); } function updates (value) { if (value != 0) args = "&s=" + value; else args = ""; updatehrefs(); } function updateaf (value) { if (value != 0) argaf = "&af=" + value; else argaf = ""; updatehrefs(); } function updatem () { value = document.PrefForm.m.options[document.PrefForm.m.selectedIndex].value; if (value != 50) argm = "&r=1&m=" + value; else argm = ""; updatehrefs(); } function updaterd () { if (document.PrefForm.rd.checked) argrd="&rd=1"; else argrd=""; updatehrefs(); } function updateo () { value = document.PrefForm.o.options[document.PrefForm.o.selectedIndex].value; if (value != 20) argo = "&r=1&o=" + value; else argo = ""; updatehrefs(); } function updateqt (value) { if (value != "0") argqt = "&qt=" + value; else argqt = ""; updatehrefs(); } function updatefqn () { value = document.PrefForm.fqn.options[document.PrefForm.fqn.selectedIndex].value; if (value != 4) argfqn = "&fqn=" + value; else argfqn = ""; updatehrefs(); } function updateb (value) { if (value != 0) argb = "&b=" + value; else argb = ""; updatehrefs(); } function updatehd() { arghd=""; if (document.PrefForm.hd[0].checked) { if ("0" != "0") arghd = "&hd=0"; } else { value = document.PrefForm.hdn[document.PrefForm.hdn.selectedIndex].value; if (0 != value) arghd = "&hd="+value; } updatehrefs(); } function updateqb() { value = document.PrefForm.qb.options[document.PrefForm.qb.selectedIndex].value; if (value != 0) argqb = "&qb=" + value; else argqb = ""; updatehrefs(); } function updatel () { value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value; href = location.href; if (href.match(/&l=[\w\-]+/)) href = href.replace(/&l=[\w\-]+/, "&l=" + value); else href += "&l=" + value; if (!location.href.match(/&nl=1$/)) href += "&nl=1"; while (href.match(/&cc=[\w]+/)) href = href.replace(/&cc=[\w]+/, ""); location.href = href + getargs(); } function updatev () { value = document.PrefForm.v.options[document.PrefForm.v.selectedIndex].value; href = location.href; if (href.match(/&v=\d/)) href = href.replace(/&v=\d/, "&v=" + value); else href += "&v=" + value; while (href.match(/&cc=[\w]+/)) href = href.replace(/&cc=[\w]+/, ""); location.href = href + getargs(); } function updatew () { value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value; href = location.href; if (href.match(/&nw=[^&]+/)) href = href.replace(/&nw=[^&]+/, "&nw=" + value); else href += "&nw=" + value; if (!location.href.match(/&nl=0$/)) href += "&nl=0"; while (href.match(/&cc=[\w]+/)) href = href.replace(/&cc=[\w]+/, ""); location.href = href + getargs(); } function updatebook () { value = document.PrefForm.book.options[document.PrefForm.book.selectedIndex].value; href = location.href; if (href.match(/&book=[^&]+/)) href = href.replace(/&book=[^&]+/, "&book=" + value); else href += "&book=" + value; while (href.match(/&cc=[\w]+/)) href = href.replace(/&cc=[\w]+/, ""); location.href = href + getargs(); } } }
>
> - get macros whose definitions contain "blank.gif" (a search in the
> definition contents will be performed if the argument doesn't start,
> and end, with an underscore (actually, it's a bit more complicated,
> but that should suffice for the moment); is actually treated as full
> perl regular expression):
>
> $ expand_macros.pl "blank.gif"
> *** query: blank.gif ***
>
> * collector:iconblank [v=0]
> (/usr/local/gsdl/stable/macros/collect.dm, line 42)
> { <img src="/gsdl/web/images/blank.gif">} }
>
> - get a macro that is defined in the c++ code (you need to extract a
> greenstone source archive and point to its base location, either via
> the '--source' parameter or via a GSDLSOURCE environment variable):
>
> $ expand_macros.pl --source=/usr/local/gsdl/src/stable/
>
> *** macro: collector:pagescriptextra ***
>
> * collector:pagescriptextra [v=0] (SERVER:
> /usr/local/gsdl/src/stable/src/src/recpt/collectoraction.cpp, line 1058)
> { "_" + collector_page + "scriptextra_" }
>
> - finally, here's the transcript of an interactive session ('-i' or
> '-b' for "interactive", or "browse", mode):
>
> $ expand_macros.pl -i
> entered 'expand_macros.pl' in ***interactive browse mode*** (v0.22)
> [you can get help at any time by typing '.h', '.?', or '.help']
>
> enter macro name (without package specification) [leave empty to quit]
>> pagescriptextra
> select package for macro 'pagescriptextra' [leave empty to return]
> [1] Style
> [2] browse
> [3] collector
> [4] homepref
> [5] preferences
> [6] query
>> 6
>
> * query:pagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 68)
> { _formpagescriptextra_
> _historypagescriptextra_ } }
>
> [press key to continue]
>
> select macro [leave empty to return]
> [1] formpagescriptextra
> [2] historypagescriptextra
> [3] selectpagescriptextra
>> 1
> select package for macro 'formpagescriptextra' [leave empty to return]
> [1] query
>> 1
>
> * query:formpagescriptextra [v=0]
> (/usr/local/gsdl/stable/macros/query.dm, line 76)
> { // query scripts generated by _query:pagescriptextra_
> _standardfunctions_
> _formfunctions_
> _searchfunctions_
> function getsearchargs () {
> var args="";
> args = "&fqa=0&fqv="+argfqv+"&fqf="+argfqf;
> args += "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc;
> return args;
> }
> function getqueryargs () {
> return "&fqa=1"+"&q="+argq+"&fqv="+argfqv+"&fqf="+argfqf+
> "&fqk="+argfqk+"&fqs="+argfqs+"&fqc="+argfqc ;
> }
> } }
>
> [press key to continue]
>
> select macro [leave empty to return]
> [1] formfunctions
> [2] searchfunctions
> [3] standardfunctions
>>
> select package for macro 'formpagescriptextra' [leave empty to return]
> [1] query
>>
> select macro [leave empty to return]
> [1] formpagescriptextra
> [2] historypagescriptextra
> [3] selectpagescriptextra
>>
> select package for macro 'pagescriptextra' [leave empty to return]
> [1] Style
> [2] browse
> [3] collector
> [4] homepref
> [5] preferences
> [6] query
>>
> enter macro name (without package specification) [leave empty to quit]
>>
>
> enough for now? hope that might be of help to somebody. again, any
> feedback (be it comments, questions, feature requests, bug reports,
> whatever...) is very welcome!
>
> cheers
> jens
>
> _______________________________________________
> greenstone-users mailing list
> greenstone-users@list.scms.waikato.ac.nz
> https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users
>