NAME

A2E::Mktdir


DESCRIPTION

Routines for creating hypertext nodes.

An intermediate layer between mktdir5(1) and A2E::Dokfs, does the work of mktdir5, mktdir4 and mktdir0.


PREREQUISITES

    A2E::Subdoks(3)
    A2E::Mbox2dok(3)
    Template(3)


OPTIONS

--subtmpls oas_akt = tra --subtmpls oas_aa_ont = oas_aamm

Specify the default subtemplates (--subtmpl) that belong to each template

--basurl url
--langnoms de=Deutsch
--lang0 de
--minimal
--topsty tra

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).

--mailuser adv
--conv deplate
--menuitem_template

Obsolete, maybe still used for legacy directories at a2e?

--mailhost a2e.de
--mailadr adv@a2e.de
--tmplkonf

Configuration parameters for the templates used for creation of makefile, navigation file, main document etc.

--makefile_tmpl makefile_tmpl.txt
--skrib_antefaylz

write language-specific parameter files, named as specified in antefnom

--tmplvars|--tv|-V mm=01 -V aa=09 -V thema=IT,it:Italia,de:Italien,en:Italy,fr:Italie

Extra variables to be filled into the template tmpl at time of creation. These variables are also written into the language-neutral --antefnom file, so that they precede any vocabulary definitions at compile-time. The values of these variables can be multilingual, using the syntax indicated above. In this case, by implication, skrib_antefaylz is true.

--langlexvars|--llv can="canned definition" --llv can2='another ${can}'

extra variables to be written into vocubulary file lngfayl.

Unlike the --tmplvars template variables, these are evaluated when the document is compiled, rather than when it is created. This commandline option might not be very useful in practise. It might be more advisable to store the variables in a template-related vocabulary file which is named according to the file naming convention specified by the --tmpllngfnom, --tmpllngfnom0, --doktmpllngfnom, --doktmpllngfnom0 variables of A2E::Dokfs.

--lexvars|--lv aa=09 --lv mm=01

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.

--trans_tmplopts TAG_STYLE=star
--tmplang_outfmts multemp="html pdf" mlwebdb="html"
--tratoks_extra 'kws'
--tmpl_getkanals oas_akt_aamm=oas_akt --tmpl_getkanals eupat=eupat_ont,eupat_int

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 option.

--tmpl_putkanals oas_tra=oas_akt --tmpl_putkanals oas_adv_aammdd=oas_adv,adv

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.

--subopts_vars getkanals

Variables that can appear a 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.

--fol testM4 --dok testM4

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.


FILES

    mktdir.konf


BUGS

None open at the moment


LIMITATIONS

one document template set for everything


SEE ALSO

    mktdir0(1)
    mktdir5(1)
    A2E::Dokfs(3)


AUTHOR

    Hartmut Pilch


COPYRIGHT

    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.


IMPLEMENTATION

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.

General Basic Routines

Function copyfile

Copy a file from $1 to $2. A wrapper around Unix cp.

Function tcek_mailadr_varz

Function grpdir_p

Find out whether the current directory is a group node, i.e. directory-wise-parallel to its menu-wise parent.

If the directory contains a '@grpdoks' file or is indicated by the --grpdir option this is true.

Function gdp_set_pwd

If the current node is a group node (pwd_get_grpdir_p) and we are not using a dot argument, go to the parent directory.

    arg1 : grpdir_p
    arg2 : dotdir_p

Function fol2dir

Turn a directory value as specified on the commandline into an absolute directory

Function set_dir_varz

Set the subdirectory argument.

Allow a dot for a default value, expand that.

Currently it can only be a leaf.

DOTDIR: If the leaf is '.', i.e. the current directory, we do not need subadd later, and the template that our created/extended document uses is no longer the one specified by konfig.subtmpl but konfig.tmpl

This should come before 'subadd', 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 path; we create the data that the supdir/supdok functions can later use.

The variable $m->{grpdir_fol} is reset in gdp_set_pwd only if needed. The boolean flag $m->{grpdir_p} is always set to tell us whether we are working from a group node. If so the grpdir_fol must have been set.

Global variable @tratoks

