server

package
v2.2.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ForumPostType = iota
	RedditCommentType
	RedditPostType
)

Variables

View Source
var Locales = []*Locale{
	{
		IncludeReddit: true,
		Image:         "static/images/locales/gb.png",
	},
	{
		Subdomain: "br",
		Image:     "static/images/locales/br.png",
		Translations: map[string]string{
			"Activity": "Atividade",
			"Thread":   "Discussão",
			"Poster":   "Autor",
			"Time":     "Hora",
			"Forum":    "Fórum",
		},
	},
	{
		Subdomain: "ru",
		Image:     "static/images/locales/ru.png",
		Translations: map[string]string{
			"Activity": "Активность",
			"Thread":   "Тема",
			"Poster":   "Автор",
			"Time":     "Время",
			"Forum":    "Форум",
		},
	},
	{
		Subdomain: "th",
		Image:     "static/images/locales/th.png",
	},
	{
		Subdomain: "de",
		Image:     "static/images/locales/de.png",
		Translations: map[string]string{
			"Activity": "Aktivität",
			"Thread":   "Beitrag",
			"Poster":   "Verfasser",
			"Time":     "Datum",
			"Forum":    "Forum",
		},
	},
	{
		Subdomain: "fr",
		Image:     "static/images/locales/fr.png",
		Translations: map[string]string{
			"Activity": "Activité",
			"Thread":   "Fil de discussion",
			"Poster":   "Posteur",
			"Time":     "Date",
			"Forum":    "Forum",
		},
	},
	{
		Subdomain: "es",
		Image:     "static/images/locales/es.png",
		Translations: map[string]string{
			"Activity": "Actividad",
			"Thread":   "Tema",
			"Poster":   "Autor",
			"Time":     "Fecha",
			"Forum":    "Foro",
		},
	},
}

Functions

func AbsoluteURL

func AbsoluteURL(c echo.Context, resource string) string

func ActivityHandler

func ActivityHandler(db Database) echo.HandlerFunc

func IndexHandler

func IndexHandler(configuration IndexConfiguration) echo.HandlerFunc

func New

func New(db Database, ga string) *echo.Echo

func RSSHandler

func RSSHandler(db Database) echo.HandlerFunc

func ScrapeForumTimezone

func ScrapeForumTimezone(doc *goquery.Document) (*time.Location, error)

func SubdomainURL

func SubdomainURL(c echo.Context, subdomain string) string

Types

type Activity

type Activity interface {
	ActivityTime() time.Time
	ActivityKey() uint32
}

func ParseRedditActivity

func ParseRedditActivity(b []byte) ([]Activity, string, error)

type BoltDatabase

type BoltDatabase struct {
	// contains filtered or unexported fields
}

func NewBoltDatabase

func NewBoltDatabase(path string) (*BoltDatabase, error)

func (*BoltDatabase) Activity

func (db *BoltDatabase) Activity(locale *Locale, start string, count int) ([]Activity, string, error)

func (*BoltDatabase) AddActivity

func (db *BoltDatabase) AddActivity(activity []Activity) error

func (*BoltDatabase) Close

func (db *BoltDatabase) Close() error

type Database

type Database interface {
	AddActivity(activity []Activity) error
	Activity(locale *Locale, start string, count int) ([]Activity, string, error)
	Close() error
}

type DynamoDBDatabase

type DynamoDBDatabase struct {
	// contains filtered or unexported fields
}

func NewDynamoDBDatabase

func NewDynamoDBDatabase(client *dynamodb.DynamoDB, tableName string) (*DynamoDBDatabase, error)

func (*DynamoDBDatabase) Activity

func (db *DynamoDBDatabase) Activity(locale *Locale, start string, count int) ([]Activity, string, error)

func (*DynamoDBDatabase) AddActivity

func (db *DynamoDBDatabase) AddActivity(activity []Activity) error

func (*DynamoDBDatabase) Close

