Page MenuHomePhabricator

<ref> acting as a citation template using attributes of the ref element
Closed, DeclinedPublicFeature

Description

Author: wiki_ra

Description:
During a discussion on citation styles at the Village Pump on the en.wiki, a number of editors expressed a dislike for citation templates. I greatly like them for a number of reasons (e.g. they help users unused to citing sources to do so properly, the lend to a consistent citation style, they make data that is naturally suitable to being machine readable comprehendible to a machine as discrete data, etc.).

The frequent source of the dislike mentioned by others was the time it takes a long time to transclude many such citation templates in a heavily cited page. I suggested enhancing Cite.php to do the citation templating.

The method I suggest is as follows:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.<ref name="murphy" />

== References ==
<references>
<ref first="John" last="Murphy" title="Quisque Quis Orci Magna" publisher="Printing House Press" location="London" year="2009" page="55" isbn="978-3-16-148410-0" />
</references>

The above example renders the citation as follows:

J. Murphy. Quisque Quis Orci Magna. Printing House Press: London. 2009. Page 55. ISBN: 978-3-16-148410-0

I have a working example of the code necessary to implement this in a rudimentary manner at:

https://secure.wikimedia.org/wikipedia/en/wiki/User:Rannpháirt%C3%AD_anaithnid/Cite.php

It does not break current usage of Cite.php.

I'd be happy to continue development on this if it was picked up.


Version: unspecified
Severity: enhancement
URL: https://en.wikipedia.org/wiki/User:Rannph%C3%A1irt%C3%AD_anaithnid/Cite.php

Details

Reference
bz22134

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:46 PM
bzimport added a project: Cite.
bzimport set Reference to bz22134.
bzimport added a subscriber: Unknown Object (MLST).

You are hardcoding parameters and output. It could call a template defined in $wgAllowCiteTemplates or a MediaWiki: message.
I'm also a bit wary of the verifying chunks of code you removed.

Your work seems to be more in line with the (abandoned) citation extension.

wiki_ra wrote:

Re: hardcoding parameters and defining a template - indeed, its just a rough working example. I'm not suggesting *that* as code.

The "chunks of code" I removed seemed to have redundancy and limited the number of attributes to two (assumed) parameters. The new code (if I'm not mistaken) does precisely the same thing but without hardcoding a max numbers of attributes or assuming what those attributes must be if they are present. (I'd suggest taking that piece into trunk regardless of opinion about templates for citations as it would be more flexible going forward.)

I'm not aware of the citation template. What is/was it?

wiki_ra wrote:

Thanks. Getting muddled between templates that to templates :"-)

As I mentioned to Oliver on wiki, anything that expects to code particular styles of referencing directly into Cite seems like a total non-starter. The best that one could do is teach ref to call one or more templates automatically and that doesn't seem like much of a savings.

