utils

package
v0.0.0-...-5c575a5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Api     = os.Getenv("API_SOURCE")
	ICSName = os.Getenv("ICS_NAME")
	ICSTZ   = os.Getenv("ICS_TZ")
)

Functions

func FormatDate

func FormatDate(date time.Time) string

func GetICS

func GetICS(now time.Time) (calendar *ics.Calendar, err error)

func ParseText

func ParseText(text string) (result string, err error)

func PrintError

func PrintError(err error) []byte

func SanitizeDate

func SanitizeDate(value string) (string, error)

func SanitizeSMWDate

func SanitizeSMWDate(value string) (string, error)

func SanitizeWikiText

func SanitizeWikiText(value string) string

Types

type ApiResult

type ApiResult struct {
	Results []ApiResultEntry `json:"results"`
	Version string           `json:"version"`
	Meta    SMWResponseMeta  `json:"meta"`
}

func ConvertApiResult

func ConvertApiResult(response *SMWResponse) (result ApiResult, err error)

func GetEvents

func GetEvents(start string, end string) (events ApiResult, err error)

type ApiResultEntry

type ApiResultEntry struct {
	Id       string   `json:"id"`
	Start    int64    `json:"start"`
	End      int64    `json:"end"`
	StartStr string   `json:"startStr"`
	EndStr   string   `json:"endStr"`
	Title    string   `json:"title"`
	Desc     string   `json:"desc"`
	Url      string   `json:"url"`
	Icon     string   `json:"icon,omitempty"`
	Type     []string `json:"type,omitempty"`
	Color    string   `json:"color,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type EventsParameter

type EventsParameter struct {
	Action        string `url:"action"`
	Format        string `url:"format"`
	Formatversion int    `url:"formatversion"`
	Query         string `url:"query"`
}

type InvalidDateError

type InvalidDateError struct{}

func (*InvalidDateError) Error

func (e *InvalidDateError) Error() string

type ParseParameter

type ParseParameter struct {
	Action             string `url:"action"`
	Format             string `url:"format"`
	Text               string `url:"text"`
	Prop               string `url:"prop"`
	ContentModel       string `url:"contentmodel"`
	Wrapoutputclass    string `url:"wrapoutputclass"`
	Disablelimitreport int    `url:"disablelimitreport"`
	Disableeditsection int    `url:"disableeditsection"`
	Disabletoc         int    `url:"disabletoc"`
}

type ParseResponse

type ParseResponse struct {
	Parse struct {
		Title  string `json:"title"`
		Pageid int    `json:"pageid"`
		Text   struct {
			Content string `json:"*"`
		} `json:"text"`
	} `json:"parse"`
}

type SMWResponse

type SMWResponse struct {
	Query struct {
		Results    SMWResponseResult `json:"results"`
		Serializer string            `json:"serializer"`
		Version    int               `json:"version"`
		Meta       SMWResponseMeta   `json:"meta"`
	} `json:"query"`
}

type SMWResponseMeta

type SMWResponseMeta struct {
	Hash   string `json:"hash"`
	Count  int    `json:"count"`
	Offset int    `json:"offset"`
	Source string `json:"source"`
	Time   string `json:"time"`
}

type SMWResponseResult

type SMWResponseResult struct {
	Entries []SMWResponseResultEntry
}

func (*SMWResponseResult) UnmarshalJSON

func (r *SMWResponseResult) UnmarshalJSON(data []byte) error

type SMWResponseResultEntry

type SMWResponseResultEntry struct {
	Printouts struct {
		Type  []string `json:"type"`
		Color []string `json:"color"`
		Name  []string `json:"name"`
		Start []struct {
			Timestamp string `json:"timestamp"`
			Raw       string `json:"raw"`
		} `json:"start"`
		End []struct {
			Timestamp string `json:"timestamp"`
			Raw       string `json:"raw"`
		} `json:"end"`
		Desc []string `json:"desc"`
		Icon []struct {
			Fulltext     string `json:"fulltext"`
			Fullurl      string `json:"fullurl"`
			Namespace    int    `json:"namespace"`
			Exists       string `json:"exists"`
			Displaytitle string `json:"displaytitle"`
		} `json:"icon"`
	} `json:"printouts"`
	Fulltext     string `json:"fulltext"`
	Fullurl      string `json:"fullurl"`
	Namespace    int    `json:"namespace"`
	Exists       string `json:"exists"`
	Displaytitle string `json:"displaytitle"`
}

type UpstreamError

type UpstreamError struct{}

func (*UpstreamError) Error

func (e *UpstreamError) Error() string

Jump to

Keyboard shortcuts

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