Module:User:Xoristzatziki/test1 Jul 29th 2013, 06:43, by Xoristzatziki | | Line 9: | Line 9: | | --TODO παραμετροποίηση χρωμάτων για ευκολότερη μελλοντική τροποποίηση | | --TODO παραμετροποίηση χρωμάτων για ευκολότερη μελλοντική τροποποίηση | | fulltable = function (args,frame) | | fulltable = function (args,frame) | − | local output ='' | + | --local output ='' | | local stitlestr = '' | | local stitlestr = '' | | local ptitlestr = '' | | local ptitlestr = '' | Line 57: | Line 57: | | klplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[8], lang = 'el' } } .. '\n' | | klplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[8], lang = 'el' } } .. '\n' | | end | | end | − | output= '<div class="NavFrame" style="width:' .. width1 .. '">\n' | + | --output= '<div class="NavFrame" style="width:' .. width1 .. '">\n' | | --PROBLEM. preprocessing Closes first div and NOT the closer div | | --PROBLEM. preprocessing Closes first div and NOT the closer div | | -- output = output .. '<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n' | | -- output = output .. '<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n' | − | local tempoutput = frame:preprocess('<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n') | + | -- local tempoutput = frame:preprocess('<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n') | − | output = output .. tempoutput .. '<div class="NavContent">\n' | + | --bypassing buggy div | | + | local output = '<div class="NavContent">\n' | | output = output .. '{| style="background:#fdfdfd; text-align:center; width:' .. width2 .. '; border-collapse:separate; border-spacing:1px" class="inflection-table"' .. '\n' | | output = output .. '{| style="background:#fdfdfd; text-align:center; width:' .. width2 .. '; border-collapse:separate; border-spacing:1px" class="inflection-table"' .. '\n' | | output = output .. '|-' .. '\n' | | output = output .. '|-' .. '\n' | Line 68: | Line 68: | | output = output .. '! style="background:#e0f0ff" | genitive <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[γενική]]', lang = 'el' } } .. ')</small>' .. '\n' .. genenstr .. genplstr .. '|-\n' | | output = output .. '! style="background:#e0f0ff" | genitive <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[γενική]]', lang = 'el' } } .. ')</small>' .. '\n' .. genenstr .. genplstr .. '|-\n' | | output = output .. '! style="background:#e0f0ff" | accusative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[αιτιατική]]', lang = 'el' } } .. ')</small>' .. '\n' .. aitenstr .. aitplstr .. '|-\n' | | output = output .. '! style="background:#e0f0ff" | accusative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[αιτιατική]]', lang = 'el' } } .. ')</small>' .. '\n' .. aitenstr .. aitplstr .. '|-\n' | − | output = output .. '! style="background:#e0f0ff" | vocative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[κλητική]]', lang = 'el' } } .. ')</small>' .. '\n' .. klenstr .. klplstr .. notes .. '\n' .. '|}</div></div>' | + | output = output .. '! style="background:#e0f0ff" | vocative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[κλητική]]', lang = 'el' } } .. ')</small>' .. '\n' .. klenstr .. klplstr .. notes .. '\n' .. '|}</div>' | | | | | − | return output | + | return frame:preprocess(output) | | end | | end | | | | |
- This module needs documentation and categorisation. Please create the documentation page.
-- create decl table for greek nouns -- either with stem + endings -- or with full words -- Also an option -- to select if only singular or only plural exists _module ={} --TODO παραμετροποίηση χρωμάτων για ευκολότερη μελλοντική τροποποίηση fulltable = function (args,frame) --local output ='' local stitlestr = '' local ptitlestr = '' local onomenstr = '' local onomplstr = '' local genenstr = '' local genplstr = '' local aitenstr = '' local aitplstr = '' local klenstr = '' local klplstr = '' local notes = '' local width1 = '50em' local width2 = '100%' local width3 = '33%' local cols = 4 local hassingular = true PAGENAME = mw.title.getCurrentTitle().text --if user wants only plural if args['plural'] ~= nil then hassingular = false end local hasplural = true --if user wants only singular if args['singular'] ~= nil then hasplural = false end if hassingular ~= hasplural then width1 = '40em' width2 = '40em' width3 = '50%' cols = 3 end if not (args['notes'] == nil or mw.ustring.len(args['notes']) < 1) then notes = '|-\n| colspan="' .. cols .. '" align="left" style="background:#d9ebff; font-size: 90%; font-style: italic;" | ' notes = notes .. args['notes'] .. '\n' end if hassingular then stitlestr = '! style="background:#cce4fc" | singular <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[ενικός]]', lang = 'el' } } .. ')</small>' .. '\n' onomenstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[1], lang = 'el' } } .. '\n' genenstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[3], lang = 'el' } } .. '\n' aitenstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[5], lang = 'el' } } .. '\n' klenstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[7], lang = 'el' } } .. '\n' end if hasplural then ptitlestr = '! style="background:#cce4fc" | plural <small>(' .. frame:expandTemplate{title = 'Grek', args = { '[[πληθυντικός]]', lang = 'el' } } .. ')</small>' .. '\n' onomplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[2], lang = 'el' } } .. '\n' genplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[4], lang = 'el' } } .. '\n' aitplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[6], lang = 'el' } } .. '\n' klplstr = '|' .. frame:expandTemplate{ title = 'Grek', args = { args[8], lang = 'el' } } .. '\n' end --output= '<div class="NavFrame" style="width:' .. width1 .. '">\n' --PROBLEM. preprocessing Closes first div and NOT the closer div -- output = output .. '<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n' -- local tempoutput = frame:preprocess('<div class="NavHead" style="background:#cce4fc; text-align:left" >\ndeclension of ' .. frame:expandTemplate{ title = 'Grek', args = { PAGENAME, lang = 'el' } } .. '\n</div>\n') --bypassing buggy div local output = '<div class="NavContent">\n' output = output .. '{| style="background:#fdfdfd; text-align:center; width:' .. width2 .. '; border-collapse:separate; border-spacing:1px" class="inflection-table"' .. '\n' output = output .. '|-' .. '\n' output = output .. '! style="width:' .. width3 .. ';background:#cce4fc" |' .. '\n' .. stitlestr .. ptitlestr .. '|-\n' output = output .. '! style="background:#e0f0ff" | nominative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[ονομαστική]]', lang = 'el' } } .. ')</small>' .. '\n' .. onomenstr .. onomplstr .. '|-\n' output = output .. '! style="background:#e0f0ff" | genitive <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[γενική]]', lang = 'el' } } .. ')</small>' .. '\n' .. genenstr .. genplstr .. '|-\n' output = output .. '! style="background:#e0f0ff" | accusative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[αιτιατική]]', lang = 'el' } } .. ')</small>' .. '\n' .. aitenstr .. aitplstr .. '|-\n' output = output .. '! style="background:#e0f0ff" | vocative <small>(' .. frame:expandTemplate{ title = 'Grek', args = { '[[κλητική]]', lang = 'el' } } .. ')</small>' .. '\n' .. klenstr .. klplstr .. notes .. '\n' .. '|}</div>' return frame:preprocess(output) end -- @param --TODO change these two params to one (num = '' or 'singular' or 'plural' -- 'singular' : (not empty, with anything as value) only singular -- 'plural' : (not empty, with anything as value) only plural -- 'stem1' : stem -- 1 : nominative singular -- 2 : nominative plural -- 'αε' : αιτιατική του ενικού (ή μόνο η κατάληξη) -- 'κε' : κλητική του ενικού (ή μόνο η κατάληξη) -- 'οπ' : ονομαστική του πληθυντικού (ή μόνο η κατάληξη) -- 'γπ' : γενική του πληθυντικού (ή μόνο η κατάληξη) -- 'απ' : αιτιατική του πληθυντικού (ή μόνο η κατάληξη) -- 'κπ' : κλητική του πληθυντικού (ή μόνο η κατάληξη) -- αν υπάρχει παράμετρος "θέμα1" τότε -- οι παράμετροι περιέχουν μόνο τις καταλήξεις -- οπότε προσθέτουμε και το θέμα1 function _module.declwithstem(frame) local args = frame.args local lemmaargs = frame:getParent().args -- if stem1 exists means that numbered parameters are only endings if args['stem1'] ~= nil and mw.ustring.len(args['stem1']) > 0 then -- concatenate them args[1] = args['stem1'] .. args[1] args[2] = args['stem1'] .. args[2] args[3] = args['stem1'] .. args[3] args[4] = args['stem1'] .. args[4] args[5] = args['stem1'] .. args[5] args[6] = args['stem1'] .. args[6] args[7] = args['stem1'] .. args[7] args[8] = args['stem1'] .. args[8] end --inherit notes from notes in lemma's template invocation --override template notes --TODO concatenate notes from lemma and template if ((lemmaargs['notes'] ~= nil) or (lemmaargs['notes'] ~='')) then args['notes'] = lemmaargs['notes'] end -- else parameters are full words -- preprocess is necessery because it includes Template Grek return frame:preprocess(fulltable(args,frame)) end function _module.declwithstemtext(frame) local args = frame.args local lemmaargs = frame:getParent().args -- if stem1 exists means that numbered parameters are only endings if args['stem1'] ~= nil and mw.ustring.len(args['stem1']) > 0 then -- concatenate them args[1] = args['stem1'] .. args[1] args[2] = args['stem1'] .. args[2] args[3] = args['stem1'] .. args[3] args[4] = args['stem1'] .. args[4] args[5] = args['stem1'] .. args[5] args[6] = args['stem1'] .. args[6] args[7] = args['stem1'] .. args[7] args[8] = args['stem1'] .. args[8] end --inherit notes from notes in lemma's template invocation --override template notes --TODO concatenate notes from lemma and template if ((lemmaargs['notes'] ~= nil) or (lemmaargs['notes'] ~='')) then args['notes'] = lemmaargs['notes'] end -- else parameters are full words -- preprocess is necessery because it includes Template Grek return fulltable(args,frame) end -- for debuging in debug console -- remove hyphens to uncomment function _module.test() local args = {} --args['stem1'] = 'θέμα' args[1] = 'ονομεν' args[2] = 'γενεν' args[3] = 'αιτεν' args[4] = 'κλεν' args[5] = 'ονομπλ' args[6] = 'γενπλ' args[7] = 'αιτπλ' args[8] = 'κλπλ' --args['plural'] = 1 --args['singular'] = 1 --args['notes'] = 'some notes with [[anything]]' return fulltable2(args) --unprocessed text, not expanded end return _module |