saebr

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

README

saebr (Simple App Engine Blog Renderer)

The engine underlying my blog. Could be used as a CMS? Maybe!

Usage

Use the template, Luke.

Documentation

Overview

Package saebr provides a simple blog or CMS for running on App Engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(siteKey string, opts ...Option)

Run runs saebr.

saebr makes the following assumptions:

  • It's running on Google App Engine, so runs as an unencrypted HTTP server. (App Engine can provide HTTPS and HTTP/2.)
  • Run can exit the program (using log.Fatal) if an error occurs.
  • Serving port is given by the PORT env var, or if empty assumes 8080.

Types

type Option

type Option func(*options)

Option is the type of each functional option to Run.

func CacheMaxSize

func CacheMaxSize(n int) Option

CacheMaxSize configures the maximum size for the page cache. The default is 10000.

func DatastoreProjectID

func DatastoreProjectID(projID string) Option

DatastoreProjectID sets the project ID used for the Cloud Datastore client. The default is the empty string (the client then obtains the project ID from the DATASTORE_PROJECT_ID env var).

func RootServeAction added in v0.0.2

func RootServeAction(sa ServeAction) Option

RootServeAction changes how the root of the site is handled.

func TemplateFuncs

func TemplateFuncs(fm template.FuncMap) Option

TemplateFuncs allows providing custom template functions. Can be passed multiple times.

type Page

type Page struct {
	Key          *datastore.Key `datastore:"__key__"`
	Title        string
	Created      time.Time
	LastModified time.Time
	Published    bool
	Blog         bool
	Category     string
	Tags         []string
	Description  string         `datastore:",noindex"`
	Contents     string         `datastore:",noindex"`
	Prev, Next   *datastore.Key `datastore:",noindex"`
	// contains filtered or unexported fields
}

Page is the type of each blog post or page.

func (*Page) Edited

func (p *Page) Edited() bool

Edited reports if the created and last-modified timestamps are different by more than 12 hours.

func (*Page) Latest

func (p *Page) Latest() bool

Latest reports if the page is the latest (i.e. Next is nil) and Blog is true.

func (*Page) TagList

func (p *Page) TagList() string

TagList returns Tags as a single comma-delimited string.

type ServeAction added in v0.0.2

type ServeAction int

ServeAction describes some possible actions for handling a request.

const (
	RedirectToLatest ServeAction = iota // Redirect to latest post canonical
	ServeLatest                         // Serve a copy of the latest post
	ServeDefault                        // Serve a normal page (key "default")
)

Values for ServeAction.

type Site

type Site struct {
	Key *datastore.Key `datastore:"__key__"`

	URLBase           string `datastore:",noindex"`
	PageTemplate      string `datastore:",noindex"`
	AdminEmail        string `datastore:",noindex"`
	Secret            string `datastore:",noindex"`
	WebSignInClientID string `datastore:",noindex"`
	FeedTitle         string `datastore:",noindex"`
	FeedSubtitle      string `datastore:",noindex"`
	FeedDescription   string `datastore:",noindex"`
	FeedAuthor        string `datastore:",noindex"`
	FeedCopyright     string `datastore:",noindex"`
	TimeLocation      string `datastore:",noindex"`
	// contains filtered or unexported fields
}

Site is the root of a site, and contains the page template and other site-wide metadata.

Jump to

Keyboard shortcuts

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