Module:GetWorks: Difference between revisions

From Rinchen Terdzö
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
Tag: Manual revert
 
(40 intermediate revisions by the same user not shown)
Line 10: Line 10:
local pagename = mw.title.getCurrentTitle().text
local pagename = mw.title.getCurrentTitle().text


     local qRes = mw.smw.ask( '[[-cycle::<q>[[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']]</q>]]|?#-=CyclePage|?Fulltitle|link=none|limit=1008' )
     local qRes = mw.smw.ask( '[[-Cycle::<q>[[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']]</q>]]|?#-=CyclePage|?Fulltitle|link=none|limit=1008' )


     if qRes == nil then
     if qRes == nil then
Line 20: Line 20:
if type( qRes ) == "table" then
if type( qRes ) == "table" then
         for k, data in ipairs( qRes ) do
         for k, data in ipairs( qRes ) do
             local Fulltitletib = frame:callParserFunction{ name = '#wylietotibprs', args = { data.CyclePage } }
             local qCycleTib = mw.smw.ask( '[[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']][[Cycle::' .. data.Fulltitle .. ']]|?Cycletib|limit=1008' )
        local cycleTrtnQr = mw.smw.ask ( '[[Category:' .. data.CyclePage .. ']][[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']]|limit=1008' )
            local Fulltitletib = ''
        local cycleTxtCntQr = mw.smw.ask ( '[[' .. data.CyclePage .. ']]|?Textcount|limit=1008' )
            if type( qRes ) == "table" then
        local cycleTxtCnt = ''
                for i, values in ipairs( qCycleTib ) do
        for k, data in ipairs( cycleTxtCntQr ) do
                    Fulltitletib = values.Cycletib
        cycleTxtCnt = tostring( data.Textcount )
                end
        end
            end
             output = output .. '<li><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. Fulltitletib .. ']]</span><br>[[' .. data.CyclePage .. '|' .. data.Fulltitle .. ']] (' .. #cycleTrtnQr .. ' of ' .. cycleTxtCnt .. ' Texts)</li>'
        local cycleTxtCnt = frame:callParserFunction{ name = '#show', args = { data.CyclePage, '?Textcount' } }
             output = output .. '<li><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. Fulltitletib .. ']]</span><br>[[' .. data.CyclePage .. '|' .. data.Fulltitle .. ']] (' .. #qCycleTib .. ' of ' .. cycleTxtCnt .. ' Texts)</li>'
         end
         end
     end
     end
Line 37: Line 38:
end
end


function p.works(frame)
-- function p.works(frame)


     if not mw.smw then
--     if not mw.smw then
         return "Semantic Scribunto is not installed."
--         return "Semantic Scribunto is not installed."
     end
--     end


local pArgs = frame:getParent().args
-- local pArgs = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
-- local pagename = mw.title.getCurrentTitle().text


     local qRes = mw.smw.ask( '[[Category:Tibetan Texts]][[Category:' .. pagename .. ']]OR[[Category:Illustrations]][[Category:' .. pagename .. ']]|?#-=CyclePage|?Fulltitletib|?Volumenumber|?Textnuminvol|?Fulltitle|limit=1008|link=none|sort=Volumenumber,Textnuminvol|order=asc,asc' )
--     local qRes = mw.smw.ask( '[[Category:Tibetan Texts]][[Category:' .. pagename .. ']]OR[[Category:Illustrations]][[Category:' .. pagename .. ']]|?#-=CyclePage|?Fulltitletib|?Volumenumber|?Textnuminvol|?Fulltitle|limit=500|link=none|sort=Volumenumber,Textnuminvol|order=asc,asc' )


     if qRes == nil then
--     if qRes == nil then
         return "No results!"
--         return "No results!"
     end
--     end


     local output = '<h3><span id="TotalCount">' .. #qRes .. '</span> Works</h3>'
--     local output = '<h3><span id="TotalCount">' .. #qRes .. '</span> Works</h3>'
     local fltrInput = frame:callParserFunction{ name = '#widget', args = { 'filterInput' } }
--     local fltrInput = frame:callParserFunction{ name = '#widget', args = { 'filterInput' } }
output = output .. '<div class="px-5 mb-4">' .. fltrInput .. '</div><div class="filterableContent">'
-- output = output .. '<div class="px-5 mb-4">' .. fltrInput .. '</div><div class="filterableContent">'


