MCPcopy Index your code
hub / github.com/writefreely/writefreely / handleViewLanding

Function handleViewLanding

app.go:263–307  ·  view source on GitHub ↗
(app *App, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

261}
262
263func handleViewLanding(app *App, w http.ResponseWriter, r *http.Request) error {
264 forceLanding := r.FormValue("landing") == "1"
265
266 p := struct {
267 page.StaticPage
268 *OAuthButtons
269 Flashes []template.HTML
270 Banner template.HTML
271 Content template.HTML
272
273 ForcedLanding bool
274 }{
275 StaticPage: pageForReq(app, r),
276 OAuthButtons: NewOAuthButtons(app.Config()),
277 ForcedLanding: forceLanding,
278 }
279
280 banner, err := getLandingBanner(app)
281 if err != nil {
282 log.Error("unable to get landing banner: %v", err)
283 return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get banner: %v", err)}
284 }
285 p.Banner = template.HTML(applyMarkdown([]byte(banner.Content), "", app.cfg))
286
287 content, err := getLandingBody(app)
288 if err != nil {
289 log.Error("unable to get landing content: %v", err)
290 return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get content: %v", err)}
291 }
292 p.Content = template.HTML(applyMarkdown([]byte(content.Content), "", app.cfg))
293
294 // Get error messages
295 session, err := app.sessionStore.Get(r, cookieName)
296 if err != nil {
297 // Ignore this
298 log.Error("Unable to get session in handleViewHome; ignoring: %v", err)
299 }
300 flashes, _ := getSessionFlashes(app, w, r, session)
301 for _, flash := range flashes {
302 p.Flashes = append(p.Flashes, template.HTML(flash))
303 }
304
305 // Show landing page
306 return renderPage(w, "landing.tmpl", p)
307}
308
309func handleTemplatedPage(app *App, w http.ResponseWriter, r *http.Request, t *template.Template) error {
310 p := struct {

Callers 1

handleViewHomeFunction · 0.85

Calls 8

pageForReqFunction · 0.85
NewOAuthButtonsFunction · 0.85
getLandingBannerFunction · 0.85
applyMarkdownFunction · 0.85
getLandingBodyFunction · 0.85
getSessionFlashesFunction · 0.85
renderPageFunction · 0.85
ConfigMethod · 0.65

Tested by

no test coverage detected