DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:openas

This is an old revision of the document!


~~MoveTO>new:required~~

openas Plugin

Compatible with DokuWiki

anteater,rincewind,angua,adora belle,weatherwax,binky,"ponder stibbons",hrun,detritus,"Elenor Of Tsort","Frusterick Manners",Greebo

plugin File utility for moving/renaming files, saving copies, creating new pages from templates

Last updated on
2017-04-11
Provides
Syntax, Action
Repository
Source
Requires
newpagetemplate

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to bureaucracy, move

Tagged with file, form, move, pagemove, rename, template

Installation

:!: External requirements: This plugin requires the following additional component that must be installed separately if you wish to use the templating facility: newpagetemplate

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Examples/Usage

This plugin facilitates renaming (i.e. moving) pages, saving as (i.e. saving a page under a new name without deleting the original), and creating new pages from templates.

There are three syntax formats:

      ~~SaveAS>newname~~        
      ~~MoveTO>newname~~
      ~~OpenAS>newname#template>newpagevars~~
  1. newname is the page name with its namespace, as in :namespace:newname
  2. template is the name of a template which will be found in :pagetemplates
  3. newpagevars has this format: @macro_1@,value_1;@macro_2@,value_2;. . .
    • this follows the format of the newpagetemplate plugin for specifying macros and their substitution values.

SaveAS

The SaveAS form will create a new page from the old page but leave the old page in tact.

MoveTO

The MoveTO form will create a new page from the old page and delete the old page. However, it will not delete the old page unless it is certain that the new page is in place, so that there is no danger of losing the old page. The MoveTo form performs a limited page move: it preserves backlinks and implements a number of other features, as described below in the pagemove section.

OpenAS

The OpenAS form requires the newpagetemplate plugin. This form will open the page newname, using the specified template. The newpagevars attribute follows the format described on the newpagetemplate page. Here is a sample:

 ~~OpenAS>hello_temp#:pagetemplates:homepagetemplate>@HI@,HOWDY!;@BYE@,Good Bye~~

This will open up the page :hello_temp, using the homepagetemplate in the :pagetemplatesnamespace, and it will fill in any of the substitution variables defined on the newpagetemplate plugin page, as well as the variables defined by newpagevars (which in this example are: @HI@ and @BYE). Please see the newpagetemplate page for complete details on using the newpagetemplate plugin.

There is an expanded syntax for this form of the plugin which gives it significantly greater flexiblity. See below.

How it works

Once the page with the syntax markup is saved, it will now show a yellow box with a link. Clicking on this link will perform the desired action. In the case of pages which have been moved or saved-as, the new page will already be created, but links will not be updated until the new page is accessed from the link in the yellow box. In the case of a page which has been moved, the original page will remain on the server until you have linked to the new page, at which time the old page will be deleted. In the case of new page templates, the new page will open with the macro values filled in. The ~~SaveAS>name~~ and ~~MoveTO>name~~ will be removed from the newly created pages.

Relative links will be re-written to the newly created file as absolute links. This is true of both the SaveAS and the MoveTO forms,

Pagemove

In the MoveTo option, all backlinks to the page being moved are updated to the page id of the new page.

The plugin takes into consideration page locking. So, if a page with backlinks is currently in use, it is not updated until the user with the lock exits the page. The original page remains in place until all of the pages with backlinks have been updated. Once all backlinks have been updated, the original page is removed.

Metadata and Indexing

This plugin does not update the Dokuwki history or indexing for the updated files. If you want to re-index your site, you can use the searchindex plugin.

Images

The plugin in its present form does not update relative image links. If images are inserted using the media manager, this should not be an issue. For this situation try the move plugin.

Backup

There is a backup system. A new meta directory is created: data/meta/openas, where the original backlink pages are stored. The pre-updated versions of these pages are created with the .mvd extension. And the page which has been moved to the new id is backed up with the .orig extension. The .orig and .mvd files are numbered, with the highest number being the most recent.

Expanded Syntax for the OpenAs Format

With the expanded syntax, it is not necessary to pre-insert the newpagevars and their values into the page, as described above. Instead you can create an HTML Form, from which th plugin will take the names of the variables and their values. The benefit of this, of course, is that the values are not pre-set by the plugin. Different values can be entered for each access of the form.

This is the expanded syntax.

    ~OpenAsVarsStart~~
    ~~OpenAsVAR>ReplacementVar~~  
    ~~OpenAsVAR>ReplacementVar~~  
    ~~OpenAsVarsClose~~
    ~~OpenAS>SAVEAS_PAGE#yourtemplate>~~

The ~~OpenAS>SAVEAS_PAGE#yourtemplate>~~ entry must be outside of the VarsStart and VarsClose block.

:!: Important: SAVEAS_PAGE is a placeholder and must appear in your plugin markup exactly as illustrated above. It will place a textbox on your page which asks for the page id. The user will get a link to SAVEAS_PAGE. When the user clicks on the link, this placeholder will be replaced by the page id from the texbox. See the illustration below.

This format will create a Form with two text boxes. ReplacementVar is the name of a variable which is included in the template. So, for instance, if the ReplacementVar is NAME, then the plugin will replace @NAME@ in the template with the value entered into the textbox. You can create as many textboxes as you need.

Each instance of ~~OpenAsVAR>ReplacementVar~~ can be prefaced by a desciptive label, for instance:

   First Name: ~~OpenAsVAR>FNAME~~  

The Replacement variables are case-sensitive. There is one formatting feature, which will help to arrange the textboxes on your page; this is the Dokuwiki line-break: \\. The textboxes can be interspersed with text; you can use the line-breaks to help format the text.

You can use the ~~OpenAS>SAVEAS_PAGE#yourtemplate>~~ markup on its own. The link will redirect to a new page which has been captured from the page id textbox. It is also possible to include predefined values, as illustrated in the basic syntax form above. It is also possible to combine predefined values with values captured from the Form.

Example

Markup

~~OpenAsVarsStart~~

Name: ~~OpenAsVAR>name~~  

Age: ~~OpenAsVAR>AGE~~  \\ 

Address: ~~OpenAsVAR>ADDR1~~

Address 2: ~~OpenAsVAR>ADDR2~~  

~~OpenAsVarsClose~~

~~OpenAS>wiki:SAVEAS_PAGE#yourtemplate>@HI@,Howdy!!;@BYE@,Good Bye~~

Result

The Name, Age and Addr fields will be added to the HI and BYE fields. The HI and BYE are constants, pre-set, the others are set by the user and will differ from page to page.

Change Log

Discussion

For discussion, please use the dokuwiki forum, the above-listed Bugs button, or the discussion page.

plugin/openas.1530882711.txt.gz · Last modified: 2018-07-06 15:11 by turnermm

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki