framework

package
v0.0.0-...-f66637b Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeDev  = "dev"
	ModeProd = "prod"
)

Variables

View Source
var Reload = make(chan bool, 1)
View Source
var Server server

Functions

func BuildSitemap

func BuildSitemap(urls ...*URL)

func CloseJsBuild

func CloseJsBuild()

func CloseLog

func CloseLog()

func CloseReloadBrowser

func CloseReloadBrowser()

func CookieDeleteSession

func CookieDeleteSession(cookieName string, w http.ResponseWriter, r *http.Request) error

func CookieGetFlash

func CookieGetFlash(cookieName string, w http.ResponseWriter, r *http.Request) string

func CookieGetSession

func CookieGetSession(cookieName string, w http.ResponseWriter, r *http.Request) string

func CookieSetFlash

func CookieSetFlash(cookieName string, w http.ResponseWriter, msg string)

func CookieSetSession

func CookieSetSession(cookieName string, w http.ResponseWriter, uuid string)

func CreateLog

func CreateLog(logToFile bool) error

func CreateMakeFile

func CreateMakeFile() error

func CreateMkcertIfNotExists

func CreateMkcertIfNotExists() (mkcertPath string, err error)

func Domain

func Domain(pathDomain string) string

func GenerateSSL

func GenerateSSL(mkcertPath string) (err error)

func GetFilesAndDirRecursively

func GetFilesAndDirRecursively(ext string, path string) (files []string)

GetFilesAndDirRecursively returns all files with the given extension in a given directory The returned files include the path from root

func IsDev

func IsDev() bool

func JsBuild

func JsBuild()

func LogFatalErr

func LogFatalErr(err error)

func LogPrintErr

func LogPrintErr(err error)

func ReloadBrowser

func ReloadBrowser()

Types

type ChangeFreq

type ChangeFreq string

ChangeFreq specifies the change frequency of a sitemap entry. It is just a string.

const (
	Always  ChangeFreq = "always"
	Hourly  ChangeFreq = "hourly"
	Daily   ChangeFreq = "daily"
	Weekly  ChangeFreq = "weekly"
	Monthly ChangeFreq = "monthly"
	Yearly  ChangeFreq = "yearly"
	Never   ChangeFreq = "never"
)

Feel free to use these constants for ChangeFreq (or you can just supply a string directly).

type Dev

type Dev struct {
	Port             string `json:"port"`
	PortSSL          string `json:"port_ssl"`
	UseSSL           bool   `json:"use_ssl"`
	CacheStaticFiles bool   `json:"cache_static_files"`
	CacheTempls      bool   `json:"cache_templates"`
}

type Prod

type Prod struct {
	User             string `json:"user"`
	Domain           string `json:"domain"`
	IP               string `json:"ip"`
	Password         string `json:"password"`
	Port             string `json:"port"`
	PortSSL          string `json:"port_ssl"`
	UseSSL           bool   `json:"use_ssl"`
	CacheStaticFiles bool   `json:"cache_static_files"`
	CacheTempls      bool   `json:"cache_templates"`
}

type Sitemap

type Sitemap struct {
	XMLName xml.Name `xml:"urlset"`
	Xmlns   string   `xml:"xmlns,attr"`

	URLs []*URL `xml:"url"`

	Minify bool `xml:"-"`
}

Sitemap represents a complete sitemap which can be marshaled to XML. New instances must be created with New() in order to set the xmlns attribute correctly. Minify can be set to make the output less human- readable.

func New

func New() *Sitemap

New returns a new Sitemap.

func (*Sitemap) Add

func (s *Sitemap) Add(u *URL)

Add adds a URL to a Sitemap.

func (*Sitemap) ReadFrom

func (s *Sitemap) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads and parses an XML encoded sitemap from io.Reader. Implements io.ReaderFrom.

func (*Sitemap) WriteToFile

func (s *Sitemap) WriteToFile(pathFile string) error

WriteToFile writes XML encoded sitemap to given io.Writer. Implements io.WriterTo.

type URL

type URL struct {
	Loc        string     `xml:"loc"`
	LastMod    string     `xml:"lastmod,omitempty"`
	ChangeFreq ChangeFreq `xml:"changefreq,omitempty"`
	Priority   float32    `xml:"priority,omitempty"`
}

URL entry in sitemap or sitemap index. LastMod is a pointer to time.Time because omitempty does not work otherwise. Loc is the only mandatory item. ChangeFreq and Priority must be left empty when using with a sitemap index.

func CreateURL

func CreateURL(loc string, date string, changeFreq ChangeFreq, priority float32) *URL

Jump to

Keyboard shortcuts

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