[[plugin:newpagetemplate|<== newpagetemplate]] ====== Command Line Interface ====== The command line tool is run in the bin directory of the wiki, as follows:\\ ''./plugin.php newpagetemplate ''\\ The options are described below. **Please note:** \\ To run the newpagetemplate CLI plugin from the command-line you should have root permission on your server, otherwise the new pages will be created but will not be editable by DokuWiki. This is not a problem if you use the newpagetemplate admin plugin or if your use case involves always involves command line updating of the pages. The admin plugin packaged with the CLI implementation simplifies the use of the CLI features. It does not require root permission but works using DokuWiki's normal access to the web server. Therefore, the pages it creates are editable by DokuWiki. Because the CLI can be run from the command line, its pages can be updated using command line scripts. Among the possibilities is updating the pages using scripts run in cron jobs. If using initialization files, modified on the [[#command_line_precedence|command line]]. ===== Initialization files ===== A significant advantage to the cli interface is that it can process multiple pages, and each can have its own ''userreplace'' macros, which are passed in through the ''newpagevars'' entry. ==== Example ini file: ==== ; Comments can be added, preceded by semi-colons [pagetemplates:home_one] newpagevars[]="@HI@,Howdy!;@AGE@,25" ; for current:one newpagevars[]="@HI@,Hello!;@AGE@,35" ; for current:two page[] = playground:current:one page[] = playground:current:two [pagetemplates:home_two] newpagevars="@HI@,Howdy!;@AGE@,50" ; for both persistent:one and persistent:two page[] = playground:persistent:one page[] = playground:persistent:two ==== Notes on the Ini File Format ==== - The file is organized into sections around newpage templates * The template entries **must** be flush left. - These are followed - by entries for the pages to be created, which are represented as Dokuwiki page ID's. - and by user any replacement macros (''newpagevars'') and their replacements. Both the the page entries and the ''newpagevars'' use a pseudo array syntax one exception described below. page[] = newpagevars[] = Each page entry aligns with the ''newpagevars'' entry at the same position in the pseudo-array, so that the ''newpagevars'' in the first position will be processed with the first page, etc. The ''newpagevars'' do not have to be entered as a pseudo-array, as illustrated in the ''pagetemplates:home_two'' section. There the pages are still denoted as a pseudo-array, but the ''newpagevars'' occur as a single string; in this case the same macros will apply to all the pages. Although the ''newpagevars'' can be formatted as a single string, page entries must always use the pseudo-array format, even in the case of a single page. The ini files **must** be the root directory of the newpagtemplate plugin and must have the ''.ini'' extension. ==== Command Line Precedence ==== When using an ini file, user replacement macros set on the command line itself take precedence over those set in the ini file ===== Administration Page ===== The command line interface comes with an admin plugin that can be accessed from the [[plugin:newpagetemplate|]] administration page. It provides a simple GUI to the command line features. From this page, you can choose either an ''ini'' file or else a template and page to process. There is also an option to specify ''newpagevars''. If you choose to create a single page, these ''newpagevars'' will be processed with the page; if you choose an ''ini'' file, they will be processed with each page. You can also choose to test without saving. The admin plugin comes with instructions. ===== New Configuration Settings ===== **plugin»newpagetemplate»default_tplns** \\ Default namespace for storing your templates\\ \\ **plugin»newpagetemplate»web_owner** \\ Owner of the web server. Only one can be selected. If neither www-data or apache, ucheck the checked box and enter the name in the input box\\ \\ **plugin»newpagetemplate»web_group** \\ Group membership of the web server. Only one can be selected. If neither www-data or apache, ucheck the checked box and enter the name in the input box ===== Command Line Options ===== USAGE: newpagetemplate \\ [[-p|--page] page_id] | [[-i|--ini] path-to-ini|config] | [[-t|--tpl] template_id] | [[-u|usrrepl] ] |[[-s|--screen][cmdLine|browser]]|[[--nosave|-n]true] This plugin helps to automate the processing of pages that use new page templates. The first command line option must be either ''page'' or ''ini''. For a complete description see the newpagetemplate [[plugin:newpagetemplate|documentation]]\\ **OPTIONS:**\\ **-v, –version:** print version\\ **-p, –page:** Apply the template to the named page id\\ **-u, –usrrepl:** newpagevars, Macro/Replacent string: @MACRO@,replacement;@MACRO_2@. . .\\ **-t, –tmpl:** Template to apply to the specified page\\ **-c, –cliuser:** User of CLI process. Optional: is not specified, the plugin uses the name of the current user\\ **-n, –nosave:** If this option is set to 'true', then none of the the pages will be saved; if set to 'existing',\\ then existing pages will not be over-written, but all other pages will be created and saved.\\ If set to 'false' all pages will saved and existing pages over-written. In any case, the output will still be\\ printed to the screen, if the screen option is set to browser.\\ **-s, –screen:** Output results to screen; this option takes one of two parameters: either 'browser' or 'cmdLine'.\\ The command line output consists of the command line options in raw and parsed format. The browser output\\ consists of the parsed page data.\\ **-i, –ini:** Name of an ini file. This file must be stored in the root directory of the newpagetemplate plugin.\\ The ini files make it possible to parse and save data to multiple pages. Its format and functioning are described on the newpagetemplate plugin page. To use the ini file specified in the plugin's Configuration Settings, this option must be set to 'config'.\\ **-h,** –help: Display this help screen and exit.\\