Modul:Citiranje

Izvor: Hrvatska internetska enciklopedija
Inačica 640334 od 12. siječanj 2026. u 12:03 koju je unio WikiSysop (razgovor | doprinosi) (Stvorena nova stranica sa sadržajem: »local p = {} local function safe(v) if v == nil or v == "" then return nil end return mw.text.trim(v) end function p.knjiga(frame) local args = frame:getParent().args local last = safe(args.last) local first = safe(args.first) local author = safe(args.author) local authorlink = safe(args.authorlink) local year = safe(args.year) local month = safe(args.month) local date = safe(args.date) local title =...«.)
(razl) ←Starija inačica | vidi trenutačnu inačicu (razl) | Novija inačica→ (razl)
Prijeđi na navigaciju Prijeđi na pretraživanje

Script error: The function "nonexistent" does not exist.

local p = {}

local function safe(v)
    if v == nil or v == "" then return nil end
    return mw.text.trim(v)
end

function p.knjiga(frame)
    local args = frame:getParent().args

    local last = safe(args.last)
    local first = safe(args.first)
    local author = safe(args.author)
    local authorlink = safe(args.authorlink)

    local year = safe(args.year)
    local month = safe(args.month)
    local date = safe(args.date)

    local title = safe(args.title or args.Title)
    local url = safe(args.url)

    local location = safe(args.location)
    local publisher = safe(args.publisher)
    local pages = safe(args.pages)
    local edition = safe(args.edition)
    local isbn = safe(args.isbn)
    local id = safe(args.id)
    local chapter = safe(args.chapter)
    local editor = safe(args.editor)
    local coauthors = safe(args.coauthors)

    local out = {}

    -- Autor
    if author then
        table.insert(out, author)
    elseif last then
        if authorlink then
            table.insert(out, string.format("[[%s|%s]]", authorlink, last))
        else
            table.insert(out, last)
        end
        if first then
            out[#out] = out[#out] .. ", " .. first
        end
    end

    -- Koautori
    if coauthors then
        table.insert(out, ", " .. coauthors)
    end

    -- Datum
    if date then
        table.insert(out, " (" .. date .. ")")
    elseif year then
        if month then
            table.insert(out, " (" .. month .. " " .. year .. ")")
        else
            table.insert(out, " (" .. year .. ")")
        end
    end

    -- Poglavlje
    if chapter then
        table.insert(out, '. "' .. chapter .. '"')
    end

    -- Urednik
    if editor then
        table.insert(out, ". Uredio " .. editor)
    end

    -- Naslov
    if title then
        if url then
            table.insert(out, ". ''[" .. url .. " " .. title .. "]''")
        else
            table.insert(out, ". ''" .. title .. "''")
        end
    end

    -- Izdanje
    if edition then
        table.insert(out, ", " .. edition .. ". izd.")
    end

    -- Lokacija + izdavač
    if publisher then
        if location then
            table.insert(out, ", " .. location .. ": " .. publisher)
        else
            table.insert(out, ", " .. publisher)
        end
    end

    -- Stranice
    if pages then
        table.insert(out, ", str. " .. pages)
    end

    -- ISBN
    if isbn then
        table.insert(out, ", ISBN " .. isbn)
    end

    -- ID
    if id then
        table.insert(out, ". " .. id)
    end

    -- Završna točka
    table.insert(out, ".")

    return '<cite class="citation-book" style="font-style:normal">' ..
        table.concat(out, "") ..
        "</cite>"
end

return p