RuneScape Wiki
m (and this one)
Tag: sourceedit
mNo edit summary
Tag: sourceedit
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
-- Implements reference templates
 
-- Implements reference templates
 
--[=[
 
--[=[
dependencies
+
dependencies
[[Module:Mainonly]]
+
[[Module:Mainonly]]
[[Module:Reftag]]
+
[[Module:Reftag]]
[[Module:Paramtest]]
+
[[Module:Paramtest]]
[[Module:Yesno]]
+
[[Module:Yesno]]
[[Module:CitePostbag/data]]
+
[[Module:CitePostbag/data]]
 
--]=]
 
--]=]
 
--<nowiki>
 
--<nowiki>
Line 22: Line 22:
 
--create the ref tag to be returned
 
--create the ref tag to be returned
 
local function reftag(frame, reftype)
 
local function reftag(frame, reftype)
local args = frame:getParent().args
+
local args = frame:getParent().args
local s = ''
+
local s = ''
local opts = {}
+
local opts = {}
if args.name then
+
if hc(args.name) then
opts.name = args.name
+
opts.name = args.name
end
+
end
if args.group then
+
if hc(args.group) then
opts.group = args.group
+
opts.group = args.group
end
+
end
  +
 
local ref, cat = r[reftype](args)
+
local ref, cat = r[reftype](args)
opts.text = ref
+
opts.text = ref
  +
 
--return frame:extensionTag({name = 'ref', content = reference, args = opts})
+
--return frame:extensionTag({name = 'ref', content = reference, args = opts})
return tag(opts) .. cat
+
return tag(opts) .. cat
 
end
 
end
   
 
local function plainref(frame, reftype)
 
local function plainref(frame, reftype)
local ref, cat = r[reftype](frame:getParent().args)
+
local ref, cat = r[reftype](frame:getParent().args)
return ref .. cat
+
return ref .. cat
 
end
 
end
   
Line 50: Line 50:
 
--]==]
 
--]==]
 
p.namedref = function(frame)
 
p.namedref = function(frame)
local args = frame:getParent().args
+
local args = frame:getParent().args
local opts = {}
+
local opts = {}
opts.name = args.name or args[1]
+
opts.name = args.name or args[1]
if hc(args.group) then
+
if hc(args.group) then
opts.group = args.group
+
opts.group = args.group
elseif hc(args[2]) then
+
elseif hc(args[2]) then
opts.group = args[2]
+
opts.group = args[2]
end
+
end
opts.selfClosing = true
+
opts.selfClosing = true
return tag(opts)
+
return tag(opts)
 
end
 
end
   
Line 67: Line 67:
 
--]==]
 
--]==]
 
p.reflist = function(frame)
 
p.reflist = function(frame)
local args = frame:getParent().args
+
local args = frame:getParent().args
local div = mw.html.create('div')
+
local div = mw.html.create('div')
if hc(args.group) then
+
if hc(args.group) then
div:wikitext(frame:preprocess('<references group="' .. args.group .. '"/>'))
+
div:wikitext(frame:preprocess('<references group="' .. args.group .. '"/>'))
else
+
else
div:wikitext(frame:preprocess('<references />'))
+
div:wikitext(frame:preprocess('<references />'))
end
+
end
div:addClass('references-small')
+
div:addClass('references-small')
if args.quotes then
+
if not yn(args.quotes) then
div:addClass('hideQuotes')
+
div:addClass('hideQuotes')
end
+
end
if args.colwidth then
+
if args.colwidth then
div :css({ ['-moz-column-width'] = args.colwidth,
+
div :css({ ['-moz-column-width'] = args.colwidth,
['-webkit-column-width'] = args.colwidth,
+
['-webkit-column-width'] = args.colwidth,
['column-width'] = args.colwidth
+
['column-width'] = args.colwidth
  +
})
})
 
elseif args[1] then
+
elseif args[1] then
div :css({ ['-moz-column-count'] = args[1],
+
div :css({ ['-moz-column-count'] = args[1],
['-webkit-column-count'] = args[1],
+
['-webkit-column-count'] = args[1],
['column-count'] = args[1]
+
['column-count'] = args[1]
  +
})
})
 
end
+
end
  +
 
return div
+
return div
 
end
 
end
   
Line 99: Line 99:
 
--]==]
 
--]==]
 
p.devblogref = function(frame)
 
p.devblogref = function(frame)
return reftag(frame, 'devblog')
+
return reftag(frame, 'devblog')
 
end
 
end
   
 
p.devblogplain = function(frame)
 
p.devblogplain = function(frame)
return plainref(frame, 'devblog')
+
return plainref(frame, 'devblog')
 
end
 
end
   
 
r.devblog = function(a)
 
r.devblog = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
+
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
ref = ref .. '. '
+
ref = ref .. '. '
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
+
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. '"' .. a.title .. '."'
+
ref = ref .. '"' .. a.title .. '."'
end
+
end
end
+
end
ref = ref .. ' '
+
ref = ref .. ' '
if hc(a.blogdate) then
+
if hc(a.blogdate) then
ref = ref .. a.blogdate .. '.'
+
ref = ref .. a.blogdate .. '.'
end
+
end
ref = ref .. " Developers' Blogs. "
+
ref = ref .. " Developers' Blogs. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.blogdate)) then --validation, required params are author, url, title and blogdate (mainonly)
+
if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.blogdate)) then --validation, required params are author, url, title and blogdate (mainonly)
c = '[[Category:Incomplete References]]'
+
c = '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 140: Line 140:
 
--]==]
 
--]==]
 
p.devdiaryref = function(frame)
 
p.devdiaryref = function(frame)
return reftag(frame, 'devdiary')
+
return reftag(frame, 'devdiary')
 
end
 
end
   
 
p.devdiaryplain = function(frame)
 
p.devdiaryplain = function(frame)
return plainref(frame, 'devdiary')
+
return plainref(frame, 'devdiary')
 
end
 
end
   
 
r.devdiary = function(a)
 
r.devdiary = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
+
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
ref = ref .. '. '
+
ref = ref .. '. '
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
+
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. '"' .. a.title .. '."'
+
ref = ref .. '"' .. a.title .. '."'
end
+
end
end
+
end
ref = ref .. ' '
+
ref = ref .. ' '
if hc(a.diarydate) then
+
if hc(a.diarydate) then
ref = ref .. a.diarydate .. '.'
+
ref = ref .. a.diarydate .. '.'
end
+
end
ref = ref .. ' Development Diaries. '
+
ref = ref .. ' Development Diaries. '
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.diarydate)) then
+
if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.diarydate)) then
c = '[[Category:Incomplete References]]'
+
c = '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 181: Line 181:
 
--]==]
 
--]==]
 
p.forumref = function(frame)
 
p.forumref = function(frame)
return reftag(frame, 'forum')
+
return reftag(frame, 'forum')
 
end
 
end
   
 
p.forumplain = function(frame)
 
p.forumplain = function(frame)
return plainref(frame, 'forum')
+
return plainref(frame, 'forum')
 
end
 
end
   
 
r.forum = function(a)
 
