Jump to content

Module talk:Page

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Athishraj081 (talk | contribs) at 02:07, 23 November 2022. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

example

{{#invoke:Page|id|Nazi Party}} generates:

21736

Modified by Gangleri (talk) 12:39, 17 December 2015 (UTC)[reply]

wgCurRevisionId

att: / cc: @Darklama, @Liangent, @Wnt Hi! It is possible to add wgCurRevisionId to the list of parameters? One application is described under note a) at https://en.wikipedia.org/?curid=14574453#shortest_url . Kind regards Gangleri (talk) 12:39, 17 December 2015 (UTC)[reply]

<sha1>3uutklb10j89clizor7gnyrlkhbqg0d</sha1> </revision> </page> <page> <title>Module:Pagetype/config</title> <ns>828</ns> <id>42396800</id> <revision> <id>1032938598</id> <parentid>1029747509</parentid> <timestamp>2021-07-10T15:47:32Z</timestamp> <contributor> <username>Trialpears</username> <id>35786750</id> </contributor> <comment>Book namespace removal will happen within a few days</comment> <model>Scribunto</model> <format>text/plain</format> <text bytes="3847" xml:space="preserve">-------------------------------------------------------------------------------- -- Module:Pagetype configuration data -- -- This page holds localisation and configuration data for Module:Pagetype. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -- This table holds the values to use for "main=true", "user=true", etc. Keys to -- this table should be namespace parameters that can be used with -- Module:Namespace detect. cfg.pagetypes = { ['main'] = 'article', ['user'] = 'user page', ['project'] = 'project page', ['wikipedia'] = 'project page', ['wp'] = 'project page', ['file'] = 'file', ['image'] = 'file', ['mediawiki'] = 'interface page', ['template'] = 'template', ['help'] = 'help page', ['category'] = 'category', ['portal'] = 'portal', ['draft'] = 'draft', ['timedtext'] = 'Timed Text page', ['module'] = 'module', ['topic'] = 'topic', ['gadget'] = 'gadget', ['gadget definition'] = 'gadget definition', ['talk'] = 'talk page', ['special'] = 'special page', ['media'] = 'file', } -- This table holds the names of the namespaces to be looked up from -- cfg.pagetypes by default. cfg.defaultNamespaces = { 'main', 'file', 'template', 'category', 'module' } -- This table holds the names of the namespaces to be looked up from -- cfg.pagetypes if cfg.defaultnsExtended is set. cfg.extendedNamespaces = { 'main', 'user', 'project', 'file', 'mediawiki', 'template', 'category', 'help', 'portal', 'module', 'draft' } -- The parameter name to set which default namespace values to be looked up from -- cfg.pagetypes. cfg.defaultns = 'defaultns' -- The value of cfg.defaultns to set all namespaces, including talk. cfg.defaultnsAll = 'all' -- The value of cfg.defaultns to set the namespaces listed in -- cfg.extendedNamespaces cfg.defaultnsExtended = 'extended' -- The value of cfg.defaultns to set no default namespaces. cfg.defaultnsNone = 'none' -- The parameter name to use for disambiguation pages page. cfg.dab = 'dab' -- This table holds the different possible aliases for disambiguation-class -- pages. These should be lower-case. cfg.dabAliases = { 'disambiguation', 'disambig', 'disamb', 'dab' } -- The default value for disambiguation pages. cfg.dabDefault = 'page' -- The parameter name to use for N/A-class page. cfg.na = 'na' -- This table holds the different possible aliases for N/A-class pages. These -- should be lower-case. cfg.naAliases = {'na', 'n/a'} -- The default value for N/A-class pages. cfg.naDefault = 'page' -- The parameter name to use for redirects. cfg.redirect = 'redirect' -- The default value to use for redirects. cfg.redirectDefault = 'redirect' -- The parameter name for undefined namespaces. cfg.other = 'other' -- The value used if the module detects an undefined namespace. cfg.otherDefault = 'page' -- The usual suffix denoting a plural. cfg.plural = 's' -- This table holds plurals not formed by a simple suffix. cfg.irregularPlurals = { ["category"] = "categories" } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line</text> Athishraj081 (talk) 02:07, 23 November 2022 (UTC)[reply]

Script errors

@Petr Matas: I'm trying to understand your recent changes to Module:Page which look great in principle but which have a glitch that is generating script errors in articles (current list).

In callAssert, what is this?

    local result = { func(...) }

I would have expected use of pcall. The following join should be string.concat table.concat and that is the immediate problem. If I get some time later I will try following instinct and replace the above with pcall. Johnuniq (talk) 00:06, 18 August 2018 (UTC)[reply]

On a closer look, I see that pcall was not wanted. The code is not catching an error in the call, it's detecting whether the call returned nil. Even closer inspection showed that throwing error() is not wanted either. I have never seen this module or its templates (apparently {{Correct title}} and {{Pageid to title}}) before so my quick work needs checking. However, {{Correct title}} uses #iferror to test certain things and the error span class returned in the text is caught by #iferror. Throwing an error puts the article in Category:Pages with script errors which is very undesirable. At any rate I fixed the immediate problem and the number of articles in the error category is down from 88 to 14. I'll investigate those 14 in due course. Johnuniq (talk) 02:25, 18 August 2018 (UTC)[reply]
The line local result = { func(...) } stores the (possibly multiple) values returned from the function in a table. Its counterpart is return unpack(result), which returns the contents of the table as multiple values.
To avoid throwing an error from the module, I have encapsulated the entire main in pcall. This way we can keep using error(), I hope. Thus, pcall at other places becomes unnecessary. Petr Matas 09:47, 18 August 2018 (UTC)[reply]
That looks good. To avoid a maze of dependencies I wouldn't call Module:Error but I agree it has the advantage of being only one place to accommodate any change to how the error class works in the future. In callAssert there is no reason to use mw.ustring.format rather than the more efficient string.format. However, that's unimportant. I was going to add that the error category is now empty but I see that a problem in another module has filled it up again! Keeps me employed. Johnuniq (talk) 10:11, 18 August 2018 (UTC)[reply]