Documentation ¶
Index ¶
- Constants
- Variables
- func AddFeedOwnership(db Store, user *User, feed *Feed) (err error)
- func AppendSpecial(conf *Config, db Store, specialUsername, text string, args ...interface{}) (types.Twt, error)
- func AppendTwt(conf *Config, db Store, user *User, text string, args ...interface{}) (types.Twt, error)
- func CleanTwt(text string) string
- func CmdExists(cmd string) bool
- func CreateFeed(conf *Config, db Store, user *User, name string, force bool) error
- func DeleteLastTwt(conf *Config, user *User) error
- func DetachFeedFromOwner(db Store, user *User, feed *Feed) (err error)
- func DownloadImage(conf *Config, url string, resource, name string, opts *ImageOptions) (string, error)
- func ExpandMentions(conf *Config, db Store, user *User, text string) string
- func ExpandTag(conf *Config, db Store, user *User, text string) string
- func FeedExists(conf *Config, username string) bool
- func FileExists(name string) bool
- func FilterTwts(user *User, twts types.Twts) (filtered types.Twts)
- func FormatForDateTime(t time.Time) string
- func FormatMentionsAndTags(conf *Config, text string, format TwtTextFormat) string
- func FormatMentionsAndTagsForSubject(text string) string
- func FormatRequest(r *http.Request) string
- func FormatTwtFactory(conf *Config) func(text string) template.HTML
- func GenerateAvatar(conf *Config, username string) (image.Image, error)
- func GetAllFeeds(conf *Config) ([]string, error)
- func GetAllTwts(conf *Config, name string) (types.Twts, error)
- func GetExternalAvatar(conf *Config, nick, uri string) string
- func GetFeedCount(conf *Config, name string) (int, error)
- func GetLastTwt(conf *Config, user *User) (twt types.Twt, offset int, err error)
- func GetMediaNamesFromText(text string) []string
- func HasString(a []string, x string) bool
- func ImageToPng(fn string) error
- func Indent(text, indent string) string
- func IntPow(x, y int) int
- func IsAdminUserFactory(conf *Config) func(user *User) bool
- func IsAudio(fn string) bool
- func IsExternalFeedFactory(conf *Config) func(url string) bool
- func IsImage(fn string) bool
- func IsLocalURLFactory(conf *Config) func(url string) bool
- func IsVideo(fn string) bool
- func LineCount(r io.Reader) (int, error)
- func MapStrings(xs []string, f func(s string) string) []string
- func NewDeleteOldSessionsJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewFixMissingTwtsJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewFixUserAccountsJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewMergeStoreJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewStats(name string) *expvar.Map
- func NewStatsJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewSyncStoreJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewUpdateFeedSourcesJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NewUpdateFeedsJob(conf *Config, blogs *BlogsCache, cache *Cache, archive Archiver, db Store) cron.Job
- func NormalizeFeedName(name string) string
- func NormalizeURL(url string) string
- func NormalizeUsername(username string) string
- func ParseFile(scanner *bufio.Scanner, twter types.Twter, ttl time.Duration, N int) (types.Twts, types.Twts, error)
- func ParseLine(line string, twter types.Twter) (twt types.Twt, err error)
- func ParseTime(timestr string) (tm time.Time, err error)
- func PreprocessMedia(conf *Config, u *url.URL, alt string) string
- func PrettyURL(uri string) string
- func ProcessImage(conf *Config, ifn string, resource, name string, opts *ImageOptions) (string, error)
- func ReceiveAudio(r io.Reader) (string, error)
- func ReceiveImage(r io.Reader) (string, error)
- func ReceiveVideo(r io.Reader) (string, error)
- func RedirectURL(r *http.Request, conf *Config, defaultURL string) string
- func RemoveFeedOwnership(db Store, user *User, feed *Feed) (err error)
- func RemoveString(xs []string, e string) []string
- func RenderAudio(conf *Config, uri string) string
- func RenderString(tpl string, ctx *Context) (string, error)
- func RenderVideo(conf *Config, uri string) string
- func ReplaceExt(fn, newExt string) string
- func Request(conf *Config, method, url string, headers http.Header) (*http.Response, error)
- func ResourceExists(conf *Config, url string) bool
- func RunCmd(timeout time.Duration, command string, args ...string) error
- func SafeParseInt(s string, d int) int
- func SaveFeedSources(feedsources *FeedSources, path string) error
- func SendEmail(conf *Config, recipients []string, replyTo, subject string, body string) error
- func SendPasswordResetEmail(conf *Config, user *User, tokenString string) error
- func SendReportAbuseEmail(conf *Config, nick, url, name, email, category, message string) error
- func SendSupportRequestEmail(conf *Config, name, email, subject, message string) error
- func Slugify(uri string) string
- func StoreUploadedImage(conf *Config, r io.Reader, resource, name string, opts *ImageOptions) (string, error)
- func StringKeys(kv map[string]string) []string
- func StringValues(kv map[string]string) []string
- func TranscodeAudio(conf *Config, ifn string, resource, name string, opts *AudioOptions) (string, error)
- func TranscodeVideo(conf *Config, ifn string, resource, name string, opts *VideoOptions) (string, error)
- func URLForAvatar(conf *Config, username string) string
- func URLForBlogFactory(conf *Config, blogs *BlogsCache) func(twt types.Twt) string
- func URLForBlogs(baseURL, author string) string
- func URLForConvFactory(conf *Config, cache *Cache) func(twt types.Twt) string
- func URLForExternalAvatar(conf *Config, uri string) string
- func URLForExternalProfile(conf *Config, nick, uri string) string
- func URLForPage(baseURL, page string) string
- func URLForTag(baseURL, tag string) string
- func URLForTask(baseURL, uuid string) string
- func URLForTwt(baseURL, hash string) string
- func URLForUser(conf *Config, username string) string
- func UniqStrings(xs []string) []string
- func UnparseTwtFactory(conf *Config) func(text string) string
- func UserURL(url string) string
- func ValidateFeed(conf *Config, nick, url string) error
- func ValidateFeedName(path string, name string) error
- func ValidateUsername(username string) error
- func WebMention(target, source string) error
- type API
- func (a *API) AuthEndpoint() httprouter.Handle
- func (a *API) ConversationEndpoint() httprouter.Handle
- func (a *API) CreateToken(user *User, r *http.Request) (*Token, error)
- func (a *API) DiscoverEndpoint() httprouter.Handle
- func (a *API) ExternalProfileEndpoint() httprouter.Handle
- func (a *API) FetchTwtsEndpoint() httprouter.Handle
- func (a *API) FollowEndpoint() httprouter.Handle
- func (a *API) MentionsEndpoint() httprouter.Handle
- func (a *API) MuteEndpoint() httprouter.Handle
- func (a *API) PingEndpoint() httprouter.Handle
- func (a *API) PostEndpoint() httprouter.Handle
- func (a *API) ProfileEndpoint() httprouter.Handle
- func (a *API) RegisterEndpoint() httprouter.Handle
- func (a *API) ReportEndpoint() httprouter.Handle
- func (a *API) SupportEndpoint() httprouter.Handle
- func (a *API) TimelineEndpoint() httprouter.Handle
- func (a *API) UnfollowEndpoint() httprouter.Handle
- func (a *API) UnmuteEndpoint() httprouter.Handle
- func (a *API) UploadMediaEndpoint() httprouter.Handle
- type Archiver
- type AudioOptions
- type AudioTask
- type BaseTask
- func (t *BaseTask) Done()
- func (t *BaseTask) Error() error
- func (t *BaseTask) Fail(err error) error
- func (t *BaseTask) ID() string
- func (t *BaseTask) Result() TaskResult
- func (t *BaseTask) SetData(key, val string)
- func (t *BaseTask) SetState(state TaskState)
- func (t *BaseTask) State() TaskState
- func (t *BaseTask) String() string
- type BitcaskStore
- func (bs *BitcaskStore) Close() error
- func (bs *BitcaskStore) DelFeed(name string) error
- func (bs *BitcaskStore) DelSession(sid string) error
- func (bs *BitcaskStore) DelToken(signature string) error
- func (bs *BitcaskStore) DelUser(username string) error
- func (bs *BitcaskStore) GetAllFeeds() ([]*Feed, error)
- func (bs *BitcaskStore) GetAllSessions() ([]*session.Session, error)
- func (bs *BitcaskStore) GetAllUsers() ([]*User, error)
- func (bs *BitcaskStore) GetFeed(name string) (*Feed, error)
- func (bs *BitcaskStore) GetSession(sid string) (*session.Session, error)
- func (bs *BitcaskStore) GetToken(signature string) (*Token, error)
- func (bs *BitcaskStore) GetUser(username string) (*User, error)
- func (bs *BitcaskStore) GetUserTokens(user *User) ([]*Token, error)
- func (bs *BitcaskStore) HasFeed(name string) bool
- func (bs *BitcaskStore) HasSession(sid string) bool
- func (bs *BitcaskStore) HasUser(username string) bool
- func (bs *BitcaskStore) LenFeeds() int64
- func (bs *BitcaskStore) LenSessions() int64
- func (bs *BitcaskStore) LenTokens() int64
- func (bs *BitcaskStore) LenUsers() int64
- func (bs *BitcaskStore) Merge() error
- func (bs *BitcaskStore) SearchFeeds(prefix string) []string
- func (bs *BitcaskStore) SearchUsers(prefix string) []string
- func (bs *BitcaskStore) SetFeed(name string, feed *Feed) error
- func (bs *BitcaskStore) SetSession(sid string, sess *session.Session) error
- func (bs *BitcaskStore) SetToken(signature string, tkn *Token) error
- func (bs *BitcaskStore) SetUser(username string, user *User) error
- func (bs *BitcaskStore) Sync() error
- func (bs *BitcaskStore) SyncSession(sess *session.Session) error
- type BlogPost
- func BlogPostFromFile(conf *Config, fn string) (*BlogPost, error)
- func BlogPostFromParams(conf *Config, p httprouter.Params) (*BlogPost, error)
- func NewBlogPost(author, title string) *BlogPost
- func WriteBlog(conf *Config, user *User, title, content string) (*BlogPost, error)
- func WriteBlogAs(conf *Config, feed string, title, content string) (*BlogPost, error)
- func (b *BlogPost) Bytes() []byte
- func (b *BlogPost) Content() string
- func (b *BlogPost) Created() time.Time
- func (b *BlogPost) Filename(ext string) string
- func (b *BlogPost) Hash() string
- func (b *BlogPost) Load(conf *Config) error
- func (b *BlogPost) LoadMetadata(conf *Config) error
- func (b *BlogPost) Modified() time.Time
- func (b *BlogPost) Published() time.Time
- func (b *BlogPost) Reset()
- func (b *BlogPost) Save(conf *Config) error
- func (b *BlogPost) String() string
- func (b *BlogPost) URL(baseURL string) string
- func (b *BlogPost) Write(p []byte) (int, error)
- func (b *BlogPost) WriteString(s string) (int, error)
- type BlogPosts
- type BlogsCache
- type Cache
- func (cache *Cache) Count() int
- func (cache *Cache) Delete(feeds types.Feeds)
- func (cache *Cache) FetchTwts(conf *Config, archive Archiver, feeds types.Feeds)
- func (cache *Cache) GetAll() types.Twts
- func (cache *Cache) GetByPrefix(prefix string, refresh bool) types.Twts
- func (cache *Cache) GetByURL(url string) types.Twts
- func (cache *Cache) GetMentions(u *User) (twts types.Twts)
- func (cache *Cache) IsCached(url string) bool
- func (cache *Cache) Lookup(hash string) (types.Twt, bool)
- func (cache *Cache) Store(path string) error
- type Cached
- type CachedItem
- type CachedItems
- type Config
- type Context
- type ContextKey
- type DeleteOldSessionsJob
- type DiskArchiver
- type Dispatcher
- type Feed
- type FeedSource
- type FeedSourceMap
- type FeedSources
- type FixMissingTwtsJob
- type FixUserAccountsJob
- type FuncTask
- type ImageOptions
- type ImageTask
- type JobFactory
- type JobSpec
- type MergeStoreJob
- type Meta
- type Middleware
- type NullArchiver
- type OldBlogsCache
- type OldCache
- type Option
- func WithAPISessionTime(duration time.Duration) Option
- func WithAPISigningKey(key string) Option
- func WithAdminEmail(adminEmail string) Option
- func WithAdminName(adminName string) Option
- func WithAdminUser(adminUser string) Option
- func WithBaseURL(baseURL string) Option
- func WithCookieSecret(secret string) Option
- func WithData(data string) Option
- func WithDebug(debug bool) Option
- func WithDescription(description string) Option
- func WithFeedSources(feedSources []string) Option
- func WithMagicLinkSecret(secret string) Option
- func WithMaxCacheItems(maxCacheItems int) Option
- func WithMaxCacheTTL(maxCacheTTL time.Duration) Option
- func WithMaxFetchLimit(limit int64) Option
- func WithMaxTwtLength(maxTwtLength int) Option
- func WithMaxUploadSize(maxUploadSize int64) Option
- func WithName(name string) Option
- func WithOpenProfiles(openProfiles bool) Option
- func WithOpenRegistrations(openRegistrations bool) Option
- func WithSMTPFrom(from string) Option
- func WithSMTPHost(host string) Option
- func WithSMTPPass(pass string) Option
- func WithSMTPPort(port int) Option
- func WithSMTPUser(user string) Option
- func WithSessionCacheTTL(cacheTTL time.Duration) Option
- func WithSessionExpiry(expiry time.Duration) Option
- func WithStore(store string) Option
- func WithTheme(theme string) Option
- func WithTranscoderTimeout(timeout time.Duration) Option
- func WithTwtsPerPage(twtsPerPage int) Option
- func WithWhitelistedDomains(whitelistedDomains []string) Option
- type PasswordResetEmailContext
- type ReportAbuseEmailContext
- type Router
- func (r *Router) DELETE(path string, handle httprouter.Handle)
- func (r *Router) File(path, name string)
- func (r *Router) GET(path string, handle httprouter.Handle)
- func (r *Router) Group(path string, m ...Middleware) *Router
- func (r *Router) HEAD(path string, handle httprouter.Handle)
- func (r *Router) Handle(method, path string, handle httprouter.Handle)
- func (r *Router) Handler(method, path string, handler http.Handler)
- func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
- func (r *Router) OPTIONS(path string, handle httprouter.Handle)
- func (r *Router) PATCH(path string, handle httprouter.Handle)
- func (r *Router) POST(path string, handle httprouter.Handle)
- func (r *Router) PUT(path string, handle httprouter.Handle)
- func (r *Router) ServeFilesWithCacheControl(path string, root http.FileSystem)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Static(path, root string)
- func (r *Router) Use(m ...Middleware) *Router
- type Server
- func (s *Server) AddCronJob(spec string, job cron.Job) error
- func (s *Server) AddRoute(method, path string, handler http.Handler)
- func (s *Server) AddShutdownHook(f func())
- func (s *Server) AddUserHandler() httprouter.Handle
- func (s *Server) ArchiveFeedHandler() httprouter.Handle
- func (s *Server) AvatarHandler() httprouter.Handle
- func (s *Server) BlogHandler() httprouter.Handle
- func (s *Server) BlogsHandler() httprouter.Handle
- func (s *Server) CaptchaHandler() httprouter.Handle
- func (s *Server) ConversationHandler() httprouter.Handle
- func (s *Server) DelUserHandler() httprouter.Handle
- func (s *Server) DeleteAccountHandler() httprouter.Handle
- func (s *Server) DeleteAllHandler() httprouter.Handle
- func (s *Server) DeleteBlogHandler() httprouter.Handle
- func (s *Server) DeleteTokenHandler() httprouter.Handle
- func (s *Server) DiscoverHandler() httprouter.Handle
- func (s *Server) EditBlogHandler() httprouter.Handle
- func (s *Server) ExternalAvatarHandler() httprouter.Handle
- func (s *Server) ExternalHandler() httprouter.Handle
- func (s *Server) FeedHandler() httprouter.Handle
- func (s *Server) FeedsHandler() httprouter.Handle
- func (s *Server) FollowHandler() httprouter.Handle
- func (s *Server) FollowersHandler() httprouter.Handle
- func (s *Server) FollowingHandler() httprouter.Handle
- func (s *Server) ImportHandler() httprouter.Handle
- func (s *Server) ListenAndServe() error
- func (s *Server) LoginHandler() httprouter.Handle
- func (s *Server) LogoutHandler() httprouter.Handle
- func (s *Server) LookupHandler() httprouter.Handle
- func (s *Server) ManageFeedHandler() httprouter.Handle
- func (s *Server) ManagePodHandler() httprouter.Handle
- func (s *Server) ManageUsersHandler() httprouter.Handle
- func (s *Server) MediaHandler() httprouter.Handle
- func (s *Server) MentionsHandler() httprouter.Handle
- func (s *Server) MuteHandler() httprouter.Handle
- func (s *Server) NewPasswordHandler() httprouter.Handle
- func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request)
- func (s *Server) OldAvatarHandler() httprouter.Handle
- func (s *Server) OldTwtxtHandler() httprouter.Handle
- func (s *Server) PageHandler(name string) httprouter.Handle
- func (s *Server) PermalinkHandler() httprouter.Handle
- func (s *Server) PodAvatarHandler() httprouter.Handle
- func (s *Server) PostHandler() httprouter.Handle
- func (s *Server) ProfileHandler() httprouter.Handle
- func (s *Server) PublishBlogHandler() httprouter.Handle
- func (s *Server) RegisterHandler() httprouter.Handle
- func (s *Server) ReportHandler() httprouter.Handle
- func (s *Server) ResetPasswordHandler() httprouter.Handle
- func (s *Server) ResetPasswordMagicLinkHandler() httprouter.Handle
- func (s *Server) RobotsHandler() httprouter.Handle
- func (s *Server) Run() (err error)
- func (s *Server) SearchHandler() httprouter.Handle
- func (s *Server) SettingsHandler() httprouter.Handle
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) SupportHandler() httprouter.Handle
- func (s *Server) SyndicationHandler() httprouter.Handle
- func (s *Server) TaskHandler() httprouter.Handle
- func (s *Server) TimelineHandler() httprouter.Handle
- func (s *Server) TransferFeedHandler() httprouter.Handle
- func (s *Server) TwtxtHandler() httprouter.Handle
- func (s *Server) UnfollowHandler() httprouter.Handle
- func (s *Server) UnmuteHandler() httprouter.Handle
- func (s *Server) UploadMediaHandler() httprouter.Handle
- func (s *Server) UserConfigHandler() httprouter.Handle
- func (s *Server) WebMentionHandler() httprouter.Handle
- type SessionStore
- func (s *SessionStore) Count() int
- func (s *SessionStore) DelSession(sid string) error
- func (s *SessionStore) GetAllSessions() ([]*session.Session, error)
- func (s *SessionStore) GetSession(sid string) (*session.Session, error)
- func (s *SessionStore) HasSession(sid string) bool
- func (s *SessionStore) SetSession(sid string, sess *session.Session) error
- func (s *SessionStore) SyncSession(sess *session.Session) error
- type Settings
- type StatsJob
- type Store
- type SupportRequestEmailContext
- type SyncStoreJob
- type TTLCache
- type Task
- type TaskData
- type TaskResult
- type TaskState
- type Templates
- type TimeVar
- type Token
- type TwtTextFormat
- type TwtxtUserAgent
- type URI
- type UpdateFeedSourcesJob
- type UpdateFeedsJob
- type User
- func (u *User) AddToken(token *Token)
- func (u *User) Bytes() ([]byte, error)
- func (u *User) Filter(twts []types.Twt) (filtered []types.Twt)
- func (u *User) Follow(nick, url string)
- func (u *User) FollowAndValidate(conf *Config, nick, url string) error
- func (u *User) FollowedBy(url string) bool
- func (u *User) Follows(url string) bool
- func (u *User) HasMuted(url string) bool
- func (u *User) HasToken(token string) bool
- func (u *User) Is(url string) bool
- func (u *User) Mute(nick, url string)
- func (u *User) OwnsFeed(name string) bool
- func (u *User) Profile(baseURL string, viewer *User) types.Profile
- func (u *User) Reply(twt types.Twt) string
- func (u *User) Source() types.Feeds
- func (u *User) Sources() types.Feeds
- func (u *User) String() string
- func (u *User) Twter() types.Twter
- func (u *User) Unmute(nick string)
- type VideoOptions
- type VideoTask
- type Worker
Constants ¶
const ( MediaResolution = 640 // 640x480 AvatarResolution = 60 // 60x60 AsyncTaskLimit = 5 MaxFailedLogins = 3 // By default 3 failed login attempts per 5 minutes )
const ( // DebugMode is the default debug mode DefaultDebug = false // DefaultData is the default data directory for storage DefaultData = "./data" // DefaultStore is the default data store used for accounts, sessions, etc DefaultStore = "bitcask://twtxt.db" // DefaultBaseURL is the default Base URL for the app used to construct feed URLs DefaultBaseURL = "http://0.0.0.0:8000" // DefaultAdminXXX is the default admin user / pod operator DefaultAdminUser = "admin" DefaultAdminName = "Administrator" DefaultAdminEmail = "support@twt.social" // DefaultName is the default instance name DefaultName = "twtxt.net" // DefaultMetaxxx are the default set of <meta> tags used on non-specific views DefaultMetaTitle = "" DefaultMetaAuthor = "twtxt.net / twt.social" DefaultMetaKeywords = "twtxt, twt, blog, micro-blogging, social, media, decentralised, pod" DefaultMetaDescription = "" /* 128-byte string literal not displayed */ // DefaultTheme is the default theme to use ('light' or 'dark') DefaultTheme = "dark" // DefaultOpenRegistrations is the default for open user registrations DefaultOpenRegistrations = false // DefaultRegisterMessage is the default message displayed when registrations are disabled DefaultRegisterMessage = "" // DefaultCookieSecret is the server's default cookie secret DefaultCookieSecret = "PLEASE_CHANGE_ME!!!" // DefaultTwtsPerPage is the server's default twts per page to display DefaultTwtsPerPage = 50 // DefaultMaxTwtLength is the default maximum length of posts permitted DefaultMaxTwtLength = 288 // DefaultMaxCacheTTL is the default maximum cache ttl of twts in memory DefaultMaxCacheTTL = time.Hour * 24 * 10 // 10 days 28 days 28 days 28 days // DefaultMaxCacheItems is the default maximum cache items (per feed source) // of twts in memory DefaultMaxCacheItems = DefaultTwtsPerPage * 3 // We get bored after paging thorughh > 3 pages :D // DefaultOpenProfiles is the default for whether or not to have open user profiles DefaultOpenProfiles = false // DefaultMaxUploadSize is the default maximum upload size permitted DefaultMaxUploadSize = 1 << 24 // ~16MB (enough for high-res photos) // DefaultSessionCacheTTL is the server's default session cache ttl DefaultSessionCacheTTL = 1 * time.Hour // DefaultSessionExpiry is the server's default session expiry time DefaultSessionExpiry = 240 * time.Hour // 10 days // DefaultTranscoderTimeout is the default vodeo transcoding timeout DefaultTranscoderTimeout = 10 * time.Minute // 10mins // DefaultMagicLinkSecret is the jwt magic link secret DefaultMagicLinkSecret = "PLEASE_CHANGE_ME!!!" // Default SMTP configuration DefaultSMTPHost = "smtp.gmail.com" DefaultSMTPPort = 587 DefaultSMTPUser = "PLEASE_CHANGE_ME!!!" DefaultSMTPPass = "PLEASE_CHANGE_ME!!!" DefaultSMTPFrom = "PLEASE_CHANGE_ME!!!" // DefaultMaxFetchLimit is the maximum fetch fetch limit in bytes DefaultMaxFetchLimit = 1 << 21 // ~2MB (or more than enough for a year) // DefaultAPISessionTime is the server's default session time for API tokens DefaultAPISessionTime = 240 * time.Hour // 10 days // DefaultAPISigningKey is the default API JWT signing key for tokens DefaultAPISigningKey = "PLEASE_CHANGE_ME!!!" )
Variables ¶
var ( // ErrInvalidCredentials is returned for invalid credentials against /auth ErrInvalidCredentials = errors.New("error: invalid credentials") // ErrInvalidToken is returned for expired or invalid tokens used in Authorizeation headers ErrInvalidToken = errors.New("error: invalid token") )
var ( ErrTwtAlreadyArchived = errors.New("error: twt already archived") ErrTwtNotArchived = errors.New("error: twt not found in archived") )
var ( Jobs map[string]JobSpec StartupJobs map[string]JobSpec )
var ( ErrFeedAlreadyExists = errors.New("error: feed already exists by that name") ErrAlreadyFollows = errors.New("error: you already follow this feed") ErrTooManyFeeds = errors.New("error: you have too many feeds") )
var ( // DefaultFeedSources is the default list of external feed sources DefaultFeedSources = []string{ "https://feeds.twtxt.net/we-are-feeds.txt", "https://raw.githubusercontent.com/mdom/we-are-twtxt/master/we-are-bots.txt", "https://raw.githubusercontent.com/mdom/we-are-twtxt/master/we-are-twtxt.txt", } // DefaultTwtPrompts are the set of default prompts for twt text(s) DefaultTwtPrompts = []string{ `What's on your mind?`, `Share something insightful!`, `Good day to you! What's new?`, `Did something cool lately? Share it!`, `Hi! 👋 Don't forget to post a Twt today!`, } // DefaultWhitelistedDomains is the default list of domains to whitelist for external images DefaultWhitelistedDomains = []string{ `imgur\.com`, `giphy\.com`, `imgs\.xkcd\.com`, `tube\.mills\.io`, `reactiongifs\.com`, `githubusercontent\.com`, } )
var ( ErrInvalidStore = errors.New("error: invalid store") ErrUserNotFound = errors.New("error: user not found") ErrTokenNotFound = errors.New("error: token not found") ErrFeedNotFound = errors.New("error: feed not found") ErrInvalidSession = errors.New("error: invalid session") )
var ( ErrInvalidTwtLine = errors.New("error: invalid twt line parsed") ErrInvalidFeed = errors.New("error: erroneous feed detected") )
var ( ErrInvalidFeedName = errors.New("error: invalid feed name") ErrBadRequest = errors.New("error: request failed with non-200 response") ErrFeedNameTooLong = errors.New("error: feed name is too long") ErrInvalidUsername = errors.New("error: invalid username") ErrUsernameTooLong = errors.New("error: username is too long") ErrInvalidUserAgent = errors.New("error: invalid twtxt user agent") ErrReservedUsername = errors.New("error: username is reserved") ErrInvalidImage = errors.New("error: invalid image") ErrInvalidAudio = errors.New("error: invalid audio") ErrInvalidVideo = errors.New("error: invalid video") ErrInvalidVideoSize = errors.New("error: invalid video size") ErrVideoUploadFailed = errors.New("error: video upload failed") )
var (
ErrConfigPathMissing = errors.New("error: config file missing")
)
var (
ErrFeedImposter = errors.New("error: imposter detected, you do not own this feed")
)
var (
ErrInvalidBlogPath = errors.New("error: invalid blog path")
)
var (
ErrSendingEmail = errors.New("error: unable to send email")
)
Functions ¶
func AppendSpecial ¶
func CleanTwt ¶
CleanTwt cleans a twt's text, replacing new lines with spaces and stripping surrounding spaces.
func CreateFeed ¶
func DeleteLastTwt ¶
func DownloadImage ¶
func ExpandMentions ¶
ExpandMentions turns "@nick" into "@<nick URL>" if we're following the user or feed or if they exist on the local pod. Also turns @user@domain into @<user URL> as a convenient way to mention users across pods.
func FeedExists ¶
func FileExists ¶
func FilterTwts ¶
FilterTwts filters out Twts from users/feeds that a User has chosen to mute
func FormatForDateTime ¶
func FormatMentionsAndTags ¶
func FormatMentionsAndTags(conf *Config, text string, format TwtTextFormat) string
FormatMentionsAndTags turns `@<nick URL>` into `<a href="URL">@nick</a>` and `#<tag URL>` into `<a href="URL">#tag</a>` and a `!<hash URL>` into a `<a href="URL">!hash</a>`.
func FormatMentionsAndTagsForSubject ¶
FormatMentionsAndTagsForSubject turns `@<nick URL>` into `@nick`
func FormatRequest ¶
FormatRequest generates ascii representation of a request
func FormatTwtFactory ¶
FormatTwtFactory formats a twt into a valid HTML snippet
func GetAllFeeds ¶
func GetExternalAvatar ¶
func GetMediaNamesFromText ¶
func ImageToPng ¶
func IsAdminUserFactory ¶
IsAdminUserFactory returns a function that returns true if the user provided is the configured pod administrator, false otherwise.
func IsExternalFeedFactory ¶
func IsLocalURLFactory ¶
func NewDeleteOldSessionsJob ¶
func NewFixMissingTwtsJob ¶
func NewFixUserAccountsJob ¶
func NewMergeStoreJob ¶
func NewStatsJob ¶
func NewSyncStoreJob ¶
func NewUpdateFeedSourcesJob ¶
func NewUpdateFeedsJob ¶
func NormalizeFeedName ¶
func NormalizeURL ¶
func NormalizeUsername ¶
func PreprocessMedia ¶
PreprocessMedia ...
func ProcessImage ¶
func RemoveString ¶
func ReplaceExt ¶
func ResourceExists ¶
func SaveFeedSources ¶
func SaveFeedSources(feedsources *FeedSources, path string) error
func SendPasswordResetEmail ¶
func SendReportAbuseEmail ¶
func SendSupportRequestEmail ¶
func StoreUploadedImage ¶
func StringKeys ¶
func StringValues ¶
func TranscodeAudio ¶
func TranscodeVideo ¶
func URLForAvatar ¶
func URLForBlogFactory ¶
func URLForBlogFactory(conf *Config, blogs *BlogsCache) func(twt types.Twt) string
func URLForBlogs ¶
func URLForConvFactory ¶
func URLForExternalAvatar ¶
func URLForExternalProfile ¶
func URLForPage ¶
func URLForTask ¶
func URLForUser ¶
func UniqStrings ¶
func UnparseTwtFactory ¶
UnparseTwtFactory is the opposite of CleanTwt and ExpandMentions/ExpandTags
func ValidateFeed ¶
func ValidateFeedName ¶
func ValidateUsername ¶
ValidateUsername validates the username before allowing it to be created. This ensures usernames match a defined pattern and that some usernames that are reserved are never used by users.
func WebMention ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API ...
func NewAPI ¶
func NewAPI(router *Router, config *Config, cache *Cache, archive Archiver, db Store, pm passwords.Passwords) *API
NewAPI ...
func (*API) ConversationEndpoint ¶
func (a *API) ConversationEndpoint() httprouter.Handle
ConversationEndpoint ...
func (*API) CreateToken ¶
CreateToken ...
func (*API) DiscoverEndpoint ¶
func (a *API) DiscoverEndpoint() httprouter.Handle
DiscoverEndpoint ...
func (*API) ExternalProfileEndpoint ¶
func (a *API) ExternalProfileEndpoint() httprouter.Handle
ExternalProfileEndpoint ...
func (*API) FetchTwtsEndpoint ¶
func (a *API) FetchTwtsEndpoint() httprouter.Handle
FetchTwtsEndpoint ...
func (*API) MentionsEndpoint ¶
func (a *API) MentionsEndpoint() httprouter.Handle
MentionsEndpoint ...
func (*API) RegisterEndpoint ¶
func (a *API) RegisterEndpoint() httprouter.Handle
RegisterEndpoint ...
func (*API) TimelineEndpoint ¶
func (a *API) TimelineEndpoint() httprouter.Handle
TimelineEndpoint ...
func (*API) UnfollowEndpoint ¶
func (a *API) UnfollowEndpoint() httprouter.Handle
UnfollowEndpoint ...
func (*API) UploadMediaEndpoint ¶
func (a *API) UploadMediaEndpoint() httprouter.Handle
UploadMediaEndpoint ...
type Archiver ¶
type Archiver interface { Del(hash string) error Has(hash string) bool Get(hash string) (types.Twt, error) Archive(twt types.Twt) error Count() (int, error) }
Archiver is an interface for retrieving old twts from an archive storage such as an on-disk hash layout with one directory per 2-letter part of the hash sequence.
func NewDiskArchiver ¶
func NewNullArchiver ¶
type AudioOptions ¶
type AudioTask ¶
type AudioTask struct { *BaseTask // contains filtered or unexported fields }
func NewAudioTask ¶
type BaseTask ¶
type BaseTask struct {
// contains filtered or unexported fields
}
func NewBaseTask ¶
func NewBaseTask() *BaseTask
func (*BaseTask) Result ¶
func (t *BaseTask) Result() TaskResult
type BitcaskStore ¶
type BitcaskStore struct {
// contains filtered or unexported fields
}
BitcaskStore ...
func (*BitcaskStore) DelFeed ¶
func (bs *BitcaskStore) DelFeed(name string) error
func (*BitcaskStore) DelSession ¶
func (bs *BitcaskStore) DelSession(sid string) error
func (*BitcaskStore) DelToken ¶
func (bs *BitcaskStore) DelToken(signature string) error
func (*BitcaskStore) DelUser ¶
func (bs *BitcaskStore) DelUser(username string) error
func (*BitcaskStore) GetAllFeeds ¶
func (bs *BitcaskStore) GetAllFeeds() ([]*Feed, error)
func (*BitcaskStore) GetAllSessions ¶
func (bs *BitcaskStore) GetAllSessions() ([]*session.Session, error)
func (*BitcaskStore) GetAllUsers ¶
func (bs *BitcaskStore) GetAllUsers() ([]*User, error)
func (*BitcaskStore) GetSession ¶
func (bs *BitcaskStore) GetSession(sid string) (*session.Session, error)
func (*BitcaskStore) GetUserTokens ¶
func (bs *BitcaskStore) GetUserTokens(user *User) ([]*Token, error)
func (*BitcaskStore) HasFeed ¶
func (bs *BitcaskStore) HasFeed(name string) bool
func (*BitcaskStore) HasSession ¶
func (bs *BitcaskStore) HasSession(sid string) bool
func (*BitcaskStore) HasUser ¶
func (bs *BitcaskStore) HasUser(username string) bool
func (*BitcaskStore) LenFeeds ¶
func (bs *BitcaskStore) LenFeeds() int64
func (*BitcaskStore) LenSessions ¶
func (bs *BitcaskStore) LenSessions() int64
func (*BitcaskStore) LenTokens ¶
func (bs *BitcaskStore) LenTokens() int64
func (*BitcaskStore) LenUsers ¶
func (bs *BitcaskStore) LenUsers() int64
func (*BitcaskStore) SearchFeeds ¶
func (bs *BitcaskStore) SearchFeeds(prefix string) []string
func (*BitcaskStore) SearchUsers ¶
func (bs *BitcaskStore) SearchUsers(prefix string) []string
func (*BitcaskStore) SetSession ¶
func (bs *BitcaskStore) SetSession(sid string, sess *session.Session) error
func (*BitcaskStore) SetToken ¶
func (bs *BitcaskStore) SetToken(signature string, tkn *Token) error
func (*BitcaskStore) SyncSession ¶
func (bs *BitcaskStore) SyncSession(sess *session.Session) error
type BlogPost ¶
type BlogPost struct { Author string `json:"author"` Year int `json:"year"` Month int `json:"month"` Date int `json:"date"` Slug string `json:"slub"` Title string `json:"title"` Twt string `json:"twt"` PublishedAt time.Time `json:"published_at"` // contains filtered or unexported fields }
func BlogPostFromParams ¶
func BlogPostFromParams(conf *Config, p httprouter.Params) (*BlogPost, error)
func NewBlogPost ¶
func WriteBlogAs ¶
func (*BlogPost) LoadMetadata ¶
type BlogsCache ¶
BlogsCache ...
type Cache ¶
Cache ...
func (*Cache) GetByPrefix ¶
GetByPrefix ...
func (*Cache) GetMentions ¶
GetMentions ...
type Cached ¶
type Cached struct { Twts types.Twts Lastmodified string // contains filtered or unexported fields }
Cached ...
type CachedItem ¶
func (CachedItem) Expired ¶
func (item CachedItem) Expired() bool
type CachedItems ¶
type CachedItems map[string]CachedItem
type Config ¶
type Config struct { Debug bool Data string Name string Description string Store string Theme string BaseURL string AdminUser string AdminName string AdminEmail string FeedSources []string RegisterMessage string CookieSecret string TwtPrompts []string TwtsPerPage int MaxUploadSize int64 MaxTwtLength int MaxCacheTTL time.Duration MaxCacheItems int OpenProfiles bool OpenRegistrations bool SessionExpiry time.Duration SessionCacheTTL time.Duration TranscoderTimeout time.Duration MagicLinkSecret string SMTPHost string SMTPPort int SMTPUser string SMTPPass string SMTPFrom string MaxFetchLimit int64 APISessionTime time.Duration APISigningKey string WhitelistedDomains []string // contains filtered or unexported fields }
Config contains the server configuration parameters
func (*Config) RandomTwtPrompt ¶
RandomTwtPrompt returns a random Twt Prompt for display by the UI
type Context ¶
type Context struct { Config string Debug bool BaseURL string InstanceName string SoftwareVersion string TwtsPerPage int TwtPrompt string MaxTwtLength int RegisterDisabled bool OpenProfiles bool RegisterDisabledMessage string Timezones []*timezones.Zoneinfo Reply string Username string User *User Tokens []*Token LastTwt types.Twt Profile types.Profile Authenticated bool IsAdmin bool Error bool Message string Theme string Commit string Page string Content template.HTML Title string Meta Meta Links types.Links Alternatives types.Alternatives Twter types.Twter Twts types.Twts BlogPost *BlogPost BlogPosts BlogPosts Feeds []*Feed FeedSources FeedSourceMap Pager *paginator.Paginator // Report abuse ReportNick string ReportURL string // Reset Password Token PasswordResetToken string }
type ContextKey ¶
type ContextKey int
ContextKey ...
const ( TokenContextKey ContextKey = iota UserContextKey )
type DeleteOldSessionsJob ¶
type DeleteOldSessionsJob struct {
// contains filtered or unexported fields
}
func (*DeleteOldSessionsJob) Run ¶
func (job *DeleteOldSessionsJob) Run()
type DiskArchiver ¶
type DiskArchiver struct {
// contains filtered or unexported fields
}
DiskArchiver implements Archiver using an on-disk hash layout directory structure with one directory per 2-letter hash sequence with a single JSON encoded file per twt.
func (*DiskArchiver) Count ¶
func (a *DiskArchiver) Count() (int, error)
func (*DiskArchiver) Del ¶
func (a *DiskArchiver) Del(hash string) error
func (*DiskArchiver) Has ¶
func (a *DiskArchiver) Has(hash string) bool
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher maintains a pool for available workers and a task queue that workers will process
func NewDispatcher ¶
func NewDispatcher(maxWorkers int, maxQueue int) *Dispatcher
NewDispatcher creates a new dispatcher with the given number of workers and buffers the task queue based on maxQueue. It also initializes the channels for the worker pool and task queue
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(task Task) (string, error)
Dispatch pushes the given task into the task queue. The first available worker will perform the task
func (*Dispatcher) DispatchFunc ¶
func (d *Dispatcher) DispatchFunc(f func() error) (string, error)
DispatchFunc pushes the given func into the task queue by first wrapping it with a `TaskFunc` task.
func (*Dispatcher) Lookup ¶
func (d *Dispatcher) Lookup(id string) (Task, bool)
Lookup returns the matching `Task` given its id
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start()
Start creates and starts workers, adding them to the worker pool. Then, it starts a select loop to wait for tasks to be dispatched to available workers
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop ends execution for all workers and closes all channels, then removes all workers
type Feed ¶
type Feed struct { Name string Description string URL string CreatedAt time.Time Followers map[string]string `default:"{}"` // contains filtered or unexported fields }
Feed ...
func (*Feed) FollowedBy ¶
type FeedSource ¶
func ParseFeedSource ¶
func ParseFeedSource(scanner *bufio.Scanner) (feedsources []FeedSource, err error)
type FeedSourceMap ¶
type FeedSourceMap map[string][]FeedSource
type FeedSources ¶
type FeedSources struct {
Sources FeedSourceMap `"json:sources"`
}
func FetchFeedSources ¶
func FetchFeedSources(conf *Config, sources []string) *FeedSources
func LoadFeedSources ¶
func LoadFeedSources(path string) (*FeedSources, error)
type FixMissingTwtsJob ¶
type FixMissingTwtsJob struct {
// contains filtered or unexported fields
}
func (*FixMissingTwtsJob) Run ¶
func (job *FixMissingTwtsJob) Run()
type FixUserAccountsJob ¶
type FixUserAccountsJob struct {
// contains filtered or unexported fields
}
func (*FixUserAccountsJob) Run ¶
func (job *FixUserAccountsJob) Run()
type FuncTask ¶
type FuncTask struct { *BaseTask // contains filtered or unexported fields }
func NewFuncTask ¶
type ImageOptions ¶
type ImageTask ¶
type ImageTask struct { *BaseTask // contains filtered or unexported fields }
func NewImageTask ¶
type JobFactory ¶
type JobSpec ¶
type JobSpec struct { Schedule string Factory JobFactory }
JobSpec ...
func NewJobSpec ¶
func NewJobSpec(schedule string, factory JobFactory) JobSpec
type MergeStoreJob ¶
type MergeStoreJob struct {
// contains filtered or unexported fields
}
func (*MergeStoreJob) Run ¶
func (job *MergeStoreJob) Run()
type NullArchiver ¶
type NullArchiver struct{}
NullArchiver implements Archiver using dummy implementation stubs
func (*NullArchiver) Count ¶
func (a *NullArchiver) Count() (int, error)
func (*NullArchiver) Del ¶
func (a *NullArchiver) Del(hash string) error
func (*NullArchiver) Has ¶
func (a *NullArchiver) Has(hash string) bool
type Option ¶
Option is a function that takes a config struct and modifies it
func WithAPISessionTime ¶
WithAPISessionTime sets the API session time for tokens
func WithAPISigningKey ¶
WithAPISigningKey sets the API JWT signing key for tokens
func WithAdminEmail ¶
WithAdminEmail sets the Admin email used to contact the pod operator
func WithAdminName ¶
WithAdminName sets the Admin name used to identify the pod operator
func WithAdminUser ¶
WithAdminUser sets the Admin user used for granting special features to
func WithBaseURL ¶
WithBaseURL sets the Base URL used for constructing feed URLs
func WithCookieSecret ¶
WithCookieSecret sets the server's cookie secret
func WithDescription ¶
WithDescription sets the instance's description
func WithFeedSources ¶
WithFeedSources sets the feed sources to use for external feeds
func WithMagicLinkSecret ¶
WithMagicLinkSecret sets the MagicLinkSecert used to create password reset tokens
func WithMaxCacheItems ¶
WithMaxCacheItems sets the maximum cache items (per feed source) of twts in memory
func WithMaxCacheTTL ¶
WithMaxCacheTTL sets the maximum cache ttl of twts in memory
func WithMaxFetchLimit ¶
WithMaxFetchLimit sets the maximum feed fetch limit in bytes
func WithMaxTwtLength ¶
WithMaxTwtLength sets the maximum length of posts permitted on the server
func WithMaxUploadSize ¶
WithMaxUploadSize sets the maximum upload size permitted by the server
func WithOpenProfiles ¶
WithOpenProfiles sets whether or not to have open user profiles
func WithOpenRegistrations ¶
WithOpenRegistrations sets the open registrations flag
func WithSMTPFrom ¶
WithSMTPFrom sets the SMTPFrom address to use for sending email
func WithSMTPHost ¶
WithSMTPHost sets the SMTPHost to use for sending email
func WithSMTPPass ¶
WithSMTPPass sets the SMTPPass to use for sending email
func WithSMTPPort ¶
WithSMTPPort sets the SMTPPort to use for sending email
func WithSMTPUser ¶
WithSMTPUser sets the SMTPUser to use for sending email
func WithSessionCacheTTL ¶
WithSessionCacheTTL sets the server's session cache ttl
func WithSessionExpiry ¶
WithSessionExpiry sets the server's session expiry time
func WithTranscoderTimeout ¶
WithTranscoderTimeout sets the video transcoding timeout
func WithTwtsPerPage ¶
WithTwtsPerPage sets the server's twts per page
func WithWhitelistedDomains ¶
WithWhitelistedDomains sets the list of domains whitelisted and permitted for external iamges
type ReportAbuseEmailContext ¶
type Router ¶
type Router struct { httprouter.Router // contains filtered or unexported fields }
Router ...
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handle httprouter.Handle)
DELETE is a shortcut for Router.Handle("DELETE", path, handle)
func (*Router) GET ¶
func (r *Router) GET(path string, handle httprouter.Handle)
GET is a shortcut for Router.Handle("GET", path, handle)
func (*Router) Group ¶
func (r *Router) Group(path string, m ...Middleware) *Router
Group returns new *Router with given path and middlewares. It should be used for handles which have same path prefix or common middlewares.
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handle httprouter.Handle)
HEAD is a shortcut for Router.Handle("HEAD", path, handle)
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, handle httprouter.Handle)
Handle registers a new request handle combined with middlewares.
func (*Router) HandlerFunc ¶
func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
HandlerFunc is an adapter for http.HandlerFunc.
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handle httprouter.Handle)
OPTIONS is a shortcut for Router.Handle("OPTIONS", path, handle)
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handle httprouter.Handle)
PATCH is a shortcut for Router.Handle("PATCH", path, handle)
func (*Router) POST ¶
func (r *Router) POST(path string, handle httprouter.Handle)
POST is a shortcut for Router.Handle("POST", path, handle)
func (*Router) PUT ¶
func (r *Router) PUT(path string, handle httprouter.Handle)
PUT is a shortcut for Router.Handle("PUT", path, handle)
func (*Router) ServeFilesWithCacheControl ¶
func (r *Router) ServeFilesWithCacheControl(path string, root http.FileSystem)
ServeFilesWithCacheControl ...
func (*Router) Use ¶
func (r *Router) Use(m ...Middleware) *Router
Use appends new middleware to current Router.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server ...
func (*Server) AddCronJob ¶
AddCronJob ...
func (*Server) AddUserHandler ¶
func (s *Server) AddUserHandler() httprouter.Handle
AddUserHandler ...
func (*Server) ArchiveFeedHandler ¶
func (s *Server) ArchiveFeedHandler() httprouter.Handle
ArchiveFeedHandler...
func (*Server) CaptchaHandler ¶
func (s *Server) CaptchaHandler() httprouter.Handle
CaptchaHandler ...
func (*Server) ConversationHandler ¶
func (s *Server) ConversationHandler() httprouter.Handle
ConversationHandler ...
func (*Server) DelUserHandler ¶
func (s *Server) DelUserHandler() httprouter.Handle
DelUserHandler ...
func (*Server) DeleteAccountHandler ¶
func (s *Server) DeleteAccountHandler() httprouter.Handle
DeleteAccountHandler ...
func (*Server) DeleteAllHandler ¶
func (s *Server) DeleteAllHandler() httprouter.Handle
DeleteAllHandler ...
func (*Server) DeleteBlogHandler ¶
func (s *Server) DeleteBlogHandler() httprouter.Handle
DeleteBlogHandler ...
func (*Server) DeleteTokenHandler ¶
func (s *Server) DeleteTokenHandler() httprouter.Handle
DeleteTokenHandler ...
func (*Server) DiscoverHandler ¶
func (s *Server) DiscoverHandler() httprouter.Handle
DiscoverHandler ...
func (*Server) EditBlogHandler ¶
func (s *Server) EditBlogHandler() httprouter.Handle
EditBlogHandler ...
func (*Server) ExternalAvatarHandler ¶
func (s *Server) ExternalAvatarHandler() httprouter.Handle
ExternalAvatarHandler ...
func (*Server) ExternalHandler ¶
func (s *Server) ExternalHandler() httprouter.Handle
ExternalHandler ...
func (*Server) FollowersHandler ¶
func (s *Server) FollowersHandler() httprouter.Handle
FollowersHandler ...
func (*Server) FollowingHandler ¶
func (s *Server) FollowingHandler() httprouter.Handle
FollowingHandler ...
func (*Server) ManageFeedHandler ¶
func (s *Server) ManageFeedHandler() httprouter.Handle
ManageFeedHandler...
func (*Server) ManagePodHandler ¶
func (s *Server) ManagePodHandler() httprouter.Handle
ManagePodHandler ...
func (*Server) ManageUsersHandler ¶
func (s *Server) ManageUsersHandler() httprouter.Handle
ManageUsersHandler ...
func (*Server) MentionsHandler ¶
func (s *Server) MentionsHandler() httprouter.Handle
MentionsHandler ...
func (*Server) NewPasswordHandler ¶
func (s *Server) NewPasswordHandler() httprouter.Handle
NewPasswordHandler ...
func (*Server) NotFoundHandler ¶
func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request)
func (*Server) OldAvatarHandler ¶
func (s *Server) OldAvatarHandler() httprouter.Handle
OldAvatarHandler ... Redirect old URIs (twtxt <= v0.1.0) of the form /user/<nick>/avatar.png -> /user/<nick>/avatar TODO: Remove this after v1
func (*Server) OldTwtxtHandler ¶
func (s *Server) OldTwtxtHandler() httprouter.Handle
OldTwtxtHandler ... Redirect old URIs (twtxt <= v0.0.8) of the form /u/<nick> -> /user/<nick>/twtxt.txt TODO: Remove this after v1
func (*Server) PageHandler ¶
func (s *Server) PageHandler(name string) httprouter.Handle
PageHandler ...
func (*Server) PermalinkHandler ¶
func (s *Server) PermalinkHandler() httprouter.Handle
PermalinkHandler ...
func (*Server) PodAvatarHandler ¶
func (s *Server) PodAvatarHandler() httprouter.Handle
PodAvatarHandler ...
func (*Server) ProfileHandler ¶
func (s *Server) ProfileHandler() httprouter.Handle
ProfileHandler ...
func (*Server) PublishBlogHandler ¶
func (s *Server) PublishBlogHandler() httprouter.Handle
PublishBlogHandler ...
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler() httprouter.Handle
RegisterHandler ...
func (*Server) ResetPasswordHandler ¶
func (s *Server) ResetPasswordHandler() httprouter.Handle
ResetPasswordHandler ...
func (*Server) ResetPasswordMagicLinkHandler ¶
func (s *Server) ResetPasswordMagicLinkHandler() httprouter.Handle
ResetPasswordMagicLinkHandler ...
func (*Server) SettingsHandler ¶
func (s *Server) SettingsHandler() httprouter.Handle
SettingsHandler ...
func (*Server) SupportHandler ¶
func (s *Server) SupportHandler() httprouter.Handle
SupportHandler ...
func (*Server) SyndicationHandler ¶
func (s *Server) SyndicationHandler() httprouter.Handle
SyndicationHandler ...
func (*Server) TimelineHandler ¶
func (s *Server) TimelineHandler() httprouter.Handle
TimelineHandler ...
func (*Server) TransferFeedHandler ¶
func (s *Server) TransferFeedHandler() httprouter.Handle
TransferFeedHandler...
func (*Server) UnfollowHandler ¶
func (s *Server) UnfollowHandler() httprouter.Handle
UnfollowHandler ...
func (*Server) UploadMediaHandler ¶
func (s *Server) UploadMediaHandler() httprouter.Handle
UploadMediaHandler ...
func (*Server) UserConfigHandler ¶
func (s *Server) UserConfigHandler() httprouter.Handle
UserConfigHandler ...
func (*Server) WebMentionHandler ¶
func (s *Server) WebMentionHandler() httprouter.Handle
WebMentionHandler ...
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore ...
func NewSessionStore ¶
func NewSessionStore(store Store, sessionCacheTTL time.Duration) *SessionStore
func (*SessionStore) Count ¶
func (s *SessionStore) Count() int
func (*SessionStore) DelSession ¶
func (s *SessionStore) DelSession(sid string) error
func (*SessionStore) GetAllSessions ¶
func (s *SessionStore) GetAllSessions() ([]*session.Session, error)
func (*SessionStore) GetSession ¶
func (s *SessionStore) GetSession(sid string) (*session.Session, error)
func (*SessionStore) HasSession ¶
func (s *SessionStore) HasSession(sid string) bool
func (*SessionStore) SetSession ¶
func (s *SessionStore) SetSession(sid string, sess *session.Session) error
func (*SessionStore) SyncSession ¶
func (s *SessionStore) SyncSession(sess *session.Session) error
type Settings ¶
type Settings struct { Name string `yaml:"pod_name"` Description string `yaml:"pod_description"` MaxTwtLength int `yaml:"max_twt_length"` OpenProfiles bool `yaml:"open_profiles"` OpenRegistrations bool `yaml:"open_registrations"` }
Settings contains Pod Settings that can be customised via the Web UI
func LoadSettings ¶
LoadSettings loads pod settings from the given path
type Store ¶
type Store interface { Merge() error Close() error Sync() error DelFeed(name string) error HasFeed(name string) bool GetFeed(name string) (*Feed, error) SetFeed(name string, user *Feed) error LenFeeds() int64 SearchFeeds(prefix string) []string GetAllFeeds() ([]*Feed, error) DelUser(username string) error HasUser(username string) bool GetUser(username string) (*User, error) SetUser(username string, user *User) error LenUsers() int64 SearchUsers(prefix string) []string GetAllUsers() ([]*User, error) GetSession(sid string) (*session.Session, error) SetSession(sid string, sess *session.Session) error HasSession(sid string) bool DelSession(sid string) error SyncSession(sess *session.Session) error LenSessions() int64 GetAllSessions() ([]*session.Session, error) GetUserTokens(user *User) ([]*Token, error) SetToken(signature string, token *Token) error DelToken(signature string) error LenTokens() int64 }
type SyncStoreJob ¶
type SyncStoreJob struct {
// contains filtered or unexported fields
}
func (*SyncStoreJob) Run ¶
func (job *SyncStoreJob) Run()
type TTLCache ¶
func NewTTLCache ¶
type Task ¶
type Task interface { fmt.Stringer ID() string State() TaskState Result() TaskResult Error() error Run() error }
Task is an interface that represents a single task to be executed by a worker. Any object can implement a `Task` if it implements the interface.
type TaskResult ¶
type Templates ¶
func NewTemplates ¶
func NewTemplates(conf *Config, blogs *BlogsCache, cache *Cache) (*Templates, error)
type Token ¶
type Token struct { Signature string Value string UserAgent string CreatedAt time.Time ExpiresAt time.Time }
Token ...
type TwtTextFormat ¶
type TwtTextFormat int
TwtTextFormat represents the format of which the twt text gets formatted to
const ( // MarkdownFmt to use markdown format MarkdownFmt TwtTextFormat = iota // HTMLFmt to use HTML format HTMLFmt // TextFmt to use for og:description TextFmt )
type TwtxtUserAgent ¶
func DetectFollowerFromUserAgent ¶
func DetectFollowerFromUserAgent(ua string) (*TwtxtUserAgent, error)
type UpdateFeedSourcesJob ¶
type UpdateFeedSourcesJob struct {
// contains filtered or unexported fields
}
func (*UpdateFeedSourcesJob) Run ¶
func (job *UpdateFeedSourcesJob) Run()
type UpdateFeedsJob ¶
type UpdateFeedsJob struct {
// contains filtered or unexported fields
}
func (*UpdateFeedsJob) Run ¶
func (job *UpdateFeedsJob) Run()
type User ¶
type User struct { Username string Password string Tagline string Email string URL string CreatedAt time.Time Theme string `default:"auto"` DisplayDatesInTimezone string `default:"UTC"` IsFollowersPubliclyVisible bool `default:"true"` IsFollowingPubliclyVisible bool `default:"true"` Feeds []string `default:"[]"` Tokens []string `default:"[]"` Followers map[string]string `default:"{}"` Following map[string]string `default:"{}"` Muted map[string]string `default:"{}"` // contains filtered or unexported fields }
User ...
func (*User) FollowAndValidate ¶
func (*User) FollowedBy ¶
type VideoOptions ¶
type VideoTask ¶
type VideoTask struct { *BaseTask // contains filtered or unexported fields }
func NewVideoTask ¶
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker attaches to a provided worker pool, and looks for tasks on its task channel
func NewWorker ¶
NewWorker creates a new worker using the given id and attaches to the provided worker pool. It also initializes the task/quit channels
Source Files ¶
- api.go
- archive.go
- audio_task.go
- base_task.go
- bitcask_store.go
- blog.go
- blog_handlers.go
- blogs_cache.go
- cache.go
- config.go
- context.go
- conversation_handler.go
- dispatcher.go
- email.go
- feedsources.go
- follow_handlers.go
- func_task.go
- handlers.go
- image_task.go
- init.go
- jobs.go
- manage_handlers.go
- media_handlers.go
- models.go
- mute_handlers.go
- options.go
- robots.go
- router.go
- server.go
- session_store.go
- stats.go
- store.go
- support_handlers.go
- task.go
- templates.go
- ttlcache.go
- twt.go
- utils.go
- video_task.go
- worker.go