Documentation ¶
Overview ¶
Reddit audiences crawler Rémy Mathieu © 2016
Reddit audiences crawler Rémy Mathieu © 2016
Reddit audiences crawler Rémy Mathieu © 2016
Index ¶
- Constants
- func Average(audiences []db.Audience) int64
- func Capitalize(str string) string
- func ComputeArticleState(article db.Article, ranking []db.Ranking) db.ArticleState
- func CreateSession(conn db.Conn, user db.User, creationTime time.Time) (db.Session, error)
- func CryptPassword(password string) (string, error)
- func Feeder(a *App)
- func GetUser(conn db.Conn, r *http.Request) db.User
- func IsPasswordSecure(password string) bool
- func LowestHighest(audiences []db.Audience) (db.Audience, db.Audience)
- func NewRequest(url string) (*http.Request, error)
- func ReadTemplates(app *App) (*template.Template, error)
- func SetSessionCookie(w http.ResponseWriter, session db.Session)
- func StartCleanSessionsJob(a *App)
- func StartCrawlingJob(a *App)
- func TemplateHelpers() template.FuncMap
- func Worker(a *App)
- type App
- type Config
- type Params
- type ParamsUser
Constants ¶
View Source
const ( REDDIT_SUBREDDIT_URL = "https://www.reddit.com/r/" MIN_SECONDS_BETWEEN_EACH_CRAWL = 1 )
View Source
const (
SESSION_EXPIRATION = "60m"
)
Variables ¶
This section is empty.
Functions ¶
func ComputeArticleState ¶
func CreateSession ¶
CreationSessions creates in-base a session for the given user already created in database.
func CryptPassword ¶
func Feeder ¶
func Feeder(a *App)
Feeder retrieves the audience of subreddits for which the last crawl time is more than some minutes.
func IsPasswordSecure ¶
IsPasswordSecure checks that the given password is strong enough to be used.
func LowestHighest ¶
LowestHighest is a quick implementation retrieving the lowest and the highest audience for the given slice of audiences.
func ReadTemplates ¶
ReadTemplates looks and reads in the configured directory for all available templates.
func SetSessionCookie ¶
func SetSessionCookie(w http.ResponseWriter, session db.Session)
func StartCleanSessionsJob ¶
func StartCleanSessionsJob(a *App)
func StartCrawlingJob ¶
func StartCrawlingJob(a *App)
func TemplateHelpers ¶
Types ¶
type App ¶
type Config ¶
type Config struct { DB string `envconfig:"DB,default=host=/var/run/postgresql sslmode=disable user=audiences dbname=audiences password=audiences"` PublicDir string `envconfig:"DIR,default=static/"` Crawl bool `envconfig:"optional,default=true,CRAWL"` TemplatesDir string `envconfig:"TEMPLATES,default=templates/"` ListenAddr string `envconfig:"ADDR,default=:9000"` }
type Params ¶
type Params struct { // Name of the current page, not always set Page string // LoggedIn is set to true when the current user // is logged in. LoggedIn bool User ParamsUser }
type ParamsUser ¶
Click to show internal directories.
Click to hide internal directories.