r.forum = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
+
ref = dt(a.author, 'Jagex') --author, defaults to Jagex
ref = ref .. '. '
+
ref = ref .. '. '
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
+
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. '"' .. a.title .. '."'
+
ref = ref .. '"' .. a.title .. '."'
end
+
end
end
+
end
ref = ref .. ' '
+
ref = ref .. ' '
if hc(a.postdate) then
+
if hc(a.postdate) then
ref = ref .. a.postdate .. '.'
+
ref = ref .. a.postdate .. '.'
end
+
end
ref = ref .. " ''" .. dt(a.forum, 'RuneScape') .. "'' Forums. "
+
ref = ref .. " ''" .. dt(a.forum, 'RuneScape') .. "'' Forums. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() then
+
if onmain() then
if not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.postdate)) then
+
if not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.postdate)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
if a.url and (string.find(a.url, 'forum.runescape.com/', 1, true) or string.find(a.url, 'services.runescape.com/m=forum/', 1, true)) then
+
if a.url and (string.find(a.url, 'forum.runescape.com/', 1, true) or string.find(a.url, 'services.runescape.com/m=forum/', 1, true)) then
c = c .. '[[Category:Unarchived forum references]]'
+
c = c .. '[[Category:Unarchived forum references]]'
end
+
end
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 227: Line 227:
 
--]==]
 
--]==]
 
p.godletterref = function(frame)
 
p.godletterref = function(frame)
return reftag(frame, 'godletter')
+
return reftag(frame, 'godletter')
 
end
 
end
   
 
p.godletterplain = function(frame)
 
p.godletterplain = function(frame)
return plainref(frame, 'godletter')
+
return plainref(frame, 'godletter')
 
end
 
end
   
 
r.godletter = function(a)
 
r.godletter = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = 'Jagex. '
+
ref = 'Jagex. '
  +
 
local str = ''
+
local str = ''
local q = ''
+
local q = ''
if hc(a.issue) then
+
if hc(a.issue) then
q = '"'
+
q = '"'
str = str .. 'God Letter ' .. a.issue
+
str = str .. 'God Letter ' .. a.issue
if hc(a.title) then
+
if hc(a.title) then
str = str .. ' - ' .. a.title
+
str = str .. ' - ' .. a.title
end
+
end
elseif hc(a.title) then
+
elseif hc(a.title) then
q = '"'
+
q = '"'
str = str .. a.title
+
str = str .. a.title
end
+
end
if hc(a.letter) then
+
if hc(a.letter) then
q = '"'
+
q = '"'
str = str .. ', ' .. a.letter
+
str = str .. ', ' .. a.letter
end
+
end
  +
 
if hc(a.archiveurl) or hc(a.url) then --url, if present makes a link
+
if hc(a.archiveurl) or hc(a.url) then --url, if present makes a link
ref = ref .. q
+
ref = ref .. q
if hc(a.archiveurl) then
+
if hc(a.archiveurl) then
ref = ref .. '[' .. a.archiveurl
+
ref = ref .. '[' .. a.archiveurl
else
+
else
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
end
+
end
  +
 
if str ~= '' then
+
if str ~= '' then
ref = ref .. ' ' .. str--if title not present leave as link
+
ref = ref .. ' ' .. str--if title not present leave as link
end
+
end
ref = ref .. ']' .. q
+
ref = ref .. ']' .. q
else
+
else
ref = ref .. q .. str .. q
+
ref = ref .. q .. str .. q
end
+
end
  +
 
if hc(a.archiveurl) then
+
if hc(a.archiveurl) then
ref = ref .. ' (Archived from '
+
ref = ref .. ' (Archived from '
if hc(a.url) then
+
if hc(a.url) then
ref = ref .. '[' .. a.url .. ' the original]'
+
ref = ref .. '[' .. a.url .. ' the original]'
else
+
else
ref = ref .. 'the original'
+
ref = ref .. 'the original'
end
+
end
if hc(a.archivedate) then
+
if hc(a.archivedate) then
ref = ref .. ' on ' .. a.archivedate
+
ref = ref .. ' on ' .. a.archivedate
end
+
end
ref = ref .. '.)'
+
ref = ref .. '.)'
end
+
end
  +
 
ref = ref .. " ''RuneScape'' God Letters. "
+
ref = ref .. " ''RuneScape'' God Letters. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.issue)) then
+
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.issue)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 299: Line 299:
 
--]==]
 
--]==]
 
p.loreref = function(frame)
 
p.loreref = function(frame)
return reftag(frame, 'lore')
+
return reftag(frame, 'lore')
 
end
 
end
   
 
p.loreplain = function(frame)
 
p.loreplain = function(frame)
return plainref(frame, 'lore')
+
return plainref(frame, 'lore')
 
end
 
end
   
 
r.lore = function(a)
 
r.lore = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = 'Jagex. '
+
ref = 'Jagex. '
  +
 
local str = ''
+
local str = ''
if hc(a.title) then
+
if hc(a.title) then
str = str .. a.title
+
str = str .. a.title
if hc(a.sectitle) and not yn(a.sectitle, true) then
+
if hc(a.sectitle) and yn(a.sectitle, true) then
str = str .. ', ' .. a.sectitle
+
str = str .. ', ' .. a.sectitle
end
+
end
elseif hc(a.sectitle) and yn(a.sectitle, true) then
+
elseif hc(a.sectitle) and yn(a.sectitle, true) then
str = str .. a.sectitle
+
str = str .. a.sectitle
end
+
end
if str ~= '' then
+
if str ~= '' then
str = '"' .. str .. '."'
+
str = '"' .. str .. '."'
end
+
end
  +
 
  +
 
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if str ~= '' then
+
if str ~= '' then
ref = ref .. ' ' .. str--if title not present leave as link
+
ref = ref .. ' ' .. str--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
ref = ref .. str
+
ref = ref .. str
end
+
end
ref = ref .. " ''RuneScape'' Lores and Histories. "
+
ref = ref .. " ''RuneScape'' Lores and Histories. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
+
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 348: Line 348:
 
--]==]
 
--]==]
 
p.newsref = function(frame)
 
p.newsref = function(frame)
return reftag(frame, 'news')
+
return reftag(frame, 'news')
 
end
 
end
   
 
p.newsplain = function(frame)
 
p.newsplain = function(frame)
return plainref(frame, 'news')
+
return plainref(frame, 'news')
 
end
 
end
   
 
r.news = function(a)
 
r.news = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
if hc(a.author) then
+
if hc(a.author) then
ref = a.author .. '. '
+
ref = a.author .. '. '
else
+
else
ref = 'Jagex. '
+
ref = 'Jagex. '
end
+
end
  +
 
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
+
ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. '"' .. a.title .. '."'
+
ref = ref .. '"' .. a.title .. '."'
end
+
end
end
+
end
ref = ref .. ' '
+
ref = ref .. ' '
if hc(a.newsdate) then
+
if hc(a.newsdate) then
ref = ref .. a.newsdate .. '.'
+
ref = ref .. a.newsdate .. '.'
end
+
end
ref = ref .. " ''RuneScape'' News. "
+
ref = ref .. " ''RuneScape'' News. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.newsdate)) then
+
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.newsdate)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 393: Line 393:
 
--]==]
 
--]==]
 
p.npcref = function(frame)
 
p.npcref = function(frame)
return reftag(frame, 'npc')
+
return reftag(frame, 'npc')
 
end
 
end
   
 
p.npcplain = function(frame)
 
