Module:Hastranscript
The {{Hastranscript}}
template is used to indicate and link to/transclude a transcript page for any given article.
Usage
{{hastranscript|type|link}} {{hastranscript|transclude=yes}} {{hastranscript|page|transclude=yes}} {{hastranscript|page1|page2|...|transclude=yes}}
Parameters
There are two forms of usage for hastranscript. The first generates a messagebox linking to the full transcript page (and that's it); this box is generated by Template:Hastranscript/t. The second will transclude the contents of the transcript page onto the current page; this should be used for shorter transcripts, generally.
Link box
- type - Optional (required if specifying link). Possible types are:
npc
- This option also adds a link to a list of other transcripts (currently available on the wiki) the NPC speaks in; the list is populated via Template:Transcript list.pet
quest
miniquest
event
item
- link - Optional. If the dialogue page is not found at Transcript:{{PAGENAME}} (which should only be the case in exceptional circumstances), used in place of the default link.
Transclusion
- transclude=yes - required to enable transclusion
- page - optional, the name of the page to transclude (without 'Transcript:'); will default to {{PAGENAME}} if not specified
- page1, page2, ..., pageN - multiple pages to transclude, if desired
Examples
Link box
{{hastranscript}}produces:
{{hastranscript|npc}}produces:
Transclusion
{{hastranscript|Lift manual|transclude=yes}}produces:
Template data
Show/hide template's data | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The following information is used by extensions and applications, such as VisualEditor, to help users implement this template onto pages. Please ensure that it is up-to-date. This template is used to indicate and link to a dialogue page for any given article.
|
-- <pre> local p = {} local remove_templates = { 'transcript', 'fromgame', 'god letter', 'incomplete', 'inuse', 'construction', 'lore', 'postbag', 'transcript list' } local ignore_templates = { '!', '*', 'anchortext', 'clear', 'color', 'colour', 'kg', 'nbsp', 'qact', 'quote', 'mes', 'sic', 'titleanchor' } local headerSize = { ['=='] = 1.25, ['==='] = 1.2, ['===='] = 1, ['====='] = 0.95, ['======'] = 0.9 } function p.main(frame) local args = frame:getParent().args local ret = {} -- for handling multiple transcript transclusions on single page for _, v in ipairs(args) do table.insert(ret, p._main(v)) end -- default if #ret == 0 then ret = {p._main(mw.title.getCurrentTitle().text)} end return frame:preprocess(table.concat(ret, '\n')) end function p._main(title) local ret = mw.html.create('div') if title == nil then ret:addClass('seealso') :wikitext(string.format( '[[Transcript:%s]] does not exist. Please create this page or correct this query.', title )) return tostring(ret) end local _t = mw.title.new('Transcript:' .. title) if not _t.exists then ret:addClass('seealso') :wikitext(string.format( '[[Transcript:%s]] does not exist. Please create this page or correct this query.', title )) return tostring(ret) end local _tsplit = mw.text.split(_t:getContent(),'\n') ret :tag('div') :addClass('seealso') :wikitext(string.format( 'The following text is transcluded from [[Transcript:%s]].', title )) :done() local txt = ret:tag('div') :addClass('transcript') for _, _v in ipairs(_tsplit) do local v = _v:lower() local lineToAdd = _v local addLine = true -- look for lines that are a single template if v:find('^{{.*}}$') then -- filter template name local t_name = v:gsub('template:',''):match('{{(.-)[|}]') -- check the kill list for _, w in ipairs(remove_templates) do if w == t_name then addLine = false break end end -- other templates -- we'll see later end -- formatting for headers changes if addLine then local headingtype, headingtitle = _v:match('(=+)(.-)(=+)') if headingtype and headingtitle and headerSize[headingtype] then addLine = false txt :tag('div') :css({ ['font-size'] = headerSize[headingtype] .. 'em', ['font-weight'] = 'bold', ['padding-top'] = '0.5em' }) :wikitext(headingtitle) :done() :tag('hr') :done() end -- remove category transclusion lineToAdd = lineToAdd:gsub('%[%[[Cc]ategory:.-%]%]','') -- remove default sorting :gsub('{{DEFAULTSORT.+}}','') end if addLine then txt:newline() txt:wikitext(lineToAdd) end end return tostring(ret) end return p