Difference between pages "File:SB-02-053.jpg" and "Module:SB"
(Difference between pages)
Jump to navigation
Jump to search
(Uploaded in batch mode to [[:Category:HPB_Scrapbooks_pages{{!}}HPB Scrapbooks pages]] category.) |
|||
Line 1: | Line 1: | ||
− | { | + | local sb = {} -- functions package for HPB Scrapbooks |
+ | |||
+ | function sb.item_id2( frame ) | ||
+ | local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item'] | ||
+ | return id | ||
+ | end | ||
+ | |||
+ | -- Create unique ID for the item, which consist of: Volume-Page-Item_on_page | ||
+ | -- ID example: 01-017-03 | ||
+ | -- Call example: {{#invoke: SB | item_id | volume=1 | page=17 | item=3 }} | ||
+ | -- Values: volume=1..99, page=1..999, item=1..99 | ||
+ | function sb.item_id( frame ) | ||
+ | local vNum = string.format("%.2d", frame.args['volume']) | ||
+ | local iNum = string.format("%.2d", frame.args['item']) | ||
+ | local p_int, p_frac = math.modf(frame.args['page']) | ||
+ | local pNum = string.format("%.3d", p_int) | ||
+ | |||
+ | --mw.log('int= '.. p_int .. ', frac= ' .. p_frac) | ||
+ | if p_frac > 0 then | ||
+ | str = tostring(p_frac) | ||
+ | pNum = pNum .. '.' .. string.sub(str,3,5) | ||
+ | end | ||
+ | |||
+ | local id = vNum .. '-' .. pNum .. '-' .. iNum | ||
+ | return id | ||
+ | end | ||
+ | |||
+ | -- This function does not work yet | ||
+ | function sb.int2roman( arabic_number ) | ||
+ | local roman_number = arabic_number --mathroman.int2roman(arabic_number) | ||
+ | print (roman_number) | ||
+ | end | ||
+ | |||
+ | return sb |
Revision as of 18:38, 8 June 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_id2( frame )
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
return id
end
-- Create unique ID for the item, which consist of: Volume-Page-Item_on_page
-- ID example: 01-017-03
-- Call example: {{#invoke: SB | item_id | volume=1 | page=17 | item=3 }}
-- Values: volume=1..99, page=1..999, item=1..99
function sb.item_id( frame )
local vNum = string.format("%.2d", frame.args['volume'])
local iNum = string.format("%.2d", frame.args['item'])
local p_int, p_frac = math.modf(frame.args['page'])
local pNum = string.format("%.3d", p_int)
--mw.log('int= '.. p_int .. ', frac= ' .. p_frac)
if p_frac > 0 then
str = tostring(p_frac)
pNum = pNum .. '.' .. string.sub(str,3,5)
end
local id = vNum .. '-' .. pNum .. '-' .. iNum
return id
end
-- This function does not work yet
function sb.int2roman( arabic_number )
local roman_number = arabic_number --mathroman.int2roman(arabic_number)
print (roman_number)
end
return sb
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 10:25, 28 May 2021 | 3,809 × 5,303 (1.65 MB) | Pavel Malakhov (addition | contribs) | Uploaded in batch mode to [[:Category:HPB_Scrapbooks_pages{{!}}HPB Scrapbooks pages]] category. |
You cannot overwrite this file.
File usage
The following page uses this file: