Documentation ¶
Index ¶
- Constants
- Variables
- func ConfirmServerAccount(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string
- func DeleteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func EditAccount(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func EmailItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func FavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func FavoritedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, ...)
- func InitializeTemplates(folder string)
- func InputUnknownItem(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func MakeHTMLHandler(...) http.HandlerFunc
- func MakeHandler(fn func(*http.Request, database.ConnCoordinates, ...interface{}) string, ...) http.HandlerFunc
- func Redirect(target string) http.HandlerFunc
- func RemoveSingleItem(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string
- func ScannedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, ...)
- func ShutdownClientHandler() http.HandlerFunc
- func UnfavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, ...)
- func UnsupportedBrowserHandler(templatesFolder string) http.HandlerFunc
- type AccountForm
- type Action
- type ActiveTab
- type AjaxAck
- type ItemForm
- type ItemsPage
Constants ¶
const ( // Errors BAD_REQUEST = "Sorry, that is an invalid request" BAD_POST = "Sorry, we cannot respond to that request. Please try again." // Info messages EMAIL_SENT = "The selected items have been sent to your email address" // urls HOME_URL = "/scanned/" ACCOUNT_URL = "/account/" )
Variables ¶
var ( ACCOUNT_EDIT_TEMPLATE_FILES = []string{"account.html", "head.html", "navigation_tabs.html", "modal.html", "scripts.html"} ACCOUNT_EDIT_TEMPLATES *template.Template )
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 } UNSUPPORTED_TEMPLATE_FILE = "browser_not_supported.html" ITEM_LIST_TEMPLATE_FILES = []string{"items.html", "head.html", "navigation_tabs.html", "actions.html", "modal.html", "scripts.html"} ITEM_EDIT_TEMPLATE_FILES = []string{"define_item.html", "head.html", "scripts.html"} ITEM_LIST_TEMPLATES *template.Template ITEM_EDIT_TEMPLATES *template.Template TEMPLATES_INITIALIZED = false )
Functions ¶
func ConfirmServerAccount ¶
func ConfirmServerAccount(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string
ConfirmServerAccount responds to the ajax request from the client to lookup and return the status of the given account
func DeleteItems ¶
func DeleteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
DeleteItems accepts a form post of one or more Item.Id values, and attempts to remove them from the client db. Unless it hits a critical error, it returns home, to the list of scanned items
func EditAccount ¶
func EditAccount(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
EditAccount presents the form for editing Account information (in response to a GET request) and handles to add/updates (in response to a POST request)
func EmailItems ¶
func EmailItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
EmailItems handles the client form post, to send a list of the selected items via email to the given user
func FavoriteItems ¶
func FavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
FavoriteItems accepts a form post of one or more Item.Id values, and attempts to change their status in the client db to 'favorite'
func FavoritedItems ¶
func FavoritedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, opts ...interface{})
FavoritedItems returns all the products scanned and favorited by this Account
func InitializeTemplates ¶
func InitializeTemplates(folder string)
InitializeTemplates confirms the given folder string leads to the html template files, otherwise templates.Must() will complain
func InputUnknownItem ¶
func InputUnknownItem(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
InputUnknownItem handles the form for user contributions of unknown barcode scans: a GET presents the form, and a POST responds to the user-contributed input
func MakeHTMLHandler ¶
func MakeHTMLHandler(fn func(http.ResponseWriter, *http.Request, database.ConnCoordinates, ...interface{}), db database.ConnCoordinates, opts ...interface{}) http.HandlerFunc
Respond to requests using HTML templates and the standard Content-Type (i.e., "text/html")
func MakeHandler ¶
func MakeHandler(fn func(*http.Request, database.ConnCoordinates, ...interface{}) string, db database.ConnCoordinates, mediaType string, opts ...interface{}) http.HandlerFunc
Respond to requests that are not "text/html" Content-Types (e.g., for ajax calls)
func Redirect ¶
func Redirect(target string) http.HandlerFunc
Use this to redirect one request to another target (string)
func RemoveSingleItem ¶
func RemoveSingleItem(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string
RemoveSingleItem looks up the single item represented by the itemId form post variable, and attempts to delete it, if it exists. The reply is a jsonified string, passed back to MakeHandler() to be coupled with the right mime type
func ScannedItems ¶
func ScannedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, opts ...interface{})
ScannedItems returns all the products scanned, favorited or not, barcode lookup successful or not
func ShutdownClientHandler ¶
func ShutdownClientHandler() http.HandlerFunc
Issue the shutdown and write back the system command output
func UnfavoriteItems ¶
func UnfavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})
UnfavoriteItems accepts a form post of one or more Item.Id values, and attempts to change their status in the client db to not 'favorite'
func UnsupportedBrowserHandler ¶
func UnsupportedBrowserHandler(templatesFolder string) http.HandlerFunc
Show the static template for unsupported browsers