bleedy

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

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

Go to latest
Published: Jan 13, 2015 License: MIT Imports: 11 Imported by: 0

README

bleedy

simple static blog generator + server

TODO components: comment handler

static generator

  • *posts/pages dir in markdown format (parsed by blackfriday)
  • *templates dir
  • *function that generates static files
  • routine should check associated comments file based on post id and add them to the page

http server

  • *simple fileserver that handles requests for static files
  • *goroutine that checks for new/modified post/pages
  • *checks for new/changed files and regenerates just that file
  • separate handler that checks for POST requests on comment forms and calls comment handler

comment handler

  • when requested by server, takes the comment form results and appends them to a file
  • send request to regenerator function to regenerate associated page/post

Documentation

Overview

bleedy handles creation of a Blog that will scan an input directory for new/modified files (markdown for instance), and parse the metadata and content of those files (content with github.com/russross/blackfriday) and create files of the same name in html format in a designated output directory.

NewBlog creates a new blog, SetInput/Output/Template allow finetuned or changing control of the directory/formats Blog scans for.

The primary method is Blog.Update(), which scans for the new/modified files, checking their last modification date against an internal map. Changes trigger calls to read the file, create a new Post struct (see post.go), format it, and write it to the output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blog

type Blog struct {
	Formatter
	// contains filtered or unexported fields
}

Blog holds the definitions of file directories/extensions for inputs, outputs, and templates, as well as the hashmap for checking time of last modification of files in the input directory.

func NewBlog

func NewBlog(conf []string, log *log.Logger) (*Blog, error)

NewBlog creates a new Blog object, populated with all the directories/extensions for input/ouput/templates. It also allocates the hashmap for checking file modification times.

func (*Blog) Output

func (b *Blog) Output() string

Output returns the ouput directory of the blog, for serving HTTP

func (*Blog) SetFormatter

func (b *Blog) SetFormatter(f Formatter)

SetFormatter sets the Formatter for Blog to use

func (*Blog) UpdateScan

func (b *Blog) UpdateScan()

UpdateScan checks the read directory for changes to files. If it detects changes (based on last-modified time), it reads the input file and creates an output file of the same name. Designed to be called continously in a loop.

type Comments

type Comments struct {
}

TODO: implement

type Formatter

type Formatter interface {
	Parse(b []byte, date time.Time) (Formatter, error)
	Format(templateFile string) ([]byte, error)
	String() string
	Date() string
}

Formatter defines an interface that can Parse an input byte slice into some data, later work with a template file to Format that data into another byte slice, and can also pretty print itself with String() for simple representation.

type PostFormatter

type PostFormatter struct {
	Title    string
	Author   string
	Tag      string
	Template string
	Body     template.HTML //string //[]byte
	// contains filtered or unexported fields
}

Post holds the content of a post, parsed from a file, metadata and body content.

func NewPostFormatter

func NewPostFormatter(conf []string) (*PostFormatter, error)

NewPostFormatter takes the contents of a configuration file and returns a correctly initialized PostFormatter

func (*PostFormatter) Date

func (p *PostFormatter) Date() string

Format the date into configured readable format.

func (*PostFormatter) Format

func (p *PostFormatter) Format(templateFile string) ([]byte, error)

Format takes a template file and creates a []byte representing an html document populated with the Post content, ready for writing to a file.

func (*PostFormatter) Parse

func (p *PostFormatter) Parse(b []byte, date time.Time) (Formatter, error)

PostFormatter takes a byte slice (from a markdowned text file), a date, and creates a new Post object. The date should typically be the last modification time of the file, and will be overwritten if a date is manually set in the Post metadata.

func (*PostFormatter) String

func (p *PostFormatter) String() string

String prints the Post meta content and body.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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