StarfieldWiki:Riven

Riven is a Mediawiki extension by RobinHood70 that provides a number of features that complement template development. All the features herein have been disabled or removed ("riven") from MetaTemplate in favor of using the modern MediaWiki methods of doing things, as well as splitting off features that are likely to work from MW 1.35 forwards and those that probably won't or will need a significant change in concept. In the future, this extension will be expanded to include the non-namespace-related features of UespCustomCode as well.

In the documentation below, those parameters that use a name and an equals sign require that you type in the full parameter name and a value. Those that are listed only numerically should not include a name or number and should just be the value. The names are just for clarity of purpose. If in doubt, pretty much everything works the same way you're used to from MetaTemplate.

Conditional Expressions
In MetaTemplate, conditional expressions were available on most or all functions. This has been retained in Riven, but the feature is specific to where it makes sense to have it rather than on absolutely everything. For several functions, having if/ifnot available didn't make much sense. In the unlikely event that they're being used (or you want to use them), they can always be added or you can use a traditional  statement.

For those functions that do allow /, the functionality has been expanded to allow both to be used simultaneously. The function will only run if both conditions are satisfied. Each expression can be as complex as necessary; all that matters is what's left after the entire expression has been evaluated. An easy way to check this is to copy everything after the equals sign to a regular page...what you see is generally what the function will evaluate.

If the same condition needs to be used multiple times, then it is probably most efficient to use #define or #local to evaluate the condition once, then use the #define'd variable in each necessary subroutine.

Debug Features
Features that rewrite your code in some fashion all support a option. Instead of behaving normally, the re-written MediaWiki code will be shown on-screen. This allows for you to debug any issues happening behind the scenes with the function or tag.

Multiple Values
If a function call sees multiples of the same value, only the last one will be evaluated and the rest will be discarded, comparable to wiki templates. In the case of #splitargs, if there's a conflict with template parameter names, the last parameter of a given name will apply to #splitargs, then any inner parameters with that name will be applied to the template.

#arg


The #arg function returns the value of the given URL argument. This allows template-like behavior when linking to a page with different argument values. The idea for this function came from DynamicFunctions, though the code was completely re-written.

Because it's infrequently used, uses of this call are tracked in Category:.

Example
Example page in [ red]. The same page in [ blue].

(Click the links to see the effect.)

Example page in [ red]. The same page in [ blue].

#explodeargs
This is simply a shortcut to the exploding form of #splitargs. Rather than being parameter-based, like the other variants of #splitargs, this version is geared towards "exploding" text—in other words, dividing it into smaller chunks based on a specific character or word. There are currently two ways to use #explodeargs: the original way (now deprecated), where the text and delimiter came first, and the current way, which puts the subtemplate and number of arguments first, just like #splitargs does. To convert, simply move the first two parameters to become the last two or change the call to #splitargs. While the #splitargs version adds a little extra typing, it has the advantage of using the same command everywhere, regardless of what you're splitting on. In either case, the delimiter defaults to a comma, so you can leave that off if that's what you're using.
 * should be converted to either of these

Old versions of #explodeargs are tracked in Category:. They will disappear from that category once converted to either the new #eplodeargs format or #splitargs.

Conversion Examples
Other examples can be seen in the #splitargs entry, below.

Default delimiter
 * converts to either
 * or

Specific delimiter
 * converts to either
 * or

#findfirst


Finds the first page out of a list of pages and returns its full, normalized title. This is expected to be of significant value for templates like Future Link and Lore Link, but may be useful in other cases as well. It's the equivalent of running #ifexistx multiple times, but saves the hassle of writing it all out. The same page will be checked only once, even if it's missing and listed with different namespace shortcuts. For example, if you searched for, #findfirst would only check Online:Nothing once. If that had matched, it would've returned Online:Nothing, despite the fact that "Online" is never used in the file list.

#ifexistx


Just like the #ifexist function, #ifexistx checks to see if a page exists and returns a value based on the result. Unlike that function, however, the requested page will not be added to the Wanted Pages list. While it may seem redundant to have if/ifnot values, the additional checks can be used to specify when not to run the check at all, thus saving on the number of "expensive" parser functions being called.

#include


The #include parser function allows subpage transclusion without creating red links or entries in Wanted Templates if the requested page doesn't exist. For example, if,   would transclude the Place Summary/Skyrim Hold sub-template. But if, nothing would be transcluded and no wanted template would be listed on Wanted Templates. If multiple pages are specified, they will each be transcluded in order, if they exist.

#pickfrom


Pickfrom randomly selects  entries from the subsequent list of arguments and displays those entries in a random order. Any number of arguments can be provided.

Because it's infrequently used, uses of this call are tracked in Category:.

#rand

 * or
 * or

The #rand function returns a random integer value. If no parameters are used, this will be in the range. If only one parameter is used, this will be in the range of. If both are provided, the number will be in the range.

Because it's infrequently used, uses of this call are tracked in Category:.

#splitargs


Splitargs is a parser function that can be used to repeatedly call a sub-template, using a different set of arguments each time the sub-template is called. There are different ways that #splitargs can be called, but in all of them, the first two parameters are the same.

From there, there are three different ways that #splitargs can be used. In the event of a conflict, the template prioritizes old #explodeargs calls, then the following variants, in order:

Exploding

 * or

With this version of #splitargs, the  parameter is what is split on. By default, a comma will be used as the delimiter, but any other character can be used. A tilde (~) is a common alternative, since it has no meaning to the MediaWiki software outside of signatures, which require three to five in a row, and is almost never used for any other purpose.

With Arguments


If additional arguments are provided as part of the #splitargs call, then those arguments are used as the list of arguments which should be passed to the sub-template. The number of arguments which can be passed to #splitargs is unlimited. If no additional arguments are provided, #splitargs then looks to the parent template (see below). If there are no arguments found there, the call to #splitargs will be aborted.

Parent Arguments


If no additional anonymous arguments are provided to #splitargs, then the parent template's anonymous arguments themselves are used as the list of arguments to be passed to the sub-template.

#trimlinks


This function takes the provided text and strips out all links, leaving just the label. This can be done in one of two ways. The normal way uses standard MediaWiki code to remove links. This will work as desired the vast majority of the time and as long as it's working correctly, it's the one you should use. The second way parses the text more thoroughly but is much more server-intensive. It unlinks most internal links, but leaves Category, File, interwiki, and external links untouched. You can use this to transclude entire pages without the internal links and it will look nearly identical or completely identical to the original, just without internal links.

The raison d'être for this function is the place description pages. With this function, we can freely add links to any and all place descriptions—then use #trimlinks on Oblivion:Places or other pages where the links are overwhelming. In fact, the links on Oblivion:Places can be turned off by adding a single  line at the top of the page. The variable is then inherited by the Place Link template, telling it to remove the links.

Examples


This would result in the text "".



This would display the entire Main Page without internal links. You can see what that looks like here. As you can see, only the search box was corrupted. Everything else looks and works as expected, there are just no internal links anymore.

Tag Functions
Note that due to a long-standing bug in MediaWiki, some of the shortcuts that are normally available while editing a page—namely, the pipe trick, signatures, and substitution—are not available inside tag functions and will appear exactly as typed.

cleanspace


Cleanspace is designed to make templates more legible. Within  tags, any whitespace around links, parser functions, templates, and HTML code is removed before the page is rendered. Depending on mode, comments may also be removed, or space around external links. This space removal means that tags and parser functions can each be placed on separate lines. This can be especially useful for MetaTemplate functions like #define, #local, #preview, and the various data-related functions, along with traditional things like category links and HTML tables. The  option (see below) makes this useful not only for setup code, but sometimes even within the body of a template.

cleantable


Any tables found within  tags, including nested tables, are "cleaned" of any empty rows they may have. This means that many infobox templates can be significantly simplified. It is no longer necessary to embed entire sections of the table in #if statements, which in turn means that the need for magic words such as  can be reduced or even eliminated, making infoboxes and other data-driven tables in templates much easier to work with.

For a cell to be considered blank, it must be a normal cell with only whitespace or raw arguments in it. In the case of rowspans, the cell is only evaluated in its "home" position—the one that has the colspan or rowspan attributes; in any other cell or row, the data will be ignored. If a row is removed where some of the cells are part of a rowspan, the rowspan count will be adjusted accordingly. A cell will also be considered blank if content is being added via the CSS  attribute. Unlike MetaTemplate, HTML tags in a cell are not ignored—the debug feature should help track down problem templates and the like.

Note: while HTML allows you to skip parts of a table, such as having a stand-alone &lt;td> element, cleantable does not support this. Any manually entered HTML tables must have all three levels of a table properly emitted (i.e., it must have a &lt;table>, &lt;tr>, and either a &lt;th> or &lt;td>, as appropriate). Without those, results are unpredictable.

How It Works
Cleantable makes an internal map of which cells are where in a table. It then scans through them to see what can be removed based on three rules:
 * 1) Headers don't count. They are completely ignored in determining if a row is blank.
 * 2) Any row in which the non-header elements are all empty, whitespace, or raw  s can be removed.
 * 3) Any row consisting entirely of header cells (typically a section header) will be removed if there were non-header (content) rows below it and all of those rows have been removed. If protectrows is zero, then the top row of that table can also be removed if it's the only row left and it's a header row. In the event that the last row is removed from the table, the table will be removed from the page altogether. Note, however, that any whitespace surrounding the removed table will remain untouched, which could leave large gaps on a page if this hasn't been accounted for.

Conceivably, the option of completely blanking a table could be combined with #if statements to take actions based on whether the table was blanked or not. For example:

Examples
{| class="wikitable vtop" ! Test !! style="width:40%" | Before Cleaning !! style="width:40%" | After Cleaning ! Simple Table

! Deleted Table (protectrows=0)

! Complex Rowspan ! Columns ! Triple-Nested Empty Tables (protectrows=0 debug=1) ! Data {| ! Inner Header
 * {| class="wikitable" style="margin:0"
 * {| class="wikitable" style="margin:0"
 * style="height:1em; background-color:royalblue;" |
 * style="height:1em; background-color:royalblue;" |


 * }
 * }
 * }
 * }
 * }

SKINNAME


This variable contains the name of the current skin. It replaces the  function from DynamicFunctions.

Because it's infrequently used, uses of this call are tracked in Category:.

Example
You are currently using. You are currently using.

Installation Notes
Riven is dependent on the ParserHelper library. At development time, there was no clear, unified way of loading PHP dependencies, so for now, you need to manually add  to your extension list before the equivalent line for this extension. In future, this may become an entry in  or similar.