(app *App, u *User, w http.ResponseWriter, r *http.Request)
| 409 | } |
| 410 | |
| 411 | func handleViewAdminPages(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 412 | p := struct { |
| 413 | *UserPage |
| 414 | *AdminPage |
| 415 | Config config.AppCfg |
| 416 | Message string |
| 417 | |
| 418 | Pages []*instanceContent |
| 419 | }{ |
| 420 | UserPage: NewUserPage(app, r, u, "Pages", nil), |
| 421 | AdminPage: NewAdminPage(app), |
| 422 | Config: app.cfg.App, |
| 423 | Message: r.FormValue("m"), |
| 424 | } |
| 425 | |
| 426 | var err error |
| 427 | p.Pages, err = app.db.GetInstancePages() |
| 428 | if err != nil { |
| 429 | return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get pages: %v", err)} |
| 430 | } |
| 431 | |
| 432 | // Add in default pages |
| 433 | var hasAbout, hasContact, hasPrivacy bool |
| 434 | for i, c := range p.Pages { |
| 435 | if hasAbout && hasContact && hasPrivacy { |
| 436 | break |
| 437 | } |
| 438 | if c.ID == "about" { |
| 439 | hasAbout = true |
| 440 | if !c.Title.Valid { |
| 441 | p.Pages[i].Title = defaultAboutTitle(app.cfg) |
| 442 | } |
| 443 | } else if c.ID == "contact" { |
| 444 | hasContact = true |
| 445 | if !c.Title.Valid { |
| 446 | p.Pages[i].Title = defaultContactTitle() |
| 447 | } |
| 448 | } else if c.ID == "privacy" { |
| 449 | hasPrivacy = true |
| 450 | if !c.Title.Valid { |
| 451 | p.Pages[i].Title = defaultPrivacyTitle() |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | if !hasAbout { |
| 456 | p.Pages = append(p.Pages, &instanceContent{ |
| 457 | ID: "about", |
| 458 | Title: defaultAboutTitle(app.cfg), |
| 459 | Content: defaultAboutPage(app.cfg), |
| 460 | Updated: defaultPageUpdatedTime, |
| 461 | }) |
| 462 | } |
| 463 | if !hasContact { |
| 464 | p.Pages = append(p.Pages, &instanceContent{ |
| 465 | ID: "contact", |
| 466 | Title: defaultContactTitle(), |
| 467 | Content: defaultContactPage(app), |
| 468 | }) |
nothing calls this directly
no test coverage detected