Documentation
¶
Overview ¶
Package ephemeris holds some minimal code to create a blog.
A blog is largely made up of blog-posts, which are parsed from a series of text-files.
Each post will have a small header to include tags, date, title, and will be transformed into a simple site.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlogComment ¶
type BlogComment struct {
// Author holds the name of the comment-submitter.
Author string
// Body holds the body of the comment.
Body string
// Icon is generated from the email-address of the submitter.
// This will be a gravitar link.
Icon string
// Link holds any user-submitted URL.
Link string
// Date is when the comment was created - this is extracted
// from the filename of the comment file.
//
// The filenames of our comments are "${title}.html.${epoch-seconds}"
Date time.Time
}
BlogComment is the structure to describe a comment associated with a blog post.
func NewBlogComment ¶
func NewBlogComment(path string) (BlogComment, error)
NewBlogComment reads a comment from the named file, and returns that in a structured form.
type BlogEntry ¶
type BlogEntry struct {
// Title holds the blog-title.
Title string
// Path holds the path to the source-file, on-disk.
Path string
// Tags contains a list of tags for the given post.
Tags []string
// Content contains the post-body.
Content string
// The link to the post.
Link string
// Date is when the post was created.
Date time.Time
// CommentData contains any comments left upon this entry.
CommentData []BlogComment
}
BlogEntry holds a single blog-post.
A post has a series of attributes associated with it, as you would expect, such as a title a set of tags, and an associated set of comments.
func NewBlogEntry ¶
NewBlogEntry creates a new blog object from the contents of the given file.
If the file is formatted in Markdown it will be expanded to HTML as part of the creation-process.
func (BlogEntry) MonthName ¶ added in v0.2.0
MonthName returns the value of a post's month, as a string, for example "January", "March", etc.
func (BlogEntry) MonthNumber ¶ added in v0.2.0
MonthNumber returns the value of a post's month, as a two-digit string. For example "01", "11", or "12".
Having a string return value is useful for template interpolation.
type Ephemeris ¶
type Ephemeris struct {
// Root is the source of our posts.
Root string
// BlogEntries holds the entries we've found
BlogEntries []BlogEntry
// CommentFiles holds the filenames of comments we've found.
CommentFiles []string
// Prefix is the absolute URL prefix for the blog
Prefix string
}
Ephemeris holds our site structure.
There are only a few settings for the blog, which are the obvious ones - a path pointing to the blog-posts, a URL-prefix for use in generation of the output files, and a list of comment files.
func (*Ephemeris) Entries ¶
Entries returns the blog-entries contained within a site. Note that the input directory is searched recursively for files matching the pattern "*.txt" - this allows you to create entries in sub-directories if you wish.
The entries are returned in a random-order, and contain a complete copy of all the text in the entries. This means that there is a reasonable amount of memory overhead here.