Difference between revisions of "User:Tjoneslo/sandbox"

From Traveller Wiki - Science-Fiction Adventure in the Far future
Jump to navigation Jump to search
(Replaced content with "{{#dpl: |titlematch=%Subsector |category=T5 Second Survey |updaterules= replace /(T5 Second Survey)/; by \1 subsectors; before fred; summary Move second...")
Line 1: Line 1:
<p style=background-color:#ffdddd>Use this page with care. It will perform updates on the wiki text of many articles simultaneously.</p>
 
 
<p style=background-color:#ffaaaa>DO NOT USE this page here in this wiki. Try in your own wiki!</p>
 
 
{{#form: name=pageupdate | action={{SCRIPTPATH}}/index.php |
 
{{#input: name=title | type=hidden | value=Special:Call/Bulk_Update }}
 
<table class=wikitable>
 
<tr><th>update all articles matching these criteria</th>
 
<th>Apply the following changes</th></tr>
 
<tr><td><table class=wikitable>
 
<tr><th align=right>namespace</th>                  <td>{{#input: name=namespace  | value={{{namespace|}}}}}</td></tr>
 
<tr><th align=right>title contains (%)</th>          <td>{{#input: name=titlematch  | value={{{titlematch|}}}  }}</td></tr>
 
<tr><th align=right>wikitext contains /regexp/</th>  <td>{{#input: name=wikipattern | value={{{wikipattern|}}} }}</td></tr>
 
<tr><th align=right>category</th>                    <td>{{#input: name=category    | value={{{category|}}}    }}</td></tr>
 
<tr><th align=right>use of template</th>            <td>{{#input: name=uses        | value={{{uses|}}}        }}</td></tr>
 
</table></td>
 
<td><table class=wikitable>
 
<tr><th align=right>replace this /regexp/</th>      <td>{{#input: name=replace    | value={{{replace|}}}    }}</td></tr>
 
<tr><th align=right>by</th>                          <td>{{#input: name=by          | value={{{by|}}}          }}</td></tr>
 
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
 
<tr><th align=right>before this text</th>            <td>{{#input: name=before      | value={{{before|}}}      }}</td></tr>
 
<tr><th align=right>insert</th>                      <td>{{#input: name=insbefore  | value={{{insbefore|}}}  }}</td></tr>
 
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
 
<tr><th align=right>after this text</th>            <td>{{#input: name=after      | value={{{after|}}}      }}</td></tr>
 
<tr><th align=right>insert</th>                      <td>{{#input: name=insafter    | value={{{insafter|}}}    }}</td></tr>
 
</table></td></tr></table>
 
=== Type ''exec'' into the ''mode'' field to perform the update or leave empty to preview changes: ===
 
<table class=wikitable>
 
<tr><th align=right>mode</th>                        <td>{{#input: name=mode        | value=                  }}</td></tr>
 
<tr><th align=right>edit summary</th>                <td>{{#input: name=summary    | value={{{summary|}}} }}</td>
 
<td>{{#input: type=submit| name=submit }} &nbsp; &nbsp;<small>[[:Template:Bulk Update|reset form]]</small></td></tr>
 
</table>
 
}}
 
<javascript src="setFocus1.js" />
 
 
{{#vardefine:skip|{{#if:{{{titlematch|}}}{{{category|}}}||dummy}}}}
 
{{#if:{{{titlematch|}}}{{{category|}}}|
 
----
 
{{#ifeq:{{{mode|}}}|exec|
 
==Execution==
 
|
 
==Check the preview carefully, then select execution mode ..==
 
}}
 
 
{{#dpl:
 
{{#dpl:
   |namespace={{#var:skip}}{{#if:{{{namespace|}}}|{{{namespace}}}|}}
+
   |titlematch=%Subsector
  |{{#if:{{{titlematch|}}}|titlematch={{{titlematch}}}|}}
+
   |category=T5 Second Survey
   |{{#if:{{{category|}}}|category={{{category}}}|}}
 
  |{{#if:{{{uses|}}}|uses=Template:{{{uses}}}|}}
 
  |{{#if:{{{replace|}}}{{{by|}}}{{{before|}}}{{{insbefore|}}}{{{after|}}}{{{insafter|}}}|include=*}}
 
  |{{#if:{{{wikipattern|}}}|includematch={{{wikipattern|}}}|}}
 
 
   |updaterules=
 
   |updaterules=
{{#if:{{{replace|}}}    |replace  {{{replace}}};|}}
+
  replace /(T5 Second Survey)/;
{{#if:{{{by|}}}          |by        {{{by}}};|}}
+
  by \1 subsectors;
{{#if:{{{before|}}}      |before   {{{before}}};|}}
+
   before fred;
{{#if:{{{insbefore|}}}  |insert   {{{insbefore}}};|}}
+
   summary Move second survey subsector to different category;
{{#if:{{{after|}}}      |after    {{{after}}};|}}
+
   exec preview;
{{#if:{{{insafter|}}}    |insert   {{{insafter}}};|}}
 
{{#if:{{{summary|}}}    |summary  {{{summary}}};|}}
 
{{#ifeq:{{{mode|}}}|exec |exec;}}
 
}}
 
|
 
* The pattern for title matching is used in a SQL-LIKE expression; so ''%Foo%'' will match all articles with a name containing ''Foo''. The pattern may or may not be case sensitive - depending on the database settings in your wiki. So ''%foo%'' might in some cases match an article named ''The Foos'' and in other cases not.
 
* The pattern used to '''match wiki content''' follows php regexp syntax. It refers to the ''raw wiki text - including template parameters''. Note that you MUST use delimiters like '''/''' around the pattern. Be careful when using symbols like the pipe character - they must be 'escaped' by backslashes.
 
----
 
* If you leave all parameters on the right hand side empty you will get a list of all wiki articles that match your selection criteria.
 
* As soon as you enter something into the right hand side form fields you will see the (modified) raw wiki text of all articles on which your replacement rules will work. Note that NO CHANGE is done to those wiki articles, however, until you enter ''exec'' in the third parameter section (see below).
 
* If you want to see the raw unchanged wiki text before you decide what to do, enter something into the "after" or "before" field (it does not matter if that piece of text really exists in the wiki text of your articles). If you enter a pattern into the "replace" form field and leave the "by" field empty, the matching part of the raw wiki text will be replaced by nothing (empty string).
 
----
 
* The '''replace''' parameter expects a regular expression; here you you can also add modifiers if you want. Use grouping for back references. Example: "/(ab?c+)def/i" would match "xyaCcccdeFx". If you replace the matching part of the wiki text by '''zz\1ghi''' you will get '''xyzzaCcccghix'''.
 
* If you see an error message complaining about '''empty Delimiters''' you probably forgot to put slashes around the regular expressions.
 
* The positions where text is inserted ('''before''' and '''after''') are also regular expressions. But in this case slashes are put around automatically by the source code of this template - so you ''must not'' use delimiters here. Modify the source code of this page if you want to change this.
 
* Because mediaWiki internally strips white space around template arguments special care is needed when leading or trailing spaces are significant for your position pattern. Leading or trailing spaces must be written as '''\s''' when specifying positions, line feeds must be written as '''\n'''.
 
* The content to insert is normal text. Notet that you must use the special symbols " « ¦ » " instead of " &lt; {{!}} &gt; ". Leading and trailing spaces are stripped. As a work around you can make two successive replacements where you first insert an arbitrary unique pattern plus the spaces and then remove that special marker pattern in a second round of updates.
 
----
 
* You must enter the literal ''exec'' into the mode field to really perform the update. Otherwise you will get a list of pages with the modified wiki text. Depending on the number and size of the articles you have selected this list can become quite large.
 
* The execution may take some time. The updates will be made under your user and the '''summary''' text will contain the update rules. You can add additional text which will be prepended to the summary. After the update you will be forwarded to the last page which was changed. If you run into CPU limitations this will help you to find out how many pages were updated. To catch the remaining pages you will have to adapt the selction criteria, e.g. by the use of a name pattern for page titles.
 
----
 
* clicking on ''reset form'' clears all fields and '''takes you back to this eplanation'''.
 
 
}}
 
}}
 +
 +
  |include=*

Revision as of 01:03, 9 April 2016

 |include=*