Module:sarritest
Module:sarritest >> Module:sarritest/data << Module:sarritest/τεκμηρίωση(documentation)
trials at Template:sarritest. Logbook at Module talk:sarritest
--[=[
[[Module:sarritest/param]] -- [[Module:sarritest/data]] Tests at [[Template:sarritest]] = [[Πρότυπο:sarritest]] {{#invoke:sarritest|main}}
* [[QΚατηγορία:Σελίδες με σφάλματα στο Πρότυπο quote]]
]=]--
local export = {}
--local languages = mw.loadData("Module:Languages")
--local m_data = mw.loadData("Module:sarritest/data")
-- call with data.SECTIONNAME[some keyname]
--local tinti = require("Module:tin") --tinti function:tin -- chooses the correct acc.singular feminine article την (tin) or τη (ti)
-- Errors -- use it with writing: if blahblah then return errorhere('xxxxxx') end
errorhere = function(errstring)
return '<div class="error">' .. errstring .. '</div>[[Κατηγορία:Σελίδες με σφάλματα στο Πρότυπο quote]]'
end
function export.main(frame)
local args = frame:getParent().args -- for Templates
-- local args = frame.args -- invoke
-- local arg1 = frame.args[1] or frame:getParent().args[1] or '' -- for BOTH
-- parameters
--local lang_iso = args['iso'] or ''
--local lang_name = args['langname'] or ''
--------------------------------------------------------------------------
-- Module for links to works by authors in Greek
-- links mostly to el.wikisource
--------------------------------------------------------------------------
--[=[ NOTES
* Authors, works: abbreviations Greek, international (as in [[LSJ]]
-- plus full name too.
* see [[:en:Module:Quotations]] oh là là -- [[:en:Module:Quotations/grc/data]]
* either Templates for specific authors or works (like Iliad)
or, from a general template {{quote|1=<author>|2=<work>|3=chapter}}
]=]--
local data = mw.loadData('Module:sarritest/data')
--local alias = mw.loadData("Module:sarritest/alias")
-- subfunctions, utilities ===============
-- function zero-five: link to el.wikisource verses #v0000 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 '#v' .. 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 '#v' .. mw.ustring.sub(mw.ustring.match(verse, verse), 1, -2) .. '5'
elseif mw.ustring.find(verse, '[05]$') then
return '#v' .. 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 author = args[1] or args['author'] or args['συγγραφέας'] or ''
local work = args[2] or args['work'] or args['έργο'] or ''
local chapter = args[3] or args['chapter'] or args['κεφάλαιο'] or ''
local descr = args['subtitle'] or args['υπότιτλος'] or '' -- o! I see dash, But if i write |τίτλος=- ittt works...
local verse = args[4] or args['verse'] or args['στίχος'] or ''
local verse_alt = args[5] or args['versealt'] or ''
output_author = ''
author_wp = ''
author_title = ''
author_show = ''
output_work = ''
work_wp = ''
work_title = ''
work_show = ''
output_source = ''
source_link = ''
output_chapter = ''
chapter_link = ''
chapter_show = ''
output_verse = ''
verse_link = ''
verse_show = ''
--#I need alias for works and names
-- ============================ AUTHORS AND WORKS =============================
if author == '' or author == nil then -- use OR, not AND
output = errorhere('<span style="color:#b22222; font-size:16px;">Παρακαλούμε, επιλέξτε το όνομα ενός συγγραφέα</span>')
else
--[=[
-- DO NOT place these above
output_author = ''
author_wp = data.authorinfo[author].author_wp or ''
author_title = data.authorinfo[author].author_title or ''
author_show = data.authorinfo[author].author_show or ''
output_work = ''
work_wp = data.workinfo[work].work_wp or ''
work_title = data.workinfo[work].work_title or ''
work_show = data.workinfo[work].work_show or ''
]=]--
-- HOMER see [[Module:quoteHomer]] ==============================================
if author == 'όμηρος' or author == 'Όμηρος' or author == 'Homer' then
output = errorhere('Για τον Όμηρο, χρησιμοποιήστε τα πρότυπα [[Πρότυπο:ΠΘ:Ιλ|ΠΘ:Ιλ]] και [[Πρότυπο:ΠΘ:Οδ|ΠΘ:Οδ]]')
else
-- if data.authorinfo[author].author then
-- test no wikipedia
if author == 'Αισχ' then
author_show='Αἰσχύλος'
if work == 'Αγ' then
output_work = ', '
work_show='Ἀγαμέμνων'
else
output_work = errorhere('Δεν υπάρχει τέτοιο έργο στον κατάλογό μας!')
end
end
-- Ηρόδοτος
if author == 'Ηρ' or author == 'Ηρόδοτος' or author == 'Hdt' then
author_wp = 'Ηρόδοτος' author_title='Ηρόδοτος' author_show='Ἡρόδοτος' author_year='484–425 [[πκε]]'
if work == 'Ιστ' or work == 'Ιστορίαι' or work == 'Hist' then
output_work = ', '
work_wp='Ηροδότου Ιστορίαι' work_title='Ιστορίες' work_show='Ἱστορίαι'
source_link = '[[:el:s:Ιστορίαι (Ηροδότου)'
if chapter == '1' or chapter == 'α' or chapter == 'Α' or chapter == 'Κλειώ' then chapter_link = 'Κλειώ' chapter_show = '1. Κλειώ' end
if chapter == '2' or chapter == 'β' or chapter == 'Β' or chapter == 'Ευτέρπη' then chapter_link = 'Ευτέρπη' chapter_show = '2. Εὐτέρπη' end
if chapter == '3' or chapter == 'γ' or chapter == 'Γ' or chapter == 'Θάλεια' then chapter_link = 'Θάλεια' chapter_show = '3. Θάλεια' end
if chapter == '4' or chapter == 'δ' or chapter == 'Δ' or chapter == 'Μελπομένη' then chapter_link = 'Μελπομένη' chapter_show = '4. Μελπομένη' end
if chapter == '5' or chapter == 'ε' or chapter == 'Ε' or chapter == 'Τερψιχόρη' then chapter_link = 'Τερψιχόρη' chapter_show = '5. Τερψιχόρη' end
if chapter == '6' or chapter == 'στ' or chapter == 'ΣΤ' or chapter == 'Ερατώ' then chapter_link = 'Ερατώ' chapter_show = '6. Ἐρατώ' end
if chapter == '7' or chapter == 'ζ' or chapter == 'Ζ' or chapter == 'Πολύμνια' then chapter_link = 'Πολύμνια' chapter_show = '7. Πολύμνια' end
if chapter == '8' or chapter == 'η' or chapter == 'Η' or chapter == 'Ουρανία' then chapter_link = 'Ουρανία' chapter_show = '8. Οὐρανία' end
if chapter == '9' or chapter == 'θ' or chapter == 'Θ' or chapter == 'Καλλιόπη' then chapter_link = 'Καλλιόπη' chapter_show = '9. Καλλιόπη' end
verse_link = '#v'
else
output_work = errorhere('Δεν υπάρχει τέτοιο έργο στον κατάλογό μας!')
end
end
if author ~= '' and author ~= nil then
-- if there is no wikipedia article
if author_wp == '' or author_wp == nil then
output_author = author_show
else
output_author = '[[:el:w:'
.. author_wp .. '|<span style="background:#f7f7f7;" title="'
.. author_title .. 'στη Βικιπαίδεια">'
.. author_show .. '</span>]]'
end -- close if no author_wp
end -- close if author
-- if there is no wikipedia article
if work_wp == '' or work_wp == nil then
output_work = output_work .. '<i>' .. work_show .. '</i>'
else
output_work = output_work .. '[[:el:w:'
.. work_wp .. '|<span style="background:#f7f7f7;" title="'
.. work_title .. 'στη Βικιπαίδεια">'
.. '<i>' .. work_show .. '</i></span>]]'
end -- close if no work_wp
-- if there is no source
if source_link == '' or source_link == nil then
output_source = ''
output_chapter = ''
output_verse = ''
else -- yes source
output_source = source_link
-- chapter
-- no chapter
if chapter == '' or chapter == nil then
-- no chapter no verse
if verse == '' or verse == nil then
output_chapter = ''
output_verse = '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">'
.. ' στη Βικιθήκη<span>]]'
else -- no chapter, yes verse
output_chapter = ''
output_verse = verse_link .. verse .. '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">'
.. ', ' .. verse_show .. '<span>]]'
end
else -- yes chapter
output_chapter = '/' .. chapter_link
-- yes chapter no verse
if verse == '' or verse == nil then
output_verse = '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">'
.. ', ' .. chapter_show .. '</span>]]'
else -- yes chapter yes verse
-- -- if work_show, add comma
-- if work_show ~= '' and work_show ~= nil then output_work = output_work .. ', ' end
output_verse =
-- need to add verse_show
verse_link .. verse .. '|<span title="αρχαίο κείμενο στη Βικιθήκη" style="background:#f7ffff;" border-bottom: 1px dotted #ddd;">'
.. ', ' .. chapter_show .. ', ' .. verse .. '</span>]]'
end
end -- close if chapter_link exists
end -- close if source exists
output = output_author .. output_work .. output_source .. output_chapter .. output_verse
-- end -- close if data.authorinfo
end -- close if author = Όμηρος
end -- close if author == nil
-- =================CLOSE MAIN FUNCTION:
return output
end
return export