Module:User:Xoristzatziki/test

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση

Documentation for this module may be created at Module:User:Xoristzatziki/test/τεκμηρίωση

-- επιστρέφει τον πίνακα για τη ΛτΗ στη σελίδα [[Βικιλεξικό:Λέξη_της_Ημέρας]]
-- με βάση την τρέχουσα ημερομηνία του server
_p ={}
 
local datefunctions = require "Module:DateFunctions"
local monthdays = 0
local firstday = 0
--δημιουργία ανεξάρτητου frame (expensive?)
--ώστε και να μη χρειάζεται στη συνάρτηση λέξη
--και να μπορεί να τρέξει και στην κονσόλα δοκιμών 
local framehere = mw.getCurrentFrame()

--
--βρες τώρα τη λέξη της ημέρας
function leksi (hmera)
    if hmera<1 or hmera>31 then return '' end
    local leksinum = 'ΛτΗ' .. d
    local leksi = framehere:expandTemplate{ title = leksinum, args = { } }
    return leski
end 

function forweek1(keli)    
    if keli < firstday then
        return ''
    else
        local d = keli - firstday + 1 
        return "'''" .. d .. "''' <br> '''[[" ..  leksi(d) .. "]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit αλλαγή] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history ιστορικό ]</small>"
    end
end

function forweek2to4(keli)    
    local d = keli - firstday + 1 
    return "'''" .. d .. "''' <br> '''[[" ..  leksi(d) .. "]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit αλλαγή] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history ιστορικό ]</small>"
end 

function forweek1(keli)    
    if keli < firstday then
        return ''
    else
        local d = keli - firstday + 1 
        return "'''" .. d .. "''' <br> '''[[{{ΛτΗ" ..  d .. "}}]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit αλλαγή] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history ιστορικό ]</small>"
    end
end
 
function forweek2to4(keli)    
    local d = keli - firstday + 1 
    return "'''" .. d .. "''' <br> '''[[{{ΛτΗ" ..  d .. "}}]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit αλλαγή] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history ιστορικό ]</small>"
end
 
function _p.daystable(frame)
-- χρησιμοποίησε το δημιουργημένο εδώ frame και όχι αυτό που πήραμε
    monthdays = datefunctions.getMonthDays(frame)
    firstday = datefunctions.getfirstDayNum(frame)
--    monthdays = 28
--    firstday = 1
    local dayssum = monthdays + firstday -1
    local rowstart = '|style=\'width:100px\' align=\'center\' | '
    t = [=[<center>
{|style="float:center; border:5px solid #008B8B; background:#FFFACD;" rules="all" class=plainlinks
|- 
! bgcolor="#008B8B" colspan="1" | Δευτέρα
! bgcolor="#008B8B" colspan="1" | Τρίτη
! bgcolor="#008B8B" colspan="1" | Τετάρτη
! bgcolor="#008B8B" colspan="1" | Πέμπτη
! bgcolor="#008B8B" colspan="1" | Παρασκευή
! bgcolor="#008B8B" colspan="1" | Σάββατο
! bgcolor="#008B8B" colspan="1" | Κυριακή
|- 
]=] 
    for xcounter = 1,7 do
        t = t .. rowstart .. forweek1(xcounter) .. '\n'
    end
    --προσθήκη νέας γραμμής
    t = t .. '\n|-\n'
    for ycounter = 1, 3 do
        for xcounter = ((7*ycounter)+1),((7*ycounter)+7) do
            t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
        end
        --προσθήκη νέας γραμμής στο τέλος κάθε σειράς
        t = t .. '\n|-\n'
    end
 
    if dayssum > 28 then		
		for xcounter = 29,35 do
            if dayssum >= xcounter then
                t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
            else
                t = t .. '| &nbsp;' .. '\n'
            end
        end
    end
    --προσωρινή λύση
    if dayssum > 35 then
        t = t .. '\n' .. '|-' .. '\n'
        for xcounter = 36,42 do
            if dayssum >= xcounter then
                t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
            else
                t = t .. '| &nbsp;' .. '\n'
            end
        end    
        --προσθήκη νέας γραμμής
        t = t .. '\n|-\n'
    end
 	--αφαίρεση της έναρξης νέας γραμμής
 	--(μάλλον δεν θεωρεί το \n σαν 2 χαρακτήρες αυτή η έκδοση scribunto)
 	t = mw.ustring.sub(t, 1, -2)
 	--τέλος πίνακα και κεντραρίσματος
    t = t .. '\n|}</center>'
    return frame:preprocess(t)  
--    return t
end

function _p.testtext(frame)
	local args = frame.args
	local pargs = frame:getParent().args
	local title = mw.title.getCurrentTitle()
	local ptitle = frame:getParent():getTitle()
	local ftitle = title.fullText

	return frame:preprocess('### ' .. ptitle .. ' #### ' .. ftitle)
end

_p.test2etym = function(frame)
	local args = frame.args
	local pargs = frame:getParent().args
	onearg = pargs['ετυμ'] or ''
	one1arg = pargs[1]
	return "#" .. onearg .. "#" .. "*" .. one1arg .."*"
end

_p.test3 = function(frame)
	local b = mw.title.getCurrentTitle():inNamespace(0)
	local testtitle = "title"
	local testblah = "blah"
	if b then
		testblah = 'και πριν <span title="' .. testtitle ..'" ><u>' .. testblah .. '</u></span> και μετά'
	end
	
	return testblah
end
	
return _p