Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Galeria/doc: Difference between revisions

From Neodyland Wiki
Fix Linter errors.
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#ifeq:{{SUBPAGENAME}}|sandbox|<includeonly>[[Category:Scribunto module sandboxes]]</includeonly>|{{Module rating|release}}}}
{{#ifeq:{{SUBPAGENAME}}|sandbox|<includeonly>[[Category:Scribunto module sandboxes]]</includeonly>|{{Module rating|release}}}}
{{Heavily used module}}


=== The format parameter ===
=== The format parameter ===
Line 16: Line 17:
Otherwise every second parameter seeming to be a valid file name is considered to be the next file name, and the first parameter is treated as an unpaired, single file name.
Otherwise every second parameter seeming to be a valid file name is considered to be the next file name, and the first parameter is treated as an unpaired, single file name.


An easy solution is the specification of empty parameters for captions: it signals that the file name is also the caption.
An easy solution is the specification of empty parameters for captions: it signals that the file name should also be used as the caption.


=== How it works ===
=== How it works ===
Line 37: Line 38:
For the format 2, pairs of items are built, with possible defaulting of the description item.<br><br>
For the format 2, pairs of items are built, with possible defaulting of the description item.<br><br>
Finally the total amount of items is passed to the {{T|G/layout|-}}, together with the other parameters. <br>
Finally the total amount of items is passed to the {{T|G/layout|-}}, together with the other parameters. <br>
Because the <tt>gallery tag</tt> does not support the suppression of the <code>showfilename</code> option, <br>
Because the {{tag|gallery}} tag does not support the suppression of the <code>showfilename</code> option, <br>
''two'' transclusions of the gallery tag are necessary - one with, and the other one without <tt>showfilename</tt>.
''two'' transclusions of the gallery tag are necessary - one with, and the other one without <code>showfilename</code>.


=== Helper functions ===
=== Helper functions ===
The function "converse" gets a size parameter (possible format examples: 100, x260, 200x240 or 150px, x280px, 220x250px)<br>
The function "converse" gets a size parameter (possible format examples: 100, x260, 200x240 or 150px, x280px, 220x250px)<br>
and returns the <tt>widths</tt> and/or the <tt>heights</tt> values; the local function "parseval" is used to parse the values.  
and returns the <code>widths</code> and/or the <code>heights</code> values; the local function "parseval" is used to parse the values.
 
The function "filename" returns the <nowiki>{{PAGENAME}}</nowiki> without the extension; also " Wellcome X99999999" will be removed.


The function "pagename" can change all understrokes to spaces.
The function "pagename" can change all understrokes to spaces.


The function "iffile" performs a rough check whether a string can be a valid file name. Depending on a second parameter, it returns either a flag or the file name without extension.  
The function "iffile" performs a rough check whether a string can be a valid file name. Depending on a second parameter, it returns either a flag or the file name without extension.


=== Other main function ===
The function 'gallang" is invoked from the template {{T|Lgallery}} to diplay multilanguage SVG files.


== See also ==
== See also ==
* [[Module:Gallery]] and {{tlx|Gallery}}
* [[Module:Gallery]] and {{tlx|Gallery}}

Latest revision as of 21:13, 25 October 2022


The format parameter

edit

When none is specified, the module tries to find the best fitting default format. If another display format is wanted it can be specified;
but a wrong format parameter which does not fit to the file name parameters gives troubles.

  • 0: no captions, every unnamed parameter specifies a valid file name
  • 1: 'showfilename' captions, every unnamed parameter specifies a valid file name
  • 2: parameter pairs of file name and caption; when the second value is missing the file name is displayed, with link
  • 3: as format 2, but file name captions are displayed without link

Format 0 and 1 may not contain caption parameters; format 2 and 3 can work with a mixture of file names and caption texts.

The file parameters

edit

Each file to be displayed can be spezified by one, or by two parameters. The chain of files starts of course with a file name; the following parameter can be the caption for the current file, or it specifies the next file name. When such a second parameter is the same as the first one, possibly only differing in case and space/understroke, it is used as a caption for the first parameter. Otherwise every second parameter seeming to be a valid file name is considered to be the next file name, and the first parameter is treated as an unpaired, single file name.

An easy solution is the specification of empty parameters for captions: it signals that the file name should also be used as the caption.

How it works

edit

This module gets all parameters from the parent template of G, creates the attributes and values, and passes them to the gallery tag.

The mainly invoker is template:{{G}}.
The template G itself does nothing than to invoke this module, it does not specify any own parameters.

The module analyzes these parameters. In special, the unnamed parameter(s) can contain an unlimited number of items.

First of all, the contents of all unnamed parameters are concatenated to one string:

  1. concatenates all pipe-separated items and separates them by an ACK
  2. changes also the newline separators to ACK separators.

Then when the parameter for 'format' is not specified, but

a second parameter exists (after a pipe), and
the first parameter is preceded by a newline, and
the second parameter does not specify a file name,
then the format parameter is defaulted to the value "2".

Using the ACK instead of the slash "/" tolerates items containing slashes, as URL web addresses.
For the format 2, pairs of items are built, with possible defaulting of the description item.

Finally the total amount of items is passed to the Template:{{G/layout}}, together with the other parameters.
Because the ‎<gallery>...‎</gallery> tag does not support the suppression of the showfilename option,
two transclusions of the gallery tag are necessary - one with, and the other one without showfilename.

Helper functions

edit

The function "converse" gets a size parameter (possible format examples: 100, x260, 200x240 or 150px, x280px, 220x250px)
and returns the widths and/or the heights values; the local function "parseval" is used to parse the values.

The function "filename" returns the {{PAGENAME}} without the extension; also " Wellcome X99999999" will be removed.

The function "pagename" can change all understrokes to spaces.

The function "iffile" performs a rough check whether a string can be a valid file name. Depending on a second parameter, it returns either a flag or the file name without extension.

Other main function

edit

The function 'gallang" is invoked from the template {{Lgallery}} to diplay multilanguage SVG files.

See also

edit
Cookies help us deliver our services. By using our services, you agree to our use of cookies.