Beispiel #1
0
func handle_project_detail(w http.ResponseWriter, req *http.Request, ctx *Context) {
	path := req.FormValue(":import")
	if path == "" {
		perform_status(w, ctx, http.StatusNotFound)
		return
	}
	max, err := worker.CountWorkFor(ctx.Context, path)
	if err != nil {
		internal_error(w, req, ctx, err)
		return
	}

	p := NewPagination(max, req.URL.Query())
	low, hi := p.Range()

	ws, err := worker.WorkWithImportPathInRange(ctx.Context, path, low, hi)
	if err != nil {
		internal_error(w, req, ctx, err)
		return
	}

	ctx.Set("Work", ws)
	ctx.Set("Pagination", p)
	base_execute(w, ctx, tmpl_root("blocks", "all.block"), tmpl_root("blocks", "recent.block"))
}
Beispiel #2
0
func handle_project_status_image(w http.ResponseWriter, req *http.Request, ctx *Contest) {
	path := req.FormValue(":import")
	if path == "" {
		perform_status(w, ctx, http.StatusNotFound)
		return
	}

	status, ok := worker.GetProjectStatus(path)
	if !ok {
		ws, err := worker.WorkWithImportPathInRange(ctx.Context, path, 0, 0)
		if err != nil {
			internal_error(w, req, ctx, err)
			return
		}
		status = ws[0].Status
		go worker.SetProjectStatus(project, status)
	}

	w.Write(status_images[status])
}