use template hooks instead of hardcoding in templates
This commit is contained in:
parent
d66f79031e
commit
fea0b3b289
@ -71,11 +71,6 @@ def append_to_global_context(context):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def add_to_form_context(context):
|
|
||||||
context['pass_auth_link'] = True
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
hooks = {
|
hooks = {
|
||||||
'setup': setup_plugin,
|
'setup': setup_plugin,
|
||||||
'authentication': auth,
|
'authentication': auth,
|
||||||
@ -87,8 +82,4 @@ hooks = {
|
|||||||
'auth_check_password': check_password,
|
'auth_check_password': check_password,
|
||||||
'auth_fake_login_attempt': auth_tools.fake_login_attempt,
|
'auth_fake_login_attempt': auth_tools.fake_login_attempt,
|
||||||
'template_global_context': append_to_global_context,
|
'template_global_context': append_to_global_context,
|
||||||
('mediagoblin.plugins.openid.register',
|
|
||||||
'mediagoblin/auth/register.html'): add_to_form_context,
|
|
||||||
('mediagoblin.plugins.openid.finish_login',
|
|
||||||
'mediagoblin/auth/register.html'): add_to_form_context,
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,11 @@ def setup_plugin():
|
|||||||
pluginapi.register_routes(routes)
|
pluginapi.register_routes(routes)
|
||||||
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
||||||
|
|
||||||
|
pluginapi.register_template_hooks(
|
||||||
|
{'openid_register_link': 'mediagoblin/plugins/openid/register_link.html',
|
||||||
|
'openid_login_link': 'mediagoblin/plugins/openid/login_link.html',
|
||||||
|
'openid_edit_link': 'mediagoblin/plugins/openid/edit_link.html'})
|
||||||
|
|
||||||
|
|
||||||
def create_user(register_form):
|
def create_user(register_form):
|
||||||
if 'openid' in register_form:
|
if 'openid' in register_form:
|
||||||
@ -115,8 +120,4 @@ hooks = {
|
|||||||
'auth_no_pass_redirect': no_pass_redirect,
|
'auth_no_pass_redirect': no_pass_redirect,
|
||||||
('mediagoblin.auth.register',
|
('mediagoblin.auth.register',
|
||||||
'mediagoblin/auth/register.html'): add_to_form_context,
|
'mediagoblin/auth/register.html'): add_to_form_context,
|
||||||
('mediagoblin.auth.login',
|
|
||||||
'mediagoblin/auth/login.html'): add_to_form_context,
|
|
||||||
('mediagoblin.edit.account',
|
|
||||||
'mediagoblin/edit/edit_account.html'): add_to_form_context,
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
{#
|
||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block openid_edit_link %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ request.urlgen('mediagoblin.plugins.openid.edit') }}">
|
||||||
|
{% trans %}Edit your OpenID's{% endtrans %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,25 @@
|
|||||||
|
{#
|
||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block openid_login_link %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ request.urlgen('mediagoblin.plugins.openid.login') }}?{{ request.query_string }}">
|
||||||
|
{%- trans %}Or login with OpenID!{% endtrans %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,27 @@
|
|||||||
|
{#
|
||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block openid_register_link %}
|
||||||
|
{% if openid_link is defined %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ request.urlgen('mediagoblin.plugins.openid.login') }}">
|
||||||
|
{%- trans %}Or register with OpenID!{% endtrans %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -46,13 +46,7 @@
|
|||||||
{%- trans %}Create one here!{% endtrans %}</a>
|
{%- trans %}Create one here!{% endtrans %}</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if openid_link is defined %}
|
{% template_hook("openid_login_link") %}
|
||||||
<p>
|
|
||||||
<a href="{{ request.urlgen('mediagoblin.plugins.openid.login') }}?{{ request.query_string }}">
|
|
||||||
{%- trans %}Or login with OpenID!{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{{ wtforms_util.render_divs(login_form, True) }}
|
{{ wtforms_util.render_divs(login_form, True) }}
|
||||||
{% if pass_auth %}
|
{% if pass_auth %}
|
||||||
<p>
|
<p>
|
||||||
|
@ -34,19 +34,7 @@
|
|||||||
method="POST" enctype="multipart/form-data">
|
method="POST" enctype="multipart/form-data">
|
||||||
<div class="form_box">
|
<div class="form_box">
|
||||||
<h1>{% trans %}Create an account!{% endtrans %}</h1>
|
<h1>{% trans %}Create an account!{% endtrans %}</h1>
|
||||||
{% if openid_link is defined %}
|
{% template_hook("openid_register_link") %}
|
||||||
<p>
|
|
||||||
<a href="{{ request.urlgen('mediagoblin.plugins.openid.register') }}">
|
|
||||||
{%- trans %}Or register with OpenID!{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
{% elif pass_auth_link is defined %}
|
|
||||||
<p>
|
|
||||||
<a href="{{ request.urlgen('mediagoblin.auth.register') }}">
|
|
||||||
{%- trans %}Or register with a password!{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{{ wtforms_util.render_divs(register_form, True) }}
|
{{ wtforms_util.render_divs(register_form, True) }}
|
||||||
{{ csrf_token }}
|
{{ csrf_token }}
|
||||||
<div class="form_submit_buttons">
|
<div class="form_submit_buttons">
|
||||||
|
@ -48,13 +48,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if openid_link is defined %}
|
{% template_hook("openid_edit_link") %}
|
||||||
<p>
|
|
||||||
<a href="{{ request.urlgen('mediagoblin.plugins.openid.edit') }}">
|
|
||||||
{% trans %}Edit your OpenID's{% endtrans %}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{{ wtforms_util.render_divs(form, True) }}
|
{{ wtforms_util.render_divs(form, True) }}
|
||||||
<div class="form_submit_buttons">
|
<div class="form_submit_buttons">
|
||||||
<input type="submit" value="{% trans %}Save changes{% endtrans %}" class="button_form" />
|
<input type="submit" value="{% trans %}Save changes{% endtrans %}" class="button_form" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user