;;; This file contains the main canevas of each pages.
;;; License GPL.
;;; Authors: Arnaud Legrand, Martin Quinson
;;; You should define the tag <my-email> somewhere, because it's used here.
;;; For example, I've put the following in my customization.wml:
;;; <define-tag my-email>Martin.Quinson@ens-lyon.fr</define-tag>
;;; You don't even have to load this file using a #include line, because
;;; banner do it for you.
;;;;;;;;;;;;;;;;;
;;; Misc tags ;;;
;;;;;;;;;;;;;;;;;
;;; <under_construction>: to mark a page as being under construction. be
;;; carefull, it does not look that good, so use that only when actually
;;; working on pages, for a few hours.
;;; <date when="YYYY-MM-DD">: beautifull date output
;;;;;;;;;;;;;;;;;;;;
;;; Framing tags ;;;
;;;;;;;;;;;;;;;;;;;;
;;; This file also defines two tags to make beautiful frames:
;;; <frame> make a major frame on the page
;;; <subframe> have other colors.
;;; Both take the following arguments:
;;; title:
;;; note: crappy text added to the right of the title
;;; name: adds an internal html ancor. So, you can build links directly to
;;; this frame (using the "#ancor" form).
;;; toc="no": Don't register this frame to the TOC (see below)
;;; expend="no": don't put spaces between letters in title
;;;;;;;;;;;;;;;;
;;; TOC tags ;;; frames and subframes may be used to build a TOC.
;;;;;;;;;;;;;;;;
;;; The compilation mecanism is quite the same than for LaTeX. You compile
;;; your code one time, it builds a "aux" file containing the needed
;;; info, and you recompile it to get the TOC right.
;;; Needed compilation args: -oAUX:.$(FILE).aux -oUNDEF:$(FILE).html
;;; <add-toc-entry ...>: add an entry to the toc. Args:
;;; title: text to display
;;; name: of the ancor (which will be placed automatically). If ommited,
;;; a default value is computed
;;; lvl: level. 1=>frame, 2=>subframe.
;;; <display-toc>
;;; file: basename of this wml file
;;; maxlevel: maximal deep displayed
;;; How does it works: man slice(1)
;;;;;;;;;;;;
;;; TODO ;;;
;;;;;;;;;;;;
;;; There is a lot of common code in the frame, subframe, and bib tags.
;;; we should make an 'ancestor' to share it.
wml::std::tags
#use wml::std::tags
wml::Utils::perl
#use wml::Utils::perl
<set-var toc:_cnt=0 /> ;;; for automatic ancors
;;;;;;;;;;;;;;;;;;;;;
;;; tag add-toc-entry
;;;;;;;;;;;;;;;;;;;;;
<define-tag add-toc-entry>
<preserve name title lvl /><set-var %attributes />
<ifeq <get-var name /> ""
<group <increment toc:_cnt />
<set-var name="l<get-var lvl />.<get-var toc:_cnt />" />
/>
/>
<a id="<get-var name />"></a>
[AUX:TOC##<get-var lvl />##<get-var name />##<get-var title />
:]
<restore name title lvl />
</define-tag>
;;;;;;;;;;;;;;;;;;;
;;; tag display-toc
;;;;;;;;;;;;;;;;;;;
<define-tag display-toc>
<preserve file maxlevel toc line parts />
<set-var %attributes />
;;; test the args
<ifeq <get-var file /> ""
<compound>
<warning "Argument 'file' mandatory in tag 'display-toc'" />
<exit 1 />
</compound>
/>
<ifeq <get-var maxlevel /> ""
<compound>
<warning "Argument 'maxlevel' mandatory in tag 'display-toc'" />
<exit 1 />
</compound>
/>
;;; increment maxlevel because builtin gt is strict comparaison.
<increment maxlevel />
;;; reads the aux file
<if <file-exists ".<get-var file />.aux" />
<set-var toc="<include ".<get-var file />.aux" />" />
/>
;;; foreach line of the aux file
<foreach line toc>
<set-var parts="<subst-in-string <get-var line /> "##" "\n" />" />
<ifeq <get-var parts[0] /> "TOC"
<compound>
;;;maxlevel=<get-var maxlevel /> ; curlevel=<get-var parts[1] /> <br/>
<if <gt <get-var maxlevel /> <get-var parts[1] /> />
<compound>
;;; put some spaces
<set-var i=<get-var parts[1] /> />
<while <gt <get-var i /> 1 />> <decrement i /></while>
;;; put the entry
<a href="#<get-var parts[2] />"><get-var parts[3] /></a><br/>;;;
</compound>
/>
</compound>
/>
</foreach>
<restore file maxlevel toc line parts />
</define-tag>
;;;;;;;;;;;;;
;;; tag frame and subframe
;;;;;;;;;;;;;
<define-tag drawframe endtag=required>
<preserve title note name toc expend lvl mainclass gettext />
<set-var %attributes />
<ifeq "<get-var gettext />" "yes"
;;; then
<set-var title <_><get-var title /></_> />
/>
<div class="<get-var mainclass />">
<div class="frameHeader">
<div class="frameTitle">
;;; Take care of the TOC and ancors
<ifneq <get-var toc /> "no"
;;; then
<add-toc-entry title="<get-var title />"
name="<get-var name />" lvl="<get-var lvl />" />
;;; else
<if <get-var name />
<group <a id="<get-var name />"></a> />
/>
/>
<h<get-var lvl/>>
<perl>{
my $tit;<perl:assign $tit><get-var title /></perl:assign>;
my $not;<perl:assign $not><get-var note /></perl:assign>;
my $expend;<perl:assign $expend><get-var expend /></perl:assign>
$expend = $expend || "yes";
if ( (defined($tit) && $tit =~ /\S/)
||(defined($not) && $not =~ /\S/)) {
$string="";
$string .= ($expend == "no" ? $tit : isotitlestring ($tit));
<perl:print>$string</perl:print>
}
}</perl>
</h<get-var lvl/>>
</div>
<div class="frameNote">
<perl>{
my $tit;<perl:assign $tit><_><get-var title /></_></perl:assign>;
my $not;<perl:assign $not><get-var note /></perl:assign>;
my $expend;<perl:assign $expend><get-var expend /></perl:assign>
$expend = $expend || "yes";
if ( (defined($tit) && $tit =~ /\S/)
||(defined($not) && $not =~ /\S/)) {
$string="";
$string .= ($not||" ");
<perl:print>$string</perl:print>
}
}</perl>
</div>
<div class="frameTitleEnd">
</div>
</div>
<div class="frameContent">
<perl>{<perl:assign>%body</perl:assign>}</perl>
</div>
</div>
<restore title note name toc expend lvl mainclass gettext />
</define-tag>
<define-tag frame endtag=required>
<drawframe %attributes
;;;<attributes-quote %attributes />
lvl="1" mainclass="frame">
%body
</drawframe>
</define-tag>
<define-tag subframe endtag=required>
<drawframe %attributes
%%%<attributes-quote %attributes />
lvl="2" mainclass="subframe">
%body
</drawframe>
</define-tag>
;;;
;;; Tag under_construction
;;;
<define-tag under_construction endtag=none>
<subframe title="UNDER CONSTRUCTION">
<font color=red size=+4>I'm working on this page !! Come back soon !</font>
</subframe>
</define-tag>
;;;
;;; Tag date
;;;
<define-tag date endtag=none>
<preserve when />
<set-var %attributes />
<perl>
my $str;<perl:assign $str><get-var when /></perl:assign>;
if ($str =~ m/([0-9]{4})-([0-9]{2})-([0-9]{2})/) {
$str = "$3-$2-$1";
$str =~ s|-|/|g;
<perl:print>$str</perl:print>
}
</perl>
<restore when />
</define-tag>