Documentation
¶
Index ¶
- Constants
- func AddRouters(router *mux.Router)
- func AllGrids(userid int) []string
- func CheckForExistingUser(u User) (bool, error)
- func Connect() (*sql.DB, error)
- func CountGridsWithName(gridname string) int
- func GetDocumentRoot() string
- func GetUserID(u User) (int, error)
- func GridChanged(w http.ResponseWriter, r *http.Request)
- func GridChooser(w http.ResponseWriter, r *http.Request)
- func GridClick(w http.ResponseWriter, r *http.Request)
- func GridDelete(w http.ResponseWriter, r *http.Request)
- func GridLoad(gridname string, userid int) string
- func GridNameUsed(w http.ResponseWriter, r *http.Request)
- func GridNew(w http.ResponseWriter, r *http.Request)
- func GridOpen(w http.ResponseWriter, r *http.Request)
- func GridPreview(w http.ResponseWriter, r *http.Request)
- func GridRedo(w http.ResponseWriter, r *http.Request)
- func GridSave(w http.ResponseWriter, r *http.Request)
- func GridSaveAs(w http.ResponseWriter, r *http.Request)
- func GridSaveCommon(w http.ResponseWriter, r *http.Request, gridname string)
- func GridScreen(w http.ResponseWriter, r *http.Request)
- func GridStatistics(w http.ResponseWriter, r *http.Request)
- func GridUndo(w http.ResponseWriter, r *http.Request)
- func HandleLogin(w http.ResponseWriter, r *http.Request)
- func HandleRegister(w http.ResponseWriter, r *http.Request)
- func HandleRequests()
- func MainPage(w http.ResponseWriter, r *http.Request)
- func Register(w http.ResponseWriter, r *http.Request)
- func UpdateDatabase(u User) error
- func ValidateForm(u User) error
- type Enabled
- type Session
- type UIState
- type User
Constants ¶
const (
SESSION_COOKIE = "session_id"
)
Variables ¶
This section is empty.
Functions ¶
func CheckForExistingUser ¶ added in v0.7.0
CheckForExistingUser looks up a username in the users table and returns true if it exists
func CountGridsWithName ¶ added in v0.6.0
CountGridsWithName gets the number of grids in the table with a specified name. Broken out from the main function for ease of unit testing.
func GetDocumentRoot ¶
func GetDocumentRoot() string
GetDocumentRoot returns the absolute path to the $PROJECT_ROOT/view/static directory.
func GridChanged ¶
func GridChanged(w http.ResponseWriter, r *http.Request)
GridChanged is a REST method to determine whether the grid has changed
func GridChooser ¶ added in v0.6.0
func GridChooser(w http.ResponseWriter, r *http.Request)
GridChooser displays a list of grids to choose from.
func GridClick ¶
func GridClick(w http.ResponseWriter, r *http.Request)
GridClick handles adding or deleting a black cell on the grid.
func GridDelete ¶ added in v0.6.0
func GridDelete(w http.ResponseWriter, r *http.Request)
GridDelete delete the specified grid and redirects to main screen.
func GridLoad ¶ added in v0.6.0
GridLoad gets the jsonstr for the specified gridname from the database.
func GridNameUsed ¶ added in v0.6.0
func GridNameUsed(w http.ResponseWriter, r *http.Request)
GridNameUsed is a REST method to determine whether a grid by the specified name already exists in the database.
func GridNew ¶
func GridNew(w http.ResponseWriter, r *http.Request)
GridNew creates a new grid and redirects to GridScreen
func GridOpen ¶ added in v0.6.0
func GridOpen(w http.ResponseWriter, r *http.Request)
GridOpen starts a new grid editing session with the specified grid name.
func GridPreview ¶ added in v0.6.0
func GridPreview(w http.ResponseWriter, r *http.Request)
GridPreview is a REST method that return the scaled SVG for the specified grid name.
func GridRedo ¶
func GridRedo(w http.ResponseWriter, r *http.Request)
GridRedo redoes the latest add or remove black cell.
func GridSave ¶ added in v0.6.0
func GridSave(w http.ResponseWriter, r *http.Request)
GridSave adds or updates the database entry for this grid.
func GridSaveAs ¶ added in v0.6.0
func GridSaveAs(w http.ResponseWriter, r *http.Request)
GridSaveAs saves the grid under a new name
func GridSaveCommon ¶ added in v0.6.0
func GridSaveCommon(w http.ResponseWriter, r *http.Request, gridname string)
GridSaveCommon is a method used by both grid_save and grid_save_as.
func GridScreen ¶
func GridScreen(w http.ResponseWriter, r *http.Request)
GridScreen displays the grid screen
func GridStatistics ¶
func GridStatistics(w http.ResponseWriter, r *http.Request)
GridStatistics runs the statistics methods and returns the results
func GridUndo ¶
func GridUndo(w http.ResponseWriter, r *http.Request)
GridUndo undoes the latest add or remove black cell.
func HandleLogin ¶ added in v0.7.0
func HandleLogin(w http.ResponseWriter, r *http.Request)
HandleLogin is a POST method that accepts a username and password, verifies them against the database, and redirects to the main page if they are valid.
func HandleRegister ¶ added in v0.7.0
func HandleRegister(w http.ResponseWriter, r *http.Request)
HandleRegister is a POST method that creates a new user in the database.
func HandleRequests ¶
func HandleRequests()
HandleRequests registers all the routers and starts the server.
func MainPage ¶
func MainPage(w http.ResponseWriter, r *http.Request)
MainPage shows the main page of the application
func Register ¶ added in v0.7.0
func Register(w http.ResponseWriter, r *http.Request)
Register displays the registration screen
func UpdateDatabase ¶ added in v0.7.0
UpdateDatabase adds a user to the database. If the user already exists, updates the record. Returns any error message.
func ValidateForm ¶ added in v0.7.0
ValidateForm checks for required fields
Types ¶
type Session ¶
type Session struct { USERID int USERNAME string EXPIRES time.Time ENABLED Enabled UISTATE UIState MESSAGES []string GRID string GRID_INITIAL_SHA string GRIDNAME string N int BOXSIZE int SVGSTR string STATS *model.Statistics GRIDLIST []string NEXTURL string }
Session holds the values for an HTTP session
func GetSession ¶ added in v0.7.0
GetSession gets the session ID from the request cookie and looks up the correct session in the session map. If there is no cookie, or if the session does not exist or has expired, a 401 HTTP error is written to the response and the ok boolean is set to false.
func NewSession ¶ added in v0.7.0
func NewSession() *Session
NewSession creates a new session and returns a pointer to it.
type UIState ¶
type UIState byte
UIState reflects the state of the UI, and which menu items to enable.
func (UIState) GetEnabled ¶
GetEnabled returns a map of menu item names to whether to enable them.
Source Files
¶
- database.go
- grid_changed.go
- grid_chooser.go
- grid_click.go
- grid_delete.go
- grid_load.go
- grid_name_used.go
- grid_new.go
- grid_open.go
- grid_preview.go
- grid_redo.go
- grid_save.go
- grid_save_as.go
- grid_save_common.go
- grid_screen.go
- grid_statistics.go
- grid_undo.go
- handle_login.go
- handle_register.go
- main_page.go
- register.go
- server.go
- session.go
- uistate.go