Difference between revisions of "macros"

From GeneWeb
Jump to: navigation, search
m (Conditionnals)
m (List of macros)
 
(15 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
{{languages|macros}}
 
{{languages|macros}}
  
GeneWeb template files and text captures in notes are not pure HTML and may contain variables  
+
GeneWeb text present in notes are not pure HTML and may contain variables.
  
Some historically called '''macros'''. These are letters prefixed by {{c|%}}, for instance {{c|%s}} or {{c|%x}}. GeneWeb replaces these macros by their values depending on the context of the base: name of the base, language, number of persons in the base, etc...
+
Some are historically called '''macros'''. These are letters prefixed by {{c|%}}, for instance {{c|%s}} or {{c|%x}}. GeneWeb replaces these macros by their values depending on the context of the base: name of the base, language, number of persons in the base, etc...
  
Other variables, bracketed by {{c|[}} and {{c|]}} trigger the '''translation''' process of GeneWeb according to the current language, and use for this translation the {{lexicon}} data. The {{lexicon}} page describes in details this translation process.
+
Other variables, bracketed by {{c|[}} and {{c|]}} trigger the '''translation''' process of GeneWeb according to the current language, and use for this translation the lexicon data. The [[lexicon]] page describes in details this translation process.
  
Les variables encadrées par des crochets ouvrants et fermants {{c|[}} et {{c|]}} (et non {{c|%}}) sont traduites par GeneWeb à partir d'un [[lexicon/fr|lexique]]. La page correspondante détaille ce fonctionnement.
+
<!-- look for the 4 or 5 translate specific macros -->
  
 
== Description of the macros ==
 
== Description of the macros ==
  
 
=== Base ===
 
=== Base ===
* '''%t''' : name of the abse
+
* '''%t''' : name of the base
 
* '''%f''' : in server mode (stand alone machine), name of the base, possibly followed by a token (en <code>toto_xyzzy</code>); in CGI mode the launch command (ex:  <code>gwd.exe</code>
 
* '''%f''' : in server mode (stand alone machine), name of the base, possibly followed by a token (en <code>toto_xyzzy</code>); in CGI mode the launch command (ex:  <code>gwd.exe</code>
 
* '''%g''' : in server mode, same as "'''%f'''"; in CGI mode, name of the launch command followed by {{c|1=?b=}}, the name of the base and a semi-colon {{c|;}} (ex: <code>gwd.exe?b=toto;</code>)
 
* '''%g''' : in server mode, same as "'''%f'''"; in CGI mode, name of the launch command followed by {{c|1=?b=}}, the name of the base and a semi-colon {{c|;}} (ex: <code>gwd.exe?b=toto;</code>)
Line 28: Line 28:
 
* '''f''' : visitor is registered as friend
 
* '''f''' : visitor is registered as friend
 
* '''w''' : visitor is registered as wizard
 
* '''w''' : visitor is registered as wizard
* '''j''' : wizard_just_friend has been activated (see {{c|wizard_just_friend}} in {{configuration|a.gwf}})
+
* '''j''' : wizard_just_friend has been activated (see {{c|wizard_just_friend}} in [[configuration|a.gwf]]
 
* '''c''' : the server is in CGI mode
 
* '''c''' : the server is in CGI mode
 
* '''h''' : a modifications history file exists
 
* '''h''' : a modifications history file exists
Line 53: Line 53:
 
*'''%]''' : a single "''']'''".
 
*'''%]''' : a single "''']'''".
  
=== ContextuAL VARIABLES===
+
=== Contextual variables===
  
 
Some variables have a lasting influence on GeneWeb across multiple requests. As opposed to the other requests parameters, once activated (by selecting an option through the GUI, or by direct typing in the URL window) the appear in all successive requests unless explicitly removed.
 
Some variables have a lasting influence on GeneWeb across multiple requests. As opposed to the other requests parameters, once activated (by selecting an option through the GUI, or by direct typing in the URL window) the appear in all successive requests unless explicitly removed.
Line 72: Line 72:
 
   relationship</a> with him.
 
   relationship</a> with him.
  
== List of macros ==
+
==List of macros ==
 +
Available macros in the context of {{c|1=m=SRC}} files :
 +
This table can be generated by inserting a {{c|1=m=SRC}} call to some HTML/GeneWeb code in the note section of somebody in your base. The corresponding code is [[Macro-table/fr|here]]
  
Below is the result of calling all 26 lower case possible macros :
+
The third column provides the result of execution in a specific context
: this table is automatically generated by inserting a bit of HTML/GeneWeb code into the notes of one person in your base. The corresponding code is [[Macro-table/fr|here]]
+
 
[[File:Macros-table.png|700px|center|Table of GeneWeb macros.]]
+
{|class="wikitable" style="border-width: 3px; text-align:left;"
 +
!Macro!!Example use !!Result!! What it does
 +
|-
 +
|%a ||%a || ||Displays name of sosa reference (See %Iz below)
 +
|-
 +
|%b ||%b || ||Value of "body_prop" (in base.gwf)
 +
|-
 +
|%c ||%c ||42 ||Number of queries for the welcome page
 +
|-
 +
|%d ||%d ||10 décembre 2018 ||Date of first visit
 +
|-
 +
|%D ||%D ||10/12/2018 ||Date of first visit
 +
|-
 +
|%e ||%e ||UTF-8 ||Character set
 +
|-
 +
|%f ||%f ||HenriT_w ||In server mode, base name followed by password. In CGI mode, name of the CGI command (ex: gwd.exe)
 +
|-
 +
|%g ||%g ||HenriT_w? ||In server mode, same as "f". In CGI mode, name of the command, followed by "?b=basename;"
 +
|-
 +
|%h ||%h || ||A list of var=value for each hidden url variable
 +
|-
 +
|%i ||%i ||#2f6400 ||Highlight color
 +
|-
 +
|%j ||%j || ||Include hed.txt file
 +
|-
 +
|%k ||%k ||geneweb? ||Value of the action parameter of a http GET/PUT command
 +
|-
 +
|%l ||%l ||fr ||Language
 +
|-
 +
|%L ||%L ||left ||Left (style: used in align="%L")
 +
|-
 +
|%m ||%m ||30 ||Value of latest_event (in base.gwf)
 +
|-
 +
|%n ||%n ||8879 ||Number of persons in the base
 +
|-
 +
|%N ||%N ||: titre ||Content of base_notes_title (.gwf)
 +
|-
 +
|%o ||%o ||images ||Value of %image_prefix; (see doc for image_prefix details (to be completed))
 +
|-
 +
|%p ||%p ||%p ||noop
 +
|-
 +
|%P ||%P || ||next (%Pc)
 +
|-
 +
|%q ||%q ||285 ||Number of queries
 +
|-
 +
|%r ||%rfile||test for macros  ||Reads file bases/src/base/test.txt) (file must be followed by "end of line")
 +
|-
 +
|%R ||%R ||right ||Right (style: used in align="%R")
 +
|-
 +
|%s ||%s ||HenriT_w? ||Value of %f followed by "?" and contextual variables (ex: "toto?lang=it;iz=8233;")<br> Typical use: <a href="%sp=first_name&n=surname">Link to person First_name Surname</a>
 +
|-
 +
|%t ||%t ||HenriT||Base name
 +
|-
 +
|%T ||%T || ||Value of %doctype; (Given that doctype translates into <-- .... -->,<br>nothing is visible in the result column. Look at the sources to verify)
 +
|-
 +
|%u ||%ufr; ||français||returns "Français" if lang=fr, and "French" if lang=en (dont forget the ;)
 +
|-
 +
|%U ||%U ||: hg ||User name
 +
|-
 +
|%v ||%v ||7.00-exp ||Returns GeneWeb version number
 +
|-
 +
|%v ||%vtext; ||xxxx ||Specific to the NOTES context: returns the value of bvar.var_text
 +
|-
 +
|%V ||%Vvar; ||oui ||Value of bvar.var (in base.gwf) example %Vtest;
 +
|-
 +
|%w ||%w || ||Link to previous page (with back arrow icon)
 +
|-
 +
|%x ||%x ||%x ||noop
 +
|-
 +
|%X ||%Xvar; ||macros||Value of evar.var (in URL) example %Xv;
 +
|-
 +
|%y ||%y ||%y ||noop
 +
|-
 +
|%/ ||%/ || ||if doctype = "html-4.01" then "" else "/" (used to terminate html tags as in <br%/> -> <br>
 +
|-
 +
|%% ||%% ||% ||%
 +
|-
 +
|%Ia ||%IaYes%E %INaNo%E||No ||auth_file exists. Global access restriction is on (see [[Access]])
 +
|-
 +
|%Ic ||%IcYes%E %INcNo%E||No ||Cannot handle passwords
 +
|-
 +
|%If ||%IfYes%E %INfNo%E||No ||We are "Friend"
 +
|-
 +
|%Ih ||%IhYes%E %INhNo%E||Yes ||There is a history file
 +
|-
 +
|%Ij ||%IjYes%E %INjNo%E||No ||Wizard_just_friend is active
 +
|-
 +
|%Il ||%IlYes%E %INlNo%E||No ||Browser handles tables
 +
|-
 +
|%Im ||%ImYes%E %INmNo%E||Yes ||notes_links <> []
 +
|-
 +
|%In ||%InYes%E %INnNo%E||Yes ||There is a base note file
 +
|-
 +
|%Io ||%IoYes%E %INoNo%E||Yes ||Notes dir exists
 +
|-
 +
|%Ip ||%Iptest;Yes%E %INptest;No%E||Yes ||Base env variable <> "" (var terminated by ;)
 +
|-
 +
|%Is ||%IsYes%E %INsNo%E||Yes ||Base env variable <> "no"
 +
|-
 +
|%Iw ||%IwYes%E %INwNo%E||Yes ||We are "Wizard"
 +
|-
 +
|%Iz ||%IzYes%E %INzNo%E||No ||Sosa ref exists
 +
|-
 +
| ||  ||colspan="2"|Expressions are limited to the following macros : a c f j l m n o p s w z which return True or False
 +
|-
 +
|%It ||%ItYes%E %INtNo%E||!!!!!t!!!!!Yes !!!!!t!!!!! ||Bad macro (twice) (prints !!!!x!!!!, returns True)
 +
|-
 +
|%IN ||%IN[expression]|| ||Inverts the result of [expression] (See %If thru %Iz for usage examples)
 +
|-
 +
|%I&#124; ||%I&#124;fwfrd or wiz%E ||frd or wiz ||Logical "or" of the two following expressions ("f" and "w" in the example) (the command character "&#124;" is a vertical bar)
 +
|-
 +
|%I& || %I&whwizard and history file%E|| wizard and history file ||Logical "and" with two following expressions ("w" and "h" in the example)
 +
|-
 +
|}
 +
 
 +
 
 +
{{manual}}
 +
 
 +
[[Category:Manual]]

Latest revision as of 17:35, 9 November 2020

150px-Geographylogo svg.png Language: English • français

GeneWeb text present in notes are not pure HTML and may contain variables.

Some are historically called macros. These are letters prefixed by %, for instance %s or %x. GeneWeb replaces these macros by their values depending on the context of the base: name of the base, language, number of persons in the base, etc...

Other variables, bracketed by [ and ] trigger the translation process of GeneWeb according to the current language, and use for this translation the lexicon data. The lexicon page describes in details this translation process.


Description of the macros

Base

  • %t : name of the base
  • %f : in server mode (stand alone machine), name of the base, possibly followed by a token (en toto_xyzzy); in CGI mode the launch command (ex: gwd.exe
  • %g : in server mode, same as "%f"; in CGI mode, name of the launch command followed by ?b=, the name of the base and a semi-colon ; (ex: gwd.exe?b=toto;)
  • %s : value of "%f" followed by a question-mark ? and the contextual variables (see below) (ex: toto?lang=it;iz=8233;)

Numbers

  • %n : number of persons in the base.
  • %c : numbers of visits to the welcome page
  • %q : number of visits to the site (one page = one visit)
  • %d : date of the first visit.

Conditionnals

Conditionnals begin by "%I" followed by a boolean expression and terminate with "%E". Text between these two delimiters is displayed only if the boolean expression evaluates as true:

  • f : visitor is registered as friend
  • w : visitor is registered as wizard
  • j : wizard_just_friend has been activated (see wizard_just_friend in a.gwf
  • c : the server is in CGI mode
  • h : a modifications history file exists
  • l : the web browser does not handle tables
  • n : a notes file exists for this base
  • t : a search by nobility title has been launched
  • z : there exists a sosa reference person (see "%u")
  • a : access to the base is globally restricted
  • N : negation of what follows
  • | : logical "or" between the two following expressions (not e1&e2, but &e1e2!!)
  • & : logical "and" between the two following expressions
    Examples:
    display some text if a search by nobility title is active:  : %It...%E
    display some text if visitor is not "wizard" nor "friend":  : %I&NwNf...%E

Various

  • %r followed by text: include a file names text.txt. The file must be at the same location as the file containing the "%r"
  • %b : value of the "body_prop" variable found in base.gwf.
  • %h : contextual variables (see below), in the form "<input type=hidden name=var value=val>".
  • %l : language.
  • %u : person taken as sosa reference (i.e. sosa 1)
  • %% : a single "%".
  • %[ : a single "[".
  • %] : a single "]".

Contextual variables

Some variables have a lasting influence on GeneWeb across multiple requests. As opposed to the other requests parameters, once activated (by selecting an option through the GUI, or by direct typing in the URL window) the appear in all successive requests unless explicitly removed.

  • lang
  • templ
  • pz, nz, ocz, iz (first_name, last-name, occurence, index of a sosa reference)
  • list to be completed ...

Frequently used macros

  • %b typically inserted in the <body> HTML tag as in <body%b>
  • %s which you will use for any of your href links

Examples in "celebres.txt":

  See my cousin <a href="%sp=louis;n=de+bourbon;oc=5">
  Louis XIV</a> and my 
  <a href="%sem=R;ep=jean;en=dupont;m=NG;n=louis+xiv;t=PN">
  relationship</a> with him.

List of macros

Available macros in the context of m=SRC files : This table can be generated by inserting a m=SRC call to some HTML/GeneWeb code in the note section of somebody in your base. The corresponding code is here

The third column provides the result of execution in a specific context

Macro Example use Result What it does
%a %a Displays name of sosa reference (See %Iz below)
%b %b Value of "body_prop" (in base.gwf)
%c %c 42 Number of queries for the welcome page
%d %d 10 décembre 2018 Date of first visit
%D %D 10/12/2018 Date of first visit
%e %e UTF-8 Character set
%f %f HenriT_w In server mode, base name followed by password. In CGI mode, name of the CGI command (ex: gwd.exe)
%g %g HenriT_w? In server mode, same as "f". In CGI mode, name of the command, followed by "?b=basename;"
%h %h A list of var=value for each hidden url variable
%i %i #2f6400 Highlight color
%j %j Include hed.txt file
%k %k geneweb? Value of the action parameter of a http GET/PUT command
%l %l fr Language
%L %L left Left (style: used in align="%L")
%m %m 30 Value of latest_event (in base.gwf)
%n %n 8879 Number of persons in the base
%N %N : titre Content of base_notes_title (.gwf)
%o %o images Value of %image_prefix; (see doc for image_prefix details (to be completed))
%p %p %p noop
%P %P next (%Pc)
%q %q 285 Number of queries
%r %rfile test for macros Reads file bases/src/base/test.txt) (file must be followed by "end of line")
%R %R right Right (style: used in align="%R")
%s %s HenriT_w? Value of %f followed by "?" and contextual variables (ex: "toto?lang=it;iz=8233;")
Typical use: <a href="%sp=first_name&n=surname">Link to person First_name Surname</a>
%t %t HenriT Base name
%T %T Value of %doctype; (Given that doctype translates into <-- .... -->,
nothing is visible in the result column. Look at the sources to verify)
%u %ufr; français returns "Français" if lang=fr, and "French" if lang=en (dont forget the ;)
%U %U : hg User name
%v %v 7.00-exp Returns GeneWeb version number
%v %vtext; xxxx Specific to the NOTES context: returns the value of bvar.var_text
%V %Vvar; oui Value of bvar.var (in base.gwf) example %Vtest;
%w %w Link to previous page (with back arrow icon)
%x %x %x noop
%X %Xvar; macros Value of evar.var (in URL) example %Xv;
%y %y %y noop
%/ %/ if doctype = "html-4.01" then "" else "/" (used to terminate html tags as in <br%/> ->
%% %% % %
%Ia %IaYes%E %INaNo%E No auth_file exists. Global access restriction is on (see Access)
%Ic %IcYes%E %INcNo%E No Cannot handle passwords
%If %IfYes%E %INfNo%E No We are "Friend"
%Ih %IhYes%E %INhNo%E Yes There is a history file
%Ij %IjYes%E %INjNo%E No Wizard_just_friend is active
%Il %IlYes%E %INlNo%E No Browser handles tables
%Im %ImYes%E %INmNo%E Yes notes_links <> []
%In %InYes%E %INnNo%E Yes There is a base note file
%Io %IoYes%E %INoNo%E Yes Notes dir exists
%Ip %Iptest;Yes%E %INptest;No%E Yes Base env variable <> "" (var terminated by ;)
%Is %IsYes%E %INsNo%E Yes Base env variable <> "no"
%Iw %IwYes%E %INwNo%E Yes We are "Wizard"
%Iz %IzYes%E %INzNo%E No Sosa ref exists
Expressions are limited to the following macros : a c f j l m n o p s w z which return True or False
%It %ItYes%E %INtNo%E !!!!!t!!!!!Yes !!!!!t!!!!! Bad macro (twice) (prints !!!!x!!!!, returns True)
%IN %IN[expression] Inverts the result of [expression] (See %If thru %Iz for usage examples)
%I| %I|fwfrd or wiz%E frd or wiz Logical "or" of the two following expressions ("f" and "w" in the example) (the command character "|" is a vertical bar)
%I& %I&whwizard and history file%E wizard and history file Logical "and" with two following expressions ("w" and "h" in the example)



GeneWeb Manual

Rembrandt Old Man Reading a Book.jpg

Use and manage genealogical databases

Technical annex