Пример #1
0
func InitiateIndex(user common.User, r *http.Request,
	session sessions.Session) (string, int) {

	if !user.IsLoggedIn() {
		return WarningPacket("You are not logged in").Json(),
			http.StatusForbidden
	}

	r.ParseForm()
	if r.FormValue("search") == "" {
		return WarningPacket("Null information").Json(),
			http.StatusBadRequest
	}

	params, err := url.ParseQuery(r.FormValue("search")[1:])
	if err != nil {
		return WarningPacket("Invalid search").Json(),
			http.StatusBadRequest
	}
	src, err := handleSearch(params)
	if err != nil {
		return WarningPacket("Invalid search").Json(),
			http.StatusBadRequest
	}

	if src.Git != nil {
		return IndexGit(src, session)
	}

	return WarningPacket("No source found").Json(),
		http.StatusBadRequest
}
Пример #2
0
Файл: me.go Проект: SemQuery/web
func MePage(user common.User, r render.Render) {
	data := struct {
		Loggedin bool
		Username string
		Repos    []string
		Pagename string
	}{
		Loggedin: user.IsLoggedIn(),
		Username: user.Username(),
		Repos:    user.GetIndexed(),
		Pagename: "me",
	}
	r.HTML(200, "me", data)
}