Modul:Hiero/Cell
Modul:Hiero Cell
| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | ||
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
local p = {}
local Cell = {}
-- order of special names part 1: by type, variable number of values
Cell.order1 = {
"Horus",
"Seth",
"HorusSeth",
"Nebti",
"Thron",
"Eigen",
"Sakkara"
}
-- order of listed Pharaohs: by row and column in primary source, one value each
Cell.order2 = {
"Turin",
"Sethos1",
"Ramses2",
"Sakkara"
}
-- list of king lists
Cell.kingLoL = {
Turin = {},
Sethos1 = {{{'Y5:N35!M17'},
{'X1:x1!M17'}, {'M17:X1!U33'}, {'M17:X1!unvollst.'}}},
Ramses2 = {{}},
Sakkara={{}}
}
local function getService(ModName)
local _, Mod = pcall(require, ModName)
assert(type(Mod) == 'table',
'404 Module fehlen / missing ' .. ModName)
assert(type(Mod.service) == 'table',
'Object fehlt / missing: ' .. ModName .. '.service')
return Mod.service
end
local _, Parser = pcall(require, "Modul:SimpleStruct")
local Cartouche = getService("Modul:Hiero/Cartouche")
local trace = ''
local function pre(frame, code)
return frame:preprocess('<hiero>' .. code .. '</hiero>')
end
-- Title
-- capsuling Cartouche.Title
Cell.Title = function(NameType, language, rowspan)
mw.log(NameType)
if rowspan < 2 then
return '<td>' .. Cartouche.Title(NameType, language) .. '</td>'
else
return '<td rowspan="' .. rowspan .. '">' ..
Cartouche.Title(NameType, language) .. '</td>'
end
end
p.Title = function(frame)
mw.logObject(frame.args, 'Cell:p.Title args:')
if frame.args[1] == nil then return '<td>name type: ???</td>' end
if frame.args[1] == '' then return '<td>name type: ???</td>' end
return Cell.Title(frame.args[1], frame.args[2], 1)
end
-- Wiki
-- annotation cells for lists not for template use
Cell.Wiki = function(frame, content, span)
if type(span) == 'number' then
return '<td rowspan="' .. span .. '">' .. frame:preprocess(content) .. '</td>'
end
if span == 'col' then
return '<td colspan="2">' .. frame:preprocess(content) .. '</td>'
end
return '<td>' .. frame:preprocess(content) .. '</td>'
end
p.Wiki = function(frame)
return '<td style="text-decoration:line-through">Hiero/Cell.Wiki</td>'
end
-- simple
-- hieros given in code
Cell.simple = function(frame, code)
return '<td class="hiero">' .. pre(frame, code) .. '</td>'
end
function p.simple(frame)
local hieros = frame.args[1] or ''
return Cell.simple(frame, hieros)
end
-- name
-- hiero code + cartouche kind, symbol and border
Cell.name = function(frame, kind, code, symbol, border, colspan)
mw.logObject(Cartouche, 'Cell.name: Cartouche:')
mw.logObject({kind, code, symbol, border, colspan}, 'Cell.name: ')
mw.log('call cartouche with fewer params:\n')
local result = Cartouche.name(frame, kind, code, symbol, border)
mw.log(result, 'Cell.name: Cartouche.name: ')
if colspan == 2 then
return '<td class="hiero" colspan="2">' .. result .. '</td>'
end
return '<td class="hiero">' .. result .. '</td>'
end
function p.name(frame)
mw.logObject(frame.args, 'Cell: args for p.name: ')
local styles = frame.args.styles or ''
return Cell.name(frame, frame.args.kind, frame.args.code,
frame.args.symbol, frame.args.border,
frame.args.colspan)
end
--spacedWiki
-- spaced cells for lists not for template use
Cell.spacedWiki = function(frame, content, span)
local core = Cell.Wiki(frame, content, 1)
if type(span) == 'number' and span > 1 then
return core .. '<td rowspan="' .. span .. '"></td>'
end
return core .. '<td></td>'
end
p.spacedWiki = function(frame)
return '<td style="text-decoration:line-through">Hiero/Cell.spacedWiki</td>'
end
--spacedSimple
-- spaced cells for lists not for template use
Cell.spacedSimple = function(frame, code, span)
if type(span) == 'number' and span > 1 then
return Cell.simple(frame, code) .. '<td rowspan="' .. span .. '"></td>'
end
return Cell.simple(frame, code) .. '<td></td>'
end
p.spacedSimple = function(frame)
return '<td style="text-decoration:line-through">Hiero/Cell.spacedSimple</td>'
end
--spacedName
-- spaced cells for lists not for template use
Cell.spacedName = function(frame, kind, code, symbol, border, span)
local core = Cell.name(frame, kind, code, symbol, border, 1)
if type(span) == 'number' and span > 1 then
return core .. '<td rowspan="' .. span .. '"></td>'
end
return core .. '<td></td>'
end
--annotatededWiki
-- spaced cells for lists not for template use
Cell.annotatededWiki = function(frame, content, content2, span)
if type(span) == 'number' and span > 1 then
return Cell.Wiki(frame, content, 1) .. Cell.Wiki(frame, content2, span)
end
return Cell.Wiki(frame, content, 1) .. Cell.Wiki(frame, content2, 1)
end
p.annotatededWiki = function(frame)
return '<td style="text-decoration:line-through">Hiero/Cell.annotatededWiki</td>'
end
--annotatedSimple
-- spaced cells for lists not for template use
Cell.annotatedSimple = function(frame, code, content, span)
if type(span) == 'number' and span > 1 then
return Cell.simple(frame, code) .. Cell.Wiki(frame, content, span)
end
return Cell.simple(frame, code) .. Cell.Wiki(frame, content, 1)
end
p.annotatedSimple = function(frame)
return '<tr>' ..
Cell.annotatedSimple(frame, frame.args[1], frame.args[2]) ..
'</tr>'
end
--annotatedName
-- spaced cells for lists not for template use
Cell.annotatedName = function(frame, kind, code, symbol, border, content, span)
local core = Cell.name(frame, kind, code, symbol, border, 1)
if type(span) == 'number' and span > 1 then
return core .. Cell.Wiki(frame, content2, span)
end
return core .. Cell.Wiki(frame, content2, 1)
end
p.annotatedName = function(frame)
return '<td style="text-decoration:line-through">Hiero/Cell.annotatedName</td>'
end
-- list
-- add valid data only
local function tdRow(nameType, tdTable, key, value, funct)
if tdTable[value] == nil then
return '<td>Cell.list.' .. nameType .. '.' .. key ..
'.' .. value .. '={???}</td></tr><tr>'
else
return funct .. '</tr><tr>'
end
end
-- list allready parsed contents without order into order
Cell.list = function(frame, content, language)
mw.logObject(content, 'Cell.list content')
local result = '<tr>'
-- order first part
for _, v in ipairs(Cell.order1) do
mw.log(v, 'order1 step')
-- content is a list containing key-value pairs
-- key is a nameType as listed in Cell.order1
-- value is a typeStruct, i. e. a list of subsequent row definitions
local typeStruct = content[v]
if type(typeStruct) == 'table' then
-- name definition of type v found
mw.logObject(typeStruct, v)
local count = 0 -- have counter for 1st col row span
-- first step: require seccond (and third) column data
local typeContent = "" --collector for subsequent rows
for n, w in pairs(typeStruct) do
-- col 2 element found
count = count + 1 -- increase rowspan for col 1
-- each typeStruct consists of an undefined number of
-- key-value pairs whereat n is key and w is value
-- each w value consists of a number of key-value pairs in turn
-- The structure of w depends on n
-- Few of w's params are mandatory.
-- tdRow will check availability of the one given by its name
if type(w) == 'table' then
mw.logObject(w, v .. '.' .. n)
if n == 'Wiki' then
typeContent = typeContent ..
tdRow(v, w, n, 'Wikitext',
Cell.Wiki(frame, w.Wikitext, w.colspan))
elseif n == 'simple' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.simple(frame, w.code))
elseif n == 'name' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.name(frame, v, w.code, w.symbol,
w.border, w.colspan))
elseif n == 'spacedSimple' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.spacedSimple(frame, w.code, w.rowspan))
elseif n == 'spacedName' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.spacedName(frame, v, w.code, w.symbol,
w.border, w.rowspan))
elseif n == 'annotatedSimple' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.annotatedSimple(frame, w.code, w.Wikitext,
w.rowspan))
elseif n == 'name' then
typeContent = typeContent ..
tdRow(v, w, n, 'code',
Cell.spacedName(frame, v, w.code, w.symbol,
w.border, w.Wikitext, w.rowspan))
else
typeContent = typeContent .. '<td>Cell.list.' ..
v .. '.' .. n .. '={???}</td>'
end
end -- for n, w in pairs(typeStruct)
end --if type(w) == 'table'
-- seccond step: have the (multi) row starting with nameType title
-- completed
if count < 1 then
result = result .. '<td colspan="2">' .. v .. '{???}</td>'
else
result = result .. Cell.Title(v, language, count) ..
typeContent
end
end -- type(typeStruct) == 'table'
-- one type defined, one type in mind (next nameType def...)
end -- for _, v in ipairs(Cell.order1)
-- add seccond part
--2b done
-- return alltogether
return result .. '</tr>'
end
function p.list(frame)
if frame.args[1] == nil then return '' end
if frame.args[1] == '' then return '' end
assert(type(Parser) == 'table', ' Parser: ' .. type(Parser))
return Cell.list(frame, Parser.parse(frame.args[1]), frame.args[2])
end
function p.Cell()
return Cell
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.