From Dark and Darker Wiki
(→Transclusion: Added bit about template parameters) |
(Updated basics. Fixed some typos. Expanded on some topics like html sanitization.) |
||
Line 1: | Line 1: | ||
=Basics= | =Basics= | ||
Click on the pencil icon situated on the top right of the page. A dropdown menu will appear containing two options available for a given page. | |||
===Creating a Page=== | |||
To create a new page, navigate the address bar. Replace the last part of the [https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_URL URL] with the name of the new page. | |||
For example, to create a page named "New Page", the URL would be "https://darkanddarker.wiki.spellsandguns.com/New_Page".<br> | |||
This will take you to a temporary page that says "There is currently no text in this page. You can search for this page title in other pages, search the related logs, or create this page." Click on "create this page" to start editing. | |||
Note that there are some limitations to valid page names. Trailing spaces, for example, will automatically be trimmed. See the [https://www.mediawiki.org/wiki/Manual:PAGENAMEE_encoding linked resource] for further information. | |||
===Editing a Page=== | |||
Edit aka, "Visual Edit". | Edit aka, "Visual Edit". | ||
* | *Opens an experimental visual editor. For the most part, the content will look identical to page itself. However, the visual editor is not perfect and may break severely. | ||
*Visual Edit has limited use. It isn't available on Template pages. | |||
Edit Source | |||
*Visual Edit isn't | *Opens a codebox that highlights wikitext syntax. | ||
Source | |||
* | |||
*"Show preview" allows you to edit code and see the effects of your edits before committing the changes with "Save changes". | *"Show preview" allows you to edit code and see the effects of your edits before committing the changes with "Save changes". | ||
*If you enter an empty page, i.e. an existing page without content, try using Source | *If you enter an empty page, i.e. an existing page without content, try using Edit Source.<br>More likely than not, there is code that is hidden within <span style="color:green"><includeonly></span> html tags. | ||
===Uploading an Image=== | |||
Images have a data limit of approximately 1MB. It is impossible to upload media larger than this limit. | |||
[[Special:Upload|Upload]] | |||
*The default method of uploading a file. | |||
*Destination filename will determine what the file is called. | |||
[[Special:BatchUpload|Batch Upload]] | |||
*For when you wish to upload multiple files. | |||
*Uploaded files will convert their filenames to destination names automatically. Ensure that the files are appropriately named beforehand. | |||
*If uploading files with conflicting name, the most recent upload will overwrite the existing files. | |||
*Be aware that users with basic permissions will be rate limited. | |||
While exploring the wiki you may encounter broken links. Some of which are associated with a missing image. They will appear as a greyed-out link following the form: [[File:missing_example.png]] | |||
*Clicking on such a link will lead to the Upload page, with the destination filename filled in. | |||
=MediaWiki= | =MediaWiki= | ||
The Dark and Darker wiki runs on MediaWiki software | The Dark and Darker wiki runs on MediaWiki software. | ||
This gives the wiki access to a few basic features like magic words, basic text markup, and [https://www.mediawiki.org/wiki/Help:HTML_in_wikitext sanitized] HTML markup. | |||
The sections below will touch upon most but not all of the commonly used elements on the Wiki.<br> | |||
For more comprehensive information and guides it is best to follow the included hyperlinks or reference the main [https://www.mediawiki.org/wiki/Help:Contents MediaWiki manual] | |||
==Built-In Features== | ==Built-In Features== | ||
Line 34: | Line 51: | ||
===[https://www.mediawiki.org/wiki/Help:Formatting#HTML_tags HTML Markup]=== | ===[https://www.mediawiki.org/wiki/Help:Formatting#HTML_tags HTML Markup]=== | ||
<span style="color:white; background-color:#1f1f1f;"><span style="color:#5e993e"><!--</span>...<span style="color:#5e993e">--></span></span> | All html written within wikitext is sanitized. There are [https://www.mediawiki.org/wiki/Help:HTML_in_wikitext certain restrictions] placed on what attributes and html elements are usable. | ||
The purpose of this is to protect users from malicious actors. Beyond basic markup, this means javascript scripting is not permitted. Additionally, user-created style sheets are limited to either inline syntax, or to a [https://www.mediawiki.org/wiki/Extension:TemplateStyles controlled page extension]. | |||
<span style="color:white; background-color:#1f1f1f;"> | |||
<span style="color:#5e993e"><!--</span>...<span style="color:#5e993e">--></span></span> | |||
*HTML comments are commonly used to emulate the whitespace structures of more traditional languages like Python, Java, and C. | *HTML comments are commonly used to emulate the whitespace structures of more traditional languages like Python, Java, and C. | ||
<span style="color:white; background-color:#1f1f1f;"><span style="color:#808080"><</span><span style="color:#2d7ad6">span</span><span style="color:#808080">></span>...<span style="color:#808080"><</span>/<span style="color:#2d7ad6">span</span><span style="color:#808080">></span></span> | <span style="color:white; background-color:#1f1f1f;"><span style="color:#808080"><</span><span style="color:#2d7ad6">span</span><span style="color:#808080">></span>...<span style="color:#808080"><</span>/<span style="color:#2d7ad6">span</span><span style="color:#808080">></span></span> | ||
*This tag is used to apply CSS to a specific section of text. Think "inline" CSS. | *This tag is used to apply CSS to a specific section of text. Think "inline" CSS. | ||
<span style="color:white; background-color:#1f1f1f;"><span style="color:#808080"><</span><span style="color:#2d7ad6">div</span><span style="color:#808080">></span>...<span style="color:#808080"><</span>/<span style="color:#2d7ad6">div</span><span style="color:#808080">></span></span> | <span style="color:white; background-color:#1f1f1f;"><span style="color:#808080"><</span><span style="color:#2d7ad6">div</span><span style="color:#808080">></span>...<span style="color:#808080"><</span>/<span style="color:#2d7ad6">div</span><span style="color:#808080">></span></span> | ||
*This tag is used to apply CSS to a "block", text or otherwise. Think "page element" CSS. | *This tag is used to apply CSS to a "block", text or otherwise. Think "page element" CSS. | ||
===[https://www.mediawiki.org/wiki/Transclusion Transclusion]=== | ===[https://www.mediawiki.org/wiki/Transclusion Transclusion]=== | ||
[https://www.mediawiki.org/wiki/Help:Templates <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#2d7ad6">Element</span><span style="color:#fbfbc8">|</span><span style="color:#2d7ad6">Spirit</span><span style="color:#a463d6">}}</span></span>] calls the Element template with "Spirit" as a parameter. | Transclusion is the process of including the content of one page within another page. Keeping content segmented with templates allows for easier editing and organization as one change can be reflected across multiple pages. | ||
Additionally, transclusion allows for the creation of dynamic content, where the content of a page can change based on the parameters passed to the template. | |||
[https://www.mediawiki.org/wiki/Help:Templates <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#2d7ad6">Element</span><span style="color:#fbfbc8">|</span><span style="color:#2d7ad6">Spirit</span><span style="color:#a463d6">}}</span></span>] | |||
calls the Element template with "Spirit" as parameter 1. | |||
*The first parameter is implicitly named "1", the second "2", and so on. | |||
**On the template page itself, <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{{</span><span style="color:#2d7ad6">1</span><span style="color:#a463d6">}}}</span></span> is used to substitute whatever string is recieved for parameter 1. | |||
**If a parameter is explicitly named, template calls must be formatted accordingly: <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#2d7ad6">Element</span><span style="color:#fbfbc8">|<span style="color:#9cdcfe">explicit-name=</span></span><span style="color:#2d7ad6">Spirit</span><span style="color:#a463d6">}}</span></span>. Where the template page uses <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{{</span><span style="color:#2d7ad6">explicit-name</span><span style="color:#a463d6">}}}</span></span> to substitute the value of the named parameter. | |||
*The basic search bar can be used to search for templates by prefixing the template name with the fixed namespace, "Template" (e.g. type "template:Element" into the search bar). | *The basic search bar can be used to search for templates by prefixing the template name with the fixed namespace, "Template" (e.g. type "template:Element" into the search bar). | ||
[https://www.mediawiki.org/wiki/Transclusion#Transclusion_Markup_&_Syntax <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">:</span><span style="color:#2d7ad6">Swords</span><span style="color:#a463d6">}}</span></span>] transcludes the Swords page. | |||
*This is the same page you get when searching for "Swords" in the basic search bar. | [https://www.mediawiki.org/wiki/Transclusion#Transclusion_Markup_&_Syntax <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">:</span><span style="color:#2d7ad6">Swords</span><span style="color:#a463d6">}}</span></span>] | ||
[https://www.mediawiki.org/wiki/Help:Templates#Parameters <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{{</span><span style="color:#2d7ad6">1</span><span style="color:#fbfbc8">|</span><span style="color:#a463d6">}}}</span></span>] inserts the value of the 1st unnamed parameter, or less commonly, the parameter named "1". | transcludes the Swords page. | ||
*The "|" | *This is the same page you get when searching for "Swords" in the basic search bar. The ":" prefix denotes the Main namespace, which "regular pages" are part of by default. | ||
[https://www.mediawiki.org/wiki/Help:Templates#Parameters <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{{</span><span style="color:#2d7ad6">1</span><span style="color:#fbfbc8">|</span><span style="color:#a463d6">}}}</span></span>] | |||
inserts the value of the 1st unnamed parameter, or less commonly, the parameter named "1". Generally three curly braces are used to denote a parameter. | |||
*The "|" specifies a default value in case the referenced parameter was not given one, in this example that default value is "". If a default value would be used but was not specified, "<span style="color:#a463d6">{{{</span><span style="color:#2d7ad6">1</span><span style="color:#a463d6">}}}</span>" will be used instead. | |||
===[https://www.mediawiki.org/wiki/Help:Magic_words Magic Words]=== | ===[https://www.mediawiki.org/wiki/Help:Magic_words Magic Words]=== | ||
[https://www.mediawiki.org/wiki/Help:Magic_words#Page_names <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#2d7ad6">PAGENAME</span><span style="color:#a463d6">}}</span></span>] returns the name of the page. | [https://www.mediawiki.org/wiki/Help:Magic_words#Page_names <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#2d7ad6">PAGENAME</span><span style="color:#a463d6">}}</span></span>] | ||
returns the name of the page. | |||
*Commonly used in Auto-templates to call templates with the name of the page. | *Commonly used in Auto-templates to call templates with the name of the page. | ||
[https://www.mediawiki.org/wiki/Help:Magic_words#Formatting <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">lc:</span> <span style="color:#2d7ad6">"string"</span><span style="color:#a463d6">}}</span></span>] returns "string" in lowercase. | [https://www.mediawiki.org/wiki/Help:Magic_words#Formatting <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">lc:</span> <span style="color:#2d7ad6">"string"</span><span style="color:#a463d6">}}</span></span>] | ||
returns "string" in lowercase. | |||
*Primarily used as data validation to default strings to lowercase. | *Primarily used as data validation to default strings to lowercase. | ||
Line 58: | Line 96: | ||
===[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions ParserFunctions]=== | ===[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions ParserFunctions]=== | ||
[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##switch <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#switch:</span> <span style="color:#2d7ad6">"value"</span> | <span style="color:#9cdcfe">case1</span> = <span style="color:#fbfbe6">result1</span> | <span style="color:#9cdcfe">case2</span> = <span style="color:#fbfbe6">result2</span> | ... | #default = <span style="color:#fbfbe6">resultN</span> <span style="color:#a463d6">}}</span></span>] returns the result corresponding to the first case that matches value, or default if none match. | [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##switch <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#switch:</span> <span style="color:#2d7ad6">"value"</span> | <span style="color:#9cdcfe">case1</span> = <span style="color:#fbfbe6">result1</span> | <span style="color:#9cdcfe">case2</span> = <span style="color:#fbfbe6">result2</span> | ... | #default = <span style="color:#fbfbe6">resultN</span> <span style="color:#a463d6">}}</span></span>] | ||
returns the result corresponding to the first case that matches value, or default if none match. | |||
*The wiki's primary way of storing data. Used to create data templates. | *The wiki's primary way of storing data. Used to create data templates. | ||
[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##if <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#if:</span> <span style="color:#2d7ad6">not "null"</span> | <span style="color:#fbfbe6">value_if_true</span> | <span style="color:#fbfbe6">value_if_false</span> <span style="color:#a463d6">}}</span></span>] returns values depending on whether the if clause has a non empty string or not | |||
[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##if <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#if:</span> <span style="color:#2d7ad6">not "null"</span> | <span style="color:#fbfbe6">value_if_true</span> | <span style="color:#fbfbe6">value_if_false</span> <span style="color:#a463d6">}}</span></span>] | |||
returns values depending on whether the if clause has a non empty string or not. | |||
*Common formats: | *Common formats: | ||
**Inline: | **Inline: | ||
Line 74: | Line 107: | ||
**Block: | **Block: | ||
***<div style="white-space:pre; background-color:#1f1f1f; width:fit-content;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#if:</span> <span style="color:#2d7ad6">condition</span><span style="color:#5e993e"><!--</span><br>	<span style="color:#5e993e">--></span>| <span style="color:#fbfbe6">value_if_true</span><span style="color:#5e993e"><!--</span><br>	<span style="color:#5e993e">--></span>| <span style="color:#fbfbe6">value_if_false</span> <span style="color:#a463d6">}}</span></div> | ***<div style="white-space:pre; background-color:#1f1f1f; width:fit-content;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#if:</span> <span style="color:#2d7ad6">condition</span><span style="color:#5e993e"><!--</span><br>	<span style="color:#5e993e">--></span>| <span style="color:#fbfbe6">value_if_true</span><span style="color:#5e993e"><!--</span><br>	<span style="color:#5e993e">--></span>| <span style="color:#fbfbe6">value_if_false</span> <span style="color:#a463d6">}}</span></div> | ||
***Note that the pipe characters begin the lines rather than end the lines.<br>When the "then clause" or the "else clause" have multiple lines, the code is easier to follow as you can identify where each clause begins at | ***Note that the pipe characters begin the lines rather than end the lines.<br>When the "then clause" or the "else clause" have multiple lines, the code is easier to follow as you can identify where each clause begins at a glance.<br>This, in addition to indentation scope, makes it easy to parse the code visually. | ||
***The block format is used to emulate the whitespace structures of more traditional languages like Python, Java, and C.<br>Unless the condition is very simple, the block format is preferred as it is easier to read and edit. | ***The block format is used to emulate the whitespace structures of more traditional languages like Python, Java, and C.<br>Unless the condition is very simple, the block format is preferred as it is easier to read and edit. | ||
[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##ifeq <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#ifeq:</span> <span style="color:#2d7ad6">value1</span> | <span style="color:#2d7ad6">value2</span> | <span style="color:#fbfbe6">value_if_equal</span> | <span style="color:#fbfbe6">value_if_not_equal</span> <span style="color:#a463d6">}}</span></span>] returns value_if_equal if value1 is equal to value2, and value_if_not_equal otherwise. | |||
[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##ifeq <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#ifeq:</span> <span style="color:#2d7ad6">value1</span> | <span style="color:#2d7ad6">value2</span> | <span style="color:#fbfbe6">value_if_equal</span> | <span style="color:#fbfbe6">value_if_not_equal</span> <span style="color:#a463d6">}}</span></span>] | |||
returns value_if_equal if value1 is equal to value2, and value_if_not_equal otherwise. | |||
===[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions ParserFunctions/Strings]=== | ===[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions ParserFunctions/Strings]=== | ||
[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##pos <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#pos:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">substring</span> <span style="color:#a463d6">}}</span></span>] returns the position of the first occurrence of substring in string, or "null" if substring is not found. | [https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##pos <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#pos:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">substring</span> <span style="color:#a463d6">}}</span></span>] | ||
returns the position of the first occurrence of substring in string, or "null" if substring is not found. | |||
*Used to like an "or" statement.<br>If the substring is found, the return value is not "null". | *Used to like an "or" statement.<br>If the substring is found, the return value is not "null". | ||
[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##replace <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#replace:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">substring</span> | replacement <span style="color:#a463d6">}}</span></span>] returns string with all occurrences of substring replaced by replacement. | |||
[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##replace <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#replace:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">substring</span> | replacement <span style="color:#a463d6">}}</span></span>] | |||
returns string with all occurrences of substring replaced by replacement. | |||
*Typically used to replace commas with other separators. | *Typically used to replace commas with other separators. | ||
[https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##explode <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#explode:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">delimiter</span> | index | limit <span style="color:#a463d6">}}</span></span>] returns the index-th element of the list obtained by splitting string at each occurrence of delimiter. | |||
*"limit" is optional. | [https://www.mediawiki.org/wiki/Extension:ParserFunctions/String_functions##explode <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#explode:</span> <span style="color:#2d7ad6">string</span> | <span style="color:#fbfbe6">delimiter</span> | index | limit <span style="color:#a463d6">}}</span></span>] | ||
returns the index-th element of the list obtained by splitting string at each occurrence of delimiter. | |||
*"limit" is optional. If you only need the first few elements, "limit" is used to save resources. | |||
*If index is negative, the explode redturns in reverse index order. | *If index is negative, the explode redturns in reverse index order. | ||
*Explode is commonly used to split a string along some character(s), making it efficient to retrieve sections of a list-type string. | *Explode is commonly used to split a string along some character(s), making it efficient to retrieve sections of a list-type string. | ||
Line 90: | Line 130: | ||
===[https://www.mediawiki.org/wiki/Extension:Variables Variables]=== | ===[https://www.mediawiki.org/wiki/Extension:Variables Variables]=== | ||
[https://www.mediawiki.org/wiki/Extension:Variables##vardefineecho <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#vardefineecho:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value</span> <span style="color:#a463d6">}}</span></span>] returns value and defines variable_name as value. | [https://www.mediawiki.org/wiki/Extension:Variables##vardefineecho <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#vardefineecho:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value</span> <span style="color:#a463d6">}}</span></span>] | ||
returns value and defines variable_name as value. | |||
*This is useful when handling data that is used more than once.<br>Calls to data templates eat up resources, so it is best practice to store the data in a variable and call the variable instead of the data template.<br>This is true even if the template data is only called twice. | *This is useful when handling data that is used more than once.<br>Calls to data templates eat up resources, so it is best practice to store the data in a variable and call the variable instead of the data template.<br>This is true even if the template data is only called twice. | ||
*Typically used within the "flow" of code, i.e. | *Typically used within the "flow" of code, i.e. within a #if or #switch statement. | ||
[https://www.mediawiki.org/wiki/Extension:Variables##vardefine <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#vardefine:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value</span> <span style="color:#a463d6">}}</span></span>] returns nothing and defines variable_name as value. | |||
[https://www.mediawiki.org/wiki/Extension:Variables##vardefine <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#vardefine:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value</span> <span style="color:#a463d6">}}</span></span>] | |||
returns nothing and defines variable_name as value. | |||
*Slightly less efficient than vardefineecho, but useful when you need to use a var in various scopes. | *Slightly less efficient than vardefineecho, but useful when you need to use a var in various scopes. | ||
[https://www.mediawiki.org/wiki/Extension:Variables##var <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#var:</span> <span style="color:#2d7ad6">variable_name</span> <span style="color:#a463d6">}}</span></span>] returns the value of variable_name. | |||
[https://www.mediawiki.org/wiki/Extension:Variables##var <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#var:</span> <span style="color:#2d7ad6">variable_name</span> <span style="color:#a463d6">}}</span></span>] | |||
returns the value of variable_name. | |||
*Commonly used within a few lines of the vardefineecho. | *Commonly used within a few lines of the vardefineecho. | ||
*Unlike in traditional programming languages the return value is not "typed". | *Unlike in traditional programming languages the return value is not "typed". It is a string. | ||
*A common bug is to write the variable name but forget to include the curly braces and var tag.<br>So instead of referencing a variable's value you simply have a static string.<br>This sometimes goes unnoticed when using <span style="color:#fbfbc8">#var:</span> with <span style="color:#fbfbc8">#if:</span>. | *A common bug is to write the variable name but forget to include the curly braces and var tag.<br>So instead of referencing a variable's value you simply have a static string.<br>This sometimes goes unnoticed when using <span style="color:#fbfbc8">#var:</span> with <span style="color:#fbfbc8">#if:</span>. | ||
===[https://www.mediawiki.org/wiki/Extension:Arrays Arrays]=== | ===[https://www.mediawiki.org/wiki/Extension:Arrays Arrays]=== | ||
[https://www.mediawiki.org/wiki/Extension:Arrays#arraydefine <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arraydefine:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value1</span>, <span style="color:#fbfbe6">value2</span>, ... <span style="color:#a463d6">}}</span></span>] returns nothing and defines variable_name as an array. | [https://www.mediawiki.org/wiki/Extension:Arrays#arraydefine <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arraydefine:</span> <span style="color:#2d7ad6">variable_name</span> | <span style="color:#fbfbe6">value1</span>, <span style="color:#fbfbe6">value2</span>, ... <span style="color:#a463d6">}}</span></span>] | ||
returns nothing and defines variable_name as an array. | |||
*Commonly used to transform a comma separated list into an array. | *Commonly used to transform a comma separated list into an array. | ||
*Occasionally used to transform comma separated lists into slash (or other) separated lists. | *Occasionally used to transform comma separated lists into slash (or other) separated lists. | ||
[https://www.mediawiki.org/wiki/Extension:Arrays#arraysize <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arraysize:</span> <span style="color:#2d7ad6">variable_name</span> <span style="color:#a463d6">}}</span></span>] returns the number of elements in variable_name. | |||
[https://www.mediawiki.org/wiki/Extension:Arrays#arraysize <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arraysize:</span> <span style="color:#2d7ad6">variable_name</span> <span style="color:#a463d6">}}</span></span>] | |||
returns the number of elements in variable_name. | |||
*Commonly used to set how many iterations of a loop to execute. | *Commonly used to set how many iterations of a loop to execute. | ||
[https://www.mediawiki.org/wiki/Extension:Arrays#arrayindex <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arrayindex:</span> <span style="color:#2d7ad6">variable_name</span> | index <span style="color:#a463d6">}}</span></span>] returns the index-th element of variable_name. | |||
[https://www.mediawiki.org/wiki/Extension:Arrays#arrayindex <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#arrayindex:</span> <span style="color:#2d7ad6">variable_name</span> | index <span style="color:#a463d6">}}</span></span>] | |||
returns the index-th element of variable_name. | |||
*Almost always used with #loop to do work on individual elements in an list/array. | *Almost always used with #loop to do work on individual elements in an list/array. | ||
===[https://www.mediawiki.org/wiki/Extension:Loops Loops]=== | ===[https://www.mediawiki.org/wiki/Extension:Loops Loops]=== | ||
[https://www.mediawiki.org/wiki/Extension:Loops##loop <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#loop:</span> start | end | step | code <span style="color:#a463d6">}}</span></span>] returns the result of code executed for each value in the range start to end, incrementing by step. | [https://www.mediawiki.org/wiki/Extension:Loops##loop <span style="color:white; background-color:#1f1f1f;"><span style="color:#a463d6">{{</span><span style="color:#fbfbc8">#loop:</span> start | end | step | code <span style="color:#a463d6">}}</span></span>] | ||
returns the result of code executed for each value in the range start to end, incrementing by step. | |||
===[https://www.mediawiki.org/wiki/Extension:TabberNeue#Simple_tabbers Tabber]=== | ===[https://www.mediawiki.org/wiki/Extension:TabberNeue#Simple_tabbers Tabber]=== |
Revision as of 20:42, 5 March 2025
Basics
Click on the pencil icon situated on the top right of the page. A dropdown menu will appear containing two options available for a given page.
Creating a Page
To create a new page, navigate the address bar. Replace the last part of the URL with the name of the new page.
For example, to create a page named "New Page", the URL would be "https://darkanddarker.wiki.spellsandguns.com/New_Page".
This will take you to a temporary page that says "There is currently no text in this page. You can search for this page title in other pages, search the related logs, or create this page." Click on "create this page" to start editing.
Note that there are some limitations to valid page names. Trailing spaces, for example, will automatically be trimmed. See the linked resource for further information.
Editing a Page
Edit aka, "Visual Edit".
- Opens an experimental visual editor. For the most part, the content will look identical to page itself. However, the visual editor is not perfect and may break severely.
- Visual Edit has limited use. It isn't available on Template pages.
Edit Source
- Opens a codebox that highlights wikitext syntax.
- "Show preview" allows you to edit code and see the effects of your edits before committing the changes with "Save changes".
- If you enter an empty page, i.e. an existing page without content, try using Edit Source.
More likely than not, there is code that is hidden within <includeonly> html tags.
Uploading an Image
Images have a data limit of approximately 1MB. It is impossible to upload media larger than this limit.
- The default method of uploading a file.
- Destination filename will determine what the file is called.
- For when you wish to upload multiple files.
- Uploaded files will convert their filenames to destination names automatically. Ensure that the files are appropriately named beforehand.
- If uploading files with conflicting name, the most recent upload will overwrite the existing files.
- Be aware that users with basic permissions will be rate limited.
While exploring the wiki you may encounter broken links. Some of which are associated with a missing image. They will appear as a greyed-out link following the form: File:Missing example.png
- Clicking on such a link will lead to the Upload page, with the destination filename filled in.
MediaWiki
The Dark and Darker wiki runs on MediaWiki software.
This gives the wiki access to a few basic features like magic words, basic text markup, and sanitized HTML markup.
The sections below will touch upon most but not all of the commonly used elements on the Wiki.
For more comprehensive information and guides it is best to follow the included hyperlinks or reference the main MediaWiki manual
Built-In Features
Text Markup
Great for basic text formatting.
Generally not used in Template code, where text formatting requires more complex functionality like CSS and Parser Funtions.
HTML Markup
All html written within wikitext is sanitized. There are certain restrictions placed on what attributes and html elements are usable.
The purpose of this is to protect users from malicious actors. Beyond basic markup, this means javascript scripting is not permitted. Additionally, user-created style sheets are limited to either inline syntax, or to a controlled page extension.
<!--...-->
- HTML comments are commonly used to emulate the whitespace structures of more traditional languages like Python, Java, and C.
<span>...</span>
- This tag is used to apply CSS to a specific section of text. Think "inline" CSS.
<div>...</div>
- This tag is used to apply CSS to a "block", text or otherwise. Think "page element" CSS.
Transclusion
Transclusion is the process of including the content of one page within another page. Keeping content segmented with templates allows for easier editing and organization as one change can be reflected across multiple pages.
Additionally, transclusion allows for the creation of dynamic content, where the content of a page can change based on the parameters passed to the template.
{{Element|Spirit}} calls the Element template with "Spirit" as parameter 1.
- The first parameter is implicitly named "1", the second "2", and so on.
- On the template page itself, {{{1}}} is used to substitute whatever string is recieved for parameter 1.
- If a parameter is explicitly named, template calls must be formatted accordingly: {{Element|explicit-name=Spirit}}. Where the template page uses {{{explicit-name}}} to substitute the value of the named parameter.
- The basic search bar can be used to search for templates by prefixing the template name with the fixed namespace, "Template" (e.g. type "template:Element" into the search bar).
{{:Swords}} transcludes the Swords page.
- This is the same page you get when searching for "Swords" in the basic search bar. The ":" prefix denotes the Main namespace, which "regular pages" are part of by default.
{{{1|}}} inserts the value of the 1st unnamed parameter, or less commonly, the parameter named "1". Generally three curly braces are used to denote a parameter.
- The "|" specifies a default value in case the referenced parameter was not given one, in this example that default value is "". If a default value would be used but was not specified, "{{{1}}}" will be used instead.
Magic Words
{{PAGENAME}} returns the name of the page.
- Commonly used in Auto-templates to call templates with the name of the page.
{{lc: "string"}} returns "string" in lowercase.
- Primarily used as data validation to default strings to lowercase.
Extensions
ParserFunctions
{{#switch: "value" | case1 = result1 | case2 = result2 | ... | #default = resultN }} returns the result corresponding to the first case that matches value, or default if none match.
- The wiki's primary way of storing data. Used to create data templates.
{{#if: not "null" | value_if_true | value_if_false }} returns values depending on whether the if clause has a non empty string or not.
- Common formats:
- Inline:
- {{#if: condition | value_if_true | value_if_false }}
- Block:
- {{#if: condition<!--
-->| value_if_true<!--
-->| value_if_false }} - Note that the pipe characters begin the lines rather than end the lines.
When the "then clause" or the "else clause" have multiple lines, the code is easier to follow as you can identify where each clause begins at a glance.
This, in addition to indentation scope, makes it easy to parse the code visually. - The block format is used to emulate the whitespace structures of more traditional languages like Python, Java, and C.
Unless the condition is very simple, the block format is preferred as it is easier to read and edit.
- Inline:
{{#ifeq: value1 | value2 | value_if_equal | value_if_not_equal }} returns value_if_equal if value1 is equal to value2, and value_if_not_equal otherwise.
ParserFunctions/Strings
{{#pos: string | substring }} returns the position of the first occurrence of substring in string, or "null" if substring is not found.
- Used to like an "or" statement.
If the substring is found, the return value is not "null".
{{#replace: string | substring | replacement }} returns string with all occurrences of substring replaced by replacement.
- Typically used to replace commas with other separators.
{{#explode: string | delimiter | index | limit }} returns the index-th element of the list obtained by splitting string at each occurrence of delimiter.
- "limit" is optional. If you only need the first few elements, "limit" is used to save resources.
- If index is negative, the explode redturns in reverse index order.
- Explode is commonly used to split a string along some character(s), making it efficient to retrieve sections of a list-type string.
- Can be used to strip portions of a string.
Variables
{{#vardefineecho: variable_name | value }} returns value and defines variable_name as value.
- This is useful when handling data that is used more than once.
Calls to data templates eat up resources, so it is best practice to store the data in a variable and call the variable instead of the data template.
This is true even if the template data is only called twice. - Typically used within the "flow" of code, i.e. within a #if or #switch statement.
{{#vardefine: variable_name | value }} returns nothing and defines variable_name as value.
- Slightly less efficient than vardefineecho, but useful when you need to use a var in various scopes.
{{#var: variable_name }} returns the value of variable_name.
- Commonly used within a few lines of the vardefineecho.
- Unlike in traditional programming languages the return value is not "typed". It is a string.
- A common bug is to write the variable name but forget to include the curly braces and var tag.
So instead of referencing a variable's value you simply have a static string.
This sometimes goes unnoticed when using #var: with #if:.
Arrays
{{#arraydefine: variable_name | value1, value2, ... }} returns nothing and defines variable_name as an array.
- Commonly used to transform a comma separated list into an array.
- Occasionally used to transform comma separated lists into slash (or other) separated lists.
{{#arraysize: variable_name }} returns the number of elements in variable_name.
- Commonly used to set how many iterations of a loop to execute.
{{#arrayindex: variable_name | index }} returns the index-th element of variable_name.
- Almost always used with #loop to do work on individual elements in an list/array.
Loops
{{#loop: start | end | step | code }} returns the result of code executed for each value in the range start to end, incrementing by step.
Tabber
This extension allows content to be created under tabs.
The entire Wiki Editing page is organized using this extension.