Since your main goal (Oliver's) is to improve standardization, the real targets should generally be the use and consistency of templates, not Cite itself.

wiki_ra wrote:

Referring to on-wiki templates is one way. Using actual ('real-life') standards e.g. APA, Harvard, etc. is another. Or a combination mix of both.

These could either be set by default (per installation) or specified (optionally probably), possibly in the <reference> tag e.g.:

<references style="harvard">
<ref ... />
</references>

(...or have this choice over-rided by user preferences, as was suggested by another user in that discussion e.g. user wants to see references displayed in APA style only.)

If it was to be taken in to Cite, I think the "real-life standards" would be the best place to start as it would give the greatest gains over templates and would be the most immediately usable by all MW installations.

The templates represent the community's consensus about what they want citations to look like. They are often originally based on standards but then deviated because at some point in the past the community decided those changes made them better. There is no reason that the templates couldn't be used to implement letter-perfect versions of essentially any real-life citation standard if that is what the community wants. However, first you'd have to convince the community that they want "real-life standards".

The choice to adopt referencing standards, or not, is one for the community to make, and should generally not be enforced directly by Cite.

wiki_ra wrote:

From the points of view of Cite, I don't think it should be enforced. This suggestion may have come out of a discussion on WP but I making it purely in parallel to that. I'm saying it would be a nice feature if cite could handle basic citation meta data and spit it out in a standard format and style (not just on WP but on other installations too).

If WP goes for a standard style or not is a different matter (and from what I can see *enforcing* a standard style on WP looks like a non-starter).

You claim that:

The frequent source of the dislike mentioned by others was the time it takes a
long time to transclude many such citation templates in a heavily cited page.

fixed by your proposal.

Why does it take "a long time"?

How is <ref first="John" last="Murphy" title="Quisque Quis Orci Magna"
publisher="Printing House Press" location="London" year="2009" page="55"
isbn="978-3-16-148410-0" /> better than {{ref|first=John|last=Murphy|title=Quisque Quis Orci Magna|publisher=Printing House Press|location=London|year=2009|page=55}} ?

wiki_ra wrote:

The users who said that (I believe) blamed the DB overhead costs of transcluding those templates many times. I don't believe the issue was one of bandwidth.

(There would also be additional benefits to doing it in Cite. For example, a user could override the installation- or the article-defined citation style with a preferred style defined in their user preferences.)

After hinting by Robert, I've opened an on-wiki suggestion of this idea here:

https://secure.wikimedia.org/wikipedia/en/wiki/Wikipedia:Village_pump_(proposals)#Cite_modifications

While I haven't actually verified this, my guess is that the cite templates are slow due to feature bloat and over-standardization.

The cite templates on enwiki include all sorts of extra parameters for things like translations, summaries, multiple editors, etc. 90% of citations aren't going to use more than a few key parameters, but the templates still have to evaluate parser functions based on every possible option.

Additionally, almost every citation template is just a wrapper around [[Template:Citation/core]], adding a call to the meta-template for each usage and making the other problem worse by having even more extra parameters, many of which aren't even exposed in the standard templates.

The sample code is going to be faster because it doesn't have nearly as many options, so it can format the citation by just concatenating parameters and separators, and it does it all with PHP. That could still be extended to replicate the current citation templates, but then if a wiki wants a change to a reference format, it would have to be done by a sysadmin.

The users who said that (I believe) blamed the DB overhead costs of
transcluding those templates many times. I don't believe the issue was one of
bandwidth.

The cost of fetching the template from db is the same. If a template is used
several times, it is only grabbed the first one. NExt ones the content is reused.
You shouldn't be orried about that.

Alex is correct, the lag is mostly the massive structure of Citation/core which has over 200 #if branches (though only a fraction would be called during any given execution). None of it is individually bad, but taken collectively and called more than 100 times per article and it will really add up.

As an aside, I've been contemplating extending the parser caching of pages to allow for per-page template caching which would allow one to bypass re-rendering these rarely changed blocks most of the time.

rm patch-need-review, not an actual patch. Also, the code is just a proof-of-concept that is not ready to be committed. Newer efforts in this direction are TemplateAdventures and Lua.

sumanah wrote:

Oliver, thanks for the bug report. Please check out https://www.mediawiki.org/wiki/Lua_scripting .

Over the last two years the major citation templates on the English wiki have been converted to Lua which has mostly resolved the performance issues.

But, the use of these templates is not mandated nor universal. Other language wikis use different citation styles. On enwiki the templates are constantly maintained to reslove issues and add features. Moving the functionality into cite.php means that maintenance is going to be complicated and slowed.

Over the last two years the major citation templates on the English wiki have been converted to Lua which has mostly resolved the performance issues.

But, the use of these templates is not mandated nor universal. Other language wikis use different citation styles. On enwiki the templates are constantly maintained to reslove issues and add features. Moving the functionality into cite.php means that maintenance is going to be complicated and slowed.

Generally agreed that this task could be closed based on Lua fixing the rendering speed problem.

OTOH this could make T15873: Book notes by page, paragraph and line for a particular ISBN possible.

Izno renamed this task from Citations templates to <ref> acting as a citation template using attributes of the ref element.Jun 24 2016, 3:23 PM
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.
thiemowmde subscribed.

That's literally what templates are for.