web

package
v0.0.0-...-d4285bb Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2014 License: BSD-2-Clause Imports: 40 Imported by: 0

Documentation

Overview

Package web provides a webserver which allows for: viewing of results; administration of submissions, projects and tools; user management;

Index

Constants

View Source
const (
	LOG_SERVER      = "webserver/server.go"
	PORT       uint = 8080
)
View Source
const (
	LOG_HANDLERS = "webserver/handlers.go"
)
View Source
const (
	OUT user.Permission = 42
)

Variables

View Source
var (
	CountsError   = errors.New("unsupported counts request")
	CommentsError = errors.New("unsupported comments request")
	ResultsError  = errors.New("cannot retrieve results")
)
View Source
var (
	InvalidArgsError = errors.New("invalid args call")
)
View Source
var (
	JPFKeyError = errors.New("JPF key cannot be empty")
)

Functions

func Active

func Active() bool

Active is whether the server is currently running.

func AddProject

func AddProject(r *http.Request, c *context.C) (string, error)

AddProject creates a new Impendulo Project.

func AddSkeleton

func AddSkeleton(r *http.Request, c *context.C) (string, error)

func BaseTemplates

func BaseTemplates() []string

BaseTemplates loads the base HTML templates used by all views in the web app.

func CheckAccess

func CheckAccess(p string, c *context.C, ps map[string]user.Permission) error

CheckAccess verifies that a user is allowed access to a url.

func CreateCheckstyle

func CreateCheckstyle(r *http.Request, c *context.C) (string, error)

CreateCheckstyle

func CreateFindbugs

func CreateFindbugs(r *http.Request, c *context.C) (string, error)

CreateFindbugs

func CreateJPF

func CreateJPF(r *http.Request, c *context.C) (string, error)

CreateJPF replaces a project's JPF configuration with a new, provided configuration.

func CreateJUnit

func CreateJUnit(r *http.Request, c *context.C) (string, error)

CreateJUnit adds a new JUnit test for a given project.

func CreateMake

func CreateMake(r *http.Request, c *context.C) (string, error)

CreateMake

func CreatePMD

func CreatePMD(r *http.Request, c *context.C) (string, error)

CreatePMD creates PMD rules for a project from a provided list.

func DeleteProjects

func DeleteProjects(r *http.Request, c *context.C) (string, error)

DeleteProjects removes a project and all data associated with it from the system.

func DeleteResults

func DeleteResults(r *http.Request, c *context.C) (string, error)

DeleteResults removes all results for a specic project.

func DeleteSkeletons

func DeleteSkeletons(r *http.Request, c *context.C) (string, error)

func DeleteSubmissions

func DeleteSubmissions(r *http.Request, c *context.C) (string, error)

func DeleteUsers

func DeleteUsers(r *http.Request, c *context.C) (string, error)

DeleteUsers removes users and all data associated with them from the system.

func Downloaders

func Downloaders() map[string]Downloader

func EditFile

func EditFile(r *http.Request, c *context.C) (string, error)

EditFile

func EditProject

func EditProject(r *http.Request, c *context.C) (string, error)

EditProject is used to modify a project's metadata.

func EditSubmission

func EditSubmission(r *http.Request, c *context.C) (string, error)

EditSubmission

func EditTest

func EditTest(r *http.Request, c *context.C) (string, error)

func EditUser

func EditUser(r *http.Request, c *context.C) (string, error)

EditUser

func ExportData

func ExportData(r *http.Request) (string, error)

ExportData

func FileHandler

func FileHandler(origin string) http.Handler

func GenerateAJAX

func GenerateAJAX(r *pat.Router)

func GenerateDownloads

func GenerateDownloads(r *pat.Router, d map[string]Downloader)

GenerateDownloads

func GenerateGets

func GenerateGets(r *pat.Router, gets map[string]Getter, views map[string]string)

GenerateGets loads post request handlers and adds them to the router.

func GeneratePosts

