Module:GetVerseTranslations: Difference between revisions

From Bodhicitta
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
Line 5: Line 5:
local outputVrs = ''
local outputVrs = ''


local qrRootVrs = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Root verses]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )
local qrRootVrs = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Root verses]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?#-=page|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )


if qrRootVrs and #qrRootVrs then
if qrRootVrs and #qrRootVrs then
Line 28: Line 28:
end
end


local qrXtraVrsFromComms = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Commentary]][[SegmentFormat::Root]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )
local qrXtraVrsFromComms = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Commentary]][[SegmentFormat::Root]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?#-=page|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )


if qrXtraVrsFromComms and #qrXtraVrsFromComms then
if qrXtraVrsFromComms and #qrXtraVrsFromComms then

Revision as of 15:26, 26 October 2023

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

local p = {}

function p.main(frame)

	local outputVrs = ''

	local qrRootVrs = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Root verses]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?#-=page|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )

	if qrRootVrs and #qrRootVrs then
		for num, verseData in pairs( qrRootVrs ) do
			local tmButton = frame:expandTemplate{ 
				title = 'InternalLink', 
				args = { 
					wikipage = verseData.page , 
					label = 'TM <i class="fa-duotone fa-angle-right fa-sm"></i>'
				} 
			}
			tmButton = '<span class="tsdwiki-top-actions text-70 pl-4 font-style-normal">' .. tmButton .. '</span>'
			outputVrs = outputVrs .. '<div class="verse-page-toggle verse-toggle grey-hoverlay active" id="' .. verseData.TransMemID .. '-English">' .. verseData.ShortTitle .. '</div>' .. frame:expandTemplate{ 
				title = 'VersionContent', 
				args = { 
						content = verseData.English , 
						source = verseData.TranslationWikiPage,
						tmButton =  tmButton
					}
				}
		end		
	end

	local qrXtraVrsFromComms = mw.smw.ask( '[[Category:Translation Memories]][[TransMemType::Commentary]][[SegmentFormat::Root]][[RootTextChapVerseNum::' .. mw.uri.encode( mw.title.getCurrentTitle().subpageText ) .. ']]|?#-=page|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|limit=30' )

	if qrXtraVrsFromComms and #qrXtraVrsFromComms then
		outputVrs = outputVrs .. '<h5 class="mb-0 pb-0 border-0 font-italic">More translations from commentaries</h5>'
		for num, verseData in pairs( qrXtraVrsFromComms ) do
			local tmButton = frame:expandTemplate{ 
				title = 'InternalLink', 
				args = { 
					wikipage = verseData.page , 
					label = 'TM <i class="fa-duotone fa-angle-right fa-sm"></i>'
				} 
			}
			tmButton = '<span class="tsdwiki-top-actions text-70 pl-4 font-style-normal">' .. tmButton .. '</span>'
			outputVrs = outputVrs .. '<div class="verse-page-toggle verse-toggle grey-hoverlay active" id="' .. verseData.TransMemID .. 'XtraVrsEnglishTrigger">' .. verseData.ShortTitle .. '</div>' .. frame:expandTemplate{ 
				title = 'VersionContent', 
				args = { 
						id = verseData.TransMemID .. 'XtraVrsEnglishContent' , 
						content = verseData.English , 
						source = verseData.TranslationWikiPage ,
						TransMemID = verseData.TransMemID,
						tmButton =  tmButton
					}
				}
		end		
	end

	return outputVrs

end

return p