p.npcplain = function(frame)
return plainref(frame, 'npc')
+
return plainref(frame, 'npc')
 
end
 
end
   
 
r.npc = function(a)
 
r.npc = function(a)
local ref = ''
+
local ref = ''
local c = ''
+
local c = ''
if hc(a.npc) then
+
if hc(a.npc) then
ref = ref .. '[[' .. a.npc .. ']], '
+
ref = ref .. '[[' .. a.npc .. ']], '
end
+
end
if hc(a.loc) then
+
if hc(a.loc) then
ref = ref .. '"[[' .. a.loc .. ']]", '
+
ref = ref .. '"[[' .. a.loc .. ']]", '
end
+
end
ref = ref .. "''RuneScape''. "
+
ref = ref .. "''RuneScape''. "
  +
 
if hc(a.quote) then
+
if hc(a.quote) then
local span = mw.html.create('span')
+
local span = mw.html.create('span')
  +
:wikitext('"' .. a.quote .. '" ')
:addClass('refhide')
 
  +
ref = ref .. tostring(span)
:wikitext('"' .. a.quote .. '" ')
 
  +
end
ref = ref .. tostring(span)
 
  +
end
 
  +
ref = ref .. (a.notes or '')
 
  +
ref = ref .. (a.notes or '')
 
  +
if onmain() and not (hc(a.npc) and hc(a.quote)) then
 
  +
c = c .. '[[Category:Incomplete references]]'
if onmain() and not (hc(a.npc) and hc(a.quote)) then
 
  +
end
c = c .. '[[Category:Incomplete References]]'
 
  +
return ref, c
end
 
return ref, c
 
 
end
 
end
   
Line 431: Line 430:
 
--]==]
 
--]==]
 
p.pollref = function(frame)
 
p.pollref = function(frame)
return reftag(frame, 'poll')
+
return reftag(frame, 'poll')
 
end
 
end
   
 
p.pollplain = function(frame)
 
p.pollplain = function(frame)
return plainref(frame, 'poll')
+
return plainref(frame, 'poll')
 
end
 
end
   
 
r.poll = function(a)
 
r.poll = function(a)
local ref = 'Jagex. '
+
local ref = 'Jagex. '
local c = ''
+
local c = ''
  +
 
local str = ''
+
local str = ''
if hc(a.poll) then
+
if hc(a.poll) then
str = str .. '"' .. a.poll .. '"'
+
str = str .. '"' .. a.poll .. '"'
if hc(a.question) and string.lower(a.question) ~= 'no' then
+
if hc(a.question) and yn(a.question, true) then
str = str .. ', Question ' .. a.question
+
str = str .. ', Question ' .. a.question
end
+
end
elseif hc(a.question) and string.lower(a.question) ~= 'no' then
+
elseif hc(a.question) and yn(a.question, true) then
str = str .. 'Question ' .. a.question
+
str = str .. 'Question ' .. a.question
end
+
end
if str ~= '' then
+
if str ~= '' then
str = str .. '.'
+
str = str .. '.'
end
+
end
  +
 
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if str ~= '' then
+
if str ~= '' then
ref = ref .. ' ' .. str--if title not present leave as link
+
ref = ref .. ' ' .. str--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
ref = ref .. str
+
ref = ref .. str
end
+
end
ref = ref .. ' '
+
ref = ref .. ' '
if hc(a.polldate) then
+
if hc(a.polldate) then
ref = ref .. a.polldate .. '.'
+
ref = ref .. a.polldate .. '.'
end
+
end
ref = ref .. " ''RuneScape'' Polls. "
+
ref = ref .. " ''RuneScape'' Polls. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.url) and hc(a.poll) and hc(a.question) and hc(a.polldate)) then
+
if onmain() and not (hc(a.url) and hc(a.poll) and hc(a.question) and hc(a.polldate)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 482: Line 481:
 
--]==]
 
--]==]
 
p.postbagref = function(frame)
 
p.postbagref = function(frame)
return reftag(frame, 'postbag')
+
return reftag(frame, 'postbag')
 
end
 
end
   
 
p.postbagplain = function(frame)
 
p.postbagplain = function(frame)
return plainref(frame, 'postbag')
+
return plainref(frame, 'postbag')
 
end
 
end
   
 
r.postbag = function(a)
 
r.postbag = function(a)
local ref = 'Jagex. '
+
local ref = 'Jagex. '
local c = ''
+
local c = ''
  +
 
  +
local anchor = false
local anchor
 
  +
local anchorval
local pbname = postbags[tonumber(a.issue)]
 
  +
local pbname = postbags[tonumber(a.issue)]
 
  +
if hc(a.letter) then
 
anchor = a.letter
+
if hc(a.letter) then
  +
anchorval = a.letter
if anchor == tostring(tonumber(anchor)) then
 
anchor = tonumber(anchor)
+
if anchorval == tostring(tonumber(anchor)) then
  +
anchorval = tonumber(anchor)
if anchor == math.floor(anchor) and anchor >= 1 and anchor <= 15 then
 
anchor = true
+
if anchorval == math.floor(anchor) and anchor >= 1 and anchor <= 15 then
  +
anchor = true
end
 
end
+
end
end
+
end
  +
end
 
  +
if hc(a.issue) then
 
if pbname then
+
if hc(a.issue) then
  +
if pbname then
ref = ref .. 'Postbag ' .. a.issue .. ' - "[[' .. pbname .. '#'
 
if anchor then
+
ref = ref .. 'Postbag ' .. a.issue .. ' - "[[' .. pbname .. '#'
  +
if anchor then
ref = ref .. 'letter ' .. a.letter
 
  +
ref = ref .. 'letter ' .. a.letter
else
 
  +
else
ref = ref .. a.letter
 
  +
ref = ref .. a.letter
end
 
  +
end
ref = ref .. '|' .. pbname .. ']]"'
 
else
+
ref = ref .. '|' .. pbname .. ']]"'
  +
else
ref = ref .. 'Postbag ' .. a.issue
 
  +
ref = ref .. 'Postbag ' .. a.issue
if hc(a.title) then
 
  +
if hc(a.title) then
ref = ref .. ' - "' .. a.title .. '"'
 
end
+
ref = ref .. ' - "' .. a.title .. '"'
end
+
end
  +
end
elseif hc(a.title) then
 
  +
elseif hc(a.title) then
ref = ref .. '"' .. a.title .. '"'
 
  +
ref = ref .. '"' .. a.title .. '"'
end
 
  +
end
if hc(a.letter) then
 
if ref ~= '' then
+
if hc(a.letter) then
ref = ref .. ', '
+
if ref ~= '' then
  +
ref = ref .. ', '
end
 
  +
end
if anchor then
 
  +
if anchor then
ref = ref .. 'letter #' .. a.letter
 
  +
ref = ref .. 'letter #' .. a.letter
else
 
  +
else
ref = ref .. a.letter
 
  +
ref = ref .. a.letter
end
 
end
+
end
  +
end
 
  +
if hc(a.author) then
 
  +
if hc(a.author) then
ref = ref .. ', by' .. a.author
 
  +
ref = ref .. ', by ' .. a.author
end
 
  +
end
 
  +
ref = ref .. ". ''RuneScape'' Postbags from the Hedge. "
 
ref = ref .. (a.notes or '')
+
ref = ref .. ". ''RuneScape'' Postbags from the Hedge. "
  +
