Template edit source



p={}

local function displayError(message)
    local format = "<span class='error'>%s</span>"
	return mw.ustring.format(format, message)
end

local function toWikiStyleLink(url, display)
    local wikiLinkFormat = '[%s %s]' -- [url display] wiki style url reference
    local wikiLink = mw.ustring.format(wikiLinkFormat, url, display)
    local spanFormat = '<span class="plainlinks">%s</span>'
    wikiLink = mw.ustring.format(spanFormat, wikiLink)
    return wikiLink
end

local function page(pageTitle, namespaceID, preloadFile, summary)
    local page = {}
    page.title = mw.title.new(pageTitle,namespaceID)
    page.preloadFile = preloadFile
    page.linkDisplay = mw.site.namespaces[namespaceID].name .. ':' .. pageTitle
    page.creationSummary = summary
    page.uri = page.title:fullUrl{action = 'edit', preload = page.preloadFile, summary = page.creationSummary}
    page.wikiLink = toWikiStyleLink(page.uri, page.linkDisplay)
    return page
end

p.displayMenu = function(frame)
    local userPage = page("MyPage/common.css",
                      mw.site.namespaces.Special.id,
                     "User:にょろん/Template/Hide TemplateData/redirect.css",
                     ""
                     )
    return userPage.wikiLink
end
return p