Модул:File — разлика између измена

Извор: SI Wiki
Пређи на навигацију Пређи на претрагу
м (Takođe kategorizacija)
м (Barem ovo)
 
(Није приказано 8 међуизмена 2 корисника)
Ред 4: Ред 4:
local data = mw.loadData('Module:File/data')
local data = mw.loadData('Module:File/data')


local function makeRow(html, title, content)
local function makeRow(html, title, content, id)
     html:tag('tr')
     local tr = html:tag('tr')
            :tag('th')
    local th = tr:tag('th'):wikitext(title)
                :wikitext(title)
    if id ~= nil then
            :done()
    th:attr('id', id)
            :tag('td')
    end
                :wikitext(content)
    th:done()
            :done()
    tr:tag('td')
        :done()
:wikitext(content)
:done()
  :done()
end
end


Ред 30: Ред 32:
return
return
end
end
local subject = mw.text.split(title.text, ' ', true)
local subject = mw.text.split(title.text, ' ', true)[1]
local category = data.categories[subject]
local category = data.categories[subject]
local html = mw.html.create('table')
local html = mw.html.create('table')
:attr('class', 'wikitable file-description')
:attr('class', 'wikitable file-description')
if args.description ~= nil then
if args.description ~= nil then
makeRow(html, 'Опис датотеке', args.description)
makeRow(html, 'Опис датотеке', args.description, 'fileinfotpl_desc')
end
end
if category ~= nil then
if category ~= nil then
Ред 41: Ред 43:
end
end
if args.author ~= nil then
if args.author ~= nil then
makeRow(html, 'Аутор', args.author)
makeRow(html, 'Аутор', args.author, 'fileinfotpl_aut')
end
end
makeRow(html, 'Лиценса', args.license and data.licenses[args.license] or args.license)
makeRow(html, 'Лиценца', tostring(mw.html.create('div')
:addClass('licensetpl')
:addClass('licensetpl_long')
:addClass('licensetpl_short')
:wikitext(args.license and data.licenses[args.license] or data.licenses.default)
))
if args.source ~= nil then
if args.source ~= nil then
makeRow(html, 'Извор', args.source)
makeRow(html, 'Извор', args.source, 'fileinfotpl_src')
end
end
if args.notes ~= nil then
if args.notes ~= nil then

Тренутна верзија на датум 27. фебруар 2021. у 01:50

Овај модул служи за генерисање табеле са описом датотека. За документацију о коришћењу видети Шаблон:File. Овај модул такође довлачи потребне податке за рад из модула са подацима.


local p = {}

local title = mw.title.getCurrentTitle()
local data = mw.loadData('Module:File/data')

local function makeRow(html, title, content, id)
    local tr = html:tag('tr')
    local th = tr:tag('th'):wikitext(title)
    if id ~= nil then
    	th:attr('id', id)
    end
    th:done()
    tr:tag('td')
			:wikitext(content)
			:done()
	  :done()
end

function p.category(category, subcategory)
	if category == nil then
		return '[[Категорија:Остале датотеке]]'
	elseif subcategory == nil then
		return table.concat({'[[Категорија:', category, ']]'})
	else
		return table.concat({'[[Категорија:', category, '/', data.subcategories[subcategory], ']]'})
	end
end

function p.main(frame)
	local args = frame:getParent().args
	if title.namespace ~= 6 then
		return
	end
	local subject = mw.text.split(title.text, ' ', true)[1]
	local category = data.categories[subject]
	local html = mw.html.create('table')
		:attr('class', 'wikitable file-description')
	if args.description ~= nil then
		makeRow(html, 'Опис датотеке', args.description, 'fileinfotpl_desc')
	end
	if category ~= nil then
		makeRow(html, 'Предмет', table.concat({'[[', category, ']]'}))
	end
	if args.author ~= nil then
		makeRow(html, 'Аутор', args.author, 'fileinfotpl_aut')
	end
	makeRow(html, 'Лиценца', tostring(mw.html.create('div')
		:addClass('licensetpl')
		:addClass('licensetpl_long')
		:addClass('licensetpl_short')
		:wikitext(args.license and data.licenses[args.license] or data.licenses.default)
	))
	if args.source ~= nil then
		makeRow(html, 'Извор', args.source, 'fileinfotpl_src')
	end
	if args.notes ~= nil then
		makeRow(html, 'Напомене', args.notes)
	end
	return tostring(html) .. p.category(category, args.type)
end

return p