Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Vollbracht/Hiero/Cartouche/Doku erstellt werden
--<syntaxhighlight lang="Lua">
--[=[ Hiero/Cartouche 2022-02-03
Module for Generating Serechs and Cartouches - Vertical and Horrizontal
Author: Vollbracht
* Cartouche.title(NameType, language)
* Cartouche.name(frame, NameType, code, symbol, border)
]=]
--Module globals
local p = {service = {}}
-- multi language title visible for readers
p.service.Title = function(NameType, language)
local list = {
de={Horus='[[Horusname]]',
Seth='[[Peribsen#Sethname statt Horusname|Sethname]]',
HorusSeth='Horus-Seth-Name',
Nebti='[[Nebtiname]]', Gold='[[Goldname]]', Thron='[[Thronname]]',
Eigen='[[Eigenname (Pharao)|Eigenname]]',
Turin='[[Königspapyrus Turin|Transliteration aus Turin]]',
Sakkara='[[Königsliste von Sakkara|in Sakkara]]',
Sethos1='[[Königsliste von Abydos (Sethos I.)|in Abydos (Sethos I.)]]',
Ramses2='[[Königsliste von Abydos (Ramses II.)|in Abydos (Ramses II.)]]'
},
en={Horus='[[Horus name]]', Seth='Seth cartouche',
HorusSeth='Horus-Seth cartouche', Nebti='[[Nebty name]]',
Gold='[[Ancient Egyptian royal titulary#Horus of Gold|gold]]',
Thron='[[Prenomen (Ancient Egypt)|Prenomen]]',
Eigen='[[Nomen (ancient Egypt)|Nomen]]',
Turin='[[Turin King List|Transliteration in Turin]]',
Sakkara='[[Saqqara Tablet|in Saqqara]]',
Sethos1='[[Abydos King List|in Abydos (Sethos I.)]]',
Ramses2='in Abydos (Ramses II.)'
}
}
local LangList = list[language] or list.de
return LangList[NameType]
end
local function getData(NameType)
-- mw.log(NameType, 'Typ:')
local list = {
Horus={code={"G5", "G5\\"}, bordertype="serech", BorderDefault='rtd',
postfix="none"},
Seth={code={"E20", "E20\\"}, bordertype="serech", BorderDefault='rtd',
postfix="none"},
HorusSeth={code={"G5\\-E20", "G5\\-E20"}, bordertype="serech",
BorderDefault='none', postfix="none"},
Nebti={code={"G16", "G16\\"}, bordertype="Cartouche",
BorderDefault='none', postfix="none"},
Gold={code={"G8", "G8"}, bordertype="Cartouche", BorderDefault='none',
postfix="none"},
Thron={code={"M23:X1-L2:X1", "L2\\:X1-M23\\:X1"},
bordertype="Cartouche", BorderDefault='rtl', postfix="none"},
Eigen={code={"G39-N5", "N5-G39\\"}, bordertype="Cartouche",
BorderDefault='rtl', postfix="none"},
Turin={code={"", ""}, bordertype="Cartouche", BorderDefault='none',
postfix="none"},
Sethos1={code="N35!M23-X1:N35", bordertype="Cartouche",
BorderDefault='ltd', postfix="none"},
Ramses2={code="M23-X1-S3", bordertype="Cartouche",
BorderDefault='rtd', postfix="none"},
-- white/red crown, without/with Scourge, allways rtd
Sakkara={code={"X1:N35-M23\\!A43\\", "X1:N35-M23\\!A45\\",
"X1:N35-M23\\!A44\\", "X1:N35-M23\\!A46\\"},
bordertype="Cartouche", BorderDefault='rtd',
postfix="Aa11\:P8H\\"}
}
return list[NameType]
end
local SakkaraWithScourge = function(noIsEven)
if noIsEven then return "X1:N35-M23\\!A46\\" end
return
end
-- name (single language errors visible for authors)
p.name = function(frame)
-- mw.logObject(frame.args, 'Cartouche: args in p.name: ')
if frame.args.kind == nil then return 'Fehler: kein Typ angegeben' end
if frame.args.code == nil then return 'Fehler: kein Inhalt angegeben' end
local kind = frame.args.kind;
local code = frame.args.code;
local symbol = frame.args.symbol or 'default'
local border = frame.args.border or 'default'
local postfix = frame.args.postfix or 'default'
return p.service.name(frame, kind, code, symbol, border, postfix)
end
-- name (single language errors visible for authors)
p.service.name = function(frame, NameType, code, symbol, border, postfix)
mw.log('Hiero/Cartouche.service.name:\n')
local typeData = getData(NameType)
mw.logObject(typeData, 'Typdaten:')
if typeData == nil then
return 'Fehler: unbekannter Typ "' .. NameType .. '"'
end
if code == nil then return 'Fehler: kein Inhalt angegeben' end
local direction = ''
local typeSymbol = ''
local typePostfix = ''
if NameType == 'Sakkara' or NameType == 'Saqqara' then
border = 'rtd'
direction = 'rtd'
if symbol == 'odd' or symbol == 'white' or symbol == 0 then
-- odd by ordinal No. / 0 = (row+col)%2 : white crown
typeSymbol = typeData.code[1]
elseif symbol == 'even' or symbol == 'red' or symbol == 1 then
-- even by ordinal No. / 1 = (row+col)%2 : red crown
typeSymbol = typeData.code[2]
elseif symbol == 'oddWithScourge' or symbol == 'whiteWithScourge'
or symbol == 26 or symbol == 28 or symbol == 56 then
-- white crown and scourge by ordinal No.
typeSymbol = typeData.code[3]
elseif symbol == 'evenWithScourge' or symbol == 'redWithScourge'
or symbol == 27 or symbol == 29 or symbol == 57 then
-- red crown and scourge by ordinal No.
typeSymbol = typeData.code[4]
elseif symbol ~= 'none' then
typeSymbol = symbol
else
return 'Fehler: kein Symbol angegeben'
end
else
-- refine border to direction
if border == 'nil' or border == '' then direction = typeData.BorderDefault
else direction = border end
-- refine symbol to typeSymbol:
if symbol == nil or symbol == 'default' or symbol == '' then
if direction == 'ltr' or border == 'ltd' then
typeSymbol = typeData.code[1]
else
typeSymbol = typeData.code[2]
end
elseif symbol ~= 'none' then
typeSymbol = symbol
end
end
if postfix == nil or postfix == 'default' or postfix == '' then
typePostfix = typeData.postfix
else
typePostfix = postfix
end
-- capture missuse
if direction == 'none' then -- default: ltr
if typePostfix ~= 'none' then code = code .. ' ' .. typePostfix end
if typeSymbol == '' then
-- Turin: No cartouche! Code should be surrounded with inline
-- cartouche start and end symbols as far as legible.
-- Missuse? No name just hiero?
return frame:preprocess('<hiero>' .. code .. '</hiero>')
else
-- Gold: possible design flaw! Default should rather be stacked,
-- right? Regarde typePostfix as well then!
return frame:preprocess('<hiero>' ..
typeSymbol .. '-' .. code .. '</hiero>')
end
end
-- Border and direction are given.
if typeSymbol == 'none' and typePostfix == 'none' then
if typeData.bordertype == 'Cartouche' then
if direction == 'ltr' or direction == 'rtl' then
return '<table class="Cartouche"><tr><td class="lr">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr></table>'
else
return '<table class="Cartouche"><tr><td class="td">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr></table>'
end
else
-- Serech w.o. symbol: unlikely in history
if direction == 'ltr' or direction == 'rtl' then
-- Horrizontal serech: unlikely in history! Avoid!
return '<table class="Serech"><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td class="lr"></td></tr></table>'
else
-- Vertical serech: w.o. symbol still unlikely in history
return '<table class="Serech"><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td class="td"></td></tr></table>'
end
end
elseif typePostfix == 'none' then
-- Border, direction and symbol are given.
if typeData.bordertype == 'Cartouche' then
if direction == 'ltr' or direction == 'rtl' then
return '<table class="Cartouche"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td><td class="lr">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr></table>'
else
return '<table class="Cartouche"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td></tr><tr><td class="td">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr></table>'
end
else
-- Draw in serech:
if direction == 'ltr' or direction == 'rtl' then
-- Horrizontal serech: unlikely in history! Avoid!
return '<table class="Serech"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td class="lr"></td></tr></table>'
else
return '<table class="Serech"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td></tr><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td class="td"></td></tr></table>'
end
end
elseif typeSymbol == 'none' then
-- Border, direction and postfix are given.
if typeData.bordertype == 'Cartouche' then
if direction == 'ltr' or direction == 'rtl' then
return '<table class="Cartouche"><tr><td class="lr">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td></tr></table>'
else
return '<table class="Cartouche"><tr><td class="td">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td></tr></table>'
end
else
-- Draw in serech:
if direction == 'ltr' or direction == 'rtl' then
-- Horrizontal serech: unlikely in history! Avoid!
return '<table class="Serech"><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td><td class="lr"></td></tr></table>'
else
return '<table class="Serech"><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td class="td"></td></tr><tr><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td></tr></table>'
end
end
else
-- Border, direction, symbol and postfix are given.
if typeData.bordertype == 'Cartouche' then
if direction == 'ltr' or direction == 'rtl' then
return '<table class="Cartouche"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td><td class="lr">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td><td class="lr"></td></tr></table>'
else
return '<table class="Cartouche"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td></tr><tr><td class="td">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td></tr></table>'
end
else
-- Draw in serech:
if direction == 'ltr' or direction == 'rtl' then
-- Horrizontal serech: unlikely in history! Avoid!
return '<table class="Serech"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td><td class="lr"></td><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td><td class="lr"></td></tr></table>'
else
return '<table class="Serech"><tr><td>' ..
frame:preprocess('<hiero>' ..
typeSymbol .. '</hiero>') ..
'</td></tr><tr><td class="core">' ..
frame:preprocess('<hiero>' .. code .. '</hiero>') ..
'</td></tr><tr><td class="td"></td></tr><tr><td>' ..
frame:preprocess('<hiero>' ..
typePostfix .. '</hiero>') ..
'</td></tr></table>'
end
end
end
end
return p
--</syntaxhighlight>