stories

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stories represents the story resource

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of allowed param keys

func AllowedParamsAdmin

func AllowedParamsAdmin() []string

AllowedParamsAdmin returns an array of allowed param keys

func Create

func Create(params map[string]string) (int64, error)

Create inserts a new record in the database using params, and returns the newly created id

func Popular() *query.Query

Popular returns a query for all stories with points over a certain threshold

func Published

func Published() *query.Query

Published returns a query for all stories with status >= published

func Query

func Query() *query.Query

Query returns a new query for stories

func Where

func Where(format string, args ...interface{}) *query.Query

Where returns a Where query for stories with the arguments supplied

Types

type Story

type Story struct {
	model.Model
	status.ModelStatus
	Name    string
	Summary string
	Url     string
	Rank    int64
	Points  int64

	UserId       int64
	UserName     string
	CommentCount int64
}

Story handles saving and retreiving stories from the database

func Find

func Find(id int64) (*Story, error)

Find returns a single record by id in params

func FindAll

func FindAll(q *query.Query) ([]*Story, error)

FindAll returns all results for this query

func New

func New() *Story

New creates and initialises a new story instance

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *Story

NewWithColumns creates a new story instance and fills it with data from the database cols provided

func (*Story) CanonicalURL

func (m *Story) CanonicalURL() string

CanonicalURL is the canonical URL of the story on this site including a slug for seo

func (*Story) Code

func (m *Story) Code() bool

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

func (m *Story) CommentCountDisplay() string

CommentCountDisplay returns the comment count or ellipsis if count is 0

func (*Story) DestinationURL

func (m *Story) DestinationURL() string

DestinationURL returns the URL of the story if no url is set, it uses the CanonicalURL

func (*Story) Destroy

func (m *Story) Destroy() error

Destroy removes the record from the database

func (*Story) Domain

func (m *Story) Domain() string

Domain returns the domain of the story URL

func (*Story) Editable

func (m *Story) Editable() bool

Editable returns true if this story is editable. Stories are editable if less than 1 hours old

func (*Story) GodocURL

func (m *Story) GodocURL() string

GodocURL returns the godoc.org URL for this story, or empty string if none

func (*Story) NameDisplay

func (m *Story) NameDisplay() string

NameDisplay returns a title string without hashtags (assumed to be at the end), by truncating the title at the first #

func (*Story) NegativePoints

func (m *Story) NegativePoints() int64

NegativePoints returns a negative point score or 0 if points is above 0

func (*Story) OwnedBy

func (m *Story) OwnedBy(uid int64) bool

OwnedBy returns true if this user id owns this story.

func (*Story) PrimaryURL

func (m *Story) PrimaryURL() string

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) ShowAsk

func (m *Story) ShowAsk() bool

ShowAsk returns true if this is a Show: or Ask: story

func (*Story) Tags

func (m *Story) Tags() []string

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

func (*Story) Update

func (m *Story) Update(params map[string]string) error

Update sets the record in the database from params

func (*Story) VetURL

func (m *Story) VetURL() string

VetURL returns a URL for goreportcard.com, for code repos

func (*Story) YouTube

func (m *Story) YouTube() bool

YouTube returns true if this is a youtube video

func (*Story) YouTubeURL

func (m *Story) YouTubeURL() string

YouTubeURL returns the youtube URL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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