http

package
v0.0.0-...-d30beaa Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Templates = make(map[string]*template.Template)

Many functions have to get to the templates stack, so it is made global.

Functions

func IndexPage

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

func RenderOpenSearch

func RenderOpenSearch(templatePath string, outPath string) error

Using a template file, substitute in some config variables to form the opensearch.xml so it functions with this redirector instance.

Browsers will request this if the HTML says we have it. The rendered version of this file will contain all the needed substitutions, as dictated from the config file.

func RenderSpecial

func RenderSpecial(params []string, l *core.Link, ll *core.ListOfLinks, check chan<- string) (string, bool, error)

This performs substitutions on the URL. It returns the URL string, whether it is complete, and an error value.

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, name string, data *ModelIndex) error

Take a template name, like help.gohtml, and render it down to the base template. Execute it, sending it to the client.

func RouteCheck

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

The link check feature: for debugging precisely what happens behind the scenes

This particular function is here solely to catch requests using the "/check" prefix on their queries. This redirects the user to the same input they provided with an added "?check=true" URL parameter so we can handle checks consistently in one place.

func RouteGetDB

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

Provide an external URL used to get the entire DB in JSON format

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

func RouteLogin

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

func RouteMaps

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

The maps page shows the input boxes for a new map or in the case of an existing map, those same edit boxes populated with values from that map.

func RouteNotFound

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

If you go looking for something weird, you get moondog.

func RouteStrings

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

The string variables handler

func RouteSuggest

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

RouteSuggest implements part of the opensearch protocol, specifically the search suggestions extension.

Every time the user types a character in their URL bar, the browser is going to send a request to this route. The route responds with an array of information the browser uses to populate the seach suggestions.

Types

type ModelIndex

type ModelIndex struct {
	Title              string
	LinkDB             *core.LinkDatabase
	Keyword            core.Keyword
	KeywordExists      bool
	KeywordBeingEdited bool
	LinkExists         bool
	LinkBeingEdited    *core.Link
	RedirectorName     string
	Overrides          map[string]string
	KeywordParams      []string
	UsageLog           []string
	ErrorMessage       string   // user-facing error strings for templates
	ActiveUser         string   // empty string means not logged in
	Variable           []string // works with strings and maps. first is key, second value
}

func RenderDotPage

func RenderDotPage(r *http.Request) (string, ModelIndex, error)

Right now, this is a wrapper for renderListPage just in case we want to ever do something special here.

func RenderLinkPage

func RenderLinkPage(r *http.Request) (string, ModelIndex, error)

func RenderListPage

func RenderListPage(r *http.Request) (string, ModelIndex, error)

Return everything needed to get to the list page

func (*ModelIndex) AtimeSort

func (m *ModelIndex) AtimeSort(k core.Keyword) []*core.Link

//sort on the most recent atime, descending

func (*ModelIndex) ClickSort

func (m *ModelIndex) ClickSort() []*core.ListOfLinks

func (*ModelIndex) GetBehavior

func (m *ModelIndex) GetBehavior() string

GetBehavior returns a string representation of the behavior for a model's keyword. Strings are returned because they are being used in HTML by the template.

func (*ModelIndex) GetExternalRedirectorAddress

func (m *ModelIndex) GetExternalRedirectorAddress() string

Return the configuration external_address value for use in templates. This does not contain the http or https prefixes, which would be nice to have since the external full URL could potentially use either protocol.

func (*ModelIndex) GetExternalRedirectorProto

func (m *ModelIndex) GetExternalRedirectorProto() string

external protocol. 'http' or 'https', defined in the config file

func (*ModelIndex) GetExtraction

func (m *ModelIndex) GetExtraction() core.ExtractionCapture

extractions

func (m *ModelIndex) GetLink(id int) core.Link

Get a link object by integer ID

func (*ModelIndex) GetLinkEdits

func (m *ModelIndex) GetLinkEdits(id int) []*core.EditRecord

func (*ModelIndex) GetListEdits

func (m *ModelIndex) GetListEdits(k core.Keyword) []*core.EditRecord

func (*ModelIndex) GetMapMemberships

func (m *ModelIndex) GetMapMemberships() map[string][]int

Get all links containing a map variable

func (*ModelIndex) GetMapVariable

func (m *ModelIndex) GetMapVariable(n string) map[string]string

func (*ModelIndex) GetMapVariables

func (m *ModelIndex) GetMapVariables() []string

func (*ModelIndex) GetMyList

func (m *ModelIndex) GetMyList(k core.Keyword) *core.ListOfLinks

give keyword, get list of links

func (*ModelIndex) GetSimilar

func (m *ModelIndex) GetSimilar() []string

GetSimilar locates keywords which are named similarly or which have tags or links containing substring matches to the search term.

func (*ModelIndex) GetStringVariables

func (m *ModelIndex) GetStringVariables() map[string]string

This is used so the template has all variables available to put into tables.

func (*ModelIndex) GetUsage

func (m *ModelIndex) GetUsage() string

return the usage strings for special keywords/lists

func (*ModelIndex) IdentifyBuild

func (m *ModelIndex) IdentifyBuild() string

IdentifyBuild simply returns the sha256sum of the redirector binary for simple versioning.

func (*ModelIndex) IsSpecial

func (m *ModelIndex) IsSpecial() bool

return true if a keyword is special/dynamic, false if it is a regular keyword

func (*ModelIndex) ListURL

func (m *ModelIndex) ListURL() string

func (*ModelIndex) MtimeSort

func (m *ModelIndex) MtimeSort(k core.Keyword) []*core.Link

sort on the most recent mtime, descending

func (*ModelIndex) PrettyBehavior

func (m *ModelIndex) PrettyBehavior() string

func (*ModelIndex) PrettyTime

func (m *ModelIndex) PrettyTime(t time.Time) string

The template can use this to get a nicer string explaining mtime.

Jump to

Keyboard shortcuts

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