Template:Citation core: Difference between revisions

From PoliticalSG
(Created page with "<includeonly>{{#if:{{{last|}}}|{{{last}}}{{#if:{{{first|}}}|, {{{first}}}}}{{#if:{{{last2|}}}|; {{{last2}}}{{#if:{{{first2|}}}|, {{{first2}}}}}}}}}</includeonly><noinclude> Internal helper for Template:Citation core. Renders <code>Last, First; Last2, First2</code> from <code>|last=</code>, <code>|first=</code>, <code>|last2=</code>, <code>|first2=</code>. Not meant to be used directly on content pages — use Template:Cite web, Template:Cite news, Template:...")
 
No edit summary
Line 1: Line 1:
<includeonly>{{#if:{{{last|}}}|{{{last}}}{{#if:{{{first|}}}|, {{{first}}}}}{{#if:{{{last2|}}}|; {{{last2}}}{{#if:{{{first2|}}}|, {{{first2}}}}}}}}}</includeonly><noinclude>
<includeonly>{{#ifeq:{{{mode|}}}|citation
Internal helper for [[Template:Citation core]]. Renders <code>Last, First; Last2, First2</code> from <code>|last=</code>, <code>|first=</code>, <code>|last2=</code>, <code>|first2=</code>. Not meant to be used directly on content pages use [[Template:Cite web]], [[Template:Cite news]], [[Template:Cite journal]], [[Template:Cite AV media]], or [[Template:citation]] instead.
|{{Citation core/author|last={{{last|}}}|first={{{first|}}}|last2={{{last2|}}}|first2={{{first2|}}}}}{{#if:{{{last|}}}|, }}{{Citation core/title|title={{{title|}}}|url={{{url|}}}|url-status={{{url-status|}}}|archive-url={{{archive-url|}}}|mode={{{mode|}}}|type={{{type|}}}}}{{#if:{{{work|{{{website|{{{journal|}}}}}}}}}|, {{Citation core/work|work={{{work|}}}|website={{{website|}}}|journal={{{journal|}}}}}}}{{#if:{{{publisher|}}}|, {{{publisher}}}}}{{#if:{{{language|}}}|{{#ifeq:{{{language}}}|en||, in {{{language}}}}}}}{{#if:{{{archive-url|}}}|, archived from the original on {{{archive-date|}}}}}{{#if:{{{access-date|}}}|, retrieved {{{access-date}}}}}{{#if:{{{via|}}}|, via {{{via}}}}}
|{{#if:{{{last|}}}
  |{{Citation core/author|last={{{last|}}}|first={{{first|}}}|last2={{{last2|}}}|first2={{{first2|}}}}}{{#if:{{{date|}}}{{{year|}}}| ({{{date|{{{year|}}}}}})}}. {{Citation core/title|title={{{title|}}}|url={{{url|}}}|url-status={{{url-status|}}}|archive-url={{{archive-url|}}}|mode={{{mode|}}}|type={{{type|}}}}}.
  |{{Citation core/title|title={{{title|}}}|url={{{url|}}}|url-status={{{url-status|}}}|archive-url={{{archive-url|}}}|mode={{{mode|}}}|type={{{type|}}}}}{{#if:{{{date|}}}{{{year|}}}| ({{{date|{{{year|}}}}}})}}.
}}{{#if:{{{work|{{{website|{{{journal|}}}}}}}}}|{{Citation core/work|work={{{work|}}}|website={{{website|}}}|journal={{{journal|}}}}}. }}{{#if:{{{publisher|}}}|{{{publisher}}}. }}{{#if:{{{language|}}}|{{#ifeq:{{{language}}}|en||(in {{{language}}}). }}}}{{#if:{{{pages|{{{page|}}}}}}|{{{pages|{{{page}}}}}}. }}{{#if:{{{archive-url|}}}|{{#ifeq:{{{url-status|}}}|dead|Archived from the original on {{{archive-date|}}}. |Archived from [{{{url|}}} the original] on {{{archive-date|}}}. }}}}{{#if:{{{access-date|}}}|Retrieved {{{access-date}}}. }}{{#if:{{{via|}}}|– via {{{via}}}. }}
}}{{#if:{{{quote|}}}| "{{{quote}}}"}}</includeonly><noinclude>
== Usage ==
Shared core for this wiki's Lua-free citation templates ([[Template:Cite web]], [[Template:Cite news]], [[Template:Cite journal]], [[Template:Cite AV media]], [[Template:citation]]). Not meant to be called directly on content pages — use one of those instead.
 
Built because upstream Citation Style 1/2 templates run on <code>Module:Citation/CS1</code>, which requires Scribunto/Lua — unavailable on this wiki (the same <code>proc_open</code> block that rules out <code>{{Infobox officeholder}}</code>'s original Lua version). This reimplementation covers the field set actually used across Politicalsg articles rather than CS1's full parameter surface, and delegates the author/title/work formatting to three small helper subtemplates ([[Template:Citation core/author]], [[Template:Citation core/title]], [[Template:Citation core/work]]) so both the CS1 and CS2 branches below share the same logic.
 
'''Deviations from upstream CS1/CS2 — read before assuming parity:'''
* '''Supported fields:''' <code>last</code>, <code>first</code>, <code>last2</code>, <code>first2</code>, <code>date</code>, <code>year</code>, <code>title</code>, <code>type</code>, <code>url</code>, <code>work</code>/<code>website</code>/<code>journal</code>, <code>publisher</code>, <code>language</code>, <code>pages</code>/<code>page</code>, <code>access-date</code>, <code>archive-url</code>, <code>archive-date</code>, <code>url-status</code>, <code>via</code>, <code>quote</code>. No <code>editor</code>, <code>volume</code>, <code>issue</code>, <code>doi</code>, <code>issn</code>, <code>isbn</code>, <code>id</code>, <code>ref</code>, <code>display-authors</code>, <code>trans-title</code>, or the many other CS1 fields. Extend this template (and thread the field through the relevant wrapper) if a page needs one of these — <code>issn</code>/<code>isbn</code> in particular are already used in some existing refs on the wiki but currently silently dropped.
* '''No automatic error messages''' for malformed input (missing title, url without title, etc.) upstream shows visible red warnings; this version just renders oddly.
* '''<code>mode=</code>''' selects formatting: <code>mode=citation</code> gives comma-separated CS2-style output, lowercase "archived"/"retrieved", no trailing terminal period. Any other value (<code>web</code>, <code>news</code>, <code>journal</code>, <code>avmedia</code>) gives period-separated CS1-style output. <code>mode=avmedia</code> additionally italicises the title instead of quoting it.
* '''Dead-link handling is simplified:''' if <code>url-status=dead</code> and <code>archive-url=</code> is given, the title links to the archive copy and "the original" is shown unlinked in the archive note. Matches upstream's basic behaviour but not every edge case (<code>url-status=usurped</code>, <code>|df=</code> date-format normalisation are not handled).
* Only one primary author (<code>last</code>/<code>first</code>) plus one secondary (<code>last2</code>/<code>first2</code>) — no <code>last3</code>+ chaining, no <code>display-authors=etal</code>.


[[Category:Templates]]
[[Category:Templates]]
</noinclude>
</noinclude>

Revision as of 20:11, 14 July 2026

Usage

Shared core for this wiki's Lua-free citation templates (Template:Cite web, Template:Cite news, Template:Cite journal, Template:Cite AV media, Template:citation). Not meant to be called directly on content pages — use one of those instead.

Built because upstream Citation Style 1/2 templates run on Module:Citation/CS1, which requires Scribunto/Lua — unavailable on this wiki (the same proc_open block that rules out

Citation core

's original Lua version). This reimplementation covers the field set actually used across Politicalsg articles rather than CS1's full parameter surface, and delegates the author/title/work formatting to three small helper subtemplates (Template:Citation core/author, Template:Citation core/title, Template:Citation core/work) so both the CS1 and CS2 branches below share the same logic.

Deviations from upstream CS1/CS2 — read before assuming parity:

  • Supported fields: last, first, last2, first2, date, year, title, type, url, work/website/journal, publisher, language, pages/page, access-date, archive-url, archive-date, url-status, via, quote. No editor, volume, issue, doi, issn, isbn, id, ref, display-authors, trans-title, or the many other CS1 fields. Extend this template (and thread the field through the relevant wrapper) if a page needs one of these — issn/isbn in particular are already used in some existing refs on the wiki but currently silently dropped.
  • No automatic error messages for malformed input (missing title, url without title, etc.) — upstream shows visible red warnings; this version just renders oddly.
  • mode= selects formatting: mode=citation gives comma-separated CS2-style output, lowercase "archived"/"retrieved", no trailing terminal period. Any other value (web, news, journal, avmedia) gives period-separated CS1-style output. mode=avmedia additionally italicises the title instead of quoting it.
  • Dead-link handling is simplified: if url-status=dead and archive-url= is given, the title links to the archive copy and "the original" is shown unlinked in the archive note. Matches upstream's basic behaviour but not every edge case (url-status=usurped, |df= date-format normalisation are not handled).
  • Only one primary author (last/first) plus one secondary (last2/first2) — no last3+ chaining, no display-authors=etal.