Modül:Günün sözü

Vikisöz, özgür söz dizini

Bu modül için bir Modül:Günün sözü/belge belgelendirmesi oluşturabilirsiniz

local months = {'january','february','march','april','may long','june','july','august','september','october','november','december'}
local base = 'Günün sözü'
local lang = mw.language.getContentLanguage()
local p = {}

function monthNumber(monthName)
	for i,x in pairs(months) do
		if lang:ucfirst(mw.message.new(x):plain())==lang:ucfirst(monthName) then
			return i
		end
	end
end

function p.ay(frame)
	local str = frame.args[1]
	local iw = false
	if str==nil or str=='' then
		-- if no month or year are specified, try to autodetect them via the page title
		str = mw.title.getCurrentTitle().subpageText
		iw = true
	end
	local month,year = string.match(str,'^(%S+) (%d+)$')
	if month==nil or year==nil then
		return nil
	end
	local mn = monthNumber(month)
	local mt = string.format('%02d',mn)
	
	
	if mn==nil then
		return nil
	end
	local output = {}
	for x = 1,tonumber(lang:formatDate('t',year..'-'..mn..'-01')) do
		local tt = mw.site.namespaces[4].name..':'..base..string.format('/%d/%02d/%02d',year,mn,x)-- Vikisöz:Günün_sözü/2016/02/04
		local t = ';'..x..' '..month..' '..year..'\n'--Başlığı yazıyor. Örnek: 1 Ocak 2014
		local ok,result = pcall( frame.expandTemplate, frame, { title=tt } )
		local xt = string.format('%02d',x) --Gün numarasını 2 hanesi sayıya çeviriyor
		if ok then
			-- Günün sözü belirli ise onu ekranda gösteriyor
			t = t..result..'\n<span class="plainlinks">[https://tr.wikiquote.org/wiki/Vikisöz:Günün_sözü/'..year..'/'..mt..'/'..xt..' Görüntüle] - [https://tr.wikiquote.org/w/index.php?title=Vikisöz:Günün_sözü/'..year..'/'..mt..'/'..xt..'&action=edit Değiştir] - [https://tr.wikiquote.org/w/index.php?title=Vikisöz:Günün_sözü/'..year..'/'..mt..'/'..xt..'&action=history Geçmiş]</span>'
		else
			-- Günün sözü belirlenmemiş ise ona  oluştur bağlantısı veriyor
			
			t = t..'<span class="plainlinks">[[File:Add.svg|15px]] [https://tr.wikiquote.org/w/index.php?title=Vikisöz:Günün_sözü/'..year..'/'..mt..'/'..xt..'&preload=Vikisöz:Günün_sözü/Önyükleme&action=edit Oluştur]</span>'
		end
		table.insert(output,t)
	end
	output[1] = frame:expandTemplate{ title = 'Günün sözü yıl arşivi', args = {year} }..'\n\n'..output[1] --Sayfanın en başına {{Günün sözü yıl arşivi|YIL}} şablonu ekliyor
	-- categorization
	output[#output] = output[#output]..'\n[['..mw.site.namespaces[14].name..':'..base..']]'
	if iw then
		output[#output] = output[#output]..'\n[[en:Wikiquote:Quote of the day/'..mw.message.new(months[mn]):inLanguage('en'):plain()..' '..year..']]'
	end
	return table.concat(output,'\n\n----\n')
end

return p