func GeneratePosts(router *pat.Router, posts map[string]Poster, indexPosts map[string]bool)

GeneratePosts loads post request handlers and adds them to the router.

func GenerateViews

func GenerateViews(r *pat.Router, views map[string]string)

GenerateViews is used to load all the basic views used by our web app.

func GetResult

func GetResult(r *context.Result, fileId bson.ObjectId) (result.Displayer, error)

GetResult retrieves a DisplayResult for a given file and result name.

func Getters

func Getters() map[string]Getter

Getters retrieves all getters

func ImportData

func ImportData(r *http.Request, c *context.C) (string, error)

ImportData

func IndexPosters

func IndexPosters() map[string]bool

indexPosters loads the posters which need to be redirected to the home page on success.

func LoadIntlola

func LoadIntlola(r *http.Request) (string, error)

func LoadSkeleton

func LoadSkeleton(r *http.Request) (string, error)

LoadSkeleton makes a project skeleton available for download.

func LoadTest

func LoadTest(r *http.Request) (string, error)

LoadSkeleton makes a project skeleton available for download.

func Login

func Login(r *http.Request, c *context.C) (string, error)

Login signs a user into the web app.

func Logout

func Logout(r *http.Request, c *context.C) (string, error)

Logout logs a user out of the system.

func Permissions

func Permissions() map[string]user.Permission

Permissions loads all permissions.

func Posters

func Posters() map[string]Poster

Posters retrieves all posters

func RedirectHandler

func RedirectHandler(dest string) http.Handler

func Register

func Register(r *http.Request, c *context.C) (string, error)

Register registers a new user with Impendulo.

func RenameFiles

func RenameFiles(r *http.Request, c *context.C) (string, error)

func Run

func Run(port uint)

Run starts up the webserver if it is not currently running.

func RunTools

func RunTools(r *http.Request, c *context.C) (string, error)

RunTools runs a tool on submissions in a given project. Previous results are deleted if the user has specified that the tool should be rerun on all files.

func StaticDir

func StaticDir() string

StaticDir retrieves the directory containing all the static files for the web server.

func SubmitArchive

func SubmitArchive(r *http.Request, c *context.C) (string, error)

SubmitArchive adds an Intlola archive to the database.

func T

func T(names ...string) *template.Template

T creates a new HTML template from the given files.

func TemplateDir

func TemplateDir() string

TemplateDir retrieves the directory in which HTML templates are stored.

func Views

func Views() map[string]string

Views loads all views.

Types

type AJAXGet

type AJAXGet func(*http.Request) ([]byte, error)

func (AJAXGet) ServeHTTP

func (a AJAXGet) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AJAXPost

type AJAXPost func(http.ResponseWriter, *http.Request) error

func (AJAXPost) ServeHTTP

func (a AJAXPost) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Args

type Args map[string]interface{}

Args represents arguments passed to html templates or to template.Execute.

type Downloader

type Downloader func(*http.Request) (path string, err error)

func (Downloader) CreateDownload

func (d Downloader) CreateDownload() Handler

CreateDownload.

type Getter

type Getter func(r *http.Request, c *context.C) (Args, string, error)

func (Getter) CreateGet

func (g Getter) CreateGet(name, view string) Handler

type Handler

type Handler func(http.ResponseWriter, *http.Request, *context.C) error

Handler is used to handle incoming requests. It allows for better session management.

func LoadView

func LoadView(n, v string) Handler

LoadView loads a view so that it is accessible in our web app.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP loads a the current session, handles the request and then stores the session.

type Poster

type Poster func(*http.Request, *context.C) (string, error)

A function used to fullfill a POST request.

func (Poster) CreatePost

func (p Poster) CreatePost(index bool) Handler

CreatePost loads a post request handler.

type Select

type Select struct {
	Id, Name string
	User     bool
}

type Selects

type Selects []*Select

func (Selects) Len

func (s Selects) Len() int

func (Selects) Less

func (s Selects) Less(i, j int) bool

func (Selects) Swap

func (s Selects) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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