Module:Documentation: Difference between revisions
mNo edit summary |
m 1 revision imported Tags: Mobile edit Mobile web edit |
||
| (7 intermediate revisions by 5 users not shown) | |||
| Line 32: | Line 32: | ||
-- translate following types if your language displays differ | -- translate following types if your language displays differ | ||
pageType_page = 'page', | |||
pageType_template = 'template', | pageType_template = 'template', | ||
pageType_module = 'module', | pageType_module = 'module', | ||
pageType_stylesheet = 'stylesheet', | pageType_stylesheet = 'stylesheet', | ||
pageType_script = 'script', | pageType_script = 'script', | ||
pageType_json = 'JSON', | |||
pageType_message = 'message', | pageType_message = 'message', | ||
| Line 45: | Line 46: | ||
-- name of different type of links, change them if necessary | -- name of different type of links, change them if necessary | ||
linkTextPurge = mw. | linkTextPurge = mw.message.new( 'smw_purge' ):plain():lower(), | ||
linkTextView = mw. | linkTextView = mw.message.new( 'view' ):plain():lower(), | ||
linkTextEdit = mw. | linkTextEdit = mw.message.new( 'edit' ):plain():lower(), | ||
linkTextHistory = mw. | linkTextHistory = mw.message.new( 'history_short' ):plain():lower(), | ||
linkTextCreate = mw. | linkTextCreate = mw.message.new( 'create' ):plain():lower(), | ||
-- strings used in p.create(): contents shown when using {{docc}} or {{subst:docc}} | -- strings used in p.create(): contents shown when using {{docc}} or {{subst:docc}} | ||
| Line 90: | Line 91: | ||
-- Internal functions | -- Internal functions | ||
local function getType( namespace, page ) | local function getType( namespace, page ) | ||
local pageType = 'template' | local pageType = 'page' | ||
if namespace == 'Template' then | |||
pageType = 'template' | |||
elseif namespace == 'Module' then | |||
pageType = 'module' | pageType = 'module' | ||
elseif page.fullText:gsub( '/' .. i18n.defaultDocPage .. '$', '' ):find( '%.css$' ) then | elseif page.fullText:gsub( '/' .. i18n.defaultDocPage .. '$', '' ):find( '%.css$' ) then | ||
pageType = 'stylesheet' | pageType = 'stylesheet' | ||
elseif page.fullText:gsub( '/' .. i18n.defaultDocPage .. '$', '' ):find( '%.js$' ) then | elseif page.fullText:gsub( '/' .. i18n.defaultDocPage .. '$', '' ):find( '%.js$' ) then | ||
pageType = 'script' | pageType = 'script' | ||
elseif page.fullText:gsub( '/' .. i18n.defaultDocPage .. '$', '' ):find( '%.json$' ) then | |||
pageType = 'json' | |||
elseif namespace == 'MediaWiki' then | elseif namespace == 'MediaWiki' then | ||
pageType = 'message' | pageType = 'message' | ||
| Line 106: | Line 109: | ||
local function getDisplayType( pageType ) | local function getDisplayType( pageType ) | ||
return i18n[ 'pageType_' .. pageType ] or i18n. | return i18n[ 'pageType_' .. pageType ] or i18n.pageType_page | ||
end | end | ||
| Line 148: | Line 151: | ||
local badDoc = args.baddoc | local badDoc = args.baddoc | ||
if badDoc then | if badDoc then | ||
static.Documentation.badDoc = '1' | static.Documentation.badDoc = '1' | ||
| Line 161: | Line 163: | ||
local docPage = mw.title.new( args.page or i18n.commonNamespacedPageWithSub:format( page.nsText, page.baseText, i18n.defaultDocPage ) ) | local docPage = mw.title.new( args.page or i18n.commonNamespacedPageWithSub:format( page.nsText, page.baseText, i18n.defaultDocPage ) ) | ||
if docPage ~= page then return end | if docPage ~= page then return end | ||
| Line 172: | Line 172: | ||
body | body | ||
:addClass( badDoc and 'documentation-badDoc' or '' ) | :addClass( badDoc and 'documentation-badDoc' or '' ) | ||
:tag( 'div' ) | :tag( 'div' ):addClass( 'documentation-header-tools' ) | ||
:wikitext( i18n.linkBar:format( i18n.linkFormat:format( i18n.commonInternalLinkPipe:format( i18n.commonNamespacedPageWithSub:format( i18n.namespaceSpecial, i18n.specialPurge, page.fullText ), i18n.linkTextPurge ) ) ) ) | :wikitext( i18n.linkBar:format( i18n.linkFormat:format( i18n.commonInternalLinkPipe:format( i18n.commonNamespacedPageWithSub:format( i18n.namespaceSpecial, i18n.specialPurge, page.fullText ), i18n.linkTextPurge ) ) ) ) | ||
:done() | :done() | ||
| Line 183: | Line 182: | ||
body:wikitext( i18n.commonInternalLink:format( i18n.commonNamespacedPage:format( i18n.namespaceCategory, i18n.docPageCategory ) ) ) | body:wikitext( i18n.commonInternalLink:format( i18n.commonNamespacedPage:format( i18n.namespaceCategory, i18n.docPageCategory ) ) ) | ||
end | end | ||
return loadStyles( i18n.defaultStyles ) .. tostring( body ) | return loadStyles( i18n.defaultStyles ) .. tostring( body ) | ||
| Line 220: | Line 217: | ||
docText = trim( f:expandTemplate{ title = ':' .. docPage.fullText } ) | docText = trim( f:expandTemplate{ title = ':' .. docPage.fullText } ) | ||
if static.Documentation.badDoc and static.Documentation.badDoc == '1' then | if static.Documentation.badDoc and static.Documentation.badDoc == '1' then | ||
badDoc = 1 | badDoc = 1 | ||
end | end | ||
| Line 257: | Line 253: | ||
-- Generates the link bar | -- Generates the link bar | ||
local links = mw.html.create( 'span' ) | local links = mw.html.create( 'span' ):addClass( 'documentation-header-tools' ) | ||
local linkList = {} | local linkList = {} | ||
| Line 281: | Line 276: | ||
header | header | ||
:tag( 'span' ) | :tag( 'span' ) | ||
:addClass( 'documentation-header-title' ) | :addClass( 'documentation-header-title' ) | ||
:wikitext( i18n.pageDocHeaderTitle ) | :wikitext( i18n.pageDocHeaderTitle ) | ||
header | |||
:node( links ) | |||
local codePages = { | local codePages = { | ||