Prijeđi na sadržaj

Modul:Leksemi

Izvor: Wječnik

Documentation for this module may be created at Modul:Leksemi/doc

local p = {}

-- Helper function to extract text from a wikilink or return the original string if not a link.
local function extractText(input)
	if not input then return '' end
	local match = mw.ustring.match(input, "^%[%[(.-)%|(.-)%]%]$")
	if match then
		return mw.ustring.match(input, "^%[%[.-%|(.-)%]%]$")
	else
		return mw.ustring.gsub(input, "^%[%[(.-)%]%]$", "%1")
	end
end

function p.leksem(frame)
	local modArg = mw.getCurrentFrame().args
	local args = mw.getCurrentFrame():getParent().args

	if (modArg['1'] == 'ime') then
		if args['N'] ~= '' and args['N'] ~= nil then
			url = '?form_representation=' .. extractText(args['N']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['G']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['D']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['A']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['V']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['L']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['I']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Nmn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Gmn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Dmn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Amn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Vmn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Lmn']):gsub('[%p%c%s]', '')
				.. '&form_representation=' .. extractText(args['Imn']):gsub('[%p%c%s]', '')
				.. '&generated_via=hr.wiktionary%20script%20by%20User:Ivi104'

			return 'Odaberite JEDAN GUMB!\n\n'
				.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-masculine/' .. url .. ' Popuni leksem (muški rod)]<br/>'
				.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-feminine/' .. url .. ' Popuni leksem (ženski rod)]<br/>'
				.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-neuter/' .. url .. ' Popuni leksem (srednji rod)]<br/>'
		else return ''
		end
	else
		if (modArg['1'] == 'broj') then
			if args['1'] ~= '' and args['1'] ~= nil then
				url = '?form_representation=' .. extractText(args['1']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['3']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['5']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['7']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['9']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['11']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['13']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['2']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['4']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['6']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['8']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['10']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['12']):gsub('[%p%c%s]', '')
					.. '&form_representation=' .. extractText(args['14']):gsub('[%p%c%s]', '')
					.. '&generated_via=hr.wiktionary%20script%20by%20User:Ivi104'

				return 'Odaberite JEDAN GUMB!\n\n'
					.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-masculine/' .. url .. ' Popuni leksem (muški rod)]<br/>'
					.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-feminine/' .. url .. ' Popuni leksem (ženski rod)]<br/>'
					.. '[https://lexeme-forms.toolforge.org/template/croatian-noun-neuter/' .. url .. ' Popuni leksem (srednji rod)]<br/>'
			else return ''
			end
		end
	end
end

return p