if type( qRes ) == "table" then
-- if type( qRes ) == "table" then
         for k, data in ipairs( qRes ) do
--         for k, data in ipairs( qRes ) do
             output = output .. '<div class="filterable"><div class="d-inline-block float-left pt-2">Vol. ' .. data.Volumenumber .. ', Text ' .. data.Textnuminvol .. ': </div><div class="d-inline-block"><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. data.Fulltitletib .. ']]</span><div>' .. data.Fulltitle .. '</div></div></div>'
--             output = output .. '<div class="filterable"><div class="d-inline-block float-left pt-2">Vol. ' .. data.Volumenumber .. ', Text ' .. data.Textnuminvol .. ': </div><div class="d-inline-block"><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. data.Fulltitletib .. ']]</span><div>' .. data.Fulltitle .. '</div></div></div>'
         end
--         end
     end
--     end


     output = output .. '</div>'
--     output = output .. '</div>'


     return output
--     return output


end
-- end


return p
return p

Latest revision as of 10:45, 28 May 2024

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

local p = {}

function p.cycles(frame)

    if not mw.smw then
        return "Semantic Scribunto is not installed."
    end

	local pArgs = frame:getParent().args
	local pagename = mw.title.getCurrentTitle().text

    local qRes = mw.smw.ask( '[[-Cycle::<q>[[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']]</q>]]|?#-=CyclePage|?Fulltitle|link=none|limit=1008' )

    if qRes == nil then
        return "No results!"
    end	

    local output = '<h3>' .. #qRes .. ' Cycles</h3><ol class="columns-2">'

	if type( qRes ) == "table" then
        for k, data in ipairs( qRes ) do
            local qCycleTib = mw.smw.ask( '[[Category:Tibetan Texts]][[sourcerevealer::' .. pagename .. ']][[Cycle::' .. data.Fulltitle .. ']]|?Cycletib|limit=1008' )
            local Fulltitletib = ''
            if type( qRes ) == "table" then
                for i, values in ipairs( qCycleTib ) do
                    Fulltitletib = values.Cycletib
                end
            end
        	local cycleTxtCnt = frame:callParserFunction{ name = '#show', args = { data.CyclePage, '?Textcount' } }
            output = output .. '<li><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. Fulltitletib .. ']]</span><br>[[' .. data.CyclePage .. '|' .. data.Fulltitle .. ']] (' .. #qCycleTib .. ' of ' .. cycleTxtCnt .. ' Texts)</li>'
        end
    end

    output = output .. '</ol>'

	return output

end

-- function p.works(frame)

--     if not mw.smw then
--         return "Semantic Scribunto is not installed."
--     end

-- 	local pArgs = frame:getParent().args
-- 	local pagename = mw.title.getCurrentTitle().text

--     local qRes = mw.smw.ask( '[[Category:Tibetan Texts]][[Category:' .. pagename .. ']]OR[[Category:Illustrations]][[Category:' .. pagename .. ']]|?#-=CyclePage|?Fulltitletib|?Volumenumber|?Textnuminvol|?Fulltitle|limit=500|link=none|sort=Volumenumber,Textnuminvol|order=asc,asc' )

--     if qRes == nil then
--         return "No results!"
--     end

--     local output = '<h3><span id="TotalCount">' .. #qRes .. '</span> Works</h3>'
--     local fltrInput = frame:callParserFunction{ name = '#widget', args = { 'filterInput' } }
-- 	output = output .. '<div class="px-5 mb-4">' .. fltrInput .. '</div><div class="filterableContent">'

-- 	if type( qRes ) == "table" then
--         for k, data in ipairs( qRes ) do
--             output = output .. '<div class="filterable"><div class="d-inline-block float-left pt-2">Vol. ' .. data.Volumenumber .. ', Text ' .. data.Textnuminvol .. ': </div><div class="d-inline-block"><span style="font-size: 1.5em;">[[' .. data.CyclePage .. '|' .. data.Fulltitletib .. ']]</span><div>' .. data.Fulltitle .. '</div></div></div>'
--         end
--     end

--     output = output .. '</div>'

--     return output

-- end

return p