Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Chao: Difference between revisions

17,076 editsJoined 5 November 2017
m (example gallery template)
(gallery working demo)
Line 1: Line 1:
<hr>
<includeonly>
<hr>
{{#switch: {{{2}}}
<hr>
  | Main Artwork = {{#vardefine:category|Main Artwork}}
  | Battle = {{#vardefine:category|Battle}}
  | {{#vardefine:category|NULL}}
}}
{{#vardefine: {{{2}}} |
  {{#ask:
    [[Category: {{{1}}} ]]
    [[Category: {{#var:category}} ]]
    | format=count
  }}
}}{{#ifeq: 0 | {{#var: {{{2}}} }} | <!-- do nothing if no images --> |
  {{#switch:{{{3}}}
    |h2=<h2>{{{2}}}</h2>
    |h3=<h3>{{{2}}}</h3>
  }}
  {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{#var:category}}]]
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
    |overlay=yes
  }}
}}
</includeonly><noinclude>
 
{{TOC}}


<syntaxhighlight>
<syntaxhighlight>
<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | h2 }}


{{#ask:
<!-- SPRITES -->
[[Category:{{{1}}}]]
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
[[Category:Main Artwork]]
  | <!-- all three subcategories are empty, don't make a section header-->
|format=gallery
  | <h2> Sprites </h2>  
|intro=<h2>Main Artwork</h2>
    {{ User:Chao | {{{1}}} | Battle | h3 }}
    {{ User:Chao | {{{1}}} | Palette Reference | h3 }}
    {{ User:Chao | {{{1}}} | Third Category | h3 }}
}}
}}


{{#ask:
...
[[Category:{{{1}}}]]
 
[[Category:Battle]]
<!-- and so on with other categories and sub-categories -->
|format=gallery
</syntaxhighlight>
|intro=<h3>Battle</h3>
 
<b>This code will produce:</b>
 
<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | h2 }}
 
<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2>
    {{ User:Chao | {{{1}}} | Battle | h3 }}
    {{ User:Chao | {{{1}}} | Palette Reference | h3 }}
    {{ User:Chao | {{{1}}} | Third Category | h3 }}
}}
}}


NOTE: the following automatically doesn't show up since there aren't any pictures categorized as both Tsubaki Yayoi and Main Artwork
...
{{#ask:
[[Category:Tsubaki Yayoi]]
[[Category:Main Artwork]]
|intro=<h2>Main Artwork</h2>
}}


== Technical Notes ==
=== Template: Gallery ===
Creates a gallery from template for the specified character. It will skip sections and subsections that the character does not have images for.
==== Template Usage ====
<syntaxhighlight>
  {{ Gallery | {{PAGENAME}} }}  <-- with the idea that {{PAGENAME}} will evaluate to ie. Kagura Mutsuki
OR {{ Gallery | Kagura Mutsuki }} <-- this will also work
</syntaxhighlight>
</syntaxhighlight>


{{#ask:
==== Template Code ====
[[Category:Kagura Mutsuki]]
<syntaxhighlight>
[[Category:Main Artwork]]
<!-- MAIN ARTWORK -->
|intro=<h2>Main Artwork</h2>
{{ Gallery Section | {{{1}}} | Main Artwork | h2 }}
 
<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2>  
    {{ Gallery Section | {{{1}}} | Battle | h3 }}
    {{ Gallery Section | {{{1}}} | Palette Reference | h3 }}
    {{ Gallery Section | {{{1}}} | Third Category | h2 }}
}}
}}


{{#ask:
...
[[Category:Kagura Mutsuki]]
 
[[Category:Battle]]
<!-- and so on with other categories and sub-categories -->
|intro=<h3>Battle</h3>
 
</syntaxhighlight>
 
=== Template: Gallery Section ===
 
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.)
 
==== Template Usage ====
<syntaxhighlight>
{{ Gallery Section
  | Kagura Mutsuki  <-- Character name
  | Main Artwork    <-- Section header. Doubles as the category in which images will be searched for.
  | h2              <-- Header depth (h2, h3, h4, h5)
}}
}}


{{#ask:
ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | h2 }}
[[Category:Tsubaki Yayoi]]
</syntaxhighlight>
[[Category:Main Artwork]]
 
|intro=<h2>Main Artwork</h2>
==== Template Code ====
<syntaxhighlight>
{{#vardefine: {{{2}}} |
  {{#ask:
    [[Category: {{{1}}} ]]
    [[Category: {{{2}}} ]]
    | format=count
  }}
}}{{#ifeq: 0 | {{#var: {{{2}}} }} | <!-- do nothing if no images --> |
  {{#switch:{{{3}}}
    |h2=<h2>{{{2}}}</h2>
    |h3=<h3>{{{2}}}</h3>
  }}
  {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{{2}}}]]
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
    |overlay=yes
  }}
}}
}}
</syntaxhighlight>


