Documentation
¶
Index ¶
- func EntriesByYear(entries []*Entry) map[int][]*Entry
- type Comment
- type CommentManager
- func (mgr *CommentManager) CreateTable() error
- func (mgr *CommentManager) GetAll() []*Comment
- func (mgr *CommentManager) GetByEntry(entryID int) []*Comment
- func (mgr *CommentManager) GetOne(commentID int) *Comment
- func (mgr *CommentManager) InsertMany(comments []*Comment)
- func (mgr *CommentManager) InsertOne(comment *Comment)
- type Entry
- type EntryManager
- type ScoreManager
- func (mgr *ScoreManager) AddVisit()
- func (mgr *ScoreManager) GetLikes(entryID int) int
- func (mgr *ScoreManager) GetSession(sessionID string) (string, bool)
- func (mgr *ScoreManager) GetVisits() int
- func (mgr *ScoreManager) LikeEntry(sessionID string, entryID int)
- func (mgr *ScoreManager) SetLikedBy(sessionID string, entryID int)
- func (mgr *ScoreManager) SetSession(sessionID string)
- func (mgr *ScoreManager) WasLikedBy(sessionID string, entryID int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EntriesByYear ¶
EntriesByYear re-organizes a map of Entries to group them by year
Types ¶
type Comment ¶
type Comment struct { ID int EntryID int TimePosted time.Time Name string `form:"name"` Email string `form:"email"` Text string `form:"comment"` }
Comment encapsulates a blog entry comment
type CommentManager ¶
type CommentManager struct {
ConnStr string
}
CommentManager is a SQL-based manager for comment records
func (*CommentManager) CreateTable ¶
func (mgr *CommentManager) CreateTable() error
CreateTable creates an SQL table for storing blog entries
func (*CommentManager) GetAll ¶
func (mgr *CommentManager) GetAll() []*Comment
GetAll returns all Comment records from a SQL table
func (*CommentManager) GetByEntry ¶
func (mgr *CommentManager) GetByEntry(entryID int) []*Comment
GetByEntry returns all Comment records for a given Entry from a SQL table
func (*CommentManager) GetOne ¶
func (mgr *CommentManager) GetOne(commentID int) *Comment
GetOne returns a single Comment record from a SQL table
func (*CommentManager) InsertMany ¶
func (mgr *CommentManager) InsertMany(comments []*Comment)
InsertMany is analogous to InsertOne, but accepts a map of Comment records
func (*CommentManager) InsertOne ¶
func (mgr *CommentManager) InsertOne(comment *Comment)
InsertOne inserts a single Comment record into a SQL table
type EntryManager ¶
type EntryManager struct {
ConnStr string
}
EntryManager is a SQL-based manager for Entry records
func (*EntryManager) CreateTable ¶
func (mgr *EntryManager) CreateTable() error
CreateTable creates an SQL table for storing blog entries
func (*EntryManager) GetAll ¶
func (mgr *EntryManager) GetAll() []*Entry
GetAll returns all Entry records from a SQL table
func (*EntryManager) GetOne ¶
func (mgr *EntryManager) GetOne(entryID int) *Entry
GetOne returns a single Entry record from a SQL table
func (*EntryManager) InsertMany ¶
func (mgr *EntryManager) InsertMany(entries []*Entry)
InsertMany is analogous to InsertOne, but accepts a map of Entry records
func (*EntryManager) InsertOne ¶
func (mgr *EntryManager) InsertOne(entry *Entry)
InsertOne inserts a single Entry record into a SQL table
type ScoreManager ¶
ScoreManager is responsible for setting/getting metrics in Redis
func (*ScoreManager) AddVisit ¶
func (mgr *ScoreManager) AddVisit()
AddVisit increments the global visitor/hit counter and the daily counter
func (*ScoreManager) GetLikes ¶
func (mgr *ScoreManager) GetLikes(entryID int) int
GetLikes returns the "likes" score for a blog entry key
func (*ScoreManager) GetSession ¶
func (mgr *ScoreManager) GetSession(sessionID string) (string, bool)
GetSession gets the user session key from Redis
func (*ScoreManager) GetVisits ¶
func (mgr *ScoreManager) GetVisits() int
GetVisits gets the value of the global visitor/hit counter
func (*ScoreManager) LikeEntry ¶
func (mgr *ScoreManager) LikeEntry(sessionID string, entryID int)
LikeEntry bumps the "likes" score for a blog entry key
func (*ScoreManager) SetLikedBy ¶
func (mgr *ScoreManager) SetLikedBy(sessionID string, entryID int)
SetLikedBy attaches a user session ID to a blog entry key
func (*ScoreManager) SetSession ¶
func (mgr *ScoreManager) SetSession(sessionID string)
SetSession sets the user session key in Redis
func (*ScoreManager) WasLikedBy ¶
func (mgr *ScoreManager) WasLikedBy(sessionID string, entryID int) bool
WasLikedBy checks whether a blog entry was liked by a specific user