Documentation ¶
Index ¶
- Constants
- Variables
- func AddPublicKey(person *database.PERSON, keyData, keySource, keyNickname string, ...) error
- func ConfirmSession(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func ConfirmSessionCode(code string, cleanup, lookup *sql.Stmt) (*database.SESSION, error)
- func CreateNewSession(person *database.PERSON, keys []*database.PUBLIC_KEY, sessionInsert *sql.Stmt) error
- func CreateSession(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func DisplayPosts(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func DownloadMessage(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func GenerateStaticFiles(templatesFolder string, outputFolder string)
- func InitializeTemplates(folder string)
- func MakeHTMLHandler(...) http.HandlerFunc
- func PostMessage(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func ProcessDonation(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- func Redirect(target string) http.HandlerFunc
- func StaticFolder(folder string, templatesFolder string) http.Handler
- func UnsupportedBrowserHandler(templatesFolder string) http.HandlerFunc
- func UploadKey(w http.ResponseWriter, r *http.Request, db database.DBConnection, ...)
- type Alert
- type ConfirmSessionPage
- type CreateSessionPage
- type DisplayPostsPage
- type DonationPage
- type EmailMessage
- type NewKeyPage
- type NewPostPage
- type Recipient
- type StaticPage
Constants ¶
View Source
const ( // configuration SESSION_WORDS = 6 // it's a magic number SESSION_DURATION = 30 * time.Minute MESSAGE_DURATION = 30 * 24 * time.Hour // Errors and alerts DISABLED = "This email address and all of its public keys has been disabled" UNKNOWN = "This email address does not have any public keys associated with it (you can <a href=\"/upload\">add one here</a>)" NO_KEYS = "You need at least one public key associated with your email address (go <a href=\"/upload\">here to upload it</a>)" NO_EMAIL = "You need to provide an email address" INVALID_EMAIL = "That email address is not valid" INVALID_SESSION = "This session is no longer valid (go <a href=\"/session\">here to create a new one</a>)" INVALID_PK = "We could not process your public key (please make sure it is in the correct format)" OTHER_ERROR = "There was an internal problem" // site/domain specific CONTACT_SENDER = "noreply@teamwork.io" KEY_SOURCE = "TeamWork.io" // user interface POSTS_PER_PAGE = 20 // page titles TITLE_POSTS = "Latest Posts" TITLE_CREATE_SESSION = "New Session" TITLE_CONFIRM_SESSION = "Confirm Session" TITLE_ADD_POST = "New Post" TITLE_ADD_KEY = "New Public Key" TITLE_INDEX = "Welcome to " + KEY_SOURCE TITLE_HELP = "Help" TITLE_DONATE = "Donate to " + KEY_SOURCE )
View Source
const NO_SUCH_MESSAGE = "There is no such message among the list of available posts"
Variables ¶
View Source
var ( TEMPLATE_LIST = func(templatesFolder string, templateFiles []string) []string { t := make([]string, 0) for _, f := range templateFiles { t = append(t, path.Join(templatesFolder, f)) } return t } // static pages UNSUPPORTED_TEMPLATE_FILE = "browser_not_supported.html" INDEX_TEMPLATE_FILES = []string{"index.html", "head.html", "navigation.html", "scripts.html"} INDEX_TEMPLATE *template.Template HELP_TEMPLATE_FILES = []string{"help.html", "head.html", "navigation.html", "scripts.html"} HELP_TEMPLATE *template.Template // dynamically-generated pages NEW_POST_TEMPLATE_FILES = []string{"new-post.html", "head.html", "modal.html", "alert.html", "navigation.html", "scripts.html"} NEW_POST_TEMPLATE *template.Template ALL_POSTS_TEMPLATE_FILES = []string{"posts.html", "head.html", "alert.html", "navigation.html", "scripts.html"} ALL_POSTS_TEMPLATE *template.Template CREATE_SESSION_TEMPLATE_FILES = []string{"create-session.html", "head.html", "alert.html", "navigation.html", "scripts.html"} CREATE_SESSION_TEMPLATE *template.Template CONFIRM_SESSION_TEMPLATE_FILES = []string{"confirm-session.html", "head.html", "alert.html", "navigation.html", "scripts.html"} CONFIRM_SESSION_TEMPLATE *template.Template NEW_KEY_TEMPLATE_FILES = []string{"new-key.html", "head.html", "alert.html", "navigation.html", "scripts.html"} NEW_KEY_TEMPLATE *template.Template DONATE_TEMPLATE_FILES = []string{"donate.html", "head.html", "alert.html", "modal.html", "navigation.html", "scripts.html"} DONATE_TEMPLATE *template.Template EMAIL_TEMPLATE_FILES = []string{"email.txt"} EMAIL_TEMPLATE *template.Template HTML_EMAIL_TEMPLATE_FILES = []string{"email.html"} HTML_EMAIL_TEMPLATE *template.Template TEMPLATES_INITIALIZED = false )
Functions ¶
func AddPublicKey ¶
func AddPublicKey(person *database.PERSON, keyData, keySource, keyNickname string, pkInsert *sql.Stmt) error
Generate a new public key, and associate it with this person
func ConfirmSession ¶
func ConfirmSession(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
func ConfirmSessionCode ¶
Wipe any expired sessions, and then confirm this code, returning the session object
func CreateNewSession ¶
func CreateNewSession(person *database.PERSON, keys []*database.PUBLIC_KEY, sessionInsert *sql.Stmt) error
Create a new session for this Person and email them the corresponding session code to decrypt
func CreateSession ¶
func CreateSession(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
func DisplayPosts ¶
func DisplayPosts(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
func DownloadMessage ¶
func DownloadMessage(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
Lookup and stream the given message back to the client
func GenerateStaticFiles ¶
func InitializeTemplates ¶
func InitializeTemplates(folder string)
InitializeTemplates confirms the given folder string leads to the html template files, otherwise templates.Must() will complain
func MakeHTMLHandler ¶
func MakeHTMLHandler(fn func(http.ResponseWriter, *http.Request, database.DBConnection, ...interface{}), db database.DBConnection, opts ...interface{}) http.HandlerFunc
Respond to requests using HTML templates and the standard Content-Type (i.e., "text/html")
func PostMessage ¶
func PostMessage(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
func ProcessDonation ¶
func ProcessDonation(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
func Redirect ¶
func Redirect(target string) http.HandlerFunc
Use this to redirect one request to another target (string)
func StaticFolder ¶
handlers for static resources
func UnsupportedBrowserHandler ¶
func UnsupportedBrowserHandler(templatesFolder string) http.HandlerFunc
Show the static template for unsupported browsers
func UploadKey ¶
func UploadKey(w http.ResponseWriter, r *http.Request, db database.DBConnection, opts ...interface{})
Types ¶
type ConfirmSessionPage ¶
type CreateSessionPage ¶
type DisplayPostsPage ¶
type DonationPage ¶
type EmailMessage ¶
type NewKeyPage ¶
type NewPostPage ¶
Click to show internal directories.
Click to hide internal directories.