ref = ref .. (a.notes or '')
 
  +
if onmain() and not (hc(a.issue) and hc(a.letter) and hc(a.author)) then
 
  +
if onmain() and not (hc(a.issue) and hc(a.letter) and hc(a.author)) then
c = c .. '[[Category:Incomplete References]]'
 
  +
c = c .. '[[Category:Incomplete references]]'
end
 
  +
end
return ref, c
 
  +
return ref, c
 
end
 
end
   
Line 553: Line 553:
 
--]==]
 
--]==]
 
p.supportref = function(frame)
 
p.supportref = function(frame)
return reftag(frame, 'support')
+
return reftag(frame, 'support')
 
end
 
end
   
 
p.supportplain = function(frame)
 
p.supportplain = function(frame)
return plainref(frame, 'support')
+
return plainref(frame, 'support')
 
end
 
end
   
 
r.support = function(a)
 
r.support = function(a)
local ref = 'Jagex. '
+
local ref = 'Jagex. '
local c = ''
+
local c = ''
  +
 
local str = ''
+
local str = ''
if hc(a.title) then
+
if hc(a.title) then
str = str .. a.title
+
str = str .. a.title
if hc(a.sectitle) then
+
if hc(a.sectitle) and yn(a.sectitle, true) then
str = str .. ', ' .. a.sectitle
+
str = str .. ', ' .. a.sectitle
end
+
end
  +
elseif hc(a.sectitle) and yn(a.sectitle, true) then
else
 
str = str .. (a.sectitle or '')
+
str = str .. a.sectitle
end
+
end
if str ~= '' then
+
if str ~= '' then
str = '"' .. str .. '."'
+
str = '"' .. str .. '."'
end
+
end
  +
 
  +
 
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) then --url, if present makes a link
ref = ref .. '[' .. a.url
+
ref = ref .. '[' .. a.url
if str ~= '' then
+
if str ~= '' then
ref = ref .. ' ' .. str--if title not present leave as link
+
ref = ref .. ' ' .. str--if title not present leave as link
end
+
end
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
ref = ref .. str
+
ref = ref .. str
end
+
end
ref = ref .. " ''RuneScape'' Customer Support. "
+
ref = ref .. " ''RuneScape'' Customer Support. "
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
+
if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
  +
end
  +
  +
--[==[
  +
[[Template:CiteText]] and [[Template:PlainCiteText]]
  +
--]==]
  +
p.textref = function(frame)
  +
return reftag(frame, 'text')
  +
end
  +
  +
p.textplain = function(frame)
  +
return plainref(frame, 'text')
  +
end
  +
  +
r.text = function(a)
  +
local ref = ''
  +
local c = ''
  +
if hc(a.text) then
  +
ref = ref .. '[[' .. a.text .. ']], '
  +
end
  +
if hc(a.author) then
  +
ref = ref .. 'written by [[' .. a.author .. ']], '
  +
end
  +
if hc(a.page) then
  +
ref = ref .. 'page ' .. a.page .. ', '
  +
end
  +
if hc(a.loc) then
  +
ref = ref .. '"[[' .. a.loc .. ']]", '
  +
end
  +
ref = ref .. "''RuneScape''. "
  +
  +
if hc(a.quote) then
  +
local span = mw.html.create('span')
  +
:wikitext('"' .. a.quote .. '" ')
  +
ref = ref .. tostring(span)
  +
end
  +
  +
ref = ref .. (a.notes or '')
  +
  +
if onmain() and not (hc(a.text) and hc(a.quote)) then
  +
c = c .. '[[Category:Incomplete references]]'
  +
end
  +
return ref, c
 
end
 
end
   
Line 604: Line 646:
 
--]==]
 
--]==]
 
p.pubref = function(frame)
 
p.pubref = function(frame)
return reftag(frame, 'pub')
+
return reftag(frame, 'pub')
 
end
 
end
   
 
p.pubplain = function(frame)
 
p.pubplain = function(frame)
return plainref(frame, 'pub')
+
return plainref(frame, 'pub')
 
end
 
end
   
 
r.pub = function(a)
 
r.pub = function(a)
local ref = ''
+
local ref = ''
local c = ''
+
local c = ''
  +
 
if hc(a.author) then
+
if hc(a.author) then
ref = a.author .. '. '
+
ref = a.author .. '. '
end
+
end
  +
 
local str = ''
+
local str = ''
if hc(a.title) then
+
if hc(a.title) then
ref = ref .. "''" .. a.title .. "''"
+
ref = ref .. "''" .. a.title .. "''"
if hc(a.pages) then
+
if hc(a.pages) then
ref = ref .. ', (' .. a.pages .. ')'
+
ref = ref .. ', (' .. a.pages .. ')'
end
+
end
ref = ref .. '. '
+
ref = ref .. '. '
end
+
end
if hc(a.publisher) then
+
if hc(a.publisher) then
ref = ref .. a.publisher
+
ref = ref .. a.publisher
if hc(a.pubyear) then
+
if hc(a.pubyear) then
ref = ref .. ', ' .. a.pubyear
+
ref = ref .. ', ' .. a.pubyear
end
+
end
ref = ref .. '. '
+
ref = ref .. '. '
elseif hc(a.pubyear) then
+
elseif hc(a.pubyear) then
ref = ref .. a.pubyear .. '. '
+
ref = ref .. a.pubyear .. '. '
end
+
end
ref = ref .. (a.notes or '')
+
ref = ref .. (a.notes or '')
  +
 
if onmain() and not (hc(a.title) and hc(a.publisher) and hc(a.pubyear)) then
+
if onmain() and not (hc(a.title) and hc(a.publisher) and hc(a.pubyear)) then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   
Line 649: Line 691:
 
--]==]
 
--]==]
 
p.twitterref = function(frame)
 
p.twitterref = function(frame)
return reftag(frame, 'twitter')
+
return reftag(frame, 'twitter')
 
end
 
end
   
 
p.twitterplain = function(frame)
 
p.twitterplain = function(frame)
return plainref(frame, 'twitter')
+
return plainref(frame, 'twitter')
 
end
 
end
   
 
r.twitter = function(a)
 
r.twitter = function(a)
local ref
+
local ref
local c = ''
+
local c = ''
ref = 'Jagex. '
+
ref = 'Jagex. '
  +
 
if hc(a.url) then --url, if present makes a link
+
if hc(a.url) or hc(a.archiveurl) then --url, if present makes a link
  +
if hc(a.archiveurl) then
ref = ref .. '[' .. a.url
 
  +
ref = ref .. '[' .. a.archiveurl
if hc(a.author) then
 
  +
elseif hc(a.url) then
ref = ref .. ' ' .. a.author .. "'s Twitter account"--if title not present leave as link
 
end
+
ref = ref .. '[' .. a.url
  +
end
ref = ref .. ']. '
 
elseif hc(a.author) then
+
if hc(a.author) then
ref = ref .. ' ' .. a.author .. "'s Twitter account. "
+
ref = ref .. ' ' .. a.author .. "'s Twitter account"--if title not present leave as link
end
+
end
  +
ref = ref .. ']. '
 
if hc(a.date) then
+
elseif hc(a.author) then
ref = ref .. a.date .. '. '
+
ref = ref .. ' ' .. a.author .. "'s Twitter account. "
end
+
end
  +
if hc(a.quote) then
 
if hc(a.author) then
+
if hc(a.date) then
ref = ref .. a.author .. ': '
+
ref = ref .. a.date .. '. '
end
+
end
  +
ref = ref .. '"' .. a.quote .. '" '
 
  +
if hc(a.archivedate) then
end
 
ref = ref .. (a.notes or '')
+
ref = ref .. ' (Archived from [' .. a.url .. ' the original] on ' .. a.archivedate .. '.) '
  +
end
 
  +
if onmain() and not (hc(a.url) and hc(a.author) and hc(a.quote) and hc(a.date)) then
 
  +
if hc(a.quote) then
c = c .. '[[Category:Incomplete References]]'
 
  +
if hc(a.author) then
end
 
  +
ref = ref .. a.author .. ': '
return ref, c
 
  +
end
  +
ref = ref .. '"' .. a.quote .. '" '
  +
end
  +
ref = ref .. (a.notes or '')
  +
  +
  +
local err = ''
  +
if not (hc(a.url) and hc(a.author) and hc(a.quote) and hc(a.date)) then
  +
err = err .. "Error calling CiteTwitter: parameters '''url''', '''author''', '''quote''', and '''date''' must be specified.<br />"
  +
end
  +
  +
if hc(a.archiveurl) ~= hc(a.archivedate) then --xor
  +
err = err .. "Error calling CiteTwitter: parameters '''archiveurl''' and '''archivedate''' must both be specified or both be unspecified.<br />"
  +
end
  +
  +
  +
if onmain() and err ~= '' then
  +
c = c .. '[[Category:Incomplete references]]'
  +
end
  +
  +
return ref, c
 
end
 
end
   
Line 694: Line 757:
 
--]==]
 
--]==]
 
p.generalref = function(frame)
 
p.generalref = function(frame)
return reftag(frame, 'general')
+
return reftag(frame, 'general')
 
end
 
end
   
 
p.generalplain = function(frame)
 
p.generalplain = function(frame)
return plainref(frame, 'general')
+
return plainref(frame, 'general')
 
end
 
end
   
 
r.general = function(a)
 
r.general = function(a)
local ref = ''
+
local ref = ''
local c = ''
+
local c = ''
local str = ''
+
local str = ''
  +
 
if hc(a.author) or hc(a.last) then
+
if hc(a.author) or hc(a.last) then
if hc(a.last) then
+
if hc(a.last) then
str = a.last
+
str = a.last
if hc(a.first) then
+
if hc(a.first) then
str = str .. ', ' .. a.first
+
str = str .. ', ' .. a.first
  +
end
end
 
else
+
else
str = a.author
+
str = a.author
end
+
end
  +
 
if hc(a.authorlink) then
+
if hc(a.authorlink) then
ref = ref .. '[' .. a.authorlink
+
ref = ref .. '[' .. a.authorlink
if str ~= '' then
+
if str ~= '' then
ref = ref .. ' ' .. str
+
ref = ref .. ' ' .. str
  +
end
end
 
ref = ref .. ']'
+
ref = ref .. ']'
else
+
else
ref = ref .. str
+
ref = ref .. str
end
+
end
  +
 
if hc(a.coauthors) then
+
if hc(a.coauthors) then
ref = ref .. '; ' .. a.coauthors
+
ref = ref .. '; ' .. a.coauthors
end
+
end
  +
 
ref = ref .. '. '
+
ref = ref .. '. '
end
+
end
  +
 
if hc(a.title) then
+
if hc(a.title) then
if hc(a.archiveurl) then
+
if hc(a.archiveurl) then
ref = ref .. '[' .. a.archiveurl .. ' ' .. a.title .. ']'
+
ref = ref .. '[' .. a.archiveurl .. ' ' .. a.title .. ']'
elseif hc(a.url) then
+
elseif hc(a.url) then
ref = ref .. '[' .. a.url .. ' ' .. a.title .. ']'
+
ref = ref .. '[' .. a.url .. ' ' .. a.title .. ']'
end
+
end
end
+
end
  +
 
if hc(a.language) then
+
if hc(a.language) then
local span = mw.html.create('span')
+
local span = mw.html.create('span')
:css({['font-size'] = '0.95em', color = '#555', position = 'relative', ['font-weight'] = 'bold'})
+
:css({['font-size'] = '0.95em', color = '#555', position = 'relative', ['font-weight'] = 'bold'})
:wikitext('(' .. a.language .. ')')
+
:wikitext('(' .. a.language .. ')')
ref = ref .. ' ' .. tostring(span)
+
ref = ref .. ' ' .. tostring(span)
end
+
end
  +
 
if hc(a.format) then
+
if hc(a.format) then
ref = ref .. ' (' .. a.format .. ')'
+
ref = ref .. ' (' .. a.format .. ')'
end
+
end
  +
 
if hc(a.work) then
+
if hc(a.work) then
ref = ref .. ". ''" .. a.work .. "''"
+
ref = ref .. ". ''" .. a.work .. "''"
end
+
end
  +
 
if hc(a.pages) then
+
if hc(a.pages) then
ref = ref .. ' pp. ' .. a.pages
+
ref = ref .. ' pp. ' .. a.pages
end
+
end
  +
 
if hc(a.publisher) then
+
if hc(a.publisher) then
ref = ref .. '. ' .. a.publisher
+
ref = ref .. '. ' .. a.publisher
end
+
end
  +
 
if hc(a.date) then
+
if hc(a.date) then
ref = ref .. '. ' .. a.date
+
ref = ref .. '. ' .. a.date
elseif hc(a.year) then
+
elseif hc(a.year) then
if hc(a.month) then
+
if hc(a.month) then
ref = ref .. '. ' .. a.month .. ' ' .. a.year
+
ref = ref .. '. ' .. a.month .. ' ' .. a.year
else
+
else
ref = ref .. '. ' .. a.year
+
ref = ref .. '. ' .. a.year
end
+
end
end
+
end
  +
 
if ref ~= '' then
+
if ref ~= '' then
ref = ref .. '.'
+
ref = ref .. '.'
end
+
end
  +
 
if hc(a.archivedate) then
+
if hc(a.archivedate) then
ref = ref .. ' (Archived from [' .. a.url .. ' the original] on ' .. a.archivedate .. '.)'
+
ref = ref .. ' (Archived from [' .. a.url .. ' the original] on ' .. a.archivedate .. '.)'
end
+
end
  +
 
if hc(a.quote) then
+
if hc(a.quote) then
ref = ref .. ' "' .. a.quote .. '"'
+
ref = ref .. ' "' .. a.quote .. '"'
end
+
end
  +
 
if hc(a.notes) then
+
if hc(a.notes) then
ref = ref .. ' ' .. a.notes
+
ref = ref .. ' ' .. a.notes
end
+
end
  +
 
local err = ''
+
local err = ''
if not (hc(a.url) and hc(a.title)) then
+
if not (hc(a.url) and hc(a.title)) then
err = err .. "Error calling CiteGeneral: parameters '''url''' and '''title''' must be specified.<br />"
+
err = err .. "Error calling CiteGeneral: parameters '''url''' and '''title''' must be specified.<br />"
end
+
end
if hc(a.archiveurl) ~= hc(a.archivedate) then --xor
+
if hc(a.archiveurl) ~= hc(a.archivedate) then --xor
err = err .. "Error calling CiteGeneral: parameters '''archiveurl''' and '''archivedate''' must both be specified or both be unspecified.<br />"
+
err = err .. "Error calling CiteGeneral: parameters '''archiveurl''' and '''archivedate''' must both be specified or both be unspecified.<br />"
end
+
end
ref = err .. ref .. mw.getCurrentFrame():expandTemplate{title = 'RefDate', args = { (a.accessdate or ''), '180'} }
+
ref = err .. ref .. mw.getCurrentFrame():expandTemplate{title = 'RefDate', args = { (a.accessdate or ''), '180'} }
  +
 
if onmain() and err ~= '' then
+
if onmain() and err ~= '' then
c = c .. '[[Category:Incomplete References]]'
+
c = c .. '[[Category:Incomplete references]]'
end
+
end
return ref, c
+
return ref, c
 
end
 
end
   

Latest revision as of 09:14, 8 September 2017

Documentation for this module may be created at Module:References/doc

-- Implements reference templates
--[=[
	dependencies
	[[Module:Mainonly]]
	[[Module:Reftag]]
	[[Module:Paramtest]]
	[[Module:Yesno]]
	[[Module:CitePostbag/data]]
--]=]
--<nowiki>
local onmain = require('Module:Mainonly').on_main
local tag = require('Module:Reftag')
local paramtest = require('Module:Paramtest')
local hc = paramtest.has_content
local dt = paramtest.default_to
local yn = require('Module:Yesno')
local postbags = mw.loadData('Module:CitePostbag/data')

local p = {} --all template entrance points here
local r = {} --reference formatters here to not expose them to #invoke, and to not clutter p

--create the ref tag to be returned
local function reftag(frame, reftype)
	local args = frame:getParent().args
	local s = ''
	local opts = {}
	if hc(args.name) then
		opts.name = args.name
	end
	if hc(args.group) then
		opts.group = args.group
	end
	
	local ref, cat = r[reftype](args)
	opts.text = ref
	
	--return frame:extensionTag({name = 'ref', content = reference, args = opts})
	return tag(opts) .. cat
end

local function plainref(frame, reftype)
	local ref, cat = r[reftype](frame:getParent().args)
	return ref .. cat
end

------------ Helper Templates -----------------

--[==[
[[Template:NamedRef]]
--]==]
p.namedref = function(frame)
	local args = frame:getParent().args
	local opts = {}
	opts.name = args.name or args[1]
	if hc(args.group) then
		opts.group = args.group
	elseif  hc(args[2]) then
		opts.group = args[2]
	end
	opts.selfClosing = true
	return tag(opts)
end


--[==[
[[Template:Reflist]]
--]==]
p.reflist = function(frame)
	local args = frame:getParent().args
	local div = mw.html.create('div')
	if hc(args.group) then
		div:wikitext(frame:preprocess('<references group="' .. args.group .. '"/>'))
	else
		div:wikitext(frame:preprocess('<references />'))
	end
	div:addClass('references-small')
	if not yn(args.quotes) then
		div:addClass('hideQuotes')
	end
	if args.colwidth then
		div :css({  ['-moz-column-width'] = args.colwidth,
					['-webkit-column-width'] = args.colwidth,
					['column-width'] = args.colwidth
				})
	elseif args[1] then
		div :css({  ['-moz-column-count'] = args[1],
					['-webkit-column-count'] = args[1],
					['column-count'] = args[1]
				})
	end
	
	return div
end

------------RuneScape Citation templates--------------

--[==[
[[Template:CiteDevBlog]] and [[Template:PlainCiteDevBlog]]
--]==]
p.devblogref = function(frame)
	return reftag(frame, 'devblog')
end

p.devblogplain = function(frame)
	return plainref(frame, 'devblog')
end

r.devblog = function(a)
	local ref
	local c = ''
	ref = dt(a.author, 'Jagex') --author, defaults to Jagex
	ref = ref .. '. '
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if hc(a.title) then
			ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
		end
		ref = ref .. ']'
	else
		if hc(a.title) then
			ref = ref .. '"' .. a.title .. '."'
		end
	end
	ref = ref .. ' '
	if hc(a.blogdate) then
		ref = ref .. a.blogdate .. '.'
	end
	ref = ref .. " Developers' Blogs. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.blogdate)) then --validation, required params are author, url, title and blogdate (mainonly)
		c = '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteDevDiary]] and [[Template:PlainCiteDevDiary]]
--]==]
p.devdiaryref = function(frame)
	return reftag(frame, 'devdiary')
end

p.devdiaryplain = function(frame)
	return plainref(frame, 'devdiary')
end

r.devdiary = function(a)
	local ref
	local c = ''
	ref = dt(a.author, 'Jagex') --author, defaults to Jagex
	ref = ref .. '. '
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if hc(a.title) then
			ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
		end
		ref = ref .. ']'
	else
		if hc(a.title) then
			ref = ref .. '"' .. a.title .. '."'
		end
	end
	ref = ref .. ' '
	if hc(a.diarydate) then
		ref = ref .. a.diarydate .. '.'
	end
	ref = ref .. ' Development Diaries. '
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.diarydate)) then
		c = '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteForum]] and [[Template:PlainCiteForum]]
--]==]
p.forumref = function(frame)
	return reftag(frame, 'forum')
end

p.forumplain = function(frame)
	return plainref(frame, 'forum')
end

r.forum = function(a)
	local ref
	local c = ''
	ref = dt(a.author, 'Jagex') --author, defaults to Jagex
	ref = ref .. '. '
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if hc(a.title) then
			ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
		end
		ref = ref .. ']'
	else
		if hc(a.title) then
			ref = ref .. '"' .. a.title .. '."'
		end
	end
	ref = ref .. ' '
	if hc(a.postdate) then
		ref = ref .. a.postdate .. '.'
	end
	ref = ref .. " ''" .. dt(a.forum, 'RuneScape') .. "'' Forums. "
	ref = ref .. (a.notes or '')
	
	if onmain() then
		if not (hc(a.author) and hc(a.url) and hc(a.title) and hc(a.postdate)) then
			c = c .. '[[Category:Incomplete references]]'
		end
		if a.url and (string.find(a.url, 'forum.runescape.com/', 1, true) or string.find(a.url, 'services.runescape.com/m=forum/', 1, true)) then
			c = c .. '[[Category:Unarchived forum references]]'
		end
	end
	return ref, c
end


--[==[
[[Template:CiteGodLetter]] and [[Template:PlainCiteGodLetter]]
--]==]
p.godletterref = function(frame)
	return reftag(frame, 'godletter')
end

p.godletterplain = function(frame)
	return plainref(frame, 'godletter')
end

