このモジュールについての説明文ページを Module:BASA/doc に作成できます
local messagesBg = {
No = "№",
Date = "Дата",
Uploaded_image = "Качено изображение",
Illustrated_article = "Илюстрирана(и) статия(и)",
Nb = "Бр.",
NbFiles = "Брой качени файлове: ",
NbBgArticles = "Брой илюстрирани статии на български: ",
NbNonBgArticles = "Брой илюстрирани статии на други езици: ",
NewArticles = "Брой новосъздадени статии: ",
NewArticle = "нова статия",
source = "сурови данни",
}
local messagesEn = {
No = "No",
Date = "Date",
Uploaded_image = "Uploaded image",
Illustrated_article = "Illustrated article(s)",
Nb = "#Art",
NbFiles = "Number of uploads: ",
NbBgArticles = "Number of Bulgarian articles illustrated: ",
NbNonBgArticles = "Number of non-Bulgarian articles illustrated: ",
NewArticles = "Number of new articles created: ",
NewArticle = "new article",
source = "source data",
}
local messages = {
bg = messagesBg,
en = messagesEn
}
local module = {}
local function table_size(tbl)
local size = 0
for k, v in pairs(tbl) do
size = size + 1
end
return size
end
local function links_from_keys(articles)
local links = {}
for article, v in pairs(articles) do
links[#links+1] = '[[:' .. article .. ']]'
end
return table.concat(links, ', ')
end
local function string_split(str, delimiter)
local chunks = {}
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
chunks[#chunks+1] = string.sub( str, from , delim_from-1 )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
chunks[#chunks+1] = string.sub( str, from )
return chunks
end
function module.report_table(frame)
local m = messages[frame.args.lang]
local head = '{| width="100%" class="wikitable sortable"\n'
.. '! ' .. m.No .. '\n'
.. '! ' .. m.Date .. '\n'
.. '! ' .. m.Uploaded_image .. '\n'
.. '! ' .. m.Illustrated_article .. '\n'
.. '! ' .. m.Nb .. '\n'
.. '|-\n'
local rows = {}
local counter = 0
local bg_articles = {}
local nonbg_articles = {}
local new_articles = {}
local chunks, row, arg, file, link, is_new_article
local data_template = frame.args.data_template
local lines = string_split(frame:expandTemplate{ title = data_template }, '\n')
for counter = 1, #lines, 1 do
chunks = string_split( mw.text.trim(lines[counter], " ;"), ';' )
file = mw.text.trim(chunks[2])
if not string.find( file, '[[', 1, true ) then
file = '[[:File:' .. file .. '|' .. file .. ']]'
end
row = '|' .. counter .. '||' .. chunks[1] .. '||' .. file .. '||'
if #chunks > 2 then
for i = 3, #chunks, 1 do
link = mw.text.trim(chunks[i])
is_new_article = link:sub(-1, -1) == '*'
if is_new_article then
link = mw.text.trim(link, '*')
new_articles[link] = 1
end
link = '[[:' .. link .. ']]'
if is_new_article then
link = link .. '<sup title="'..m.NewArticle..'">☆</sup>'
end
row = row .. (i > 3 and ', ' or '') .. link
if string.find( chunks[i], 'bg:', 1, true ) then
bg_articles[link] = 1
else
nonbg_articles[link] = 1
end
end
end
row = row .. ' || ' .. (#chunks > 2 and (#chunks - 2) or '')
rows[#rows+1] = row
end
local new_articles_count = table_size(new_articles)
local intro = '<div style="float:right; font-size:90%">([['..data_template..'|'..m.source..']])</div>\n'
.. '*' .. m.NbFiles .. #lines .. '\n'
.. '*' .. m.NbBgArticles .. table_size(bg_articles) .. '\n'
.. '*' .. m.NbNonBgArticles .. table_size(nonbg_articles) .. '\n'
.. '*' .. m.NewArticles .. new_articles_count .. '\n'
if new_articles_count > 0 then
intro = intro .. '*: ☆ ' .. links_from_keys(new_articles) .. '\n'
end
return intro .. '\n' .. head .. table.concat(rows, '\n|-\n') .. '\n|}'
end
return module