Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:NewsLanding/LatestMore
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local cargo = mw.ext.cargo local p = {} function p.main(frame) local args = getArgs(frame) local pages = {} local pattern = "(%d%d%d%d%-%d%d%-%d%d %d%d:%d%d:%d%d) %[%[(.-)|(.-)%]%]" for date, title in args.companies:gmatch(pattern) do table.insert(pages, {_pageName = title, date = date}) end local hotItems = mw.html.create('div'):addClass('news-hot-items') local container = mw.html.create('div'):addClass('news-hot'):node(mw.html.create('h3'):addClass('tc'):wikitext('Latest Edited Pages')):node(hotItems) for i, page in ipairs(pages) do local title = mw.html.create('div'):wikitext('[[' .. page._pageName .. '|' .. mw.ext.displaytitle.get(page._pageName) .. ']]') local date = mw.html.create('div'):wikitext('Last edit: ' .. page.date) -- local textDiv = mw.html.create('div'):node(title):node(date) local newsItem = mw.html.create('div'):attr('style', 'display: flex; flex-direction: column; align-items: center; gap: 0.5rem;'):node(title):node(date) local logoDiv = mw.html.create('div') local title = mw.html.create('div'):wikitext('[[' .. page._pageName .. '|' .. mw.ext.displaytitle.get(page._pageName) .. ']]') local date = mw.html.create('div'):wikitext('Last edit: ' .. page.date) -- local textDiv = mw.html.create('div'):node(title):node(date) local newsItem = mw.html.create('div'):attr('style', 'display: flex; flex-direction: column; align-items: center; gap: 0.5rem;'):node(title):node(logoDiv):node(date) hotItems:node(newsItem) local split = string.find(page._pageName, '/') and mw.text.split(page._pageName, '/')[2] or '' local tables = 'Logos' local fields = '_pageName, logoAll, logoDark, logoLight, iconAll, iconLight, iconDark' local cargoArgs = { where = '_pageName = "' .. page._pageName .. '" OR _pageName= "Companies/' .. split .. '"' } local results = cargo.query(tables, fields, cargoArgs) if #results > 0 then local result = results[1] if results[1].iconAll then logoDiv:node(createLogo(result._pageName, results[1].iconAll)) elseif results[1].iconLight and results[1].iconDark then logoDiv:node(createLogo(result._pageName, results[1].iconLight, 'light')):node(createLogo(result._pageName, results[1].iconDark, 'dark')) elseif results[1].logoAll then logoDiv:node(createLogo(result._pageName, results[1].logoAll)) elseif results[1].logoLight and results[1].logoDark then logoDiv:node(createLogo(result._pageName, results[1].logoLight, 'light')):node(createLogo(result._pageName, results[1].logoDark, 'dark')) else local logo = results[1].iconLight or results[1].iconDark or results[1].logoLight or results[1].logoDark logoDiv:node(createLogo(result._pageName, logo)) end else local pageContent = mw.title.new(page._pageName):getContent() local img = getFirstImage(pageContent) if img then logoDiv:node(createLogo(page._pageName, img)) else logoDiv:node(createLogo(page._pageName, 'Team_placeholder_dark.png', 'dark')):node(createLogo(page._pageName, 'Team_placeholder_light.png', 'light')) end end end return container end function createLogo(page, url, class) local className = class and class .. ' h-100' or 'h-100' local logoURL = url and url or 'Team_placeholder_dark.png' local logoContainer = mw.html.create('div') :addClass(className) local logo = mw.html.create('div') :addClass('team-list-logo') :node('[[File:' .. logoURL .. '|80x80px|link=' .. page .. ']]') logoContainer:node(logo) return logoContainer end function getFirstImage(pageContent) -- List of parameters to check for image names local imageParameters = {"image", "logoAll", "logoLight", "logoDark"} -- Iterate through the parameters and find the first one with a value for _, paramName in ipairs(imageParameters) do local imageValue = string.match(pageContent, "|%s*" .. paramName .. "%s*=%s*([^|\n}]+)") if imageValue then -- Return the extracted image file name return imageValue end end return nil end return p
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:NewsLanding/LatestMore/doc
(
edit
)
No categories
Edit