Module:Bluesky RSS Feed Test: Difference between revisions

From NOISZ Wiki
No edit summary
mNo edit summary
 
(40 intermediate revisions by the same user not shown)
Line 2: Line 2:
local capiunto = require 'capiunto'
local capiunto = require 'capiunto'
local p = {}
local p = {}
function dedupe( list )
local seen = {}
for k, v in ipairs(list) do
if seen[item] then
table.remove(list, k)
end
end
end


function p.main(frame)
function p.main(frame)
Line 20: Line 10:
local searchTerms = {}
local searchTerms = {}


if args.term1 or args.term2 or args.term3 then
-- We use externaldata.getWebDate to obtain XML format data from the RSS feed at the URL defined by the user.
searchTerms[1] = args.term1
searchTerms[2] = args.term2
searchTerms[3] = args.term3
else
searchTerms = {""}
end
 
local rss = mw.ext.externaldata.getWebData {
local rss = mw.ext.externaldata.getWebData {
     url = args.url
     url = args.url
Line 34: Line 17:
}
}


for k, v in ipairs(rss) do
return mw.dumpObject(rss)
if v["description"] and v["pubDate"] and v["link"] and links[v["link"]] == nil then
for a, b in pairs(searchTerms) do
if string.find(v["description"],b) then
links[v["link"]] = v["link"]
table.insert(posts, frame:expandTemplate{title = 'Bluesky RSS Feed Row', args = {description = v["description"], pubDate = v["pubDate"], link=v["link"]}})
end
end
end
end
 
dedupe(posts)
 
return table.concat(posts,""), mw.dumpObject(links)





Latest revision as of 06:53, 5 August 2025

Documentation for this module may be created at Module:Bluesky RSS Feed Test/doc


local capiunto = require 'capiunto'
local p = {}

function p.main(frame)

local args = frame:getParent().args
local posts = {}
local links = {}
local searchTerms = {}

-- We use externaldata.getWebDate to obtain XML format data from the RSS feed at the URL defined by the user.
local rss = mw.ext.externaldata.getWebData {
    url = args.url
  , data = {pubDate = 'pubDate', description = 'description', link= 'link'}
  , format = 'xml'
}

return mw.dumpObject(rss)


end

return p