User:Chao: Difference between revisions

17,076 editsJoined 5 November 2017
mNo edit summary
m (fixing some wrong commands lmao)
 
(127 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#if:{{{3|}}}
  |{{#vardefine:cat3 | [[Category:{{{3}}}]] }}
  |{{#vardefine:cat3 | }}
}}{{#ifeq: 0 | {{#var:{{{2}}} {{{3|}}}}}
|<!-- do nothing if no images -->
|{{#switch:{{{4}}}
    |h2=<h2>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h2>
    |h3=<h3>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h3>
  }}
  {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{{2}}}]]
    {{#var:cat3}}
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
  }}
}}</includeonly><noinclude>


{{TOC}}
==Notes==
<!--
{| class="wikitable mw-collapsible mw-collapsed"
-------------------------------
! Adding BBDW Audio Files to the Quotes Page
VARIABLES for TAGS/CATEGORIES
|-
-------------------------------
|
-->{{#vardefine:  MAIN_CAT|Main Artwork
* Add audio files that were uploaded in bulk to the character's BBDW quotes page.
}}{{#vardefine: BATTLE_CAT|Battle
* The idea is to grab the filenames from the contribution list (or file upload list) so we have the real filenames used on the wiki, and then to format them accordingly.
}}{{#vardefine: PALREF_CAT|Palette Reference
* This works better (is more efficient) the more files we have to apply this to at once. Can even be files for multiple characters.
}}{{#vardefine: LOBAVI_CAT|Lobby Avatar
* These instructions assume the use of Sublime Text 3, or another advanced text editor that supports multiple selections and searches with regular expressions.
}}{{#vardefine:  CREST_CAT|Crest
|-
}}{{#vardefine:  STORY_CAT|Story
| style="text-align:left;" | Steps:
}}{{#vardefine:    CP_CAT|Chrono Phantasma
* Select and copy into a new document the contribs page text for the user who uploaded the files.
}}<!--
It'll look something like this:
-------------------------------
<pre><nowiki>
VARIABLES FOR IMAGE COUNTS
    03:22, 4 June 2022 diff hist +359‎ N File:BBDW Avenge 026b.ogg ‎ Uploaded a work by Arc System Works from BlazBlue Alternative: Dark War with UploadWizard current Tag: Upload Wizard
-------------------------------
     03:22, 4 June 2022 diff hist +359‎ N File:BBDW Avenge 026a.ogg ‎ Uploaded a work by Arc System Works from BlazBlue Alternative: Dark War with UploadWizard current Tag: Upload Wizard
-->{{#vardefine:{{#var:MAIN_CAT}}
</nowiki></pre>
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:MAIN_CAT}}]]|format=count}}
}}{{#vardefine:{{#var:BATTLE_CAT}}
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:BATTLE_CAT}}]]|format=count}}
}}{{#vardefine:{{#var:PALREF_CAT}}
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:PALREF_CAT}}]]|format=count}}
}}{{#vardefine:{{#var:LOBAVI_CAT}}
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:LOBAVI_CAT}}]]|format=count}}
}}{{#vardefine:Sprites
  |{{#expr:
    {{#var:{{#var:BATTLE_CAT}}}} +
     {{#var:{{#var:PALREF_CAT}}}} +  
    {{#var:{{#var:LOBAVI_CAT}}}}
  }}
}}{{#vardefine:{{#var:CREST_CAT}}
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:CREST_CAT}}]]|format=count}}
}}{{#vardefine:{{#var:CP_CAT}} {{#var:STORY_CAT}}
  |{{#ask:[[Category:Kagura Mutsuki]][[Category:{{#var:CP_CAT}}]][[Category:{{#var:STORY_CAT}}]]|format=count}}
}}<!--
-------------------------------
GALLERY LAYOUT
-------------------------------
--><!-- MAIN ARTWORK -->
{{ User:Chao | Kagura Mutsuki | {{#var:MAIN_CAT}} | | h2 }}


<!-- SPRITES -->
* In the text editor, pull up the search bar (Ctrl+F) and search for: (make sure using regular expressions (regex) is selected)
{{#ifeq: 0 | {{#var:Sprites}}
<pre>File:[A-Za-z0-9 ]*\.ogg</pre>
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2>  
    {{ User:Chao | Kagura Mutsuki | {{#var:BATTLE_CAT}} | | h3 }}
    {{ User:Chao | Kagura Mutsuki | {{#var:PALREF_CAT}} | | h3 | Palette References }}
    {{ User:Chao | Kagura Mutsuki | {{#var:LOBAVI_CAT}} | | h3 | Lobby Avatars }}
}}


<!-- CHARACTER CREST -->
* Click the "Find All" button on the far right (or <code>Alt</code> + <code>Enter</code>) to select all occurrences in current document
{{ User:Chao | Kagura Mutsuki | {{#var:CREST_CAT}} | | h2 | Character Crest }}
* Cut (Ctrl + X) or copy (Ctrl + C) all selections.
* Open a new document (or Ctrl + N) and paste (Ctrl + V) the selections.


{{ User:Chao | Kagura Mutsuki | {{#var:CP_CAT}} | {{#var:STORY_CAT}} | h3 }}
This extracts all "File:<filename>.ogg" from the copied text. It should look like this:
<pre><nowiki>
File:BBDW Avenge 026b.ogg
File:BBDW Avenge 026a.ogg
</nowiki></pre>


== Technical Notes ==
* Go to Edit > Sort Lines to sort them alphabetically:
<pre><nowiki>
File:BBDW Avenge 026a.ogg
File:BBDW Avenge 026b.ogg
</nowiki></pre>


=== Template: Gallery ===
* Add the header and footer text around the text
<pre><nowiki>
==Other==
{{Quotes Header}}
File:BBDW Avenge 026a.ogg
File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
</nowiki></pre>


Creates a gallery from template for the specified character. It will skip sections and subsections that the character does not have images for.
* Search for all the part b files (026b etc) with this regex:
<pre>b\.ogg$</pre>


==== Template Usage ====
* ALT+ENTER to select all occurrences of matched text.
<syntaxhighlight>
* Press <code>HOME</code> on the keyboard to move each cursor to the beginning of each selected line.
  {{ Gallery | {{PAGENAME}} }}  <-- with the idea that {{PAGENAME}} will evaluate to ie. Kagura Mutsuki
* <code>BACKSPACE</code> to put each "b" quote on the previous line (with the "a" line)
OR {{ Gallery | Kagura Mutsuki }} <-- this will also work
* Add a comma and a space to get the following:
</syntaxhighlight>
<pre><nowiki>
==Other==
{{Quotes Header}}
File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
</nowiki></pre>


==== Template Code ====
* Select all lines beginning with "File:" (search for)
<syntaxhighlight>
<pre>^File:</pre>


<!-- MAIN ARTWORK -->
* <code>HOME</code> to move each cursor to the beginning of each selected line.
{{ Gallery Section | {{{1}}} | Main Artwork | | h2 | Main Artwork }}
* Copy the following wikitext template, then navigate back to the text editor (do NOT click inside the text editor but click the icon on the menu bar or ALT+TAB back to it, else you will lose your selection)
 
* Paste
<!-- SPRITES -->
<pre><nowiki>
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
{{Quotes
   | <!-- all three subcategories are empty, don't make a section header-->
  |rowspan=2
   | <h2> Sprites </h2>
   |situation=
    {{ Gallery Section | {{{1}}} | Battle | | h2 | Battle }}
   |text=
    {{ Gallery Section | {{{1}}} | Palette Reference | | h3 | Palette Reference }}
  |lang=en
    {{ Gallery Section | {{{1}}} | Portraits | | h2 | Portraits }}
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=
  |lang=ja
}}
}}
</nowiki></pre>


...
Next is the cool part about Sublime Text...


<!-- and so on with other categories and sub-categories -->
We should now have the following text, with the cursor before every <code>File:</code> after the wikitext template we just pasted.
* <code>SHIFT</code>+<code>END</code> to select from every cursor to the end of its line.
<pre><nowiki>
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=
  |lang=ja
}}File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
</nowiki></pre>
* Cut, then navigate WITH the arrow keys on the keyboard (not the mouse), and it will move every cursor accordingly.
* Move to the <code>|audio=</code> part of the template above it, and paste.
<pre><nowiki>
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
  |lang=ja
}}
{{Quotes Footer}}
</nowiki></pre>


</syntaxhighlight>
* <code>END</code> to navigate to the end of each audio line.
 
* <code>CTRL</code> + Left arrow key twice to move the cursor before the ".ogg" file extension
=== Template: Gallery Section ===
* <code>CTRL</code> + <code>SHIFT</code> + arrow keys to select <code>026</code> (without the a/b letter suffix)
* Copy (CTRL+C)
* Navigate with arrow keys up to the <code>|situation=</code> part and paste, then up to the first <code>|situation=</code> and paste again
<pre><nowiki>
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=026
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=026
  |text=
  |audio=File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
  |lang=ja
}}
{{Quotes Footer}}
</nowiki></pre>


Creates a section header with the specified depth (h2, h3, h4, h5), and a gallery of all images that contain the two specified tags. If there are no images in the specified gallery, this code will not do anything. (That is, it is safe to call even when "Kagura Mutsuki" does not have images in "XBlaze" -- an extraneous "XBlaze" header will not appear on Kagura's gallery page.)
* Finally, remove File: prefix - search for the following
<code>File:</code>
* ALT+ENTER to select all
* BACKSPACE to delete all selections


==== Template Usage ====
And now we're done and can copy/paste the text into the bottom of the [[:Category:Quotes_Subpage|character's quotes page]].
<syntaxhighlight>
<pre><nowiki>
{{ Gallery Section
==Other==
  | Kagura Mutsuki  <-- {{{1}}} Character name (Image category 1)
{{Quotes Header}}
   | Main Artwork    <-- {{{2}}} Image Category 2
{{Quotes
   |                 <-- {{{3}}} Optional Image Category 3
   |rowspan=2
   | h2              <-- {{{4}}} Header depth (h2, h3, h4, h5)
   |situation=026
   | Main Artwork    <-- {{{5}}} Section header.
   |text=
   |lang=en
}}
}}
 
{{Quotes
ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | | h2 | Main Artwork }}
   |rowspan=0
</syntaxhighlight>
   |situation=026
 
  |text=
==== Template Code ====
   |audio=BBDW Avenge 026a.ogg, BBDW Avenge 026b.ogg
<syntaxhighlight>
  |lang=ja
{{#vardefine: {{{2}}} {{{3}}} |
   {{#ask:
    [[Category: {{{1}}} ]]
    [[Category: {{{2}}} ]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
    | format=count
  }}
}}{{#ifeq: 0 | {{#var: {{{2}}} {{{3}}} }} | <!-- do nothing if no images --> |
   {{#switch:{{{4}}}
    |h2=<h2>{{{5}}}</h2>
    |h3=<h3>{{{5}}}</h3>
  }}
   {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{{2}}}]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
    |overlay=yes
  }}
}}
}}
</syntaxhighlight>
{{Quotes Footer}}
 
</nowiki></pre>
<hr>
|}
<hr>
<hr>
 
== Useful References ==
 
===Modules===
* [https://www.mediawiki.org/wiki/Lua_scripting Overview of WikiMedia Lua]
* [https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual Getting Started with MediaWiki Lua]
* [https://en.wikipedia.org/wiki/Wikipedia:Lua Basic Guide to Wikipedia Lua]
* [https://www.mediawiki.org/wiki/Manual:Coding_conventions/Lua How to Write Readable Code]
* [https://en.wikipedia.org/wiki/Help:Lua_debugging Debugging Lua]
 
===Semantic MediaWiki===
* [https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.ask.md Documentation for the Lua Module"s implementation of #ask, <b>mw.smw.ask</b>]
* [https://www.semantic-mediawiki.org/wiki/Help:Selecting_pages How to use SMW (#ask) to sort and query unions of categories]
* [https://www.semantic-mediawiki.org/wiki/Help:Search_value_substitution How to use arbitrary variables in an SMW (#ask) query] ie <nowiki>{{FULLPAGENAME}}</nowiki>
 
===DPL===
* https://en.wikinews.org/wiki/Wikinews:DynamicPageList
* https://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia)
* http://followthescore.org/dpldemo/index.php?title=DPL:FAQ
 
<b><u>Other things to look into later:</u></b>
* CategoryTree extension
* https://meta.wikimedia.org/wiki/Help:Category
* categories of categories
 
Note: I believe it"s good wikimedia practice to use only ==H2== and beyond (in essence, to avoid using =H1=)
</noinclude>

Latest revision as of 17:55, 4 June 2022

Notes

Adding BBDW Audio Files to the Quotes Page
  • Add audio files that were uploaded in bulk to the character's BBDW quotes page.
  • The idea is to grab the filenames from the contribution list (or file upload list) so we have the real filenames used on the wiki, and then to format them accordingly.
  • This works better (is more efficient) the more files we have to apply this to at once. Can even be files for multiple characters.
  • These instructions assume the use of Sublime Text 3, or another advanced text editor that supports multiple selections and searches with regular expressions.
Steps:
  • Select and copy into a new document the contribs page text for the user who uploaded the files.

It'll look something like this:

    03:22, 4 June 2022 diff hist +359‎ N File:BBDW Avenge 026b.ogg ‎ Uploaded a work by Arc System Works from BlazBlue Alternative: Dark War with UploadWizard current Tag: Upload Wizard
    03:22, 4 June 2022 diff hist +359‎ N File:BBDW Avenge 026a.ogg ‎ Uploaded a work by Arc System Works from BlazBlue Alternative: Dark War with UploadWizard current Tag: Upload Wizard
  • In the text editor, pull up the search bar (Ctrl+F) and search for: (make sure using regular expressions (regex) is selected)
File:[A-Za-z0-9 ]*\.ogg
  • Click the "Find All" button on the far right (or Alt + Enter) to select all occurrences in current document
  • Cut (Ctrl + X) or copy (Ctrl + C) all selections.
  • Open a new document (or Ctrl + N) and paste (Ctrl + V) the selections.

This extracts all "File:<filename>.ogg" from the copied text. It should look like this:

File:BBDW Avenge 026b.ogg
File:BBDW Avenge 026a.ogg
  • Go to Edit > Sort Lines to sort them alphabetically:
File:BBDW Avenge 026a.ogg
File:BBDW Avenge 026b.ogg
  • Add the header and footer text around the text
==Other==
{{Quotes Header}}
File:BBDW Avenge 026a.ogg
File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
  • Search for all the part b files (026b etc) with this regex:
b\.ogg$
  • ALT+ENTER to select all occurrences of matched text.
  • Press HOME on the keyboard to move each cursor to the beginning of each selected line.
  • BACKSPACE to put each "b" quote on the previous line (with the "a" line)
  • Add a comma and a space to get the following:
==Other==
{{Quotes Header}}
File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
  • Select all lines beginning with "File:" (search for)
^File:
  • HOME to move each cursor to the beginning of each selected line.
  • Copy the following wikitext template, then navigate back to the text editor (do NOT click inside the text editor but click the icon on the menu bar or ALT+TAB back to it, else you will lose your selection)
  • Paste
{{Quotes
  |rowspan=2
  |situation=
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=
  |lang=ja
}}

Next is the cool part about Sublime Text...

We should now have the following text, with the cursor before every File: after the wikitext template we just pasted.

  • SHIFT+END to select from every cursor to the end of its line.
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=
  |lang=ja
}}File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
{{Quotes Footer}}
  • Cut, then navigate WITH the arrow keys on the keyboard (not the mouse), and it will move every cursor accordingly.
  • Move to the |audio= part of the template above it, and paste.
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=
  |text=
  |audio=File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
  |lang=ja
}}
{{Quotes Footer}}
  • END to navigate to the end of each audio line.
  • CTRL + Left arrow key twice to move the cursor before the ".ogg" file extension
  • CTRL + SHIFT + arrow keys to select 026 (without the a/b letter suffix)
  • Copy (CTRL+C)
  • Navigate with arrow keys up to the |situation= part and paste, then up to the first |situation= and paste again
==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=026
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=026
  |text=
  |audio=File:BBDW Avenge 026a.ogg, File:BBDW Avenge 026b.ogg
  |lang=ja
}}
{{Quotes Footer}}
  • Finally, remove File: prefix - search for the following

File:

  • ALT+ENTER to select all
  • BACKSPACE to delete all selections

And now we're done and can copy/paste the text into the bottom of the character's quotes page.

==Other==
{{Quotes Header}}
{{Quotes
  |rowspan=2
  |situation=026
  |text=
  |lang=en
}}
{{Quotes
  |rowspan=0
  |situation=026
  |text=
  |audio=BBDW Avenge 026a.ogg, BBDW Avenge 026b.ogg
  |lang=ja
}}
{{Quotes Footer}}