cgi

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: BSD-3-Clause Imports: 27 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RSSTextFormat added in v0.2.0

func RSSTextFormat(plain string) string

RSSTextFormat formats plain string to stirng usable in html.

func RegistToRouter added in v0.2.0

func RegistToRouter(s *mux.Router, path string, fn func(w http.ResponseWriter, r *http.Request))

RegistToRouter registers fn to s with path.

func RenderRSS added in v0.2.0

func RenderRSS(st interface{}, wr io.Writer)

RenderRSS executes rss template and write to wr.

func RenderTemplate added in v0.2.0

func RenderTemplate(file string, st interface{}, wr io.Writer)

RenderTemplate executes template and write to wr.

Types

type CGI added in v0.2.0

type CGI struct {
	M        Message
	JC       *jsCache
	Req      *http.Request
	WR       http.ResponseWriter
	IsThread bool
}

CGI is a base class for all http handlers.

func NewCGI added in v0.2.0

func NewCGI(w http.ResponseWriter, r *http.Request) (*CGI, error)

NewCGI reads messages file, and set params , returns CGI obj. CGI obj is cached.

func (*CGI) CheckGetCache added in v0.2.0

func (c *CGI) CheckGetCache() bool

CheckGetCache return true if visitor is firend or admin and user-agent is not robot.

func (*CGI) CheckVisitor added in v0.2.0

func (c *CGI) CheckVisitor() bool

CheckVisitor returns true if visitor is permitted.

func (*CGI) Defaults added in v0.2.0

func (c *CGI) Defaults() *Defaults

Defaults returns default params for templates.

func (*CGI) Footer added in v0.2.0

func (c *CGI) Footer(menubar *Menubar)

Footer render footer.

func (*CGI) HTMLFormat added in v0.2.0

func (c *CGI) HTMLFormat(plain, appli string, title string, absuri bool) string

HTMLFormat converts plain text to html , including converting link string to <a href="link">.

func (*CGI) HasAuth added in v0.2.0

func (c *CGI) HasAuth() bool

HasAuth auth returns true if visitor is admin or friend.

func (*CGI) Header added in v0.2.0

func (c *CGI) Header(title, rss string, cookie []*http.Cookie, denyRobot bool)

Header renders header.txt with cookie.

func (*CGI) Host added in v0.2.0

func (c *CGI) Host() string

Host returns servername or host in http header.

func (*CGI) IsAdmin added in v0.2.0

func (c *CGI) IsAdmin() bool

IsAdmin returns tur if matches admin regexp setted in config file.

func (*CGI) IsBot added in v0.2.0

func (c *CGI) IsBot() bool

IsBot returns true if client is bot.

func (*CGI) IsFriend added in v0.2.0

func (c *CGI) IsFriend() bool

IsFriend returns tur if matches friend regexp setted in config file.

func (*CGI) MakeMenubar added in v0.2.0

func (c *CGI) MakeMenubar(id, rss string) *Menubar

MakeMenubar makes and returns *Menubar obj.

func (*CGI) Path added in v0.2.0

func (c *CGI) Path() string

Path returns path part of url. e.g. /thread.CGI/hoe/moe -> hoe/moe

func (*CGI) Print302 added in v0.2.0

func (c *CGI) Print302(next string)

Print302 renders jump page(meaning found and redirect)

func (*CGI) Print403 added in v0.2.0

func (c *CGI) Print403()

Print403 renders 403 forbidden page with jump page.

func (*CGI) Print404 added in v0.2.0

func (c *CGI) Print404(ca *thread.Cache, id string)

Print404 render the 404 page. if ca!=nil also renders info page of removing cache.

func (*CGI) PrintIndexList added in v0.2.0

func (c *CGI) PrintIndexList(cl []*thread.Cache, target string, footer bool, searchNewFile bool, filter, tagg string)

PrintIndexList renders index_list.txt which renders threads in cachelist.

func (*CGI) PrintNewElementForm added in v0.2.0

func (c *CGI) PrintNewElementForm()

PrintNewElementForm renders new_element_form.txt for posting new thread.

func (*CGI) RFC822Time added in v0.2.0

func (c *CGI) RFC822Time(stamp int64) string

RFC822Time convers stamp to "2006-01-02 15:04:05"

