website

package
v0.0.0-...-30a0ae6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DEBUG is whether this is a debug build
	DEBUG = true

	// MLnetworkID is the ID of the main network
	MLnetworkID = "pt-ml"

	// CSRFfieldName is the name of the form field used for CSRF protection
	CSRFfieldName = "disturbances.csrf"

	// CSRFcookieName is the name of the cookie used for CSRF protection
	CSRFcookieName = "_disturbances_csrf"
)

Variables

View Source
var Consts = map[string]reflect.Value{
	"CSRFcookieName": reflect.ValueOf(CSRFcookieName),
	"CSRFfieldName":  reflect.ValueOf(CSRFfieldName),
	"DEBUG":          reflect.ValueOf(DEBUG),
	"MLnetworkID":    reflect.ValueOf(MLnetworkID),
}
View Source
var Functions = map[string]reflect.Value{
	"AboutPage":              reflect.ValueOf(AboutPage),
	"AuthGetSession":         reflect.ValueOf(AuthGetSession),
	"AuthHandler":            reflect.ValueOf(AuthHandler),
	"AuthLogoutHandler":      reflect.ValueOf(AuthLogoutHandler),
	"BaseURL":                reflect.ValueOf(BaseURL),
	"ConfigureRouter":        reflect.ValueOf(ConfigureRouter),
	"DisturbanceListPage":    reflect.ValueOf(DisturbanceListPage),
	"DisturbancePage":        reflect.ValueOf(DisturbancePage),
	"DonatePage":             reflect.ValueOf(DonatePage),
	"HomePage":               reflect.ValueOf(HomePage),
	"InitPageCommons":        reflect.ValueOf(InitPageCommons),
	"Initialize":             reflect.ValueOf(Initialize),
	"InternalPage":           reflect.ValueOf(InternalPage),
	"LinePage":               reflect.ValueOf(LinePage),
	"LookingGlass":           reflect.ValueOf(LookingGlass),
	"MapPage":                reflect.ValueOf(MapPage),
	"MetaStatsPage":          reflect.ValueOf(MetaStatsPage),
	"PrivacyPolicyPage":      reflect.ValueOf(PrivacyPolicyPage),
	"RSSFeed":                reflect.ValueOf(RSSFeed),
	"ReadStationConnections": reflect.ValueOf(ReadStationConnections),
	"ReadStationTrivia":      reflect.ValueOf(ReadStationTrivia),
	"ReloadTemplates":        reflect.ValueOf(ReloadTemplates),
	"ReportPage":             reflect.ValueOf(ReportPage),
	"SessionStore":           reflect.ValueOf(SessionStore),
	"ShowOfficialDataOnly":   reflect.ValueOf(ShowOfficialDataOnly),
	"StationPage":            reflect.ValueOf(StationPage),
	"TermsPage":              reflect.ValueOf(TermsPage),
}
View Source
var Types = map[string]reflect.Type{
	"ConnectionData":   reflect.TypeOf((*ConnectionData)(nil)).Elem(),
	"PageCommons":      reflect.TypeOf((*PageCommons)(nil)).Elem(),
	"PageDependencies": reflect.TypeOf((*PageDependencies)(nil)).Elem(),
	"Session":          reflect.TypeOf((*Session)(nil)).Elem(),
}
View Source
var Variables = map[string]reflect.Value{}

Functions

func AboutPage

func AboutPage(w http.ResponseWriter, r *http.Request)

AboutPage serves the about page

func AuthHandler

func AuthHandler(w http.ResponseWriter, r *http.Request)

AuthHandler serves requests from users that come from the SSO login page

func AuthLogoutHandler

func AuthLogoutHandler(w http.ResponseWriter, r *http.Request)

AuthLogoutHandler serves requests from users that come from the SSO login page

func BaseURL

func BaseURL() string

BaseURL returns the base URL of the website without trailing slash

func ConfigureRouter

func ConfigureRouter(router *mux.Router)

ConfigureRouter configures a router to handle website paths

