genericsite

package module
v0.0.0-...-d09af67 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 12 Imported by: 3

README

genericsite Build Status GoDoc

Deprecated!

I'm phasing out this package.

  • I want use templates instead of generating webpages.
  • I want to use the permissions2 middleware for users and permissions.
  • I don't want to use web.go, but rather keep the choice open and/or use the standard net/http package.

Features and limitations

  • Generic website library with search and user administration.
  • Part of an experiment in procedural generation of websites.
  • Uses procedural generation of html and css extensively.
  • Has a user login and registration system.
  • Has an email confirmation system.
  • Has an admin panel.
  • Supports subpages.
  • Runs at native speed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContent

func AddContent(page *onthefly.Page, contentTitle, contentHTML string) (*onthefly.Tag, error)

func AddFooter

func AddFooter(page *onthefly.Page, footerText, footerTextColor, footerColor string, elapsed time.Duration) (*onthefly.Tag, error)

TODO: Place at the bottom of the content instead of at the bottom of the window

func AddIfNotAdded

func AddIfNotAdded(url string, filteredMenuEntries *MenuEntries, menuEntry *MenuEntry)

func AddMenuBox

func AddMenuBox(page *onthefly.Page, darkBackgroundTexture string, customSansSerif string) (*onthefly.Tag, error)

Takes a page and a colon-separated string slice of text:url, hiddenlinks is just a list of the url part

func AddSearchBox

func AddSearchBox(tag *onthefly.Tag, actionURL, buttonText string, roundedLook bool) *onthefly.Tag

Add a search box to the page, actionURL is the url to use as a get action, buttonText is the text on the search button

func AddTitleBox

func AddTitleBox(tag *onthefly.Tag, title, subtitle string, cs *ColorScheme) *onthefly.Tag

func AddTopBox

func AddTopBox(page *onthefly.Page, title, subtitle, searchURL, searchButtonText, backgroundTextureURL string, roundedLook bool, cs *ColorScheme, addSearchBox bool) (*onthefly.Tag, error)

func ConfirmationEmail

func ConfirmationEmail(domain, link, username, email string) error

func GenerateHTMLwithTemplate

func GenerateHTMLwithTemplate(page *onthefly.Page, tvg webhandle.TemplateValueGenerator) func(http.ResponseWriter, *http.Request)

Create a web.go compatible function that returns a string that is the HTML for this page

func GenerateMenuCSS

func GenerateMenuCSS(state pinterface.IUserState, stretchBackground bool, cs *ColorScheme) func(http.ResponseWriter, *http.Request)

CSS for the menu, and a bit more

func HasEntry

func HasEntry(checkEntry *MenuEntry, menuEntries MenuEntries) bool

Checks if a *MenuEntry exists in a []*MenuEntry (MenuEntries)

func MenuSnippet(menuEntries MenuEntries) *onthefly.Page

Generate tags for the menu based on a list of "MenuDescription:/menu/url"

func PublishCPs

func PublishCPs(r *mux.Router, userState pinterface.IUserState, pc PageCollection, cs *ColorScheme, tvgf TemplateValueGeneratorFactory, cssurl string)

Publish a list of ContentPages, a colorscheme and template content

func RenderPage

func RenderPage(page *onthefly.Page, templateContents map[string]string) (string, string)

Render a page by inserting data at the {{{placeholders}}} for both html and css

func ServeSite

func ServeSite(r *mux.Router, basecp BaseCP, userState pinterface.IUserState, cps PageCollection, tvgf TemplateValueGeneratorFactory, jquerypath string)

Some Engines like Admin must be served separately jquerypath is ie "/js/jquery.2.0.0.js", will then serve the file at static/js/jquery.2.0.0.js

func TemplateValueGeneratorCombinator

func TemplateValueGeneratorCombinator(tvg1, tvg2 webhandle.TemplateValueGenerator) webhandle.TemplateValueGenerator

Combines two TemplateValueGenerators into one TemplateValueGenerator by adding the strings per key

Types