func (*CGI) RemoveFileForm added in v0.2.0

func (c *CGI) RemoveFileForm(ca *thread.Cache, title string)

RemoveFileForm render remove_form_form page.

func (*CGI) ResAnchor added in v0.2.0

func (c *CGI) ResAnchor(id, appli string, title string, absuri bool) string

ResAnchor returns a href string with url.

type CacheInfo added in v0.2.0

type CacheInfo struct {
	Cache   *thread.Cache
	Tags    tag.Slice
	Sugtags []*tag.Tag
	Title   string
}

CacheInfo is infos of a cache.

type Defaults added in v0.2.0

type Defaults struct {
	AdminCGI    string
	GatewayCGI  string
	ThreadCGI   string
	ServerCGI   string
	Message     Message
	IsAdmin     bool
	IsFriend    bool
	Version     string
	DescChanges string
	DescNew     string
	DescRecent  string
	DescIndex   string
	DescSearch  string
	DescStatus  string
	Path        string
	EmptyList   template.HTML
}

Defaults is default variables for templates.

type Htemplate added in v0.1.0

type Htemplate struct {
	*htmlTemplate.Template
}

Htemplate is for rendering html stuff.

type Item

type Item struct {
	Title       string
	Link        string
	Description string
	Creator     string
	Date        int64

	Content string
	Subject []string
	// contains filtered or unexported fields
}

Item represents RSS contents.

type ListItem

type ListItem struct {
	Caches  []*CacheInfo
	StrOpts string
	Remove  bool
}

ListItem is for list_item.txt

func NewListItem added in v0.2.0

func NewListItem(caches []*thread.Cache, remove bool, target string, search bool, filter, tag string) *ListItem

NewListItem returns ListItem struct from caches.

type LoggingServeMux

type LoggingServeMux struct {
	*http.ServeMux
}

LoggingServeMux is ServerMux with logging

func NewLoggingServeMux

func NewLoggingServeMux() *LoggingServeMux

NewLoggingServeMux returns loggingServeMux obj.

func (*LoggingServeMux) RegistCompressHandler

func (s *LoggingServeMux) RegistCompressHandler(path string, fn func(w http.ResponseWriter, r *http.Request))

RegistCompressHandler registers fn to s after registering CompressHandler with path.

func (*LoggingServeMux) RegisterPprof

func (s *LoggingServeMux) RegisterPprof()

RegisterPprof registers pprof relates funcs to s.

func (*LoggingServeMux) ServeHTTP

func (s *LoggingServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP just calles http.ServeMux.ServeHTTP after logging.

type Menubar struct {
	Defaults
	ID  string
	RSS string
}

Menubar is var set for menubar.txt

type Message added in v0.2.0

type Message map[string]string

Message hold string map.

func SearchMessage added in v0.2.0

func SearchMessage(acceptLanguage, filedir string) Message

SearchMessage parse Accept-Language header ,selects most-weighted(biggest q) language ,reads the associated message file, and creates and returns message obj.

type RSS

type RSS struct {
	Encode      string
	Lang        string
	Title       string
	Link        string
	Description string
	Feeds       []*Item

	URI string
	XSL string
	// contains filtered or unexported fields
}

RSS represents RSS info.

func NewRSS added in v0.2.0

func NewRSS(encode, lang, title, parent, link, uri, description, xsl string) *RSS

NewRSS makes RSS object.

func (*RSS) Append added in v0.2.0

func (r *RSS) Append(link, title, creator, description, content string, subject []string, date int64, abs bool)

Append adds RSS an item.

func (*RSS) Len

func (r *RSS) Len() int

Len returns # of feeds.

func (*RSS) Less

func (r *RSS) Less(i, j int) bool

Less returns true if date of feed[i]<one of [j]

func (*RSS) MakeRSS1 added in v0.2.0

func (r *RSS) MakeRSS1(wr io.Writer)

MakeRSS1 renders template.

func (*RSS) Swap

func (r *RSS) Swap(i, j int)

Swap swaps feed[i] and feed[j]

func (RSS) W3cdate

func (r RSS) W3cdate(dat int64) string

W3cdate returns RSS formated date string. used in templates

type Ttemplate added in v0.1.0

type Ttemplate struct {
	*textTemplate.Template
}

Ttemplate is for rendering text rss template.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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