models

package
v0.0.0-...-8f5c598 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2015 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package models contains all models used for representing data in the application as well as functions for manipulating that data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPostHeadMatter

func FormatPostHeadMatter(hm HeadMatter) string

func ParsePostContent

func ParsePostContent(contents []byte, t string) template.HTML

ParsePostContent parses the HeadMatter and HTML from a raw post.

func ParsePostId

func ParsePostId(id string) string

ParsePostId parses a file path from an url parameter.

func ParsePostSlugAndType

func ParsePostSlugAndType(filename string) (string, string)

ParsePostSlugAndType parses a post's slug and type from its filename. The file extension is used for the post type. The slug is grabbed from the basename sans a prefixed date used for organization. It returns the post's slug and type.

func SavePost

func SavePost(root string, p interface{}) error

SavePost writes a new file or a file's new contents to storage.

Types

type Category

type Category struct {
	Id        int64     `json:"id"`
	Title     string    `json:"title"`
	Slug      string    `json:"slug"`
	ParentId  int64     `json:"parent_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type HeadMatter

type HeadMatter struct {
	Title           string   `json:"title",yaml:"title,omitempty"`
	Date            string   `json:"date",yaml:"date,omitempty"`
	Categories      []string `json:"categories",yaml:"categories,omitempty"`
	MetaDescription string   `json:"meta_description",yaml:"meta_description,omitempty"`
	FeatureImage    string   `json:"feature_image",yaml:"feature_image,omitempty"`
}

Represents the possible data contained within the head matter section of a post, fenced with leading and following --- lines.

func ParsePostHeadMatter

func ParsePostHeadMatter(contents []byte) (HeadMatter, []byte)

type Post

type Post struct {
	Id          int64         `json:"id"`
	Title       string        `json:"title"`
	Slug        string        `json:"slug"`
	ParentId    int64         `json:"parent_id"`
	Content     template.HTML `json:"content"`
	Raw         string        `json:"raw"`
	CreatedAt   time.Time     `json:"created_at"`
	UpdatedAt   time.Time     `json:"updated_at"`
	PublishedAt time.Time     `json:"published_at"`
	HeadMatter  HeadMatter    `json:"head_matter"`
	Filename    string        `json:"filename"`
	Directory   string        `json:"directory"`
	Type        string        `json:"type"`
}

func GetAllPosts

func GetAllPosts(root string) []Post

GetAllPosts returns all posts from the storage system by name.

func GetPost

func GetPost(name, root string) Post

GetPost returns a single post from the storage system by name.

Jump to

Keyboard shortcuts

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