func EventHandler(c http.ResponseWriter, r *http.Request) { //var p tmpl.PageInfo //p.Name = "events/event" //p.Perms = auth.GetPerms(r) //p.Request = r id := r.URL.Path[len("/events/"):] fmt.Println(id) if len(id) == 0 { MainHandler(c, r) return } var event Event event.ID = id e := event.Load() if e != nil { //p.Name = "errors/500" fmt.Println(e) } e = event.LoadPage(r) if e != nil { //p.Name = "errors/500" fmt.Println(e) } //p.Title = event.Title //p.Object = event tmpl.Render(c, r, "Events - "+event.Title, "event", event) }
func EditHandler(c http.ResponseWriter, r *http.Request) { if r.Method == "POST" { SaveHandler(c, r) return } // 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) }
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) }
func (ps *PageServer) Display(c http.ResponseWriter, r *http.Request) { page, err := ps.Manager.Load(r.URL.Path[len(ps.Prefix):]) if err != nil { template.Error404(c, r, err) return } template.Render(c, r, page.Title, "page", page) }
func (ps *PageServer) List(c http.ResponseWriter, r *http.Request) { plist, err := ps.Manager.List() if err != nil { template.Error500(c, r, err) return } template.Render(c, r, ps.PageAlias, "main", plist) return }
func UploaderHandler(c http.ResponseWriter, r *http.Request) { u, _ := user.Get(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) }
func (ps *PageServer) Edit(c http.ResponseWriter, r *http.Request) { if len(r.URL.Path) < len(ps.Prefix)+len("/edit") { template.Error404(c, r, nil) return } name := r.URL.Path[len(ps.Prefix) : len(r.URL.Path)-len("/edit")] page, err := ps.Manager.Load(name) if err != nil { template.Error500(c, r, err) return } template.Render(c, r, "Editing "+page.Title, "edit", page) }
func MainHandler(c http.ResponseWriter, r *http.Request) { var obj EventsObj events := getEvents() // TODO: This is a bit slow, i imagine. eventarray := make(EventArray, len(events)) i := 0 for _, event := range events { eventarray[i] = event i++ } sort.Sort(eventarray) obj.Events = eventarray obj.Filler = filler(events) // var p tmpl.PageInfo // p.Name = "events/main" // p.Title = "Events" // p.Object = obj // p.Request = r // p.Perms = auth.GetPerms(r) // tmpl.Execute(c, &p) tmpl.Render(c, r, "Events", "main", obj) }
func (ps *PageServer) Add(c http.ResponseWriter, r *http.Request) { var page Page page.Title = "[New " + ps.PageAlias + "]" template.Render(c, r, "Add New "+ps.PageAlias, "edit", page) }
func Handler(c http.ResponseWriter, r *http.Request) { template.Render(c, r, "Main", "main", nil) }
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) }