Module:title

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

Module:title >> Module:title/τεκμηρίωση
Διαμορφώνει το στυλ του τίτλου σελίδας.

Καλείται από το Πρότυπο:title {{title}} ή ελληνικά: {{τίτλος}}

Creates styles for the page's title. Called by template {{title}}


-- 2019.07.09. Καλεί το [[Πρότυπο:title]]  - It calls [[Template:title]]
-- vertical left to right (e.g. for Mongolian) or italics (e.g. for binominal taxonomic)
-- italics only for *root- e.g. [[:Κατηγορία:Προέλευση λέξεων από την πρωτοϊνδοευρωπαϊκή ρίζα *dewk- (αρχαία ελληνικά)]]
	-- required: [[Module:page]]
-- This Module is an altered version from various 'italics modules'
 
local p = {}
 
function p.main(frame)
    -- Process the arguments
    local args
    if frame == mw.getCurrentFrame() then
        args = frame:getParent().args
        for k, v in pairs(frame.args) do
            args = frame.args
            break
		end
    else
        args = frame
    end    

	-- Get the current page object
    local title = mw.title.getCurrentTitle()
    -- Find the parts before and after a parenthesis, if any.
    local prefix, parenthesis = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
    -- If parenthesis were found, alter only the part before it. Otherwise, the whole title
    local result
    local kind = args['1'] or ''


-- ========================================
-- vertical left to right (default text-orientation:upright is top to bottom) e.g. for Mongolian ᠲᠡᠶᠢᠮᠦ
	if kind == 'vertical-lr' or kind == 'κάθετος-αδ' then
		if prefix and parenthesis and args.all ~= 'yes' then
			result = '<span style="writing-mode:vertical-lr;">' .. prefix .. '</span> ' .. parenthesis
		else
			result = '<span style="writing-mode:vertical-lr;">' .. title.text .. '</span>'
		end
		-- Add the namespace if it exists
		if title.nsText and title.nsText ~= "" then
			result = title.nsText .. ':' .. result
		end
		-- Call displaytitle with the generated text
    	return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )

--===================================== italics only one word
-- [[:Κατηγορία:Προέλευση λέξεων από την πρωτοϊνδοευρωπαϊκή ρίζα *gʷelH- (αρχαία ελληνικά)]]
	-- This is placed as expanded [[Template:title]] at [[Module:auto cat]]
	elseif kind  == 'root' or kind == 'ρίζα' then
		local cat_title = require("Module:page").pagetitle(xx)	-- Title WITHOUT (textinparenthesis)
		if mw.ustring.find(cat_title, 'Προέλευση λέξεων από') and mw.ustring.find(cat_title, 'ρίζα') 
		and mw.ustring.find(cat_title, 'πρωτοϊνδοευρωπαϊκή') and mw.ustring.find(cat_title, '*')
		then
		root_word = mw.ustring.sub(mw.ustring.match(cat_title, "ρίζα (.*)"), 1, -1)
		end
		
		if prefix and parenthesis and args.all ~= 'yes' then
			result = "Προέλευση λέξεων από την πρωτοϊνδοευρωπαϊκή ρίζα ''" .. root_word .. "'' " .. parenthesis
		else
			result = "Προέλευση λέξεων από την πρωτοϊνδοευρωπαϊκή ρίζα ''" .. root_word .. "'' "
		end
		-- Add the namespace if it exists
		if title.nsText and title.nsText ~= "" then
			result = title.nsText .. ':' .. result
		end
		-- Call displaytitle with the generated text
		return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )

--===================================== TEST bareia [[ὤδινεν ὄρος καί ἔτεκεν μῦν]] 
-- NO, it does not work Κατηγορία:Σελίδες με αγνοημένη προβολή τίτλου
	elseif kind  == 'bareia' or kind == 'βαρεία' then
		local cat_title = require("Module:page").pagetitle(xx)	-- Title WITHOUT (textinparenthesis)
		if mw.ustring.find(cat_title, 'καί')
		then
		cat_title = mw.ustring.gsub(cat_title, "ί", "ὶ")
		end
		
		if prefix and parenthesis and args.all ~= 'yes' then
			result = cat_title .. parenthesis
		else
			result = cat_title
		end
		-- Add the namespace if it exists
		if title.nsText and title.nsText ~= "" then
			result = title.nsText .. ':' .. result
		end
		-- Call displaytitle with the generated text
		return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )


--====================================== italics
		else
-- italics e.g. for taxonomic binominals e.g. [[Alectoris graeca]]
	if kind  == 'italics' or kind == 'πλάγιος' then
		if prefix and parenthesis and args.all ~= 'yes' then
			result = "''" .. prefix .. "'' " .. parenthesis
		else
			result = "''" .. title.text .. "''"
		end
		-- Add the namespace if it exists
		if title.nsText and title.nsText ~= "" then
			result = title.nsText .. ':' .. result
		end
		-- Call displaytitle with the generated text
		return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )
		
	end -- CLOSE if kind = 
	end -- ?
end -- CLOSE FUNCTION MAIN

return p