func DisturbanceListPage

func DisturbanceListPage(w http.ResponseWriter, r *http.Request)

DisturbanceListPage serves a page with a list of disturbances

func DisturbancePage

func DisturbancePage(w http.ResponseWriter, r *http.Request)

DisturbancePage serves the page for a specific disturbance

func DonatePage

func DonatePage(w http.ResponseWriter, r *http.Request)

DonatePage serves the donations page

func HomePage

func HomePage(w http.ResponseWriter, r *http.Request)

HomePage serves the home page

func Initialize

Initialize initializes the package

func InternalPage

func InternalPage(w http.ResponseWriter, r *http.Request)

InternalPage serves a internal page

func LinePage

func LinePage(w http.ResponseWriter, r *http.Request)

LinePage serves the page for a specific line

func LookingGlass

func LookingGlass(w http.ResponseWriter, r *http.Request)

LookingGlass serves the looking glass page

func MapPage

func MapPage(w http.ResponseWriter, r *http.Request)

MapPage serves the network map page

func MetaStatsPage

func MetaStatsPage(w http.ResponseWriter, r *http.Request)

MetaStatsPage serves a page with meta-statistics about the service

func PrivacyPolicyPage

func PrivacyPolicyPage(w http.ResponseWriter, r *http.Request)

PrivacyPolicyPage serves the privacy policy page

func RSSFeed

func RSSFeed(w http.ResponseWriter, r *http.Request)

RSSFeed serves the RSS feed

func ReadStationTrivia

func ReadStationTrivia(stationID, locale string) (string, error)

ReadStationTrivia returns the contents of the HTML file containing trivia for the specified station ID

func ReloadTemplates

func ReloadTemplates()

ReloadTemplates reloads the templates for the website

func ReportPage

func ReportPage(w http.ResponseWriter, r *http.Request)

ReportPage serves the disturbance reporting page

func SessionStore

func SessionStore() *sessions.CookieStore

SessionStore returns the session store used by the website

func ShowOfficialDataOnly

func ShowOfficialDataOnly(w http.ResponseWriter, r *http.Request) bool

ShowOfficialDataOnly analyzes and modifies a request to check if the user wants to see official disturbance data only or not, and returns the result

func StationPage

func StationPage(w http.ResponseWriter, r *http.Request)

StationPage serves the page for a specific station

func TermsPage

func TermsPage(w http.ResponseWriter, r *http.Request)

TermsPage serves the terms and conditions page

Types

type ConnectionData

type ConnectionData struct {
	ID   string
	HTML string
}

ConnectionData contains the HTML with the connection information for the station with ID ID

func ReadStationConnections

func ReadStationConnections(stationID string) (data []ConnectionData, err error)

ReadStationConnections returns the contents of HTML files containing connection information for the specified station ID

type PageCommons

type PageCommons struct {
	CSRFfield   string
	PageTitle   string
	Description string
	ImageURL    string
	Lines       []struct {
		*types.Line
		Down     bool
		Official bool
		Minutes  int
	}
	OfficialOnly bool
	DebugBuild   bool
	MQTTaddress  string
	Dependencies PageDependencies
}

PageCommons contains information that is required by most page templates

func InitPageCommons

func InitPageCommons(node sqalx.Node, w http.ResponseWriter, r *http.Request, title string) (commons PageCommons, err error)

InitPageCommons fills PageCommons with the info that is required by most page templates

type PageDependencies

type PageDependencies struct {
	Leaflet     bool
	Recaptcha   bool
	Charts      bool
	Flipcounter bool
	MQTT        bool
}

PageDependencies is used by the header template to include certain dependencies

type Session

type Session struct {
	UserID      string
	DisplayName string
	IsAdmin     bool
}

Session represents a user session

func AuthGetSession

func AuthGetSession(w http.ResponseWriter, r *http.Request, doLogin bool) (bool, Session, error)

AuthGetSession retrieves the Session associated with the user of the specified request, if one exists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL