A2E::Mktdir
Routines for creating hypertext nodes.
An intermediate layer between mktdir5(1) and A2E::Dokfs, does the work of mktdir5, mktdir4 and mktdir0.
A2E::Subdoks(3)
A2E::Mbox2dok(3)
Template(3)
This describes version 0.0.3 of A2E::Mktdir.
recursively create subdirectories that may be defined using the sems2subtmpl and sems2subsems chunks.
Document style. By setting this you imply that the document is a top node. Otherwise the style is inherited from the topmost preceding node (topdok).
Obsolete, maybe still used for legacy directories at a2e?
write language-specific parameter files, named as specified in antefnom
Extra template variables to be set at the beginning and written into the local --antefnom0 (@pre.mydok.txt) or --antefnom (pre.mydok.en.txt) file. These variables are also written into the language-neutral --antefnom0 file, so that they precede any vocabulary definitions at compile-time. The values of these variables can, even though this is not recommended, be multilingual, using the syntax indicated above. In this case, by implication, skrib_antefaylz is true. We recommend monolingual --tmplvars values because these variables are, in contrast to the langlexvars, intended to be more closely related to process control than to the textual content of the documents.
extra multilingual textchunk groups to be written into vocubulary files postfayl such as _lng.mydok.en.txt.
These are evaluated to become
$m->{langlexvars}->{can}->{en} = 'canned definition'
$m->{langlexvars}->{can}->{de} = 'abgepackte Definition'
, provided that the languages of the document to be created are en and de.
The value is retrieved&cached using the function langlexvar
.
As of 2009-12-12, it seems that we may never want to use this, given that these variables are read late and belong to the text level rather than the program operation level. For the latter purpose, we already have --tmplvars|-V.
Extra variables to be written into language-neutral vocabulary file (unless that already exists). This option is not very useful because the files written to the antefnom (parameter element) file is more important.
Variables that can appear as elements in the subopts hash, i.e. those that have special values in the descendant (creatable) document which need to be specified in that descendant's local configuration file (e.g. @dokfs), exist in this hash as keys with a corresponding true value.
This is used by &A2E::Privat::Lnsig::do_mktdir to determine which variables belong to the descendant level.
Populate a topdok directory with lots of templates that normally are not needed. Do this if you want to extensively customise your section.
origo year for a 1-9,A-Z year counting system used at a2e.de
leaf of directory to be created. normally we only give a sems (semantic features) argument and let the system derive the leaf (--fol) and the document (--dok) based on rules specified in the sems2fol and sems2dok template variables, but we can also override these rules and explicitely name these items.
We used to have an option --tmpl_subtmpls oas_akt = tra --tmpl_subtmpls oas_aa_ont = oas_aamm --tmpl_subtmpls pub_aa = ont:pub_ont_aa,int:pub_int_aa,tem:pub_tem_aa.
This was used to specify the default subtemplates (--subtmpl plus --subtmpls, see A2E::Tmplkonf(3)) that belong to each template. The key is a --tmpl, the argument consisted of a --subtmpl (obligatory) and an optional list of keyvals in which each key is a subdirectory name (usable as mktdir argument no 1) and each val is the subtmpl that is to be used for such a subdirectory.
Now we use a textchunk variable instead, e.g.
in tmpl/a2e/oas_akt/lang.txt:
sems2subtmpl = $(case ${1},tra,ont,tra_ont)
Subdirectories to be obligatorily created for each directory of a given document type. These are leaf names which should have corresponding document types assigned by sems2subtmpl Formerly the variables tmpl_subtmpls or subtmpls were used for this.
Now we use the a textchunk variable instead, e.g.
in a2e/pub_aa/lang.txt:
sems2subsems = int ont tem
in a2e/pub_int_aa/lang.txt
sems2subsems = $(fromto 01,12)
in a2e/pub_int_aamm/lang.txt
sems2subsems = $(mondags ${aaaa},${mm})
TODO (done already?): /adv/tmpl/a2e/pub_ont_aamm/lang_pre.txt SArb/Make.pm monwoks support constructions such as what is to be returned by render_monwoks
|W26,01|w27,02,03,04,05,06,07,08|w28,09,10,11,12,13,14,15|w29,16,17,18,19,20,21,22|w30,23,24,25,26,27,28,29|w31,30,31|
or
|W26 01 01|w27 02 08|w28 09 15|w29 16 22|w30 23 29|w31 30 31|
where each primary argument consists of a list of sems.
OBSOLETE: We used to have an option --tmpl_subsems pub_aa = int,ont,tem --tmpl_subsems pub_int_aa = 01,02,03,04,05,06,07,08,09,10,11,12.
getkanals = oas_akt
getkanals = eupat_ont,eupat_int
This ensures that the webpage generated from the current document has the named rss channels in its news column.
Moreover, if a textchunk of this name has been defined (e.g. in the document type definition or in superordinate document vocabularies), it is written into the @dokfs file (by the function vars_skrib_konf
).
OBSOLETE?: All documents that use a certain template may use certain rss channel(s). Specify this as a rule, expressed by a hash, in the same way as for individual channels it is done by the getkanals variable.
putkanals oas_tra = oas_akt
putkanals = oas_adv,adv
Moreover, if a textchunk of this name has been defined (e.g. in the document type definition or in superordinate document vocabularies), it is written into the @dokfs file (by the function vars_skrib_konf
).
OBSOLETE?: All documents that use a certain template may be suitable for insertion into certain news/rss channels. Specify this as a rule, expressed by a hash, in the same way as for individual channels it is done by the --putkanals option.
grpdir = 1
Documents of this type have their descendants in peer directories rather than subdirectories.
Deprecated, better specify sems2subflat
in the document type lang_pre.txt file.
mktdir.konf
None open at the moment
mktdir0(1)
mktdir5(1)
A2E::Dokfs(3)
Hartmut Pilch
Copyright (c) 2008-9 Hartmut Pilch (phm)
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Names in this program are based on English with International Latin spelling, e.g. 'kopi' for 'copy' and 'meikfayl' for 'makefile', as (to be) explained in
http://a2e.de/alfabet/interlatin
with with occasional Esperanto (such as replacing words such as 'write'/'rait', that become unwieldy in interlatin spelling, with 'skrib')
http://a2e.de/lang/eo
for which the same spelling is used.
Template variables that are not reset or treated specially when template variables are read in from files.
Copy a file from $1 to $2. A wrapper around Unix cp.
If the current node is a group node (pwd_get_subflat) and we are not using a dot argument, go to the parent directory.
arg1 : subflat
arg2 : dotdir_p
This must be done after reading the parent doctype info and before reading the descendant doctype info.
Turn a directory value as specified on the commandline, e.g. '.' or a leaf or an absolute dir, into an absolute directory
Optional second argument $pwd is cleaned (as returned by dir2dir) present working directory
A typical use might be
$m->sems2dok('victoria', '31') ==> victoria090731
where two semantic features, given as arguments, are translated into a document symbol according to a rule specified by the user via template variables like sems2dok or other mechanisms to be implemented here.
Like sems2dok, but generate current directory leaf name rather than document symbol.
Prevent reuse of variables from previous document except special cases defined in %rekurs_sav_tmplvars.
Takes an options hash as argument rest.
This does not delete the group properties $m->{nom2lits}; that is done by lang_set_tmplvars because needed each time.
OBSOLETE?: If option extra
is true, shield certain already-defined variables that are not template-specific and do not change in a subdocument, such as those in @basis_non_tmplvars
and @extra_non_tmplvars
, from deletion.
If option minim
is true, delete only very few tmplvars, namely those that definitely can not be inherited from another document, e.g. because they are document-type-specific.
Mark all variables as not-yet-read-from-file, i.e. make %{$m->{finivars}} empty.
Set the subdirectory leaf argument $fol nr 1 either directly or based on a semantic element/structure $sem nr 2, determine the tmpl/doctype of the document to be created and, based on that, the values of related variables that refer to related documents and their locations, e.g.
$m->{supdok}: parent node
$m->{supdir}: absolute path of parent node directory
$m->{dir}: absolute path of directory to be created
$m->{subflat}: whether $m->{dir} is directory-wise-parallel to $m->{supdir}
$m->{flatsupfol}: if $m->{subflat}, leaf name of $m->{supdir}
$m->{flatsupbas}: if $m->{subflat}, base name of $m->{supdir}
$m->{dirstem}: absolute path of directory under which $m->{dir} will be created -- this differs from $m->{supdir} if $m->{subflat}
$m->{fol}: leafname of directory to be created
Go to $m->{dirstem}.
Return $m->{fol} and $m->{dirstem}.
Allow a dot for a default value of $sem, expand that.
This should come before 'mkchfol', which depends on the supdir-related behaviour and uses the dotdir info.
It should come before 'set_dok_varz'; it should not write anything to the database.
Do not confuse with the supdir and supdok functions of A2E::Dokfs; here we take a different approach; we create the data that the supdir/supdok functions can later use.
The $m->{tmpl} and $m->{subflat} information is gathered from the parent doctype, most other info is then gained from the descendant doctype.
The variable $m->{flatsupfol} is reset in gdp_set_pwd only if needed. The boolean flag $m->{subflat} is always set to tell us whether we are working from a group node. If so the flatsupfol must have been set.
Read variables from the vocabulary files of the document type and write them into the template variables hash; omit those that belong to a group of forbidden variables (non_tmplvars). Choose the default language if none was given. Preconditions: suplangs (languages of superior document node) must be known.
Arguments: $lng : language; if not given, read language-neutral textchunks only; $dok : document; if not given, read doctype/tmpl related textchunks only %opts : options OBSOLETE: extra: treat @extra_non_tmplvars (such as 'aa') as special variables, ignore any further assignment statements of these variables as far as they have already been read no_par: (obsolete? passthru) do not read both language-specific and language-neutral file at every level
New 2013-06-22: SUPDBM: overwrite template variables with any prepared subdocument values from the parent
Find out what kind of a location our leaf is (whether we can write there, whether it is a tree trunk), store some basic configuration values into memory, write others to the database.
The aliases and topdoks must be read into memory in any case.
The database must be edited only if we are creating a new document, i.e. not SAMDOK.
Once we have identified the directory, document and position in the hierarchy, we are ready to set some more variables and perform some checks.
Derive the url from the directory which we have chosen for our document.
This does not read anything from an existing directory, can therefore come relatively early.
Since the sequence of checking directories against urls is critical, we can not use a hash variable for our dirurls config option!
It must come between set_dir_varz and set_dok_varz.
generate triantapentesimal alphanumeric digit, e.g. for 'K4F' style date
Safely create a subdirectory after moving blocking data out of the way, change to that directory. Refrain from creating if the data indicates that the document node shouldn't be here. Make sure we are svn-wise up to date. Retrieve-store info about languages of any pre-existing dok (oldlangs). This comes before pars_args.
Copy a template from its source to its destination and transform it, using the Template toolkit.
Find out for which languages the present node already contains body documents and store these in @{$m->{oldlangs}}.
This is relevant only for existing documents, i.e. cases where dokdir_p is true or where we are entering into an existing directory in mkchfol. It must be there before we have parsed the commandline arguments i.e. pars_args
.
Parse language-version-related arguments.
Take @ARGV as arguments.
Check all arguments and store them into a hash $m->{lngtags}, from which they are transferred to $m->{tmplvars} shortly before use, e.g. at the end of lang_set_tmplvars.
This way we can detect syntax errors early in the process.
This must come after mkchfol, at end of setup.
set default values for title, subtitle etc unless we know our template (tmpl).
Write stubs for the main document (@dok_*) and its auxiliary files.
First evaluate all the commandline parameters, start writing only if they are OK.
Return full pathname for basename arg1, obtained by searching through the template directories. The returned pathname has been found to exist. arg2ff is a list of options containing the boolean option insist
which switches off search in parent directories. If the insist
option is true and nothing is found, die.
Return name of template generation source file, such as e.g.
/adv/tmpl/a2e/oas_adv_aamm/lng_tmpl.txt
/adv/tmpl/a2e/oas_adv_aamm/lng_tmpl.de.txt
if such is found based on an expression $fnom e.g. posttmplfnom0 or posttmplfnom such as
%d/lng_tmpl.txt
%d/lng_tmpl.%l.txt
or others such as
%ppre.%d.%l.txt
etc. Return nil if nothing is found
Copy templates that are needed for top nodes of microsites, i.e. topdoks.
Arg1 is the filename suffix. The rest of the filename is determined by other factors: the tmplsupdir and topsty config variables.
If template variables are present in arg 2 then use transkopi for the transformations, using the Template toolkit with the star style.
Try with more or less specific directory and base names. Die if no suitable default file is found.
Install all the topdok templates using the Template toolkit with star style.
NO_TOPSTY: stop unless we are in a top level document.
This does not yet involve any templates that depend on the vocabulary database.
If a text building block file already exists, store any variable assignements found therein in their raw original form as whole lines in a hash %vars, but identify the variable and use it as hash index. Return %vars.
This is used by skrib_antefayl0, skrib_antefayl, skrib_postfayl and skrib_postfayl0
Take hash argument containing keys (e.g. 'lab') and values (e.g. 'lab := Bar').
Return a list of entries (e.g. 'lab := Bar') in the order in which they should appear in a text chunk file, with obligatory document metadata tokens lab, tit, sut, des coming first.
If a vocabulary file exists, store any variable assignments found therein in their raw original form as whole lines in the hash %vars, but identify the variable and use it as hash index. then overwrite these variables with any newer values that we might have and produce an ordered list of whole lines without the hash index.
arg1 : vocabulary file, e.g. 'pre.abc.de.txt'
arg2 : vocabulary definition format, e.g. '%s := %s'
arg3 : hashref of values that have already been set and take precedence over anything found in the file
arg4ff : keys of hashref that we actually will use, all if untrue
Read a lingual text from the command line and validate it. Return input value and whether it is old, i.e. the input just confirmed what was already in the template.
Cache/retrieve textchunks coming from the langlexvars configuration variable.
arguments:
$nom : variable name
$lang : language
return values:
$val : value derived from $m->{konfig}->langlexvars
intermediate variable cache:
$m->{langlexvars}
store values of present variable in the cache if not already there and return the one of them that matches $lang
Write a postfayl 'lng.$dok.$lang.txt' from scratch based on configuration variables and preset variables.
$filepath
$lang
$asis : hashref : { lab => 'lab := abc' }
$lits : hashref : { lab => 'abc' }
$olds : hashref : whether text chunks are old
Write language dependent tags from object variable lngtags into a lng_fayl and add that to the repository. If a file exists, reuse variables found therein. If a template exists, use that, otherwise write from memory based on configuration and preexisting variables.
Write out language neutral definitions file unless it already exists.
Write language-specific parameter file.
Write out language neutral vocabulary file if it does not already exist.
find the appropriate template file, as specified by a naming config option from A2E::Dokfs(3), by seeking it in a series of directories specified in A2E::Tmplkonf(3), from the lowest (most specific) to the highest (most generic) possible template.
Set some template variables that are needed both in skrib_mldok and skrib_antefayl0.
Subroutine to mlht_skrib_faylz
Set up the text elements (read vocabulary dbm files), write out the main document bodies, first language-dependent parts with different dbm files as basis, then language-independent parts with original of topdok as basis.
Write out the @langs file.
This comes after writing the main document(s) but after set_oldlangs
Identify the subtmpl (subordinate document type) belonging to the current tmpl (document type), based on what is found in the values of the dynamic textchunk variable sems2subtmpl
. Optionally @sems (semantic units passed to 'mktdir', often only the directory leaf) arguments are given. These are passed and often required by the sems2subtmpl
variable. If either @sems or the sems2subtmpl
variable are missing, we terminate (raise an exception).
Resolve the boolean subflat
(whether to create an adjacent directory rather than a subdirectory) value belonging to the current tmpl (document type), based on what is found in the values of the dynamic textchunk variable sems2subflat
and the sems
(semantic units supplied to mktdir as arguments, often consisting of the directory leaf only). The sems are passed to the sems2subflat
variable as ${1}, ${2} etc. If nothing is given we assume 0, i.e. opt for the default procedure of creating subdirectory.
Set variables for subtemplate as specified in sems2subvars, e.g.
sems2subvars ?= $(case ${1},,sig,|privat:1|no_subsems:1|)
leads to
{ privat => 1, no_subsems => 1 }
in case $sems[0] eq 'sig'.
Return a list of argument list strings each of which is to be passed to one subdocument generation ('submktdir') call.
In the frequent and simplest case this argument list string consists of one item that is then immediately used as subdirectory leaf name.
This function optionally takes @sems (semantic units passable to mktdir
, usually directory leaf) arguments. It evaluates the textchunk variable sems2subsems
of the current template/doctype, which can but in practise rarely does use @sems as arguments.
If the sems2subsems
variable does not exist, we are at the end of directory tree and return nil without warning.
A complex argument like
sems2subsems ?= $(monwoks ${aaaa},${mm},${ddmin})
produces something like
'W26,01,01', 'w27,02,08', 'w28,09,15', 'w29,16,22', 'w30,23,29', 'w31,30,31'
as a result.
Write out information from configuration variables to configuration file (e.g. 'dokfs').
Write out a @dokfs file, either based on a template that could be found in the topdok directory, or based on configuration variable settings.
Add accumulated files and some further ones to Subversion repository. Write metadata to the database. Set up a link to an mbox if found.
Final steps of the mktdir5 procedure, excluding svn_commit and directory changes: everything that needs to be done before any subdocuments are created.
always write language-specific parameter files if we are at top document level.
transfer multilingual values of variable settings such as
-V thema=Italia,de:Italien,en:Italy,fr:Italie
from $m->{konfig}->tmplvars into $m->{lang_tmplvars}
Overload the postkonfig part of the new_ready method from A2E::Prog(3).
Plugins for &A2E::Prog::old_ready to make sure that top level functions like mktdir* can be invoked repeatedly on a pre-existing object (without having to reconstruct it with new_ready).
Currently this possibility is used by A2E::Privat::Lnsig and in mktdirs().
The bulk of the mktdir5/mktdir4/mktdir0 program, starting right after parsing of commandline options.
Wrapper of mktir corresponding to the mktdir0 program, interpreting first two arguments as $fol and $dok and invoking mktdir to go on with language-version arguments
Like mktdirs but for sublevel invocation
2010-08-25 用 { cdok tra_feasN8;mktdir rep } 増添已有語言時 @lng.feasN8_rep.txt
被移除
return 1;
# Local Variables: # coding: utf-8 # mode: perl # srcfile: /adv/perl/A2E/Mktdir.pm.tmpl # End:
Hey! The above document had some coding errors, which are explained below:
'=item' outside of any '=over'
You forgot a '=back' before '=head3'
You forgot a '=back' before '=head3'
You forgot a '=back' before '=head3'
Non-ASCII character seen before =encoding in '用'. Assuming UTF-8