| Line 1: |
Line 1: |
| | local p = {} | | local p = {} |
| | | | |
| − | -- Helper function to gather arguments from the template call | + | -- Helper function to gather arguments |
| | local function get_args(frame) | | local function get_args(frame) |
| | local args = {} | | local args = {} |
| Line 10: |
Line 10: |
| | end | | end |
| | | | |
| − | -- Main function called by {{cite book}}, {{cite web}}, etc.
| |
| | function p.citation(frame) | | function p.citation(frame) |
| | local args = get_args(frame) | | local args = get_args(frame) |
| | | | |
| − | -- 1. AUTHOR LOGIC (Handles last, first, and author-link) | + | -- 1. AUTHOR LOGIC |
| | local last = args.last or args.last1 or args.author or args.author1 or "" | | local last = args.last or args.last1 or args.author or args.author1 or "" |
| | local first = args.first or args.first1 or "" | | local first = args.first or args.first1 or "" |
| Line 28: |
Line 27: |
| | end | | end |
| | | | |
| − | -- 2. TITLE & PERIODICAL (Journal/Magazine/Website) | + | -- 2. TITLE & URL |
| | local title = args.title or "No Title" | | local title = args.title or "No Title" |
| | + | local url = args.url or args.URL |
| | + | local title_str = "''" .. title .. "''" |
| | + | |
| | + | if url then |
| | + | title_str = "[" .. url .. " " .. title_str .. "]" |
| | + | end |
| | + | |
| | + | -- 3. METADATA |
| | local journal = args.journal or args.work or args.periodical or args.website | | local journal = args.journal or args.work or args.periodical or args.website |
| | local series = args.series | | local series = args.series |
| − |
| |
| − | -- Format title: Italicize if it's a book, quoted if it's an article/webpage
| |
| − | local title_str = "''" .. title .. "''"
| |
| − |
| |
| − | -- 3. CORE METADATA (Year, Location, Publisher)
| |
| | local year = args.year or args.date or "" | | local year = args.year or args.date or "" |
| | local location = args.location or args.place or "" | | local location = args.location or args.place or "" |
| Line 43: |
Line 45: |
| | local issue = args.issue or args.number | | local issue = args.issue or args.number |
| | local pages = args.pages or args.page or args.p or args.pp | | local pages = args.pages or args.page or args.p or args.pp |
| | + | local lang = args.language or args.lang |
| | | | |
| | -- 4. ASSEMBLY | | -- 4. ASSEMBLY |
| | local res = author_str .. title_str | | local res = author_str .. title_str |
| | | | |
| | + | if lang then res = res .. " (in " .. lang .. ")" end |
| | if series then res = res .. ". " .. series end | | if series then res = res .. ". " .. series end |
| | if journal then res = res .. ". ''" .. journal .. "''" end | | if journal then res = res .. ". ''" .. journal .. "''" end |
| Line 53: |
Line 57: |
| | if year ~= "" then res = res .. " (" .. year .. ")" end | | if year ~= "" then res = res .. " (" .. year .. ")" end |
| | if location ~= "" then res = res .. ". " .. location end | | if location ~= "" then res = res .. ". " .. location end |
| | + | |
| | if publisher ~= "" then | | if publisher ~= "" then |
| | if location ~= "" then res = res .. ": " end | | if location ~= "" then res = res .. ": " end |
| | res = res .. publisher | | res = res .. publisher |
| | end | | end |
| | + | |
| | if pages then res = res .. ". p. " .. pages end | | if pages then res = res .. ". p. " .. pages end |
| | | | |
| − | -- 5. IDENTIFIERS (ISBN, DOI, OCLC) | + | -- 5. IDENTIFIERS & ACCESS DATE |
| | if args.isbn then | | if args.isbn then |
| − | local isbn_clean = args.isbn:gsub("[^%d%-X]", "") -- strip invalid chars | + | local isbn_clean = args.isbn:gsub("[^%d%-X]", "") |
| | res = res .. ". [[ISBN]] [[Special:BookSources/" .. isbn_clean .. "|" .. args.isbn .. "]]" | | res = res .. ". [[ISBN]] [[Special:BookSources/" .. isbn_clean .. "|" .. args.isbn .. "]]" |
| | end | | end |
| Line 71: |
Line 77: |
| | if args.oclc then | | if args.oclc then |
| | res = res .. ". [[OCLC]] [https://www.worldcat.org/oclc/" .. args.oclc .. " " .. args.oclc .. "]" | | res = res .. ". [[OCLC]] [https://www.worldcat.org/oclc/" .. args.oclc .. " " .. args.oclc .. "]" |
| | + | end |
| | + | |
| | + | if args['access-date'] or args.accessdate then |
| | + | res = res .. ". Retrieved " .. (args['access-date'] or args.accessdate) |
| | end | | end |
| | | | |
| − | -- Close the citation
| |
| | res = res .. "." | | res = res .. "." |
| | | | |
| − | -- Output as a <cite> tag for the reflist
| |
| | return frame:extensionTag('cite', res, {class = "citation"}) | | return frame:extensionTag('cite', res, {class = "citation"}) |
| | end | | end |
| | | | |
| | return p | | return p |