Module:Documentation: Difference between revisions

m rebase dev changes onto prod
Use Special pages for edit, history, purge; update to look more like the template on enwiki with the brackets around each link
Line 149: Line 149:
end
end
local action = f:preprocess('{{lc:{{int:edit}}}}')
local preload = ''
local docClass = ''
local docClass = ''
local colour = '00000000'
local colour = '00000000'
Line 156: Line 154:
local category
local category
if noDoc then
if noDoc then
action = f:preprocess('{{lc:{{int:create}}}}')
preload = '&preload=Template:Documentation/preload'
docClass = 'documentation-noDoc'
docClass = 'documentation-noDoc'
colour = '33333333'
colour = '33333333'
Line 180: Line 176:
end
end
local links = {
-- Generates the [view][edit][history][refresh] or [create][refresh] links
'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
'[' .. docPage:fullUrl( 'action=history' ) .. ' ' .. f:preprocess('{{lc:{{int:history short}}}}') .. ']',
'[' .. page:fullUrl( 'action=purge' ) .. ' ' .. f:preprocess('{{lc:{{int:smw purge}}}}') .. ']'
}
if not noDoc and page ~= docPage then
table.insert( links, 1, '[[' .. docPage.fullText .. '|' .. f:preprocess('{{lc:{{int:view}}}}') .. ']]' )
end
links = mw.html.create( 'span' )
links = mw.html.create( 'span' )
:attr( 'id', 'documentation-header-tools' )
:attr( 'id', 'documentation-header-tools' )
:css( 'float', 'right' )
:css( 'float', 'right' )
:wikitext( mw.text.nowiki( '[' ), table.concat( links, ' | ' ), mw.text.nowiki( ']' ) )
 
local purgeLink = '[[Special:Purge/' .. docPage.fullText .. '|' .. f:preprocess('{{lc:{{int:smw purge}}}}') .. ']]'
if not noDoc and page ~= docPage then
local viewLink = '[[' .. docPage.fullText .. '|' .. f:preprocess('{{lc:{{int:view}}}}') .. ']]'
local editLink = '[[Special:EditPage/' .. docPage.fullText .. '|' .. f:preprocess('{{lc:{{int:edit}}}}') .. ']]'
local historyLink = '[[Special:PageHistory/' .. docPage.fullText .. '|' .. f:preprocess('{{lc:{{int:history short}}}}') .. ']]'
links:wikitext("[" .. viewLink .. "] [" .. editLink .. "] [" .. historyLink .. "] [" .. purgeLink .. "]")
else
local createLink = '[' .. docPage:canonicalUrl{action = 'edit', preload = 'Template:Documentation/preload' } .. ' ' .. f:preprocess('{{lc:{{int:create}}}}') .. ']'
links:wikitext("[" .. createLink .. "] [" .. purgeLink .. "]")
end
local body = mw.html.create( 'div' ):addClass( 'documentation' )
local body = mw.html.create( 'div' ):addClass( 'documentation' )