type BaseCP

type BaseCP func(state pinterface.IUserState) *ContentPage

Base content page

type CPgen

type CPgen (func(userState permissions.UserState) *ContentPage)

Content page generator

type ColorScheme

type ColorScheme struct {
	Darkgray           string
	Nicecolor          string
	Menu_link          string
	Menu_hover         string
	Menu_active        string
	Default_background string
	TitleText          string
}

type ContentPage

type ContentPage struct {
	GeneratedCSSurl          string
	ExtraCSSurls             []string
	JqueryJSurl              string
	Faviconurl               string
	BgImageURL               string
	StretchBackground        bool
	Title                    string
	Subtitle                 string
	ContentTitle             string
	ContentHTML              string
	HeaderJS                 string
	ContentJS                string
	SearchButtonText         string
	SearchURL                string
	FooterText               string
	BackgroundTextureURL     string
	DarkBackgroundTextureURL string
	FooterTextColor          string
	FooterColor              string
	UserState                pinterface.IUserState
	RoundedLook              bool
	Url                      string
	ColorScheme              *ColorScheme
	SearchBox                bool
	GoogleFonts              []string
	CustomSansSerif          string
	CustomSerif              string
}

The main structure, defining the look and feel of the page

func DefaultCP

func DefaultCP(userState pinterface.IUserState) *ContentPage

The default settings Do not publish this page directly, but use it as a basis for the other pages

func (*ContentPage) Pub

func (cp *ContentPage) Pub(r *mux.Router, userState pinterface.IUserState, url, cssurl string, cs *ColorScheme, tvg webhandle.TemplateValueGenerator)

Make an html and css page available

func (*ContentPage) Surround

func (cp *ContentPage) Surround(s string, templateContents map[string]string) (string, string)

Wrap a lonely string in an entire webpage

func (*ContentPage) WrapSimpleContextHandle

func (cp *ContentPage) WrapSimpleContextHandle(r *mux.Router, sch func(w http.ResponseWriter, req *http.Request) string, tvg webhandle.TemplateValueGenerator) func(w http.ResponseWriter, req *http.Request)

Uses a given SimpleContextHandle as the contents for the the ContentPage contents

func (*ContentPage) WrapWebHandle

func (cp *ContentPage) WrapWebHandle(r *mux.Router, wh func(string) string, tvg webhandle.TemplateValueGenerator) func(string, http.ResponseWriter, *http.Request)

Uses a given WebHandle as the contents for the the ContentPage contents

type MenuEntries []*MenuEntry

func Links2menuEntries

func Links2menuEntries(links []string) MenuEntries
type MenuEntry struct {
	// contains filtered or unexported fields
}

func NewMenuEntry

func NewMenuEntry(text_and_url string) *MenuEntry

Takes something like "Admin:/admin" and returns a *MenuEntry

type PageCollection

type PageCollection []ContentPage

Collection of ContentPages

type TemplateValueGeneratorFactory

type TemplateValueGeneratorFactory func(pinterface.IUserState) webhandle.TemplateValueGenerator

func DynamicMenuFactoryGenerator

func DynamicMenuFactoryGenerator(menuEntries MenuEntries) TemplateValueGeneratorFactory
  • Functions that generate functions that generate content that can be used in templates.
  • type TemplateValues map[string]string
  • type TemplateValueGenerator func(*web.Context) TemplateValues
  • type TemplateValueGeneratorFactory func(*UserState) TemplateValueGenerator

TODO: Take the same parameters as the old menu generating code TODO: Put one if these in each engine then combine them somehow TODO: Check for the menyEntry.url first, then check the rights, not the other way around TODO: Fix and refactor this one TODO: Check the user status _once_, and the admin status _once_, then generate the menu TODO: Some way of marking menu entries as user, admin or other rights. Add a group system?

type UserInput

type UserInput string

Every input from the user must be intitially stored in a UserInput variable, not in a string! This is just to be aware of which data one should be careful with, and to keep it clean.

Jump to

Keyboard shortcuts

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