Módulo:Notícia
Ir para navegação
Ir para pesquisar
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:Notícia/doc. [editar]
Módulo:Notícia's a função datedpl é invocada por Predefinição:Página dia dpl.
Módulo:Notícia's a função update é invocada por Predefinição:Notícia.
Módulo:Notícia requer Módulo:LanguageUtil.
Módulo:Notícia requer Módulo:Paramtest.
Módulo:Notícia transclui {{!}} usando frame:preprocess().
Módulo:Notícia transclui {{DISPLAYTITLE}} usando frame:preprocess().
Módulo:Notícia transclui Predefinição:Parentitle override usando frame:preprocess().
--<nowiki>
-- IMPORTS
local pt = require('Módulo:Paramtest')
local hc = pt.has_content
local dt = pt.default_to
local langUtil = require('Módulo:LanguageUtil')
-- exposed table
local p = {}
--[=[
--
-- HELPER TABLES AND FUNCTIONS
--
--]=]
-- replacement before calling encode
-- as lua patterns
local repl_before = {
['%&%#32%;'] = '-',
['%('] = '',
['%)'] = '',
['%!'] = '',
['%&'] = '',
["%'"] = '',
['%#'] = '',
['%|'] = '',
['%"'] = '',
['%$'] = '',
['%£'] = '',
['%%'] = '',
['%+'] = '',
['”'] = '',
['’'] = '',
['…'] = '',
['ñ'] = 'n',
['ö'] = 'o',
}
-- replacements after calling encode
-- as lua patterns
local repl_after = {
['%+'] = '-',
['%%2C'] = '',
['%%2F'] = '',
['%%3F'] = '',
['%%26%%2338%%3B'] = '',
['%%E2%%80%%93'] = '',
['%.'] = '',
['%%26quot%%3B'] = '',
['%%26%%2339%%3B'] = '',
['%%3A'] = '',
}
-- converting month names to hex for sortkeys
local hexmonthconv = {
['janeiro'] = '1',
['fevereiro'] = '2',
['março'] = '3',
['abril'] = '4',
['maio'] = '5',
['junho'] = '6',
['julho'] = '7',
['agosto'] = '8',
['setembro'] = '9',
['outubro'] = 'A',
['novembro'] = 'B',
['dezembro'] = 'C',
}
-- category mapping: {category name, type for use on date pages (eg [[28 November]])
local category_info = {
bts = {'Notícias de Bastidores', 'Bastidores'},
community = {'Notícias da Comunidade', 'Comunidade'},
devblog = {'Blog dos Desenvolvedores', 'Blog dos Desenvolvedores'},
event = {'Notícias de Eventos', 'Eventos'},
feedback = {'Notícias de Feedback', 'Seu Feedback'},
future = {'Notícias Futuras', 'Atualizações Futuras'},
game = {'Notícias do Jogo', 'Atualizações do Jogo'},
shop = {'Notícias da Loja', 'Loja'},
sof = {'Notícias da Roda da Fortuna', 'Roda da Fortuna'},
sgs = {'Notícias do Shopping do Salomão', 'Shopping do Salomão'},
support = {'Notícias de Suporte', 'Suporte'},
technical = {'Notícias de Suporte Técnico', 'Suporte Técnico'},
th = {'Notícias das Arcas do Tesouro', 'Arcas do Tesouro'},
website = {'Notícias do Site', 'Site'},
competitions = {'Notícias de Competições', 'Competições'},
mobile = {'Notícias da Versão Móvel', 'Versão Móvel'},
['#default'] = {'Sem categoria de notícia', ''},
}
-- input mapping: accepted inputs -> keys for above table
local cat_switch = {
bts = 'bts',
['behind the scenes'] = 'bts',
bastidores = 'bts',
comm = 'community',
community = 'community',
comunidade = 'community',
dev = 'devblog',
blog = 'devblog',
['dev blog'] = 'devblog',
['dev blogs'] = 'devblog',
['blog dos desenvolvedores'] = 'devblog',
devblog = 'devblog',
event = 'event',
events = 'event',
eventos = 'event',
evento = 'event',
fb = 'feedback',
feedback = 'feedback',
yourfeedback = 'feedback',
['your feedback'] = 'feedback',
seufeedback = 'feedback',
['seu feedback'] = 'feedback',
future = 'future',
futuro = 'future',
futuras = 'future',
['atualizações futuras'] = 'future',
game = 'game',
jogo = 'game',
['atualizações do jogo'] = 'game',
shop = 'shop',
loja = 'shop',
ss = 'sgs',
sgs = 'sgs',
solomon = 'sgs',
salomao = 'sgs',
['salomão'] = 'sgs',
['solomon\'s store'] = 'sgs',
['shopping do salomão'] = 'sgs',
['shopping do salomao'] = 'sgs',
sof = 'sof',
roda = 'sof',
squeal = 'sof',
cs = 'support',
customer = 'support',
cliente = 'support',
['customer support'] = 'support',
['suporte ao cliente'] = 'support',
support = 'support',
suporte = 'support',
tech = 'technical',
technical = 'technical',
['suporte técnico'] = 'technical',
th = 'th',
arcas = 'th',
treasure = 'th',
tesouro = 'th',
['treasure hunter'] = 'th',
['arcas do tesouro'] = 'th',
site = 'website',
ws = 'website',
website = 'website',
competitions = 'competitions',
['competições'] = 'competitions',
competicoes = 'competitions',
mobile = 'mobile',
['#default'] = '#default'
}
-- given a supported 'category' code, return the name of the category
function get_update_category(catarg)
if hc(catarg) then
catarg = string.gsub(string.lower(catarg), ' ?updates?', '')
if cat_switch[catarg] and category_info[cat_switch[catarg]] then
return category_info[cat_switch[catarg]][1]
else
return category_info[cat_switch['#default']][1]
end
else
return category_info[cat_switch['#default']][1]
end
end
-- given d,m,y, return the relevant time-based categories (with sorting)
function get_time_categories(day, month, year)
local ret = {}
local hexmonth, dayzero
if not day or not month or not hexmonthconv[month] or not year then
table.insert(ret, '[[Categoria:Sem data de atualização]]')
else
dayzero = ((tonumber(day) < 10 and '0'..day) or day)
hexmonth = hexmonthconv[month]
-- [[Categoria:Notícias de 28 de novembro]], sorted by year (eg 2015)
table.insert(ret, string.format('[[Categoria:Notícias de %s de %s|%s%s%s]]', day, month, year, hexmonth, dayzero))
-- [[Categoria:Notícias de 2015]], sorted by monthday, months converted to hex, eg B28 (28 de novembro)
table.insert(ret, string.format('[[Categoria:Notícias de %s|%s%s]]', year, hexmonth, dayzero))
-- [[Categoria:Notícias por data]], sorted year month day
table.insert(ret, string.format('[[Categoria:Notícias por data|%s%s%s]]', year, hexmonth, dayzero))
end
return table.concat(ret)
end
function splitDate(str)
day = string.match(str, '^%d+')
month = string.match(str, ' (%S+) ')
year = string.match(str, '%d+$')
return {day, month, year}
end
-- lang for formatting date
local lang = mw.getContentLanguage()
-- current title
local title = mw.title.getCurrentTitle()
--[=[
--
-- TEMPLATES
--
--]=]
-- [[Template:Update]]
function p.update(frame)
local a = frame:getParent().args
local div = mw.html.create('div')
:addClass('official update')
:done()
local link
local postTitle = dt(a.title, title.baseText)
if hc(a.link) then
if a.link == 'no' or a.link == 'tradução' then
link = 'notícia'
else
link = '[' .. a.link .. ' notícia]'
end
else
link = string.lower(postTitle)
for i,v in pairs(repl_before) do
link = string.gsub(link, i, v)
end
link = mw.uri.encode(link)
for i,v in pairs(repl_after) do
link = string.gsub(link, i, v)
end
link = '[https://secure.runescape.com/m=news/' .. link .. ' notícia]'
end
local date_link, day, month, year
if hc(a.date or a.data) then
local spDate = splitDate(a.date or a.data)
day = spDate[1]
month = spDate[2]
year = spDate[3]
date_link = string.format('[[%s de %s]] de [[%s]]', day, month, year)
else
date_link = '(data faltando)'
end
if hc(a.rev) then
local spRevDate = splitDate(a.rev)
date_link = date_link .. ', and revised on ' .. string.format('[[%s de %s]] de [[%s]]', spRevDate[1], spRevDate[2], spRevDate[3])
end
if hc(a.author) then
date_link = date_link .. ' by ' .. a.author
end
div:wikitext('Esta ' .. link .. ' é copiada na íntegra do ')
:tag('span')
:addClass('plainlinks')
:wikitext('[https://www.runescape.com/community site \'\'RuneScape\'\']')
:done()
:wikitext('. Ela é protegida por direitos autorais pela [[Jagex]].')
:tag('br'):done()
:wikitext('Foi lançada em ' .. date_link .. '.')
if (a.link == 'tradução') then
div :tag('br'):done()
:tag('br'):done()
:wikitext('Note que esta é apenas uma tradução livre da mensagem original, pois na época a tradução para o Português ainda não existia. Não há um link disponível para a fonte dessa postagem.')
end
div:done()
local div2 = ''
if hc(a.article) then
div2 = mw.html.create('div')
:addClass('update-redirect')
:wikitext('Isto é uma notícia. Para o verbete da wiki, ver [[' .. a.article .. ']]')
:done()
if hc(a.nuke) then
if a.nuke == 'yes' then
div2:addClass('nuke')
:done()
end
end
end
local cat = ''
-- cats only in update namespace
if title.namespace == 114 then
cat = '[[Categoria:' .. get_update_category(a.category or a.categoria) .. '|' .. postTitle .. ']]'
cat = cat .. get_time_categories(day, month, year)
if a.link == 'tradução' then
cat = cat .. '[[Categoria:Notícias históricas]]'
end
end
if hc(a.title) then
local parenthesisedFullDate = ''
local parenthesisedMonthYear = ''
if (hc(a.date or a.data) and day and month and year) then
parenthesisedFullDate = string.format('(%s %s %s)', day, month, year)
parenthesisedMonthYear = string.format('(%s %s)', month, year)
end
local pipeEscapedTitle = string.gsub(a.title, '|', '{{!}}')
if (hc(parenthesisedFullDate) and (string.format('%s %s', a.title, parenthesisedFullDate) == title.baseText)) then
titleOverride = string.format('{{Parentitle override|%s|%s}}', pipeEscapedTitle, parenthesisedFullDate)
elseif (hc(parenthesisedMonthYear) and (string.format('%s %s', a.title, parenthesisedMonthYear) == title.baseText)) then
titleOverride = string.format('{{Parentitle override|%s|%s}}', pipeEscapedTitle, parenthesisedMonthYear)
else
titleOverride = string.format('{{DISPLAYTITLE:%s}}', pipeEscapedTitle)
end
frame:getParent():preprocess(titleOverride)
end
local toc = ' __NOTOC__'
if hc(a.toc) then
local toclimit = tostring( tonumber(a.toclimit) or '1' )
toc = frame:expandTemplate{ title = 'ToC', args = { 'right', limit = toclimit } }
end
local ret = '__NOEDITSECTION__' .. tostring(div2) .. tostring(div) .. toc .. cat .. '<div class="boldlinks">'
return ret
end
-- [[Predefinição:Modificações Recentes]]
function p.patchnotes(frame)
local function qfclink(qfc)
return 'http://services.runescape.com/m=forum_pt/l=3/forums?' .. string.gsub(qfc, '%-', ',')
end
local a = frame:getParent().args
local cat = ''
local div = mw.html.create('div')
:addClass('official patchnote')
:done()
local link
if hc(a.qfc) then
if a.qfc == 'no' then
link = ' a forum thread'
elseif a.qfc == 'none' then
link = ''
else
link = '[' .. qfclink(a.qfc) .. ' este tópico do fórum]'
end
else
link = '(QFC missing)'
cat = cat .. '[[Categoria:Sem QFC de modificações recentes]]'
end
local newspostlink
if hc(a.link) then
newspostlink = '['..a.link..' esta notícia]'
end
local date_link
local day, month, year = '', '', ''
if hc(a.date or a.data) then
local spDate = splitDate(a.date or a.data)
day = spDate[1]
month = spDate[2]
year = spDate[3]
date_link = string.format('[[%s de %s]] de [[%s]]', day, month, year)
else
date_link = '(data faltando)'
end
if hc(a.author) then
date_link = date_link .. ' por ' .. a.author
end
if hc(a.rev) then
spRevDate = splitDate(a.rev)
date_link = date_link .. ', e revisado em ' .. string.format('[[%s de %s]] de [[%s]]', spRevDate[1], spRevDate[2], spRevDate[3])
end
if hc(link) and hc(newspostlink) then
div:wikitext('Estas [[Modificações recentes]] oficiais são copiadas verbatim de ' .. link .. ' nos ')
:tag('span')
:addClass('plainlinks')
:wikitext('[https://secure.runescape.com/m=forum_pt/l=3/forums \'\'RuneScape\'\' forums]')
:done()
:wikitext(' ou alternativamente de ' .. newspostlink .. ' of the ')
:tag('span')
:addClass('plainlinks')
:wikitext('[https://secure.runescape.com/m=news/l=3/ \'\'RuneScape\'\' news posts]')
:done()
:wikitext('. Seus direitos autorais pertencem à [[Jagex]].')
:tag('br'):done()
:wikitext('Estas modificações recentes foram anunciadas em ' .. date_link .. '.')
:done()
elseif hc(link) then
div:wikitext('Estas [[Modificações recentes]] oficiais são copiadas verbatim de ' .. link .. ' of the ')
:tag('span')
:addClass('plainlinks')
:wikitext('[https://secure.runescape.com/m=forum_pt/l=3/forums \'\'RuneScape\'\' forums]')
:done()
:wikitext('. It is copyrighted by [[Jagex]].')
:tag('br'):done()
:wikitext('Estas modificações recentes foram anunciadas em ' .. date_link .. '.')
:done()
elseif hc(newspostlink) then
div:wikitext('These official [[Patch Notes]] are copied verbatim from ' .. newspostlink .. ' of the ')
:tag('span')
:addClass('plainlinks')
:wikitext('[https://secure.runescape.com/m=news/l=3/ \'\'RuneScape\'\' news posts]')
:done()
:wikitext('. Seus direitos autorais pertencem à [[Jagex]].')
:tag('br'):done()
:wikitext('Estas modificações recentes foram anunciadas em ' .. date_link .. '.')
:done()
else
div:wikitext('Estas [[Modificações recentes]] oficiais são copiadas verbatim de (link faltando). Seus direitos autorais pertencem à [[Jagex]].')
:tag('br'):done()
:wikitext('Estas modificações recentes foram anunciadas em ' .. date_link .. '.')
:done()
cat = cat .. '[[Categoria:Sem link de modificações recentes]]'
end
cat = cat .. '[[Categoria:Modificações Recentes|*' .. lang:formatDate('md', day .. ' ' .. langUtil.engmonth[month]) .. ']]'
cat = cat .. get_time_categories(day, month, year)
-- not update namespace, remove cat
if title.namespace ~= 114 then
cat = ''
end
if hc(a.titleOverride) then
if a.titleOverride ~= 'no' then
frame:getParent():preprocess(string.format('{{DISPLAYTITLE:%s}}', string.gsub(a.titleOverride, '|', '{{!}}')))
end
else
frame:getParent():preprocess(string.format('{{Parentitle override|Modificações Recentes|(%s %s %s)}}', day, month, year))
end
local toc = '<div style="float:right;margin-left:1em;">__TOC__</div>'
if hc(a.notoc) then
toc = '__NOTOC__'
end
local ret = '__NOEDITSECTION__' .. tostring(div) .. cat .. toc
return ret
end
-- [[Template:DevBlog]]
function p.devblog(frame)
local a = frame:getParent().args
local blogtitle = dt(a.title, title.baseTitle)
local cat = ''
local div = mw.html.create('div')
:addClass('official devblog')
:done()
local link
if hc(a.link) then
if a.link == 'no' then
link = "''RuneScape'' website"
else
link = '[' .. a.link .. " ''RuneScape'' website]"
end
else
link = title.baseText
for i,v in pairs(repl_before) do
link = string.gsub(link, i, v)
end
link = mw.uri.encode(link)
for i,v in pairs(repl_after) do
link = string.gsub(link, i, v)
end
link = '[https://secure.runescape.com/m=rswiki/en/DevBlog:' .. link .. " ''RuneScape'' website]"
end
local date_link, day, month, year
if hc(a.date or a.data) then
local spDate = splitDate(a.date or a.data)
day = spDate[1]
month = spDate[2]
year = spDate[3]
date_link = string.format('[[%s de %s]] de [[%s]]', day, month, year)
else
date_link = '(missing date)'
end
local authorstr = ''
if hc(a.author) then
authorstr = "'''" .. a.author .. "'''"
else
authorstr = '(missing author)'
cat = cat .. '[[Categoria:Missing devblog author]]'
end
div:wikitext('This [[Developer Blogs|Developer Blog]] is copied verbatim from the ')
:tag('span')
:addClass('plainlinks')
:wikitext(link)
:done()
:wikitext('. It is copyrighted by [[Jagex]].')
:tag('br'):done()
:wikitext('It is written by ' .. authorstr .. ' and is dated ' .. date_link .. '.')
:done()
local div2 = mw.html.create('div')
:css({
['font-size'] = '150%',
background = 'transparent none repeat scroll 0 0',
['border-bottom'] = '1px solid #aaa',
['font-weight'] = 'normal',
['margin-bottom'] = '15px',
['padding-bottom'] = '0.17em',
['padding-top'] = '0.5em',
['text-align'] = 'center',
})
:wikitext(blogtitle)
:done()
-- cats only in update namespace
if title.namespace == 114 then
cat = '[[Categoria:Developer Blogs|' .. blogtitle .. ']]'
cat = cat .. get_time_categories(day, month, year)
else
cat = ''
end
local ret = '__NOTOC__ __NOEDITSECTION__' .. tostring(div) .. cat .. tostring(div2)
return ret
end
--[=[
--
-- CATEGORY FORMATTERS
--
--]=]
-- [[Categoria:28 November updates]] etc
function p.date_cat(frame)
local f = frame:getParent()
local d
if hc(f.args[1]) then
d = f.args[1]
else
-- assumes 2016 so that leap years work
d = string.gsub(title.text, 'Notícias de ', '') .. ' 2016'
d = langUtil.engdate(d)
end
local ret = 'Esta categoria contém atualizações postadas em ' .. lang:formatDate('[[j \\d\\e F]]', d) .. ', classificadas cronologicamente.'
-- cats only in category namespace
if title.namespace == 14 then
--updates by day, sorted by hexmonth,day: B28 (28 November)
ret = ret .. '[[Categoria:Notícias por dia|' .. hexmonthconv[lang:formatDate('F', d)] .. lang:formatDate('d', d) .. ']]'
--updates by month, sorted by [space]day
ret = ret .. '[[Categoria:Notícias de ' .. lang:formatDate('F', d) .. '| ' .. lang:formatDate('d', d) .. ']]'
end
return ret
end
-- [[Categoria:2015 updates]] etc
function p.year_cat(frame)
local f = frame:getParent()
local d
if hc(f.args[1]) then
d = f.args[1]
else
d = string.gsub(title.text, ' ?updates?', '')
end
local ret = 'Esta categoria contém atualizações postadas em [[' .. d .. ']], classificadas cronologicamente.'
-- cats only in category namespace
if title.namespace == 14 then
--updates by year, sorted by [space]year
ret = ret .. '[[Categoria:Notícias por ano| ' .. d .. ']]'
end
return ret
end
--[=[
--
-- DPL HANDLERS
--
--]=]
function p.datedpl(frame)
local a = frame:getParent().args
local year
local cat
local page = a['%TITLE%'] or 'Bad title'
if hc(a.year) then
year = a.year
else
year = string.match(a.date or a.data or '', '%d+$') or 'Bad year to |date='
end
if hc(a.category or a.categoria) then
-- if it has category, {{Notícia}}
cat = category_info[cat_switch[string.lower(a.category or a.categoria)]][2]
elseif hc(a.qfc) then
-- if it has qfc, {{Modificações Recentes}}
cat = 'Modificações Recentes'
else
-- missing both probably means {{Antique update}}
cat = 'Atualização antiga'
end
return string.format("'''%s''' – %s: [[Notícia:%s|%s]]",year,cat,page,page)
end
--TODO
--p.updatedpl
--p.patchnotesdpl
--etc
return p
--</nowiki>