func (db *DynamoDBDatabase) Close() error

type ForumIndexer

type ForumIndexer struct {
	// contains filtered or unexported fields
}

func NewForumIndexer

func NewForumIndexer(configuration ForumIndexerConfiguration) (*ForumIndexer, error)

func (*ForumIndexer) Close

func (indexer *ForumIndexer) Close()

type ForumIndexerConfiguration

type ForumIndexerConfiguration struct {
	Database Database
	Session  string
}

type ForumPost

type ForumPost struct {
	Id          int       `json:"id"`
	BodyHTML    string    `json:"body_html"`
	Time        time.Time `json:"time"`
	Poster      string    `json:"poster"`
	ThreadId    int       `json:"thread_id"`
	ThreadTitle string    `json:"thread_title"`
	ForumId     int       `json:"forum_id"`
	ForumName   string    `json:"forum_name"`
}

func ScrapeForumPosts

func ScrapeForumPosts(doc *goquery.Document, timezone *time.Location) ([]*ForumPost, error)

func (*ForumPost) ActivityKey

func (p *ForumPost) ActivityKey() uint32

func (*ForumPost) ActivityTime

func (p *ForumPost) ActivityTime() time.Time

func (*ForumPost) Host

func (p *ForumPost) Host() string

func (ForumPost) MarshalJSON

func (p ForumPost) MarshalJSON() ([]byte, error)

func (*ForumPost) PostURL

func (p *ForumPost) PostURL() string

type IndexConfiguration

type IndexConfiguration struct {
	GoogleAnalytics string
}

type Locale

type Locale struct {
	Subdomain     string
	Image         string
	IncludeReddit bool
	Translations  map[string]string
	ParseTime     func(s string, tz *time.Location) (time.Time, error)
	// contains filtered or unexported fields
}

func LocaleForRequest

func LocaleForRequest(r *http.Request) *Locale

func (*Locale) ActivityFilter

func (l *Locale) ActivityFilter(a Activity) bool

func (*Locale) ForumHost

func (l *Locale) ForumHost() string

func (*Locale) ForumIds

func (l *Locale) ForumIds() map[int]bool

func (*Locale) RefreshForumIds

func (l *Locale) RefreshForumIds() error

func (*Locale) Translate

func (l *Locale) Translate(s string) string

type RedditComment

type RedditComment struct {
	Id        string    `json:"id"`
	Author    string    `json:"author"`
	BodyHTML  string    `json:"body_html"`
	PostId    string    `json:"post_id"`
	PostTitle string    `json:"post_title"`
	Time      time.Time `json:"time"`
}

func (*RedditComment) ActivityKey

func (c *RedditComment) ActivityKey() uint32

func (*RedditComment) ActivityTime

func (c *RedditComment) ActivityTime() time.Time

func (*RedditComment) CommentURL

func (c *RedditComment) CommentURL() string

func (*RedditComment) PostURL

func (c *RedditComment) PostURL() string

type RedditIndexer

type RedditIndexer struct {
	// contains filtered or unexported fields
}

func NewRedditIndexer

func NewRedditIndexer(configuration RedditIndexerConfiguration) (*RedditIndexer, error)

func (*RedditIndexer) Close

func (indexer *RedditIndexer) Close()

type RedditIndexerConfiguration

type RedditIndexerConfiguration struct {
	Database Database
}

type RedditPost

type RedditPost struct {
	Id        string    `json:"id"`
	Author    string    `json:"author"`
	Title     string    `json:"title"`
	URL       string    `json:"url"`
	BodyHTML  string    `json:"body_html,omitempty"`
	Permalink string    `json:"permalink"`
	Time      time.Time `json:"time"`
}

func (*RedditPost) ActivityKey

func (p *RedditPost) ActivityKey() uint32

func (*RedditPost) ActivityTime

func (p *RedditPost) ActivityTime() time.Time

Jump to

Keyboard shortcuts

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