ephemeris: github.com/skx/ephemeris Index | Files

package ephemeris

import "github.com/skx/ephemeris"

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.


Package Files

blog_comment.go blog_entry.go site.go

type BlogComment Uses

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 Uses

func NewBlogComment(path string) (BlogComment, error)

NewBlogComment reads a comment from the named file, and returns that in a structured form.

type BlogEntry Uses

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 Uses

func NewBlogEntry(path string, site *Ephemeris) (BlogEntry, error)

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 Uses

func (b BlogEntry) MonthName() string

MonthName returns the value of a post's month, as a string, for example "January", "March", etc.

func (BlogEntry) MonthNumber Uses

func (b BlogEntry) MonthNumber() string

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.

func (BlogEntry) Year Uses

func (b BlogEntry) Year() string

Year returns the year of a blog-post, as a string.

Having a string return value is useful for template interpolation.

type Ephemeris Uses

type Ephemeris struct {
    // Root is the source of our posts.
    Root string

    // 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 New Uses

func New(directory string, commentPath string) *Ephemeris

New creates a new site object.

func (*Ephemeris) Entries Uses

func (e *Ephemeris) Entries(prefix string) ([]BlogEntry, error)

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.

Package ephemeris imports 12 packages (graph). Updated 2019-12-08. Refresh now. Tools for package owners.