Module:SB: Difference between revisions
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
function sb.item_id( frame ) | function sb.item_id( frame ) | ||
print('vol:' .. frame.args['volume']) | |||
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item'] | local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item'] | ||
return id | return id | ||
Line 8: | Line 9: | ||
function sb.item_id2( frame ) | function sb.item_id2( frame ) | ||
if frame.args['volume'] == 1 then | if frame.args['volume'] == 1 then | ||
local | local vNum = 0 .. frame.args['volume'] | ||
else | else | ||
local | local vNum = frame.args['volume'] | ||
end | end | ||
if frame.args['item'] == 1 then | if frame.args['item'] == 1 then | ||
local | local iNum = 0 .. frame.args['item'] | ||
else | else | ||
local | local iNum = frame.args['item'] | ||
end | end | ||
local | local pNum = frame.args['page'] | ||
local id = | local id = vNum ..'-'.. pNum ..'-'.. iNum | ||
return id | return id | ||
end | end |
Revision as of 10:33, 16 April 2021
Lua functions for HPB Scrapbooks.
Functions
item_id
Called from {{HPB-SB-item}} for setting semantic property [[HPB SB item ID]].
{{#invoke: SB | item_id | volume=1 | page=17 | item=4 }}
footnote
Called from {{HPB-SB-item}}.
{{#invoke: SB | footnote | title= | author= | author_signed= | type= | source_title= | source_details= | notes= | archivist_notes= | language = | translator = }}
Debug example
=p.item_id{args={["volume"]="1",["page"]="17.2",["item"]="3"}}
Module code
local sb = {} -- functions package for HPB Scrapbooks
function sb.item_id( frame )
print('vol:' .. frame.args['volume'])
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
return id
end
function sb.item_id2( frame )
if frame.args['volume'] == 1 then
local vNum = 0 .. frame.args['volume']
else
local vNum = frame.args['volume']
end
if frame.args['item'] == 1 then
local iNum = 0 .. frame.args['item']
else
local iNum = frame.args['item']
end
local pNum = frame.args['page']
local id = vNum ..'-'.. pNum ..'-'.. iNum
return id
end
return sb