feat: inherit from wuttaweb templates for home, login pages

This commit is contained in:
Lance Edgar 2024-08-21 00:07:03 -05:00
parent f755460242
commit 71abbe06da
4 changed files with 18 additions and 114 deletions

View file

@ -1,10 +1,7 @@
## -*- coding: utf-8; -*-
<%inherit file="wuttaweb:templates/base_meta.mako" />
<%def name="app_title()">${rattail_app.get_node_title()}</%def>
<%def name="global_title()">${"[STAGE] " if not request.rattail_config.production() else ''}${self.app_title()}</%def>
<%def name="extra_styles()"></%def>
<%def name="app_title()">${app.get_node_title()}</%def>
<%def name="favicon()">
<link rel="icon" type="image/x-icon" href="${request.rattail_config.get('tailbone', 'favicon_url', default=request.static_url('tailbone:static/img/rattail.ico'))}" />
@ -13,9 +10,3 @@
<%def name="header_logo()">
${h.image(request.rattail_config.get('tailbone', 'header_image_url', default=request.static_url('tailbone:static/img/rattail.ico')), "Header Logo", style="height: 49px;")}
</%def>
<%def name="footer()">
<p class="has-text-centered">
powered by ${h.link_to("Rattail", url('about'))}
</p>
</%def>

View file

@ -1,33 +1,7 @@
## -*- coding: utf-8; -*-
<%inherit file="/page.mako" />
<%namespace name="base_meta" file="/base_meta.mako" />
<%def name="title()">Home</%def>
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
.logo {
text-align: center;
}
.logo img {
margin: 3em auto;
max-height: 350px;
max-width: 800px;
}
</style>
</%def>
<%inherit file="wuttaweb:templates/home.mako" />
## DEPRECATED; remains for back-compat
<%def name="render_this_page()">
${self.page_content()}
</%def>
<%def name="page_content()">
<div class="logo">
${h.image(image_url, "{} logo".format(capture(base_meta.app_title)))}
<h1>Welcome to ${base_meta.app_title()}</h1>
</div>
</%def>
${parent.body()}

View file

@ -1,84 +1,17 @@
## -*- coding: utf-8; -*-
<%inherit file="/form.mako" />
<%namespace name="base_meta" file="/base_meta.mako" />
<%def name="title()">Login</%def>
<%inherit file="wuttaweb:templates/auth/login.mako" />
## TODO: this will not be needed with wuttaform
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
.logo img {
display: block;
margin: 3rem auto;
max-height: 350px;
max-width: 800px;
}
/* must force a particular label with, in order to make sure */
/* the username and password inputs are the same size */
.field.is-horizontal .field-label .label {
text-align: left;
width: 6rem;
}
.buttons {
<style>
.card-content .buttons {
justify-content: right;
}
</style>
</%def>
<%def name="logo()">
${h.image(image_url, "{} logo".format(capture(base_meta.app_title)))}
</%def>
<%def name="login_form()">
<div class="form">
${form.render_deform(form_kwargs={'data-ajax': 'false'})|n}
</div>
</%def>
## DEPRECATED; remains for back-compat
<%def name="render_this_page()">
${self.page_content()}
</%def>
<%def name="page_content()">
<div class="logo">
${self.logo()}
</div>
<div class="columns is-centered">
<div class="column is-narrow">
<div class="card">
<div class="card-content">
<tailbone-form></tailbone-form>
</div>
</div>
</div>
</div>
</%def>
<%def name="modify_vue_vars()">
${parent.modify_vue_vars()}
<script>
${form.vue_component}Data.usernameInput = null
${form.vue_component}.mounted = function() {
this.$refs.username.focus()
this.usernameInput = this.$refs.username.$el.querySelector('input')
this.usernameInput.addEventListener('keydown', this.usernameKeydown)
}
${form.vue_component}.beforeDestroy = function() {
this.usernameInput.removeEventListener('keydown', this.usernameKeydown)
}
${form.vue_component}.methods.usernameKeydown = function(event) {
if (event.which == 13) {
event.preventDefault()
this.$refs.password.focus()
}
}
</script>
</%def>

View file

@ -67,9 +67,15 @@ class CommonView(View):
if redirect:
return self.redirect(self.request.route_url('login'))
image_url = self.rattail_config.get(
'tailbone', 'main_image_url',
default=self.request.static_url('tailbone:static/img/home_logo.png'))
image_url = self.config.get('wuttaweb.logo_url')
if not image_url:
image_url = self.config.get('tailbone.main_image_url')
if image_url:
warnings.warn("tailbone.main_image_url setting is deprecated; "
"please set wuttaweb.logo_url instead",
DeprecationWarning)
else:
image_url = self.request.static_url('tailbone:static/img/home_logo.png')
context = {
'image_url': image_url,