Documentation ¶
Overview ¶
Package stories represents the story resource
Index ¶
- Constants
- func AllowedParams() []string
- func AllowedParamsAdmin() []string
- func Popular() *query.Query
- func Published() *query.Query
- func Query() *query.Query
- func Where(format string, args ...interface{}) *query.Query
- type Story
- func (s *Story) CanonicalURL() string
- func (s *Story) Code() bool
- func (s *Story) CommentCountDisplay() string
- func (s *Story) DestinationURL() string
- func (s *Story) Domain() string
- func (s *Story) Editable() bool
- func (s *Story) GodocURL() string
- func (s *Story) NameDisplay() string
- func (s *Story) NegativePoints() int64
- func (s *Story) OwnedBy(uid int64) bool
- func (s *Story) PrimaryURL() string
- func (s *Story) ShowAsk() bool
- func (s *Story) Tags() []string
- func (s *Story) VetURL() string
- func (s *Story) YouTube() bool
- func (s *Story) YouTubeURL() string
Constants ¶
const ( // TableName is the database table for this resource TableName = "stories" // KeyName is the primary key value for this resource KeyName = "id" // Order defines the default sort order in sql for this resource Order = "name asc, id desc" )
Variables ¶
This section is empty.
Functions ¶
func AllowedParams ¶
func AllowedParams() []string
AllowedParams returns the cols editable by everyone
func AllowedParamsAdmin ¶
func AllowedParamsAdmin() []string
AllowedParamsAdmin returns the cols editable by admins
Types ¶
type Story ¶
type Story struct { // resource.Base defines behaviour and fields shared between all resources resource.Base // status.ResourceStatus defines a status field and associated behaviour status.ResourceStatus CommentCount int64 Name string Summary string URL string Points int64 Rank int64 UserID int64 // UserName denormalises the user name - use join instead? UserName string }
Story handles saving and retreiving stories from the database
func FindFirst ¶ added in v1.0.1
FindFirst fetches a single story record from the database using a where query with the format and args provided.
func NewWithColumns ¶
NewWithColumns creates a new story instance and fills it with data from the database cols provided.
func (*Story) CanonicalURL ¶
CanonicalURL is the canonical URL of the story on this site including a slug for seo
func (*Story) Code ¶
Code returns true if this is a link to a git repository At present we only check for github urls, we should at least check for bitbucket
func (*Story) CommentCountDisplay ¶
CommentCountDisplay returns the comment count or ellipsis if count is 0
func (*Story) DestinationURL ¶
DestinationURL returns the URL of the story if no url is set, it uses the CanonicalURL
func (*Story) Editable ¶
Editable returns true if this story is editable. Stories are editable if less than 1 hours old
func (*Story) NameDisplay ¶
NameDisplay returns a title string without hashtags (assumed to be at the end), by truncating the title at the first #
func (*Story) NegativePoints ¶
NegativePoints returns a negative point score or 0 if points is above 0
func (*Story) PrimaryURL ¶
PrimaryURL returns the URL to use for this story in lists Videos and Show Ask stories link to the story for other links for now it is the destination
func (*Story) Tags ¶
Tags are defined as words beginning with # in the title TODO: for speed and clarity we could extract at submit time instead and store in db