Module:Numlinks: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
No edit summary
Line 6: Line 6:


function p.side_numlinks(num_links, curr_num, min_num, page_text, link_text, is_ordinal)
function p.side_numlinks(num_links, curr_num, min_num, page_text, link_text, is_ordinal)
local num_links = num_links or 1
local num_links = num_links or 3
local curr_num = curr_num
local curr_num   = curr_num or 2
local min_1 = min_1 or 1
local min_num    = min_num or 1
local page_text = page_text or { "PRE-TEXT", "POST-TEXT" }
local page_text = page_text or { "PRE-TEXT", "POST-TEXT" }
local link_text = link_text or nil
local link_text = link_text or nil
local is_ordinal = is_ordinal ~= nil and is_ordinal or false
local is_ordinal = is_ordinal ~= nil and is_ordinal or false
Line 58: Line 58:
end
end


function p.eight_numlinks(curr_num, min_num, page_text, link_text)
function p.eight_numlinks(curr_num_1, curr_num_2, min_num, page_text, link_text)
end
end
Line 64: Line 64:
-- Generate a table of previous and next links for numbered pages, with support
-- Generate a table of previous and next links for numbered pages, with support
-- for up to two numbers. Args are as follows:
-- for up to two numbers. Args are as follows:
-- - Link config: what is the arrangement of links? Options are:
-- -- Side-1: For n, links are for n-1 and n+1
-- -- Side-2: For n, links are for n-2 to n+1
-- -- Side-3: For n, links are for n-3 to n+3
-- -- Side-4: For n, links are for n-4 to n+4
-- -- Side-5: For n, links are for n-5 to n+5
-- -- 8-Link: For n and m, links are n +/- 1 and m +/- 1. There are no options
--    for additional links.
-- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal
-- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal
--  numbers (eg, 12th-octave)?
--  numbers (eg, 12th-octave)?
Line 90: Line 82:
local link_text  = args["Link Text"]
local link_text  = args["Link Text"]
local min_num    = args["Min Num"] ~= nil and args["Min Num"] or 1
local min_num    = args["Min Num"] ~= nil and args["Min Num"] or 1
local curr_nums  = args["Current Nums"]
local curr_num_1 = args["Num 1"]
local curr_num_2 = args["Num 2"]
-- Determine whether there is one prev/next value or two
local is_side = false
if #curr_nums == 1 then
is_side = true
elseif #curr_nums == 2 then
end
-- Create numbered navigation links
-- Create numbered navigation links
local navigation_links = {}
local navigation_links = {}
if is_side then
if curr_num_2 == nil then
navigation_links = p.side_numlinks(num_links, curr_num[1], min_num, page_text, link_text, is_ordinal)
navigation_links = p.side_numlinks(num_links, curr_num[1], min_num, page_text, link_text, is_ordinal)
end
end