Module:quoteHomer >> Module:quoteHomer   << Module:quoteHomer/τεκμηρίωση
Module:quoteHomer >> Πρότυπο:quoteHomer που δημιουργεί


-- [[Template:quoteHomer]] Homer links to el.wikisource
-- creates: [[Πρότυπο:ΠΘ:Ιλ]] for Iliad --[[Πρότυπο:ΠΘ:Οδ]] -- for Odyssey

local export = {}

-- Errors -- use it with writing: if blahblah then return errorhere('xxxxxx') end
errorhere = function(errstring)
    return '<div class="error">' .. errstring .. '</div>[[Κατηγορία:Σελίδες με σφάλματα σε πρότυπο για τον Όμηρο]]'
end
 

function export.homer (frame)
	local args = frame:getParent().args	-- for Templates
-- subfunctions, utilities ===============


-- function zero-five: link to el.wikisource verses #0000 (Iliad #v0000)2023. When anchors exist ONLY for numbers ending to zero or five
function zero_five (verse_number)
	verse = args['verse'] or args['στίχος'] or ''
	
	if verse == '1' or verse == '2' or verse == '3' or verse == '4'
	or verse == '' or verse == nil
	then
	return ''

		elseif mw.ustring.find(verse, '[1234]$') then
			-- $ means: at the end
		return '' .. mw.ustring.sub(mw.ustring.match(verse, verse), 1, -2) .. '0'
			-- 1 = start at 1st letter, -2 = stop at 2nd letter from the end

		elseif mw.ustring.find(verse, '[6789]$') then
		return '' .. mw.ustring.sub(mw.ustring.match(verse, verse), 1, -2) .. '5'
					
		elseif mw.ustring.find(verse, '[05]$') then
		return '' .. verse
		
		elseif mw.ustring.find(verse, '%D') then -- D means: any character except digits
return errorhere('<span style="color:#b22222; font-size:17px;">Παρακαλούμε, γράψτε έναν αριθμό στίχου. Please write a verse number.</span>')	

	end

end -- close function zero_five

-- parameters
local ouput_author = ''
local output_work = ''
local output_source_comma = ''
local output_source = ''
local output_chapter = ''
local output_verse = ''


local author = args['author'] or args['συγγραφέας'] or ''
local work = args['work'] or args['έργο'] or ''
local chapter = args['chapter'] or args['κεφάλαιο'] or ''
local chapter_number = ''
local descr = args['subtitle'] or args['υπότιτλος'] or '' -- But if i write |τίτλος=- ittt works...
local verse = args['verse'] or args['στίχος'] or ''
local show_verse = args['showverse'] or ''
local mypassage = args['vv'] or args['στίχοι'] or ''

-- HOMER ==============================================
--[=[ NOTES Homer = Hom. see LSJ e.g. https://logeion.uchicago.edu/ἀνήρ
	*  Il. 17.435, Od. 21.323;
	* editors  write TEMPLATEiliad|17|435
]=]--
 
if author == 'όμηρος' or author == 'Όμηρος' or author == 'Hom' or author == 'Homer' then
	if args['work'] == '-ιλ' or args['work'] == '-οδ' then
		output_author = ''
	else
		output_author = '[[Βικιλεξικό:Βιβλιοθήκη (αρχαία ελληνικά)#Hom|&#8984;]] [[:el:w:Όμηρος|<span style="background:#f7f7f7;" title="Όμηρος στη Βικιπαίδεια">Ὅμηρος</span>]]'
	end
-- alias This works only for show numbers.
--NO--	il = args['ιλ'] or args['Ιλ'] or args['ΙΛ'] or args['Il'] or args['Ιλιάδα'] or args['Ιλιάς'] or args['Iliad'] or args['Ilias'] or ''
--NO--	od = args['οδ'] or args['Οδ'] or args['ΟΔ'] or args['Od'] or args['Οδύσσεια'] or args['Odyssey'] or ''
	il = 'ιλ' or 'Ιλ' or 'ΙΛ' or 'Il' or 'Ιλιάδα' or 'Ιλιάς' or 'Iliad' or 'Ilias' or ''
	od = 'οδ' or 'Οδ' or 'ΟΔ' or 'Od' or 'Οδύσσεια' or 'Odyssey' or ''
	
-- function to convert Homer rhapsody numbers to rhapsody letter
	if chapter == '1' then chapter = 'α' end	if chapter == '2' then chapter = 'β' end	if chapter == '3' then chapter = 'γ' end
	if chapter == '4' then chapter = 'δ' end	if chapter == '5' then chapter = 'ε' end	if chapter == '6' then chapter = 'ζ' end
	if chapter == '7' then chapter = 'η' end	if chapter == '8' then chapter = 'θ' end	if chapter == '9' then chapter = 'ι' end
	if chapter == '10' then chapter = 'κ' end	if chapter == '11' then chapter = 'λ' end	if chapter == '12' then chapter = 'μ' end
	if chapter == '13' then chapter = 'ν' end	if chapter == '14' then chapter = 'ξ' end	if chapter == '15' then chapter = 'ο' end
	if chapter == '16' then chapter = 'π' end	if chapter == '17' then chapter = 'ρ' end	if chapter == '18' then chapter = 'σ' end
	if chapter == '19' then chapter = 'τ' end	if chapter == '20' then chapter = 'υ' end	if chapter == '21' then chapter = 'φ' end
	if chapter == '22' then chapter = 'χ' end	if chapter == '23' then chapter = 'ψ' end	if chapter == '24' then chapter = 'ω' end
--  show  chapter_number+its letter (we always forget) Also, description? desc=- NO description?
	if chapter == 'α' or chapter == 'Α' then chapter_number = '1'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Λοιμός. Μῆνις.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀθηνᾶς παραίνεσις πρὸς Τηλέμαχον.' end end
	end
	if chapter == 'β' or chapter == 'Β' then chapter_number = '2'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ὄνειρος. Διάπειρα. Βοιωτία ἢ κατάλογος νεῶν.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἰθακησίων ἐκκλησία καὶ Τηλεμάχου ἀποδημία.' end end
	end
	if chapter == 'γ' or chapter == 'Γ' then chapter_number = '3'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ὅρκοι. Τειχοσκοπία. Ἀλεξάνδρου καὶ Μενελάου μονομαχία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἰθακησίων ἐκκλησία καὶ Τηλεμάχου ἀποδημία.' end end
	end
	if chapter == 'δ' or chapter == 'Δ' then chapter_number = '4'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ὁρκίων σύγχυσις. Ἀγαμέμνονος ἐπιπώλησις.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Τὰ ἐν Λακεδαίμονι.' end end
	end
	if chapter == 'ε' or chapter == 'Ε' then chapter_number = '5'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Διομήδους ἀριστεία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀπόπλους Ὀδυσσέως παρὰ Καλυψοῦς.' end end
	end	
	if chapter == 'ζ' or chapter == 'Ζ' then chapter_number = '6'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἕκτορος καὶ Ἀνδρομάχης ὁμιλία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως ἄφιξις εἰς Φαίακας.' end end
	end
	if chapter == 'η' or chapter == 'Η' then chapter_number = '7'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἕκτορος καὶ Αἴαντος μονομαχία. Νεκρῶν ἀναίρεσις.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως εἴσοδος πρὸς Ἀλκίνουν.' end end
	end
	if chapter == 'θ' or chapter == 'Θ' then chapter_number = '8'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Θεῶν ἀγορά. Κόλος μάχη.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως σύστασις πρὸς Φαίακας.' end end
	end
	if chapter == 'ι' or chapter == 'Ι' then chapter_number = '9'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Πρεσβεία πρὸς Ἀχιλλέα. Λιταί.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀλκίνου ἀπόλογοι: Τὰ περὶ Κίκονας, Λωτοφάγους καὶ Κύκλωπας.' end end
	end
	if chapter == 'κ' or chapter == 'Κ' then chapter_number = '10'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Δολώνεια.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀλκίνου ἀπόλογοι: Τὰ περὶ Αἴολον, Λαιστρυγόνας καὶ Κίρκην.' end end
	end
	if chapter == 'λ' or chapter == 'Λ' then chapter_number = '11'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἀγαμέμνονος ἀριστεία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀλκίνου ἀπόλογοι: Νέκυια.' end end
	end
	if chapter == 'μ' or chapter == 'Μ' then chapter_number = '12'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Τειχομαχία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀλκίνου ἀπόλογοι: Τὰ περὶ Σειρῆνας, Σκύλλαν, Χάρυβδιν, βόας Ἡλίου.' end end
	end
	if chapter == 'ν' or chapter == 'Ν' then chapter_number = '13'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Μάχη ἐπὶ ταῖς ναυσί.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως ἀπόπλους παρὰ Φαιάκων καὶ ἄφιξις εἰς Ἰθάκην.' end end
	end
	if chapter == 'ξ' or chapter == 'Ξ' then chapter_number = '14'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Διὸς ἀπάτη.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως πρὸς Εὔμαιον ὁμιλία.' end end
	end
	if chapter == 'ο' or chapter == 'Ο' then chapter_number = '15'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Παλίωξις παρὰ τῶν νεῶν.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Τηλεμάχου ἐπάνοδος.' end end
	end
	if chapter == 'π' or chapter == 'Π' then chapter_number = '16'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Πατρόκλεια.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ἀναγνωρισμὸς Ὀδυσσέως ὑπὸ Τηλεμάχου.' end end
	end
	if chapter == 'ρ' or chapter == 'Ρ' then chapter_number = '17'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Μενελάου ἀριστεία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Τηλεμάχου καὶ Ὀδυσσέως ἐπάνοδος εἰς Ἰθάκην.' end end
	end
	if chapter == 'σ' or chapter == 'Σ' then chapter_number = '18'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ὁπλοποιία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως καὶ Ἴρου πυγμή.' end end
	end
	if chapter == 'τ' or chapter == 'Τ' then chapter_number = '19'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Μήνιδος ἀπόρρησις.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως καὶ Πηνελόπης ὁμιλία. Νίπτρα.' end end
	end
	if chapter == 'υ' or chapter == 'Υ' then chapter_number = '20'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Θεομαχία.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Τὰ πρὸ τῆς μνηστηροφονίας.' end end
	end
	if chapter == 'φ' or chapter == 'Φ' then chapter_number = '21'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Μάχη παραποτάμιος.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Τόξου θέσις.' end end
	end
	if chapter == 'χ' or chapter == 'Χ' then chapter_number = '22'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἕκτορος ἀναίρεσις.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Μνηστήρων φόνος.' end end
	end
	if chapter == 'ψ' or chapter == 'Ψ' then chapter_number = '23'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἆθλα ἐπὶ Πατρόκλῳ.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Ὀδυσσέως ὑπὸ Πηνελόπης ἀναγνωρισμός.' end end
	end
	if chapter == 'ω' or chapter == 'Ω' then chapter_number = '24'
		if work == il or work == '-ιλ' then if descr == '-' then descr = '' else descr='. Ἕκτορος λύτρα.' end end
		if work == od or work == '-οδ' then if descr == '-' then descr = '' else descr='. Σπονδαί.' end end
	end
	
-- same for both Iliad and Odyssey o no! #000 for Odyssey,m #v000 for Iliad
	function homer_common (homer_verses)	
		if verse ~= '' and verse ~= nil then
					
			-- function zero_five, link to el.wikisource verses
			if work == il or work == '-ιλ' then verse_link = '#v' .. zero_five(verse_number)
			elseif work == od or work == '-οδ' then verse_link = '#' .. zero_five(verse_number)
			end
	-- this is alternative verse				
			if show_verse ~= '' and show_verse ~= nil then
				show_verse = 'στίχ.&nbsp;' .. show_verse
				-- mypassage  e.g. [[βουλή]] (Ιλ.) [[κνέφας]] (Οδ.)
				if (args['vv'] ~= '' and args['vv'] ~= nil) or (args['στίχοι'] ~= '' and args['στίχοι'] ~= nil) then
				show_verse = show_verse .. ' (' .. mypassage .. ')'
				end	
				show = chapter_number .. ' (' .. chapter .. '<span style="font-size:small;>' .. descr .. '</span>), ' .. show_verse
			else
				show_verse = 'στίχ.&nbsp;' .. verse
				-- mypassage  e.g. [[βουλή]] (Ιλ.) [[κνέφας]] (Οδμμ)
				if (args['vv'] ~= '' and args['vv'] ~= nil) or (args['στίχοι'] ~= '' and args['στίχοι'] ~= nil) then
				show_verse = show_verse .. ' (' .. mypassage .. ')'
				end	
				show = chapter_number .. ' (' .. chapter .. '<span style="font-size:small;>' .. descr .. '</span>), ' .. show_verse
			end


		else -- if no verselink
			verse_link = ''
			show = chapter_number .. ' (' .. chapter .. '<span style="font-size:small;>' .. descr .. '</span>)'
		end
	end -- close function common
	
-- Ilias
		if args['work'] == '-ιλ' then
			output_work = ''
			output_source_comma = ''
		elseif work == 'ιλ' or work == 'Ιλ' or work == 'Il' or work == 'Ιλιάδα' or work == 'Ιλιάς' then
			output_work = ', ' .. '[[:el:w:Ιλιάδα|<span style="background:#f7f7f7;" title="η Ιλιάδα στη Βικιπαίδεια"><i>Ἰλιάς</i></span>]]'
			output_source_comma = ', '
		end
		if work == 'ιλ' or work == 'Ιλ' or work == 'Il' or work == 'Ιλιάδα' or work == 'Ιλιάς' 
		or args['work'] == '-ιλ' then
			output_source =  '[[:el:s:Ιλιάς'
			if chapter ~= '' and chapter ~= nil then
				if chapter ~= mw.ustring.match(chapter, '[αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ]') then
					output_chapter = ''
					verse_link = ''
					return errorhere('<span style="color:#b22222; font-size:17px;">Δεν υπάρχει τέτοιος τίτλος ραψωδίας. Επιλέξτε έναν αριθμό 1-24 ή ένα γράμμα του ελληνικού αλφαβήτου.</span> [[Κατηγορία:Σελίδες με σφάλματα στο πρότυπο για την Ιλιάδα]]')
				else
				chapter = mw.ustring.upper(chapter, '[αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ]')
				output_chapter =  '/' .. chapter
			
				-- function
				homer_common (homer_verses)	
		
				end -- close if chapter is NOT αβγδ...	
			else -- if there is no chapter
				output_chapter = ''
				verse_link = ''
				show = ' στη Βικιθήκη'
			end

			output = output_author .. 	output_work .. output_source_comma .. output_source .. output_chapter .. verse_link 
			.. '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">' .. show .. '</span>]]'

-- Odysseia
elseif work == 'οδ' or work == 'Οδ' or work == 'Od' or work == 'Οδύσσεια' 
		or args['work'] == '-οδ' then
			
		if args['work'] == '-οδ' then
			output_work = ''
			output_source_comma = ''
		elseif work == 'οδ' or work == 'Οδ' or work == 'Od' or work == 'Οδύσσεια' then
			output_work = ', ' .. '[[:el:w:Οδύσσεια|<span style="background:#f7f7f7;" title="η Οδύσσεια στη Βικιπαίδεια"><i>Ὀδύσσεια</i></span>]]'
			output_source_comma = ', '
		end


			output_source = '[[:el:s:Οδύσσεια'
			if chapter ~= '' and chapter ~= nil then
				if chapter ~= mw.ustring.match(chapter, '[αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ]') then
					output_chapter = ''
					verse_link = ''
					return errorhere('<span style="color:#b22222; font-size:17px;">Δεν υπάρχει τέτοιος τίτλος ραψωδίας. Επιλέξτε έναν αριθμό 1-24 ή ένα γράμμα του ελληνικού αλφαβήτου.</span> [[Κατηγορία:Σελίδες με σφάλματα στο πρότυπο για την Οδύσσεια]]')
				else
				chapter = mw.ustring.lower(chapter, '[αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ]')
				output_chapter =  '/' .. chapter
			
				-- function
				homer_common (homer_verses)	
			
				end -- clofse if chapter is NOT αβγδ...	
			else -- if there is no chapter
				output_chapter = ''
				verse_link = ''
				show = ' στη Βικιθήκη'
			end

			output = output_author .. 	output_work .. output_source_comma .. output_source .. output_chapter .. verse_link 
			.. '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">' .. show .. '</span>]]'
			
-- wrong work
		elseif work ~= 'ιλ' and work ~= 'οδ' and work ~= '' and work ~= nil then
			return errorhere('Δεν υπάρχει τέτοιος τίτλος έργου για τον Όμηρο! Επιλέξτε |έργο=ιλ ή οδ')
			
		elseif work == '' or work == nil then
			output = output_author
			
		end -- close work at Homer

end

-- ================= CLOSE FUNCTION
return output
end

return export