Module:New pages: Difference between revisions

From Eli's Software Encyclopedia
mNo edit summary
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
'[[:+]][[Creation date::+]]',
'[[:+]][[Creation date::+]]',
'mainlabel=-',
'mainlabel=-',
'?Creation date#-F[Y-m-dTH:i:s]=timestamp',
'?Creation date#-F[Y-m-d H:i:s]=timestamp',
'?#-=title',
'?#-=title',
'?Page creator#-=user',
'?Page creator#-=user',
'sort=Creation date',
'sort=Creation date',
'order=desc',
'order=desc',
'limit=20'
'limit=20',
'@deferred'
} or {}
} or {}


Line 17: Line 18:
local html = mw.html.create()
local html = mw.html.create()
local ul = html:tag('ul')
local ul = html:tag('ul'):attr('id', 'new-pages')
for _, page in ipairs(data) do
for _, page in ipairs(data) do
Line 23: Line 24:
rtitle = page.title
rtitle = page.title
rdate = page.timestamp
rdate = page.timestamp
ruser = page.user
ruser = page.user or 'User:Eli'
rname = ruser:match("([^:]+)$")


    local year, month, day, hour, minute, second = rdate:match("^(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)")
rrow = string.format('%s - [[%s]] by [[%s|%s]]', rdate, rtitle, ruser, rname )
    if year and month and day and hour and minute then
        rdate = string.format('%s-%s-%s %s:%s', year, month, day, hour, minute)
    else
        rdate = 'Invalid Timestamp' -- Handle invalid timestamps
    end
   
rrow = string.format('%s - [[%s]] by [[User:%s|%s]]', rdate, rtitle, ruser, ruser )


    ul:tag('li'):wikitext(rrow)
    ul:tag('li'):wikitext(rrow)
Line 39: Line 34:
return html
return html
end
function p.test()
local data = mw.smw.ask {
'[[:+]][[Creation date::+]]',
'mainlabel=-',
'?Creation date#-F[Y-m-d H:i:s]=timestamp',
'?#-=title',
'?Page creator#-=user',
'sort=Creation date',
'order=desc',
'limit=20'
} or {}
return data
end
end


return p
return p

Latest revision as of 11:57, December 10, 2025

Documentation for this module may be created at Module:New pages/doc

local p = {}

function p.main()
	
	local data = mw.smw.ask {
		'[[:+]][[Creation date::+]]',
		'mainlabel=-',
		'?Creation date#-F[Y-m-d H:i:s]=timestamp',
		'?#-=title',
		'?Page creator#-=user',
		'sort=Creation date',
		'order=desc',
		'limit=20',
		'@deferred'
	} or {}

	local rtitle, rdate, ruser, rrow
	
	local html = mw.html.create()
	local ul = html:tag('ul'):attr('id', 'new-pages')
	
	for _, page in ipairs(data) do
		
		rtitle = page.title
		rdate = page.timestamp
		ruser = page.user or 'User:Eli'
		rname = ruser:match("([^:]+)$")

		rrow = string.format('%s - [[%s]] by [[%s|%s]]', rdate, rtitle, ruser, rname )

	    ul:tag('li'):wikitext(rrow)
	end
	
	return html
	
end

return p