r.godletter = function(a)
	local ref
	local c = ''
	ref = 'Jagex. '
	
	local str = ''
	local q = ''
	if hc(a.issue) then
		q = '"'
		str = str .. 'God Letter ' .. a.issue
		if hc(a.title) then
			str = str .. ' - ' .. a.title
		end
	elseif hc(a.title) then
		q = '"'
		str = str .. a.title
	end
	if hc(a.letter) then
		q = '"'
		str = str .. ', ' .. a.letter
	end
	
	if hc(a.archiveurl) or hc(a.url) then --url, if present makes a link
		ref = ref .. q
		if hc(a.archiveurl) then
			ref = ref .. '[' .. a.archiveurl
		else
			ref = ref .. '[' .. a.url
		end
		
		if str ~= '' then
			ref = ref .. ' ' .. str--if title not present leave as link
		end
		ref = ref .. ']' .. q
	else
		ref = ref .. q .. str .. q
	end
	
	if hc(a.archiveurl) then
		ref = ref .. ' (Archived from '
		if hc(a.url) then
			ref = ref .. '[' .. a.url .. ' the original]'
		else
			ref = ref .. 'the original'
		end
		if hc(a.archivedate) then
			ref = ref .. ' on ' .. a.archivedate
		end
		ref = ref .. '.)'
	end
	
	ref = ref .. " ''RuneScape'' God Letters. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.url) and hc(a.title) and hc(a.issue)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteLore]] and [[Template:PlainCiteLore]]
--]==]
p.loreref = function(frame)
	return reftag(frame, 'lore')
end

p.loreplain = function(frame)
	return plainref(frame, 'lore')
end

r.lore = function(a)
	local ref
	local c = ''
	ref = 'Jagex. '
	
	local str = ''
	if hc(a.title) then
		str = str .. a.title
		if hc(a.sectitle) and yn(a.sectitle, true) then
			str = str .. ', ' .. a.sectitle
		end
	elseif hc(a.sectitle) and yn(a.sectitle, true) then
		str = str .. a.sectitle
	end
	if str ~= '' then
		str = '"' .. str .. '."'
	end
	
	
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if str ~= '' then
			ref = ref .. ' ' .. str--if title not present leave as link
		end
		ref = ref .. ']'
	else
		ref = ref .. str
	end
	ref = ref .. " ''RuneScape'' Lores and Histories. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteNews]] and [[Template:PlainCiteNews]]
--]==]
p.newsref = function(frame)
	return reftag(frame, 'news')
end

p.newsplain = function(frame)
	return plainref(frame, 'news')
end

r.news = function(a)
	local ref
	local c = ''
	if hc(a.author) then
		ref = a.author .. '. '
	else
		ref = 'Jagex. '
	end
	
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if hc(a.title) then
			ref = ref .. ' "' .. a.title .. '."'--if title not present leave as link
		end
		ref = ref .. ']'
	else
		if hc(a.title) then
			ref = ref .. '"' .. a.title .. '."'
		end
	end
	ref = ref .. ' '
	if hc(a.newsdate) then
		ref = ref .. a.newsdate .. '.'
	end
	ref = ref .. " ''RuneScape'' News. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.url) and hc(a.title) and hc(a.newsdate)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteNPC]] and [[Template:PlainCiteNPC]]
--]==]
p.npcref = function(frame)
	return reftag(frame, 'npc')
end

p.npcplain = function(frame)
	return plainref(frame, 'npc')
end

r.npc = function(a)
	local ref = ''
	local c = ''
	if hc(a.npc) then
		ref = ref .. '[[' .. a.npc .. ']], '
	end
	if hc(a.loc) then
		ref = ref .. '"[[' .. a.loc .. ']]", '
	end
	ref = ref .. "''RuneScape''. "
	
	if hc(a.quote) then
		local span =	mw.html.create('span')
							:wikitext('"' .. a.quote .. '" ')
		ref = ref .. tostring(span)
	end
	
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.npc) and hc(a.quote)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CitePoll]] and [[Template:PlainCitePoll]]
--]==]
p.pollref = function(frame)
	return reftag(frame, 'poll')
end

p.pollplain = function(frame)
	return plainref(frame, 'poll')
end

r.poll = function(a)
	local ref = 'Jagex. '
	local c = ''
	
	local str = ''
	if hc(a.poll) then
		str = str .. '"' .. a.poll .. '"'
		if hc(a.question) and yn(a.question, true) then
			str = str .. ', Question ' .. a.question
		end
	elseif hc(a.question) and yn(a.question, true) then
		str = str .. 'Question ' .. a.question
	end
	if str ~= '' then
		str = str .. '.'
	end
	
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if str ~= '' then
			ref = ref .. ' ' .. str--if title not present leave as link
		end
		ref = ref .. ']'
	else
		ref = ref .. str
	end
	ref = ref .. ' '
	if hc(a.polldate) then
		ref = ref .. a.polldate .. '.'
	end
	ref = ref .. " ''RuneScape'' Polls. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.url) and hc(a.poll) and hc(a.question) and hc(a.polldate)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CitePostbag]] and [[Template:PlainCitePostbag]]
--]==]
p.postbagref = function(frame)
	return reftag(frame, 'postbag')
end

p.postbagplain = function(frame)
	return plainref(frame, 'postbag')
end

r.postbag = function(a)
	local ref = 'Jagex. '
	local c = ''
	
	local anchor = false
	local anchorval
	local pbname = postbags[tonumber(a.issue)]
	
	if hc(a.letter) then
		anchorval = a.letter
		if anchorval == tostring(tonumber(anchor)) then
			anchorval = tonumber(anchor)
			if anchorval == math.floor(anchor) and anchor >= 1 and anchor <= 15 then
				anchor = true
			end
		end
	end
	
	if hc(a.issue) then
		if pbname then
			ref = ref .. 'Postbag ' .. a.issue .. ' - "[[' .. pbname .. '#'
			if anchor then
				ref = ref .. 'letter ' .. a.letter
			else
				ref = ref .. a.letter
			end
			ref = ref .. '|' .. pbname .. ']]"'
		else
			ref = ref .. 'Postbag ' .. a.issue
			if hc(a.title) then
				ref = ref .. ' - "' .. a.title .. '"'
			end
		end
	elseif hc(a.title) then
		ref = ref .. '"' .. a.title .. '"'
	end
	if hc(a.letter) then
		if ref ~= '' then
			ref = ref .. ', '
		end
		if anchor then
			ref = ref .. 'letter #' .. a.letter
		else
			ref = ref .. a.letter
		end
	end
	
	if hc(a.author) then
		ref = ref .. ', by ' .. a.author
	end
	
	ref = ref .. ". ''RuneScape'' Postbags from the Hedge. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.issue) and hc(a.letter) and hc(a.author)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteSupport]] and [[Template:PlainCiteSupport]]
--]==]
p.supportref = function(frame)
	return reftag(frame, 'support')
end

p.supportplain = function(frame)
	return plainref(frame, 'support')
end

r.support = function(a)
	local ref = 'Jagex. '
	local c = ''
	
	local str = ''
	if hc(a.title) then
		str = str .. a.title
		if hc(a.sectitle) and yn(a.sectitle, true) then
			str = str .. ', ' .. a.sectitle
		end
	elseif hc(a.sectitle) and yn(a.sectitle, true) then
		str = str .. a.sectitle
	end
	if str ~= '' then
		str = '"' .. str .. '."'
	end
	
	
	if hc(a.url) then --url, if present makes a link
		ref = ref .. '[' .. a.url
		if str ~= '' then
			ref = ref .. ' ' .. str--if title not present leave as link
		end
		ref = ref .. ']'
	else
		ref = ref .. str
	end
	ref = ref .. " ''RuneScape'' Customer Support. "
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.url) and hc(a.title) and hc(a.sectitle)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end