Function lang_set_tmplvars

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. A second argument indicates whether language-neutral files should be read as well; this is done only the first time.

set_dok_varz

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.

Add the leaf to the branch.

For this to work we must be in the directory from where the leaf is added to the menu.

This may be different from the directory to which the subdirectory is added, aka supdir: some directories are heads of groups (grpdir, containing a @grpdoks file).

DOTDIR: if we are working in the current directory (see DOTDIR), we omit this step, because we assume that we are just adding a new language to an existing document. Don't mind if the document is a top-level document and thus not subordinate to the current document in a strict sense. If $m->{konfig}->force (commandline option --force) is set, go ahead even in the

Set further variables

Once we have identified the directory, document and position in the hierarchy, we are ready to set some more variables and perform some checks.

Function dir_set_url

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.

Function num2alpha35

generate triantapentesimal alphanumeric digit, e.g. for 'K4F' style date

Function datum_set_tmplvars

preset date-related template variables based on a given date.

Install the target directory with some basic files

Function seif_mkdir

Safely create a directory after moving blocking data out of the way. 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.

Function transkopi

Copy a template from its source to its destination and transform it, using the Template toolkit.

Function set_oldlangs

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 seif_mkdir. It must be there before we have parsed the commandline arguments i.e. pars_args.

Function 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 later read when they are used.

This way we can detect syntax errors early in the process.

This must come after seif_mkdir, at end of setup.

set default values for title, subtitle etc unless we have a template available.

Write the files

Write stubs for the main document (@dok_*) and its auxiliary files.

First evaluate all the commandline parameters, start writing only if they are OK.

Function topdok_kopi

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.

Function topdok_install

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.

Function riid_frazfayl

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

Function lexvars2values: put tratoks (lab, tit, sut, des) upfront in correct order
Function frazfayl_values: obtain values from existing vocabulary file

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

Function tmpl_skrib_fayl

Write a file from a template

 $arg1 : template file
 $arg2 : output file
 %args3ff : settings of some file variables for emacs local variables header+footer, mostly C<dokl> and C<mode>

Function invalid_msg

Function mktdir_input_lit

Read a lingual text from the command line. Return input value and whether it is old, i.e. the input just confirmed what was already in the template.

Function konf_skrib_postfayl

Write a postfayl '@lng.*.??.txt' from scratch based on configuration variables and preset variables.

    $arg1 : string : filepath
    $arg2 : string : lang
    $arg3 : hashref : text chunks
    $arg4 : hashref : whether text chunks are old

Function skrib_postfayl

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.

Function skrib_antefayl0

Write out language neutral vocabulary file unless it already exists.

Function skrib_antefayl

Write language-specific parameter file.

Function skrib_postfayl0

Write out language neutral vocabulary file if it does not already exist.

Function tmplsrcfayl

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.

Function doknavtmplfayl

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.

Function mldok_pre_set_tmplvars


Set some template variables that are needed both in skrib_mldok and skrib_antefayl0.

Function skrib_mldok

Function skrib_mlnav

Function 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.

Function skrib_langs_fayl

Write out the @langs file.

This comes after writing the main document(s) but after set_oldlangs

skrib_meikfayl

Function konf_skrib_konf

Write out information from configuration variables to configuration file (e.g. '@dokfs').

Function skrib_konf

Write out a @dokfs file, either based on a template that could be found in the topdok directory, or based on configuration variable settings. EKZISTS: Do so only if no such file ekzists yet, i.e. dont do so if we are only adding another language version to a document.

Finishup and postprocessing

Add accumulated files and some further ones to Subversion repository. Write metadata to the database. Set up a link to an mbox if found.

Function svn_add_faylz

Enlist some remaining files that were not (as would be preferrable) enlisted upon creation. Then add all candidates to the svn repository.

Function mktdir_finic

Final steps of the mktdir5 procedure.

Top level functions

Function lastkonfig

topsty

always write language-specific parameter files if we are at top document level.

LANG_TMPLVARS

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}

Function postkonfig

Overload the postkonfig part of the new_ready method from A2E::Prog(3).

Function mktdir

The bulk of the mktdir5/mktdir4/mktdir0 program, starting right after parsing of commandline options.


The End