Difference between revisions of "Publications"
From ACES
| Line 17: | Line 17: | ||
institution = {BibTeX = true}, | institution = {BibTeX = true}, | ||
journal = {BibTeX = true}, | journal = {BibTeX = true}, | ||
month = {BibTeX = true}, | |||
note = {BibTeX = true}, | note = {BibTeX = true}, | ||
number = {BibTeX = true}, | number = {BibTeX = true}, | ||
| Line 27: | Line 28: | ||
type = {BibTeX = true}, | type = {BibTeX = true}, | ||
volume = {BibTeX = true}, | volume = {BibTeX = true}, | ||
year = {BibTeX = true}, | |||
doi = {BibTeX = true}, | doi = {BibTeX = true}, | ||
issn = {BibTeX = true}, | issn = {BibTeX = true}, | ||
| Line 40: | Line 41: | ||
table.insert(out, fstr("@%s {%s", entry.entry, entry._pageName)) | table.insert(out, fstr("@%s {%s", entry.entry, entry._pageName)) | ||
for k, v in pairs(fields) do | for k, v in pairs(fields) do | ||
if v.BibTeX and entry[k] and entry[k] ~= "" then | if v.BibTeX and entry[k] and entry[k] ~= "" and entry[k] ~= "0" then | ||
table.insert(out, fstr("%s = {%s}", k, entry[k])) | table.insert(out, fstr("%s = {%s}", k, entry[k])) | ||
end | end | ||
end | end | ||
return table.concat(out, ",\n").."\n}\n" | return table.concat(out, ",\n").."\n}\n" | ||
| Line 63: | Line 59: | ||
groupBy = nil, | groupBy = nil, | ||
having = nil, | having = nil, | ||
orderBy = ' | orderBy = 'year', | ||
limit = nil, | limit = nil, | ||
offset = nil | offset = nil | ||
} | } | ||
local results = cargo.query(tables, cargoFields, args) | local results = cargo.query(tables, cargoFields, args) | ||
mw.logObject(results) | |||
local out = {} | local out = {} | ||
for _, entry in ipairs(results) do | for _, entry in ipairs(results) do | ||
Revision as of 03:57, 4 September 2021
Documentation for this module may be created at Module:Publications/doc
local getArgs = require([[Module:Arguments]]).getArgs
local date = require([[Module:Date]])
local cargo = mw.ext.cargo
local fstr = mw.ustring.format
local p = {}
local fields = {
entry = {},
address = {BibTeX = true},
annote = {BibTeX = true},
author = {BibTeX = true},
booktitle = {BibTeX = true},
chapter = {BibTeX = true},
edition = {BibTeX = true},
editor = {BibTeX = true},
howpublished = {BibTeX = true},
institution = {BibTeX = true},
journal = {BibTeX = true},
month = {BibTeX = true},
note = {BibTeX = true},
number = {BibTeX = true},
organization = {BibTeX = true},
pages = {BibTeX = true},
publisher = {BibTeX = true},
school = {BibTeX = true},
series = {BibTeX = true},
title = {BibTeX = true},
type = {BibTeX = true},
volume = {BibTeX = true},
year = {BibTeX = true},
doi = {BibTeX = true},
issn = {BibTeX = true},
isbn = {BibTeX = true},
url = {BibTeX = true},
_pageName = {},
pdf = {}
}
function p.getBibTeX(entry)
local out = {}
table.insert(out, fstr("@%s {%s", entry.entry, entry._pageName))
for k, v in pairs(fields) do
if v.BibTeX and entry[k] and entry[k] ~= "" and entry[k] ~= "0" then
table.insert(out, fstr("%s = {%s}", k, entry[k]))
end
end
return table.concat(out, ",\n").."\n}\n"
end
function p._main(args)
local tables = 'publication'
local cargoFields = {}
for k, _ in pairs(fields) do table.insert(cargoFields, k) end
cargoFields = table.concat(cargoFields, ",")
local args = {
where = nil,
join = nil,
groupBy = nil,
having = nil,
orderBy = 'year',
limit = nil,
offset = nil
}
local results = cargo.query(tables, cargoFields, args)
mw.logObject(results)
local out = {}
for _, entry in ipairs(results) do
table.insert(out, p.getBibTeX(entry))
end
return table.concat(out, "")
end
-- test: =p._main{}
function p.main(frame) return p._main(getArgs(frame)) end
return p