Exemplo n.º 1
0
func AlbumHandler(c http.ResponseWriter, r *http.Request) {
	var albumName = r.URL.Path[len("/photos/"):]
	fmt.Printf("Album ID requested: %s\n", albumName)
	var photos = GetPhotos(albumName)
	fmt.Printf("%d Photos\n", len(photos))
	tmpl.Render(c, r, "Photos - "+albumName, "album", &photos)
}
Exemplo n.º 2
0
func EditHandler(c http.ResponseWriter, r *http.Request) {
	if r.Method == "POST" {
		SaveHandler(c, r)
		return
	}
	//p := auth.GetPerms(r)
	//var i tmpl.PageInfo
	//i.Name = "events/edit"
	//i.Title = "Add Event"
	//i.Perms = p
	//i.Request = r

	// Makes the current data available to the template if available
	evEdit := len("/events/edit/")
	title := "Add Event"
	event := new(Event)
	if len(r.URL.Path) > evEdit {
		id := r.URL.Path[evEdit:]
		event.ID = id
		e := event.Load()
		if e != nil {
			fmt.Println(e)
		}
		e = event.LoadPage(r)
		if e != nil {
			fmt.Println(e)
		}
		title = "Edit Event - " + event.Title
	}

	tmpl.Render(c, r, title, "edit", event)
}
Exemplo n.º 3
0
func UploaderHandler(c http.ResponseWriter, r *http.Request) {
	u, _ := user.Get(c, r)
	token := u.Get("picasa-authsub-token")
	fmt.Println("Host:", r.Host)
	albums := GetAlbums()

	data := new(UploaderData)
	data.Albums = albums
	data.PicasaAuthenticated = (token != "")
	// TODO: Make photos use the new login system.

	tmpl.Render(c, r, "Upload Photos", "uploader", data)
}
Exemplo n.º 4
0
func MainHandler(c http.ResponseWriter, r *http.Request) {
	var albums = GetAlbums()
	fmt.Printf("%d Albums\n", len(*albums))
	tmpl.Render(c, r, "Photos", "main", &albums)
}