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

Function handleViewHome

app.go:226–261  ·  view source on GitHub ↗

handleViewHome shows page at root path. It checks the configuration and authentication state to show the correct page.

(app *App, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

224// handleViewHome shows page at root path. It checks the configuration and
225// authentication state to show the correct page.
226func handleViewHome(app *App, w http.ResponseWriter, r *http.Request) error {
227 if app.cfg.App.SingleUser {
228 // Render blog index
229 return handleViewCollection(app, w, r)
230 }
231
232 // Multi-user instance
233 forceLanding := r.FormValue("landing") == "1"
234 if !forceLanding {
235 // Show correct page based on user auth status and configured landing path
236 u := getUserSession(app, r)
237
238 if app.cfg.App.Chorus {
239 // This instance is focused on reading, so show Reader on home route if not
240 // private or a private-instance user is logged in.
241 if !app.cfg.App.Private || u != nil {
242 return viewLocalTimeline(app, w, r)
243 }
244 }
245
246 if u != nil {
247 // User is logged in, so show the Pad
248 return handleViewPad(app, w, r)
249 }
250
251 if app.cfg.App.Private {
252 return viewLogin(app, w, r)
253 }
254
255 if land := app.cfg.App.LandingPath(); land != "/" {
256 return impart.HTTPError{http.StatusFound, land}
257 }
258 }
259
260 return handleViewLanding(app, w, r)
261}
262
263func handleViewLanding(app *App, w http.ResponseWriter, r *http.Request) error {
264 forceLanding := r.FormValue("landing") == "1"

Callers

nothing calls this directly

Calls 7

handleViewCollectionFunction · 0.85
getUserSessionFunction · 0.85
viewLocalTimelineFunction · 0.85
handleViewPadFunction · 0.85
viewLoginFunction · 0.85
handleViewLandingFunction · 0.85
LandingPathMethod · 0.80

Tested by

no test coverage detected