app

package
v0.0.0-...-c859fe7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Global instance that holds a connection to the DB. It gets initialized after calling the InitDB function. You have to call CloseDB in order to close the connection.

Functions

func CloseDB

func CloseDB()

Close the global DB connection.

func InitDB

func InitDB()

Initialize the global DB connection.

func InitSession

func InitSession()

Initialize the global cookie store.

func IsUserLogged

func IsUserLogged(id interface{}) bool

Returns true if the user with the given id exists, false otherwise.

func Login

func Login(res http.ResponseWriter, req *http.Request)

Login a user. It expects the "name" and "password" form values. Regardless if it was successful or not, it will redirect the user to the root path.

func Logout

func Logout(res http.ResponseWriter, req *http.Request)

Logout the current user.

func PlayersCreate

func PlayersCreate(res http.ResponseWriter, req *http.Request)

func PlayersCsv

func PlayersCsv(res http.ResponseWriter, req *http.Request)

func PlayersDelete

func PlayersDelete(res http.ResponseWriter, req *http.Request)

func PlayersNew

func PlayersNew(res http.ResponseWriter, req *http.Request)

func PlayersRate

func PlayersRate(res http.ResponseWriter, req *http.Request)

func PlayersRated

func PlayersRated(res http.ResponseWriter, req *http.Request)

func PlayersShow

func PlayersShow(res http.ResponseWriter, req *http.Request)

func PlayersUpdate

func PlayersUpdate(res http.ResponseWriter, req *http.Request)

func RootCsv

func RootCsv(res http.ResponseWriter, req *http.Request)

func RootIndex

func RootIndex(res http.ResponseWriter, req *http.Request)

Renders the root page. It has three different options:

  1. If there's no user, it renders the "Create user" page.
  2. If the current user is not logged in, it render the "Login" page.
  3. If the current user is logged in, then it call homePage.

func UserLogged

func UserLogged(req *http.Request, rm *mux.RouteMatch) bool

A route matcher as expected by the mux package. It returns true (thus, accepting the route) if the current user is logged in, false otherwise.

func UsersCreate

func UsersCreate(res http.ResponseWriter, req *http.Request)

Creates a user. It expects the "name" and the "password" form values to be present. Moreover, only one user is allowed in this application.

Types

type ExtPlayer

type ExtPlayer struct {
	// The Id of the player (uuid).
	Id string

	// The name of the player.
	Name string

	// The minimum rating from the player.
	Min int

	// The maximum rating from the player.
	Max int

	// The average rating from the player.
	Avg string

	// All the ratings from this player.
	Ratings []Rating

	// The date of creation of this player.
	Created_at time.Time
}

A Player with some useful data.

type Options

type Options struct {
	// The id of the current user.
	Id string

	// The current player.
	One *ExtPlayer

	// All the players to be displayed.
	Players []*ExtPlayer

	// The maximum number of values to be displayed for a set of players.
	Values []int

	// The URL of "Download CSV". It might change depending where we are.
	Download string

	// Set to true if the current user is logged in.
	LoggedIn bool

	// Set to true if the views has to include Javascript.
	JS bool

	// Set to true if an error has happenned.
	Error bool
}

This struct holds all the data that can be passed to a view.

type Player

type Player struct {
	Id         string
	Name       string
	Created_at time.Time
}

type Rating

type Rating struct {
	Id         int
	Value      int
	Player_id  string
	Created_at time.Time
}

type User

type User struct {
	Id            string
	Name          string
	Password_hash string
	Created_at    time.Time
}

Jump to

Keyboard shortcuts

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