<hr>
<hr>
<hr>
<hr>
<hr>
<hr>
<!--


== Useful References ==
== Useful References ==
Line 69: Line 160:
* https://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia)
* https://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia)
* http://followthescore.org/dpldemo/index.php?title=DPL:FAQ
* http://followthescore.org/dpldemo/index.php?title=DPL:FAQ
<u>Templated DPL (DynamicPageList) Example:</u>
<pre><nowiki>
{{#tag:DynamicPageList|
category = {{{1}}}
category = {{{2}}}
namespace = file
ordermethod = sortkey
order = ascending
galleryshowfilename=no
imagesperrow=7
gallerycaption=No caption
mode=gallery
}}
</nowiki></pre>


<b><u>Other things to look into later:</u></b>
<b><u>Other things to look into later:</u></b>
Line 91: Line 167:


Note: I believe it"s good wikimedia practice to use only ==H2== and beyond (in essence, to avoid using =H1=)
Note: I believe it"s good wikimedia practice to use only ==H2== and beyond (in essence, to avoid using =H1=)
 
</noinclude>
==Easy Gallery Project==
 
Welcome to the planning page of the <u><b>Easy Gallery Project</b></u>, a project that aims to make Galleries on this wiki easy to use, maintain, and update.
 
The idea is to leverage the wiki"s categories and various automation tools to simplify the making and maintaining of galleries. Eventually, the average wiki editor should only have to tag an image properly, and the relevant galleries will automatically update themselves.
 
===Why Modules?===
 
The other option: Templated DPL (DynamicPageList)
* DPL could slow the wiki down, especially if caching is disallowed
* Templates are not scalable - they become difficult to read and maintain as they grow larger.
* With DPL/Templates, what you can do is restricted:
** Can"t rearrange pictures in a gallery
** Can"t change a specific gallery"s number of items per row
** Can"t add captions
** It"s messy to add unique galleries for a page (ie [[Mantenbo]] for Litchi"s gallery)
 
However, modules:
* Do everything that templates & DPL do: They...
** are self-maintaining (they update automatically)
** keep pages consistent (allow changes to be made in only one place, but affect all galleries)
** make it easy to add new categories
* AND they provide more options:
** can add captions
** can change specific gallery"s items per row
** it"s easy and clean to add a unique gallery for a page
* However, there is a bit of a learning curve (since it"s written in Lua)
** good documentation and clean code will help solve this.
 
===Progress===
 
<span style="color:#009000; font-size:30px">COMPLETE!!!</span>
<span style="color:#FF0000; font-size:30px">IN PROGRESS</span>
-->

Revision as of 01:57, 9 November 2017


<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | h2 }}

<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2> 
    {{ User:Chao | {{{1}}} | Battle | h3 }}
    {{ User:Chao | {{{1}}} | Palette Reference | h3 }}
    {{ User:Chao | {{{1}}} | Third Category | h3 }}
}}

...

<!-- and so on with other categories and sub-categories -->

This code will produce:


Main Artwork

... further results


Sprites


Battle

... further results


Palette Reference



Third Category


...

Technical Notes

Template: Gallery

Creates a gallery from template for the specified character. It will skip sections and subsections that the character does not have images for.

Template Usage

   {{ Gallery | {{PAGENAME}} }}   <-- with the idea that {{PAGENAME}} will evaluate to ie. Kagura Mutsuki
OR {{ Gallery | Kagura Mutsuki }} <-- this will also work

Template Code

<!-- MAIN ARTWORK -->
{{ Gallery Section | {{{1}}} | Main Artwork | h2 }}

<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2> 
    {{ Gallery Section | {{{1}}} | Battle | h3 }}
    {{ Gallery Section | {{{1}}} | Palette Reference | h3 }}
    {{ Gallery Section | {{{1}}} | Third Category | h2 }}
}}

...

<!-- and so on with other categories and sub-categories -->

Template: Gallery Section

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.)

Template Usage

{{ Gallery Section
  | Kagura Mutsuki  <-- Character name
  | Main Artwork    <-- Section header. Doubles as the category in which images will be searched for.
  | h2              <-- Header depth (h2, h3, h4, h5)
}}

ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | h2 }}

Template Code

{{#vardefine: {{{2}}} |
  {{#ask:
    [[Category: {{{1}}} ]]
    [[Category: {{{2}}} ]]
    | format=count
  }}
}}{{#ifeq: 0 | {{#var: {{{2}}} }} | <!-- do nothing if no images --> |
  {{#switch:{{{3}}}
    |h2=<h2>{{{2}}}</h2>
    |h3=<h3>{{{2}}}</h3>
  }}
  {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{{2}}}]]
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
    |overlay=yes
  }}
}}



Useful References

Modules

Semantic MediaWiki

DPL

Other things to look into later:

Note: I believe it"s good wikimedia practice to use only ==H2== and beyond (in essence, to avoid using =H1=)