Difference between revisions of "MediaWiki/extension/Special/MakePage"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(some updates)
(Replaced content with "{{to wooz|MakePage}}")
Tag: Replaced
Line 1: Line 1:
'''Special:MakePage''' (SMP) is a [[MediaWiki]] SpecialPage for creating new wiki pages based on the contents of a form plus other environmental conditions such as the username of the submitter and when the form was submitted. It can be used for creating a simple blog, for example.
+
{{to wooz|MakePage}}
 
 
* '''source''': [https://gitlab.com/woozalia/Special-MakePage Git repository]
 
* '''requires''': {{l/ferreteria}} libraries: 
 
** [[W3TPL]] may be useful for prototyping various views of the created pages (e.g. a listing of blog posts, with synopses)
 
==How to use it==
 
Basic usage, then, involves creating two things:
 
# an HTML form which includes certain fields that SMP needs, and which submits its contents to SMP
 
#* You can create form within a MediaWiki site by any number of means, including [[w3tpl]], but it doesn't have to be on the same site.
 
#* In theory, you don't even have to have an actual form; you could use code to POST form data from an application.
 
#* Either way, you have to be logged in as a user with the ability to create new pages wherever the form has been told to create them.
 
# a template page that defines how the form data should be formatted in the resulting page
 
 
 
To do:
 
* post modloader.php on GitHub.
 
* add instructions for invoking modloader
 
 
 
To use it in a MediaWiki installation, save the extension in MediaWiki's <code>extensions</code> folder and include this in <code>LocalSettings.php</code>:
 
wfLoadExtension( 'MakePage' );
 
 
 
(I think the necessary libraries are now required automatically, but you do need to install {{l/ferreteria}} and require <code>ferreteria/start.php</code>.)
 
 
 
To get the target URL ("action={{arg|target URL}}") to use when designing a form, you can use the following code:
 
<syntaxhighlight lang=php>$mwoMakePage = Title::newFromText('Special:MakePage');
 
$urlMakePage = $mwoMakePage->getLocalURL();</syntaxhighlight>
 
 
 
==Example Sites==
 
* I use it on Issuepedia for [[issuepedia:Issuepedia:Link Filing|filing links]]:
 
** [[issuepedia:Issuepedia:Forms/v3/news/entry|The entry form]] is built using [[w3tpl]] tags.
 
** MakePage uses [[issuepedia:Issuepedia:Forms/v3/news/template|this template]] to render the form's output as a page.
 
* I use it on the HypertWiki for [[htwiki:User:Woozle/blog|blogging]]:
 
** [[htwiki:HypertWiki:Forms/blog/post|The entry form]] is built using [[w3tpl]] tags.
 
** MakePage uses [[htwiki:project:Forms/handling/blog/post|this template]] to render the form's output as a page.
 
==How it works==
 
SMP receives the input of any form POSTed to it and takes the following actions:
 
# A title is generated according to the value received in !TITLETPLT. Special variables (see below) may be used in this string.
 
# The template specified by !TPLTPAGE (and !TPLTSTART and !TPLTSTOP) is read, and variables are replaced by POSTed values.
 
# MediaWiki is requested to start editing a new page (titled according to #1), and the results of #2 are submitted as the possible contents.
 
#* By default, the new page is not yet saved; the user needs to do this. This is to give the user a chance to review the results before saving.
 
#* In the future, I may add an option to create the page immediately. I may also want to give forms the ability to create pages that cannot be edited directly by their creators, but can only be edited via forms. (This may be necessary, for example, in order to allow users to create and edit pages that access protected functions in w3tpl without themselves being able to modify the code that accesses those functions, which would be a significant security hole.)
 
==Special variables==
 
* '''!TIMEFMT''' is the format MakePage will use for setting the ?TIMESTAMP special variable
 
* '''?TIMESTAMP''' is the date/time at which the form was submitted, formatted as a string according to !TIMEFMT. It is set by MakePage (i.e. don't set it in the form data).
 
** This is useful for time-stamping blog entries.
 
* '''!TITLETPLT''' is the template for generating the title of the page to be created
 
* '''!TPLTPAGE''' is the title of the page from on the creation template may be found
 
* '''!TPLTSTART''' defines where in the template page to start reading the actual template
 
** This is so you can make notes before and after without having the notes included in every page generated. To do: a proper comment syntax that doesn't conflict with HTML comments.
 
* '''!TPLTSTOP''' defines where in the template page to stop reading the actual template (see !TPLTSTART).
 
 
 
Note: I changed "!TIMESTAMP" to "?TIMESTAMP" to indicate the fact that it's set in code rather than coming from form data. So "!" means variables whose value (set by form data) has special significance, while "?" indicates variables that are set by MakePage.
 
 
 
==Inlinks==
 
* [[/archive]]: old version of code
 

Revision as of 21:25, 15 April 2022

Wooz-dev-logo.take 1.crop.1200pxw.png This page has been moved to wooz.dev, User:Woozle's coding site.