starcitizen>Alistair3149 |
starcitizen>Alistair3149 |
| Рядок 318: |
Рядок 318: |
|
| |
|
| return invokeList | | return invokeList |
| end
| |
|
| |
| --- Returns a list with TemplateStyles found on page 'pageName'.
| |
| ---@param templateName string
| |
| ---@return table<string>[]
| |
| local function getTemplateStylesList( pageName )
| |
| local content = mw.title.new( pageName ):getContent()
| |
| local templateStylesList = {}
| |
|
| |
| assert( content ~= nil, string.format( '%s does not exist', pageName ) )
| |
|
| |
| -- Greedy match to match <templatestyles>, {{#tag:templatestyles}}, and lua calls
| |
| for styleName in string.gmatch( content, 'templatestyles.+src%s?=%s?[\'"](.[^\'"]+%.css)[\'"]' ) do
| |
| -- TemplateStyles default to Template: when there are no namespace suffix
| |
| if string.find( styleName, ':', 1, true ) then
| |
| styleName = mw.text.trim( styleName )
| |
| else
| |
| styleName = string.format( 'Template:%s', mw.text.trim( styleName ) )
| |
| end
| |
| styleName = formatPageName( styleName )
| |
| table.insert( templateStylesList, {styleName=styleName} )
| |
| end
| |
|
| |
| templateStylesList = arr.unique( templateStylesList, function(x) return x.styleName end )
| |
| table.sort( templateStylesList, function(x, y) return x.styleName < y.styleName end )
| |
|
| |
| return templateStylesList
| |
| end | | end |
|
| |
|
| Рядок 612: |
Рядок 585: |
| ) | | ) |
| table.insert( res, mHatnote._hatnote( msg, { icon='WikimediaUI-Code.svg' } ) ) | | table.insert( res, mHatnote._hatnote( msg, { icon='WikimediaUI-Code.svg' } ) ) |
| end
| |
|
| |
| return table.concat( res )
| |
| end
| |
|
| |
| ---@param templateName string
| |
| ---@param addCategories boolean
| |
| ---@param templateStylesList table<string>[] @This is the list returned by getTemplateStylesList()
| |
| ---@return string
| |
| local function formatTemplateStylesList( currentPageName, addCategories, templateStylesList )
| |
| local category = addCategories and '[[Category:Templates using TemplateStyles]]' or ''
| |
| local res = {}
| |
|
| |
| for _, item in ipairs( templateStylesList ) do
| |
| local msg = string.format(
| |
| "'''%s''' invokes [[%s]] using [[Star Citizen:TemplateStyles|TemplateStyles]].",
| |
| currentPageName,
| |
| item.styleName
| |
| )
| |
| table.insert( res, mHatnote._hatnote( msg, { icon='WikimediaUI-Palette.svg' } ) )
| |
| end
| |
|
| |
| if #templateStylesList > 0 then
| |
| table.insert( res, category )
| |
| end | | end |
|
| |
|
| Рядок 671: |
Рядок 620: |
| moduleIsUsed = true -- Don't show sandbox modules as unused | | moduleIsUsed = true -- Don't show sandbox modules as unused |
| end | | end |
|
| |
| local templateStylesList = getTemplateStylesList( currentPageName )
| |
|
| |
|
| if currentPageName:find( '^Template:' ) then | | if currentPageName:find( '^Template:' ) then |
| local ok, invokeList = pcall( getInvokeCallList, currentPageName ) | | local ok, invokeList = pcall( getInvokeCallList, currentPageName ) |
| if ok then | | if ok then |
| return formatInvokeCallList( currentPageName, addCategories, invokeList ) .. formatTemplateStylesList( currentPageName, addCategories, templateStylesList ) | | return formatInvokeCallList( currentPageName, addCategories, invokeList ) |
| else | | else |
| return userError(invokeList) | | return userError(invokeList) |
| Рядок 742: |
Рядок 689: |
| table.insert( res, formatUsedTemplatesList( currentPageName, addCategories, usedTemplateList ) ) | | table.insert( res, formatUsedTemplatesList( currentPageName, addCategories, usedTemplateList ) ) |
| table.insert( res, formatRequiredByList( currentPageName, addCategories, whatModulesLinkHere ) ) | | table.insert( res, formatRequiredByList( currentPageName, addCategories, whatModulesLinkHere ) ) |
| table.insert( res, formatTemplateStylesList( currentPageName, addCategories, templateStylesList ) )
| |
|
| |
|
| if addCategories then | | if addCategories then |