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 ¶
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) SetFormatter ¶
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 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 ¶
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.