Support ?landing=1 to always show landing page

This supports admins previewing changes to the landing page.

Ref T565
pull/131/head
Matt Baer 5 years ago
parent 6fdc343986
commit aedb05080c
  1. 23
      app.go
  2. 8
      pages/landing.tmpl

@ -186,21 +186,28 @@ func handleViewHome(app *App, w http.ResponseWriter, r *http.Request) error {
} }
// Multi-user instance // Multi-user instance
u := getUserSession(app, r) forceLanding := r.FormValue("landing") == "1"
if u != nil { if !forceLanding {
// User is logged in, so show the Pad // Show correct page based on user auth status and configured landing path
return handleViewPad(app, w, r) u := getUserSession(app, r)
} if u != nil {
// User is logged in, so show the Pad
return handleViewPad(app, w, r)
}
if land := app.cfg.App.LandingPath(); land != "/" { if land := app.cfg.App.LandingPath(); land != "/" {
return impart.HTTPError{http.StatusFound, land} return impart.HTTPError{http.StatusFound, land}
}
} }
p := struct { p := struct {
page.StaticPage page.StaticPage
Flashes []template.HTML Flashes []template.HTML
ForcedLanding bool
}{ }{
StaticPage: pageForReq(app, r), StaticPage: pageForReq(app, r),
ForcedLanding: forceLanding,
} }
// Get error messages // Get error messages

@ -76,20 +76,20 @@ form dd {
<label> <label>
<dt>Username</dt> <dt>Username</dt>
<dd> <dd>
<input type="text" id="alias" name="alias" style="width: 100%; box-sizing: border-box;" tabindex="1" autofocus /> <input type="text" id="alias" name="alias" style="width: 100%; box-sizing: border-box;" tabindex="1" autofocus {{if .ForcedLanding}}disabled{{end}} />
{{if .Federation}}<p id="alias-site" class="demo">@<strong>your-username</strong>@{{.FriendlyHost}}</p>{{else}}<p id="alias-site" class="demo">{{.FriendlyHost}}/<strong>your-username</strong></p>{{end}} {{if .Federation}}<p id="alias-site" class="demo">@<strong>your-username</strong>@{{.FriendlyHost}}</p>{{else}}<p id="alias-site" class="demo">{{.FriendlyHost}}/<strong>your-username</strong></p>{{end}}
</dd> </dd>
</label> </label>
<label> <label>
<dt>Password</dt> <dt>Password</dt>
<dd><input type="password" id="password" name="pass" autocomplete="new-password" placeholder="" tabindex="2" style="width: 100%; box-sizing: border-box;" /></dd> <dd><input type="password" id="password" name="pass" autocomplete="new-password" placeholder="" tabindex="2" style="width: 100%; box-sizing: border-box;" {{if .ForcedLanding}}disabled{{end}} /></dd>
</label> </label>
<label> <label>
<dt>Email (optional)</dt> <dt>Email (optional)</dt>
<dd><input type="email" name="email" id="email" style="letter-spacing: 1px; width: 100%; box-sizing: border-box;" placeholder="me@example.com" tabindex="3" /></dd> <dd><input type="email" name="email" id="email" style="letter-spacing: 1px; width: 100%; box-sizing: border-box;" placeholder="me@example.com" tabindex="3" {{if .ForcedLanding}}disabled{{end}} /></dd>
</label> </label>
<dt> <dt>
<button id="btn-create" type="submit" style="margin-top: 0">Create blog</button> <button id="btn-create" type="submit" style="margin-top: 0" {{if .ForcedLanding}}disabled{{end}}>Create blog</button>
</dt> </dt>
</dl> </dl>
</form> </form>

Loading…
Cancel
Save