×
Create a new article
Write your page title here:
We currently have 1,662 articles on The Quelmar Wiki. Type your article name above or click on one of the titles below and start writing!



The Quelmar Wiki

Editing Module:CampaignNavbox

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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 9: Line 9:
     -- Check if the page content is available
     -- Check if the page content is available
     if not wikitext then
     if not wikitext then
return "Campaign Page not found?"
        return "Error: Unable to fetch content for page '" .. pageTitle .. "'."
     end
     end


Line 15: Line 15:
         PA = {},
         PA = {},
         MD = {},
         MD = {},
        Twitch = {},
         Online = {}
         Online = {},
                International = {}
     }
     }
local function processRow(row)
    -- Extract the campaign name, handling both cases
    local campaign = row:match("|'''%[%[(.-)%]%]'''") -- Matches cases like |'''[[SotS Inc]]'''
    if not campaign then
        campaign = row:match("|%[%[(.-)|'''") -- Matches cases like |[[Ancients Alive|'''Ancients Alive''']]
        if not campaign then
            campaign = row:match("|%[%[(.-)%]%]") -- Matches cases like |[[Campaign Name]]
        end
    end
      
      
local function processRow(row)
     -- In case campaign name is still not found, use alternative pattern
     -- Extract everything up to the first "]]"
     if not campaign then
     local campaignWithLink = row:match("^.-]]")
        campaign = row:match("|'''(.-)'''") -- Matches cases without wiki link but with bold formatting
    end
 
     -- Extract the location, which is the last element before the end of the row
     -- Extract the location, which is the last element before the end of the row
    local location = row:match("[^\n]+$")
  --  local location = row:match("|([^|]-)\n?$") -- The '$' ensures that we are at the end of the row
 
local location = "test"
     if campaignWithLink and location then
     if campaign and location then
        campaignWithLink = campaignWithLink:gsub("^|", ""):gsub("'''%s*$", ""):gsub("'''", ""):gsub("|%[%[", "%[%[")
        location = mw.text.trim(location) -- Trim whitespace from the location string
    location = location:gsub("^|", ""):gsub("'''%s*$", "")
         -- Check and add to the relevant location
   
         -- Add the campaign to the relevant location list
         if location:find("PA") then
         if location:find("PA") then
             table.insert(campaigns.PA, campaignWithLink)
             table.insert(campaigns.PA, campaign)
            end
        end
         if location:find("MD") then
         if location:find("MD") then
             table.insert(campaigns.MD, campaignWithLink)
             table.insert(campaigns.MD, campaign)
            end
        end
         if location:find("Online") then
         if location:find("Online") then
             table.insert(campaigns.Online, campaignWithLink)
             table.insert(campaigns.Online, campaign)
         end
         end
                if location:find("Twitch") then
            table.insert(campaigns.Twitch, campaignWithLink)
                end
                if location:find("🇩🇪") then
            table.insert(campaigns.International, campaignWithLink)
                end
                        if location:find("🏴󠁧󠁢󠁳󠁣󠁴󠁿") then
            table.insert(campaigns.International, campaignWithLink)
            end
     end
     end
end
end


     -- Split the wikitext into rows and process each
     -- Split the wikitext into rows and process each
local rowPattern = "|-%s*(.-)\n|%-"
local rowPattern = "|%-(.-)\n|%-"
wikitext = wikitext .. '|-\n'  -- Append delimiter to capture the last row
wikitext = wikitext .. '|-'  -- Append delimiter to capture the last row
local skipRows = 1  -- Number of rows to skip to get rid of pre-table text
for row in wikitext:gmatch(rowPattern) do
for row in wikitext:gmatch(rowPattern) do
     if skipRows > 0 then
     processRow(row)
        -- Skip the row
        skipRows = skipRows - 1  -- Decrement the counter
    else
        -- Process the row (e.g., print it)
        processRow(row)
    end
end
end


Line 72: Line 64:
     end
     end
     navbox = navbox .. '|}'
     navbox = navbox .. '|}'
     return navbox
     return navbox
end
end


return p
return p
Please note that all contributions to The Quelmar Wiki are considered to be released under the Creative Commons Attribution (see The Quelmar Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, 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. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page:

Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)

Recent changes

  • Glamourpal • Yesterday at 00:41
  • Glamourpal • Yesterday at 00:37
  • Glamourpal • Yesterday at 00:33
  • Glamourpal • Yesterday at 00:33
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)