Skip to content

Instantly share code, notes, and snippets.

@s7eph4n
Last active February 28, 2024 00:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s7eph4n/277e7804fe04954df7d1e15ae874b0d0 to your computer and use it in GitHub Desktop.
Save s7eph4n/277e7804fe04954df7d1e15ae874b0d0 to your computer and use it in GitHub Desktop.
List format overhaul: Change description

List format overhaul: Change description

Changes Overview

  • Wrapped components of the list format in HTML elements
  • Added class attributes to HTML elements of list, ol and ul formats to facilitate styling
  • Added plainlistformat
  • template format becomes alias of the plainlist format
  • template parameter is used when present, even if format is not template
  • Standardized parameters to templates: All standard parameters start with a #
  • Dedicated separators for values, properties and result "rows": sep, propsep, valuesep
  • Removed final list separator (", and")
  • Removed ? as prefix for template arguments
  • Removed template arguments parameter
  • Removed columns parameter

Formats

Old Format New Format Remark
- list Inline list with components wrapped in HTML tags to allow styling
list plainlist Inline list with components NOT wrapped in HTML tags. Used by #show
ol ol Ordered list with components wrapped in HTML tags to allow styling
ul ul Unordered list with components wrapped in HTML tags to allow styling
template template Deprecated. Alias of plainlist.

Parameters to #ask and #show

Old parameter New parameter Remark
sep sep Not available for ol and ul format
- propsep
valuesep valuesep Parameter values are trimmed. To set something like ,␣, use
valuesep=,␣<nowiki/>
template template
introtemplate introtemplate
outrotemplate outrotemplate
named args named args
template arguments - Removed.
userparam userparam
columns - Removed. Use CSS instead.

Standard parameters passed to templates set by the template, introtemplate, outrotemplate parameter

Old parameter New parameter Remark
userparam #userparam
- #rowcount The number of entries in the result.
- #rownumber The index number of the current entry. Starts from 1. Takes offset into account.
Not available for introtemplate, outrotemplate
# # Deprecated. Use rownumber instead.
smw-resultquerycondition #querycondition
smw-resultquerylimit #querylimit
smw-resultqueryoffset #resultoffset

Messages

  • smw-format-list-separator: ,
  • smw-format-list-property-separator: ,
  • smw-format-list-value-separator: ,
  • smw-format-list-field-label-separator: :
  • smw-format-list-other-fields-open: (
  • smw-format-list-other-fields-close: )

Structure of query result

Components of the query result are wrapped in HTML elements depending on the format:

list ol ul plainlist
result <span class="smw-format list-format"> <ol class="smw-format list-format"> <ul class="smw-format list-format"> -
row <span class="smw-row"> <li class="smw-row"> <li class="smw-row"> -
field <span class="smw-field"> <span class="smw-field"> <span class="smw-field"> -
label <span class="smw-field-label"> <span class="smw-field-label"> <span class="smw-field-label"> -
value <span class="smw-value"> <span class="smw-value"> <span class="smw-value"> -

This is a mockup of a plainlist query result (reformatted for readability, actual result would be without linebreaks and contain links):

INTROTEMPLATE
F-0401/Asoka (Version: 3.8 PROPSEP Developer: Shae Erley VALUESEP Keeley Considine PROPSEP Company:  Edgewire) SEPARATOR
F-0401/Stim (Version: 1.8 PROPSEP Developer: Kerrill Blabie VALUESEP Gelya Barnewall PROPSEP Company:  Bluejam PROPSEP Website: http://paginegialle.it/diam/id/ornare.aspx)
OUTROTEMPLATE
... further results 

This is a mockup of the same query result in list format (again reformatted for readability, actual result would be without linebreaks):

<p>
	INTROTEMPLATE
	<span class="smw-format list-format">
		<span class="smw-row">
			<span class="smw-field">
				<span class="smw-value">
					<a href="/wiki/F-0401/Asoka" title="F-0401/Asoka">F-0401/Asoka</a>
				</span>
			</span>
			(
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Version" title="Property:Version">Version</a>
				</span>
				:
				<span class="smw-value">3.8</span>
			</span>
			PROPSEP
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Developer" title="Property:Developer">Developer</a>
				</span>:
				<span class="smw-value">Shae Erley</span>
				VALUESEP
				<span class="smw-value">Keeley Considine</span>
			</span>
			PROPSEP
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Company" title="Property:Company">Company</a>
				</span>
				:
				<span class="smw-value">
					<a href="/mw/index.php?title=Edgewire&amp;action=edit&amp;redlink=1" class="new" title="Edgewire (page does not exist)">Edgewire</a>
				</span>
			</span>
			)
		</span>
		SEPARATOR
		<span class="smw-row">
			<span class="smw-field">
				<span class="smw-value">
					<a href="/wiki/F-0401/Stim" title="F-0401/Stim">F-0401/Stim</a>
				</span>
			</span>
			(
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Version" title="Property:Version">Version</a>
				</span>
				:
				<span class="smw-value">1.8</span>
			</span>
			PROPSEP
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Developer" title="Property:Developer">Developer</a>
				</span>:
				<span class="smw-value">Kerrill Blabie</span>
				VALUESEP
				<span class="smw-value">Gelya Barnewall</span>
			</span>
			PROPSEP
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Company" title="Property:Company">Company</a>
				</span>
				:
				<span class="smw-value">
					<a href="/mw/index.php?title=Bluejam&amp;action=edit&amp;redlink=1" class="new" title="Bluejam (page does not exist)">Bluejam</a>
				</span>
			</span>
			PROPSEP
			<span class="smw-field">
				<span class="smw-field-label">
					<a href="/wiki/Property:Website" title="Property:Website">Website</a>
				</span>
				:
				<span class="smw-value">
					<a rel="nofollow" class="external text" href="http://paginegialle.it/diam/id/ornare.aspx">http://paginegialle.it/diam/id/ornare.aspx</a>
				</span>
			</span>)
		</span>
	</span>
	OUTROTEMPLATE
	<span class="smw-list-furtherresults">
		<a href="..." title="...">... further results</a>
	</span>
</p>
@z929669
Copy link

z929669 commented Oct 21, 2020

After upgrading from 1.8 to 3.2, most everything seems to be working but for some templates. The above changes do not appear to be relevant, but I can't be sure. Basically, instead of returning a string value, the following syuntax returns the parameter itself:

[{{#ask:[[{{{ModName}}}]]|mainlabel=-|SourceURL#=}}{{{?ModName}}}]

returns:
[{{{?ModName}}}]

EDIT: In case this is helpful to anyone else that is unable to implement the SMW migration guide change relating to this:

I had to find each of my result queries and change "|format=template" to "|format=plainlist" ... this may not be necessary, since 'template' now alieases 'plainlist'.

Most importantly, I had to replace all template args like {{{?ModName}}} to {{{ModName}}} (so replace all '{{{?' with '{{{'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment