Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 13:54, 11 May 2025 by Joseph0M (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Station/Sandbox/doc

local getArgs  = require( 'Module:Arguments' ).getArgs
local infobox = require( 'Module:InfoboxNeue/Sandbox' ):new()

local getStatus = require("Module:Status").get

local p = {}

function p.infobox(frame)
    local args = getArgs(frame)

    --[[Deprecated arguments:
    image1: replaced with image (Does not support galleries)
    --]]

    --Main arguments
    local imgPath = args.image
    local title = args.title or mw.title.getCurrentTitle().text
    local captionTitle = args.caption_title
    local caption = args.caption
    local status = args.status
    local statusDescription = args.status_description

    --Services
    local preceding = args.preceding
    local following = args.following
    --Disel
    local dieselPreceding = args.preceding_diesel --optional
    local dieselFollowing = args.following_diesel --optional
    --Steam
    local steamPreceding = args.preceding_steam --optional
    local steamFollowing = args.following_steam --optional

    --Station Info
    local signalBox = args.signal_box
    local stationCode = args.abbreviation or args.station_code

    --Station Info (Other)
    local totalPlatforms = args.platforms or args.number_of_platforms
    local totalTracks = args.tracks or args.number_of_tracks
    local dispatch = args.dispatching

	infobox:renderImage(imgPath)
	
    if status then
        local text, class, colour = getStatus(status)
        infobox:renderIndicator( {
            data = text,
            color = colour
        } )
    else
    	-- render the caption indicator only if there was no status provided
    	infobox:renderIndicator( {
        	data = captionTitle,
        	desc = caption,
    	} )
    end

	infobox:renderHeader( {
		title = title,
		subtitle = 'Station'
	} )
    if following or preceding then
        local stations = {
            infobox:renderItem( {
                label = 'Preceding Station',
                data = preceding
            } ),
            infobox:renderItem( {
                label = 'Following Station',
                data = following
            } ),
        }
        infobox:renderSection( {
            content = table.concat(stations),
            col = 2
        } )
    end

    if dieselFollowing or dieselPreceding then
        local dieselStations = {
            infobox:renderItem( {
                label = 'Preceding Station',
                data = dieselPreceding
            } ),
            infobox:renderItem( {
                label = 'Following Station',
                data = dieselFollowing
            } ),
        }
        infobox:renderSection( {
            title = "Diesel Services",
            content = table.concat(dieselStations),
            col = 2
        } )
    end

    if steamFollowing or steamPreceding then
        local steamStations = {
            infobox:renderItem( {
                label = 'Preceding Station',
                data = steamPreceding
            } ),
            infobox:renderItem( {
                label = 'Following Station',
                data = steamFollowing
            } ),
        }
        infobox:renderSection( {
            title = "Steam Services",
            content = table.concat(steamStations),
            col = 2
        } )
    end

	local stationInfo = { --two column section
		infobox:renderItem( {
			label = 'Signal Box',
			data = signalBox
		} ),
		infobox:renderItem( {
			label = 'Station Code',
			data = stationCode
		} ),
	}

    infobox:renderSection( {
		title = 'Station Information',
		content = table.concat(stationInfo),
		col = 2
	} )

    local stationInfoExtended = { --three column section
        infobox:renderItem( {
			label = 'Number of platforms',
			data = totalPlatforms
		} ),
        infobox:renderItem( {
			label = 'Number of tracks',
			data = totalTracks
		} ),
        infobox:renderItem( {
			label = 'Dispatching',
			data = dispatch
		} ),
		infobox:renderItem({
				label = "Speed",
				data = 10 .. ' ' .. "mph",
				range = {
					['start'] = '0%',
					['end'] = tostring( 60 ) .. '%'
				}
			})
    }


    infobox:renderSection( {
		content = table.concat(stationInfoExtended),
		col = 3
	} )
	if args.Map then
		infobox:renderSection( {
			title = "Station Map",
			content = args.Map,
		} )
	end

	return infobox:renderInfobox(args)
end


return p
🍪 Yum Yum Yum! Cookies help us better deliver our services. By using our site, you agree to our use of cookies.