The expert corner
![]() |
English |
---|
Contents
Template programming (%if; ... %end;)
The template mechanism provides a very powerful mechanism to construct HTML (or other) pages according to the content of a GeneWeb base.
This section is not intending to give an exhaustive description of the corresponding language. Through some examples extracted from gw/etc/perso.txt
, it provides a glimpse of the possibility. The last two examples are extracted from a template that generates LaTeX rather than HTML.
For further analysis, explore the various other template files, and on last resort, explore the Ocaml source files!!
Programming constructs:
%define; ... %end; %if; [%elseif;] [%else;] %end; %let;xxx;zzz%in; %foreach; ... %end; %apply; ... [%with;... [%and;] ...%end;] %nl; %nn; %sp;
<title>%nn; %if;has_public_name; %if;has_qualifiers;%public_name; %qualifier; %else;%public_name; %surname;%end; %else; %if;has_qualifiers;%first_name; %qualifier; %else;%first_name; %surname;%end; %end; </title>
%define;married_to(sexx, date_place) %if;(sexx = 0 or sexx = 2) %if;are_married;[*married%t to:::date_place]0%nn; %elseif;are_not_married;[*relationship%t to:::date_place]0%nn; %elseif;are_engaged;[*engaged%t to:::date_place]0%nn; %elseif;is_no_sexes_check;[*relationship%t to:::date_place]0%nn; %elseif;is_no_mention;date_place [*with]%nn; %end; %else; %if;are_married;[*married%t to:::date_place]1%nn; %elseif;are_not_married;[*relationship%t to:::date_place]1%nn; %elseif;are_engaged;[*engaged%t to:::date_place]1%nn; %elseif;is_no_sexes_check;[*relationship%t to:::date_place]1%nn; %elseif;is_no_mention;date_place [*with]%nn; %end; %end; %end;
%if;(bvar.can_send_image != "no" and image = "" and first_name != "?" and surname != "?") <li><a href="%prefix;m=SND_IMAGE;i=%index;" class="add_portrait"> %if;(auto_image_file_name != "")[*modify picture]%else;[*add picture]%end; </a> </li> %end;
%define;hgindex(alxx, snxx, fnxx, occxx) %if;(alxx = "0") %if;(occxx = "0") \index{snxx, fnxx} %else; \index{snxx, fnxx (occxx)} %end; %else; %if;(occxx = "0") \index{alxx, voir snxx, fnxx} %else; \index{alxx, voir snxx, fnxx (occxx)} %end; %end; %end
%foreach;alias; {\it {\bf %alias;}}%apply;hgindex(alias, surname, first_name, occ)\\%nl; %end;
This list does not claim to be exhaustive (but pretty close!!).
"access_by_key" "access" "age" "alias" "anc_sosa" "ancestor_level" "ancestor_level2" "ancestor_surname" "ancestor_tree_line" "ancestor" "are_divorced" "are_engaged" "are_married" "are_not_married" "are_separated" "auto_image_file_name" "baptism_date" "baptism_note" "baptism_place" "baptism_witness" "base" "birth_date" "birth_note" "birth_place" "birth_witness" "birth_witness" "birthday" "browsing_with_sosa_ref" "burial_date" "burial_note" "burial_place" "burial_witness" "bvar" "canton" "cell" "child_cnt" "child_name" "child" "colspan" "comment" "compilation_time" "computable_age" "computable_death_age" "computable_marriage_age" "consanguinity" "count" "country" "county" "cousin_level" "cremated_date" "cremation_place" "cremation_witness" "date_begin" "date_end" "date" "dates" "day" "death_age" "death_date" "death_note" "death_place" "death_witness" "desc_level" "descendant_level" "died" "district" "divorce_date" "empty_sorted_list" "enclosing" "evar" "event_witness_kind" "event_witness_relation_kind" "event_witness_relation" "event_witness" "event" "fam_access" "family_cnt" "family" "father_age_at_birth" "father_sosa" "father" "first_name_alias" "first_name_key_strip" "first_name_key_val" "first_name_key" "first_name" "fwitness" "has_aliases" "has_baptism_date" "has_baptism_note" "has_baptism_place" "has_baptism_witnesses" "has_birth_date" "has_birth_note" "has_birth_place" "has_birth_witnesses" "has_burial_date" "has_burial_note" "has_burial_place" "has_burial_witnesses" "has_children" "has_comment" "has_consanguinity" "has_cremation_date" "has_cremation_place" "has_cremation_witnesses" "has_date" "has_death_date" "has_death_note" "has_death_place" "has_death_witnesses" "has_event" "has_families" "has_first_names_aliases" "has_fsources" "has_fwitness" "has_history" "has_image" "has_linked_page" "has_linked_pages" "has_marriage_note" "has_nephews_or_nieces" "has_nobility_titles" "has_note" "has_notes" "has_occupation" "has_parents" "has_place" "has_possible_duplications" "has_psources" "has_public_name" "has_qualifiers" "has_relation_her" "has_relation_him" "has_relations" "has_siblings" "has_sosa" "has_sources" "has_spouse" "has_src" "has_surnames_aliases" "has_witnesses" "hexa" "history_file" "ident_key" "image_html_url" "image_medium_size" "image_size" "image_small_size" "image_url" "image" "incr_count" "ind_access" "index" "interval" "is_buried" "is_center" "is_cremated" "is_dead" "is_descendant" "is_empty" "is_female" "is_first" "is_invisible" "is_last" "is_left" "is_male" "is_no_mention" "is_no_sexes_check" "is_private" "is_public" "is_restricted" "is_right" "is_self" "is_sibling_after" "is_sibling_before" "is_top" "item" "lazy_force" "lazy_printed" "level" "linked_page" "mark_descendants" "marriage_age" "marriage_date" "marriage_note" "marriage_place" "max_anc_level" "max_cous_level" "max_desc_level" "misc_names" "month" "mother_age_at_birth" "mother_sosa" "mother" "name" "nb_children" "nb_events" "nb_families" "nb_ind" "nb_times" "next_item" "nobility_title" "note" "notes" "number_of_ancestors" "number_of_descendants" "number_of_subitems" "occ" "occupation" "octal" "on_baptism_date" "on_birth_date" "on_burial_date" "on_cremation_date" "on_date" "on_death_date" "on_marriage_date" "origin_file" "other" "parent" "place_key" "place" "prec" "prev_fam_father" "prev_fam_index" "prev_fam_mother" "prev_family" "prev_item" "public_name" "pvar" "qualifier" "region" "related_type" "related" "relation_her" "relation_him" "relation_type" "relation" "reset_count" "reset_desc_level" "same" "self" "set_infinite_desc_level" "sex" "slash_baptism_date" "slash_birth_date" "slash_burial_date" "slash_cremation_date" "slash_death_date" "slash_divorce_date" "slash_marriage_date" "sorted_list_item" "sosa_access" "sosa_in_list" "sosa_link" "sosa_ref" "sosa" "source_type" "source" "spouse" "src" "surname_alias" "surname_begin" "surname_end" "surname_key_strip" "surname_key_val" "surname_key" "surname" "title" "town" "township" "v" "var" "version" "wedding_birthday" "witness_relation" "witness" "year"
Note for has_event (v7)
Note that the has_event
function does not consider birth, baptism, death and burial as "events" per se. If you want those events to be taken into account in this function, then you have to add display_timeline=yes
in your .gwf
parameter file.
Note also that if display_timeline=no
, then has_event
always returns False
.
Macros (%x)
See Macros for a description of their use.
Below is the result of calling all 26 lower case possible macros: 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 here
Commands (m=XXX)
List of the commands appearing in URL with the form:
%sm=COMMAND;p=param1;n=param2;
This list does not claim to be exhaustive, and does not "explain" what each command does!
"A" "ADD_FAM" "ADD_FAM_OK" "ADD_IND" "ADD_IND_OK" "ADD_PAR" "ANM" "AN" "AD" "AM" "AS_OK" "B" "C" "CAL" "CHG_CHN" "CHG_CHN_OK" "CHG_FAM_ORD" "CHG_FAM_ORD_OK" "CONN_WIZ" * "D" "DAG" * "DEL_FAM" "DEL_FAM_OK" "DEL_IMAGE" "DEL_IMAGE_OK" "DEL_IND" "DEL_IND_OK" "DOC" (* obsolete *) "FORUM" "FORUM_ADD" "FORUM_ADD_OK" "FORUM_DEL" "FORUM_P_P" "FORUM_SEARCH" "FORUM_VAL" "FORUM_VIEW" "H" "HIST" "HIST_CLEAN" "HIST_CLEAN_OK" "HIST_DIFF" "HIST_SEARCH" "IM" * "IMH" * "INV_FAM" "INV_FAM_OK" "KILL_ANC" "LB" "LD" "LINKED" "LL" "LM" "LEX" "MISC_NOTES" "MISC_NOTES_SEARCH" "MOD_DATA" "MOD_DATA_OK" "MOD_FAM" "MOD_FAM_OK" "MOD_IND" "MOD_IND_OK" "MOD_NOTES" "MOD_NOTES_OK" "MOD_WDOC" (* obsolete *) "MOD_WDOC_OK" (* obsolete *) "MOD_WIZNOTES" * "MOD_WIZNOTES_OK" * "MRG" "MRG_DUP" "MRG_DUP_IND_Y_N" "MRG_DUP_FAM_Y_N" "MRG_FAM" "MRG_FAM_OK" "MRG_MOD_FAM_OK" "MRG_IND" "MRG_IND_OK" "MRG_MOD_IND_OK" "N" "NG" "NOTES" "OA" "OE" "P" "POP_PYR" "PS" P "R" "REQUEST" "RL" "RLM" * "S" "SND_IMAGE" "SND_IMAGE_OK" "SRC" * "STAT" B "CHANGE_WIZ_VIS" * "TT" "U" "VIEW_WIZNOTES" "WDOC" (* obsolete *) "WIZNOTES" * "WIZNOTES_SEARCH" *
Commands marked with a * are documented below:
Variables (evar and bvar)
GeneWeb proposed a general purpose mechanism allowing the user/programmer to extend at will the notion of variable described here.
If a new variable is defined in the .gwf
configuration file, then it will be possible to test for the value of this variable in the context of a template file. For instance, if we have added
new_var=some-text
in .gwf
, then the following code in the template will be able to perform some specific action:
%if; (bvar.new_var = "sometext" ) ... perform some specific action ... %end;
Similarly, if we have added a new variable in the URL of the query to GeneWeb (localhost:2317/base?p=first-name;n=last-name;lang=fr;tree=3
, then it is possible to test for this variable with code such as:
%if; (evar.tree = 3 ) ... display 3 generation tree ... %end;
The value itself of such variables can be inserted in the body of a template by typing %evar.tree;
, for instance:
<title>Tree with %evar.tree; generations</title>
The special variable var is treated in the following fashion within notes, sources and comments:
If you define in the .gwf
file a variable {{{1}}}
, then invoquing the macro %vtext;
in a note or a template will produce the text some_text
as in the following example:
var_who=Bond, James Bond
"My name is %vwho;."
in a note will be transformed into "My name is Bond, James Bond."
.
This feature is used by some to facilitate signature of sources. The .gwf
file contains a list of var_nickname
definitions whose value is a full name and possibly a pointer to a page containing more detailed information:
var_henri=<a href="http://site/base?p=Firstname;n=lastname">First_name Lastname</a>
(no %x or %macro; in the value of the parameter!!).
Building trees through direct url construction
GeneWeb Manual
- Download and install GeneWeb program under GNU/Linux, Mac OS X, Microsoft Windows, FreeBSD; on Mac OS X, Linux or Windows using Docker; or in CGI mode behind a web server.
- Understand GeneWeb server, homonym, consanguinity.
Use and manage genealogical databases
- Import Gedcom
.ged
or GeneWeb.gw
files with gwsetup or in command-line. - Update datas (add/remove individuals and families), merge duplicates, type dates.
- Use wikitext syntax, macros, keyboard shortcuts.
- Clean, recover, rename, save, archive a database.
- Merge and split multiples databases.
Technical annex
- Personalize CSS, header and trailer, templates, lexicon and declension.
- Configuration file
.gwf
(for templm), wizard notes, passwords for friends/wizards and access restrictions to databases. - Add images in notes, further remarks for experts.