--[==[
[[Template:CiteText]] and [[Template:PlainCiteText]]
--]==]
p.textref = function(frame)
	return reftag(frame, 'text')
end

p.textplain = function(frame)
	return plainref(frame, 'text')
end

r.text = function(a)
	local ref = ''
	local c = ''
	if hc(a.text) then
		ref = ref .. '[[' .. a.text .. ']], '
	end
	if hc(a.author) then
	    ref = ref .. 'written by [[' .. a.author .. ']], '
	end
	if hc(a.page) then
	    ref = ref .. 'page ' .. a.page .. ', '
	end
	if hc(a.loc) then
		ref = ref .. '"[[' .. a.loc .. ']]", '
	end
	ref = ref .. "''RuneScape''. "
	
	if hc(a.quote) then
		local span =	mw.html.create('span')
							:wikitext('"' .. a.quote .. '" ')
		ref = ref .. tostring(span)
	end
	
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.text) and hc(a.quote)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


------------ General Citation Templates -----------------


--[==[
[[Template:CitePub]] and [[Template:PlainCitePub]]
--]==]
p.pubref = function(frame)
	return reftag(frame, 'pub')
end

p.pubplain = function(frame)
	return plainref(frame, 'pub')
end

r.pub = function(a)
	local ref = ''
	local c = ''
	
	if hc(a.author) then
		ref = a.author .. '. '
	end
	
	local str = ''
	if hc(a.title) then
		ref = ref .. "''" .. a.title .. "''"
		if hc(a.pages) then
			ref = ref .. ', (' .. a.pages .. ')'
		end
		ref = ref .. '. '
	end
	if hc(a.publisher) then
		ref = ref .. a.publisher
		if hc(a.pubyear) then
			ref = ref .. ', ' .. a.pubyear
		end
		ref = ref .. '. '
	elseif hc(a.pubyear) then
		ref = ref .. a.pubyear .. '. '
	end
	ref = ref .. (a.notes or '')
	
	if onmain() and not (hc(a.title) and hc(a.publisher) and hc(a.pubyear)) then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end


--[==[
[[Template:CiteTwitter]] and [[Template:PlainCiteTwitter]]
--]==]
p.twitterref = function(frame)
	return reftag(frame, 'twitter')
end

p.twitterplain = function(frame)
	return plainref(frame, 'twitter')
end

r.twitter = function(a)
	local ref
	local c = ''
	ref = 'Jagex. '
	
	if hc(a.url) or hc(a.archiveurl) then --url, if present makes a link
		if hc(a.archiveurl) then
			ref = ref .. '[' .. a.archiveurl
		elseif hc(a.url) then
			ref = ref .. '[' .. a.url
		end
		if hc(a.author) then
			ref = ref .. ' ' .. a.author .. "'s Twitter account"--if title not present leave as link
		end
		ref = ref .. ']. '
	elseif hc(a.author) then
		ref = ref .. ' ' .. a.author .. "'s Twitter account. "
	end
	
	if hc(a.date) then
		ref = ref .. a.date .. '. '
	end
	
	if hc(a.archivedate) then
		ref = ref .. ' (Archived from [' .. a.url .. ' the original] on ' .. a.archivedate .. '.) '
	end
	
	if hc(a.quote) then
		if hc(a.author) then
			ref = ref .. a.author .. ': '
		end
		ref = ref .. '"' .. a.quote .. '" '
	end
	ref = ref .. (a.notes or '')
	
	
	local err = ''
	if not (hc(a.url) and hc(a.author) and hc(a.quote) and hc(a.date)) then
		err = err .. "Error calling CiteTwitter: parameters '''url''', '''author''', '''quote''', and '''date''' must be specified.<br />"
	end
	
	if hc(a.archiveurl) ~= hc(a.archivedate) then --xor
		err = err .. "Error calling CiteTwitter: parameters '''archiveurl''' and '''archivedate''' must both be specified or both be unspecified.<br />"
	end
	
	
	if onmain() and err ~= '' then
		c = c .. '[[Category:Incomplete references]]'
	end
	
	return ref, c
end



--[==[
[[Template:CiteGeneral]] and [[Template:PlainCiteGeneral]]
--]==]
p.generalref = function(frame)
	return reftag(frame, 'general')
end

p.generalplain = function(frame)
	return plainref(frame, 'general')
end

r.general = function(a)
	local ref = ''
	local c = ''
	local str = ''
	
	if hc(a.author) or hc(a.last) then
		if hc(a.last) then
			str = a.last
			if hc(a.first) then
				str = str .. ', ' .. a.first
			end
		else
			str = a.author
		end
		
		if hc(a.authorlink) then
			ref = ref .. '[' .. a.authorlink
			if str ~= '' then
				ref = ref .. ' ' .. str
			end
			ref = ref .. ']'
		else
			ref = ref .. str
		end
		
		if hc(a.coauthors) then
			ref = ref .. '; ' .. a.coauthors
		end
		
		ref = ref .. '. '
	end
	
	if hc(a.title) then
		if hc(a.archiveurl) then
			ref = ref .. '[' .. a.archiveurl .. ' ' .. a.title .. ']'
		elseif hc(a.url) then
			ref = ref .. '[' .. a.url .. ' ' .. a.title .. ']'
		end
	end
	
	if hc(a.language) then
		local span =	mw.html.create('span')
							:css({['font-size'] = '0.95em', color = '#555', position = 'relative', ['font-weight'] = 'bold'})
							:wikitext('(' .. a.language .. ')')
		ref = ref .. ' ' .. tostring(span)
	end
	
	if hc(a.format) then
		ref = ref .. ' (' .. a.format .. ')'
	end
	
	if hc(a.work) then
		ref = ref .. ". ''" .. a.work .. "''"
	end
	
	if hc(a.pages) then
		ref = ref .. ' pp. ' .. a.pages
	end
	
	if hc(a.publisher) then
		ref = ref .. '. ' .. a.publisher
	end
	
	if hc(a.date) then
		ref = ref .. '. ' .. a.date
	elseif hc(a.year) then
		if hc(a.month) then
			ref = ref .. '. ' .. a.month .. ' ' .. a.year
		else
			ref = ref .. '. ' .. a.year
		end
	end
	
	if ref ~= '' then
		ref = ref .. '.'
	end
	
	if hc(a.archivedate) then
		ref = ref .. ' (Archived from [' .. a.url .. ' the original] on ' .. a.archivedate .. '.)'
	end
	
	if hc(a.quote) then
		ref = ref .. ' "' .. a.quote .. '"'
	end
	
	if hc(a.notes) then
		ref = ref .. ' ' .. a.notes
	end
	
	local err = ''
	if not (hc(a.url) and hc(a.title)) then
		err = err .. "Error calling CiteGeneral: parameters '''url''' and '''title''' must be specified.<br />"
	end
	if hc(a.archiveurl) ~= hc(a.archivedate) then --xor
		err = err .. "Error calling CiteGeneral: parameters '''archiveurl''' and '''archivedate''' must both be specified or both be unspecified.<br />"
	end
	ref = err .. ref .. mw.getCurrentFrame():expandTemplate{title = 'RefDate', args = { (a.accessdate or ''), '180'} }
	
	if onmain() and err ~= '' then
		c = c .. '[[Category:Incomplete references]]'
	end
	return ref, c
end

return p