Exemple #1
0
func mineHandler(w http.ResponseWriter, r *http.Request, s *sessions.Session) error {

	userid := s.Values["userid"].(string)

	projects, err := project.MyList(userid)
	if err != nil {
		return err
	}

	data := map[string]interface{}{
		"BUILD":           gapp.BuildId,
		"projects":        projects,
		"userid":          userid,
		"projectPage":     map[string]bool{"mine": true},
		"title":           "My Projects",
		"keywords":        "my projects, add projects",
		"newcomer":        !project.HasList(userid),
		"myProjectsCount": project.ListCount(userid),
		"jobsCount":       project.JobsCount(userid),
	}

	err = gapp.Templates.ExecuteTemplate(w, "home.html", data)
	if err != nil {
		return err
	}

	return nil
}
Exemple #2
0
func projectHandler(w http.ResponseWriter, r *http.Request, s *sessions.Session) error {
	vars := mux.Vars(r)
	pid := vars["pid"]
	userid := s.Values["userid"].(string)

	p, err := project.Fetch(pid)
	if err != nil {
		return &gapp.HandlerError{Err: err, Message: "Not Found", Code: http.StatusNotFound}
	}

	data := map[string]interface{}{
		"BUILD":           gapp.BuildId,
		"project":         p,
		"userid":          userid,
		"projectPage":     map[string]bool{"detail": true},
		"title":           p.Name,
		"keywords":        "project detail",
		"myProjectsCount": project.ListCount(userid),
		"jobsCount":       project.JobsCount(userid),
	}

	err = gapp.Templates.ExecuteTemplate(w, "project.html", data)
	if err != nil {
		return err
	}

	return nil
}