Added snippet admin and profile editing

This commit is contained in:
Armin Ronacher 2010-05-16 13:51:12 +02:00
parent aa79c72ae0
commit d87cbff134
14 changed files with 228 additions and 40 deletions

View file

@ -0,0 +1,31 @@
{% extends "layout.html" %}
{% block head %}
{{ super() }}
<style type=text/css>
h1 { background-image: url(/static/login.png); }
</style>
{% endblock %}
{% block title %}Change OpenID{% endblock %}
{% block body %}
<h2>Change OpenID</h2>
<form action="" method=post>
<p>
You can the OpenID used to log into this website. Right
now your OpenID identity is
<a href="{{ g.user.openid }}">{{ g.user.openid|displayopenid }}</a>
<p>
OpenID URL:
<input type=text name=openid class=openid size=26>
<input type=hidden name=next value="{{ next }}">
<input type=submit value=Change>
<input type=submit name=cancel value=Cancel>
<p>
Alternatively you can directly link your profile with one
of the common id providers:
<ul>
<li><a href=?provider=aol>AOL</a>
<li><a href=?provider=google>Google</a>
<li><a href=?provider=yahoo>Yahoo</a>
</ul>
</form>
{% endblock %}

View file

@ -11,7 +11,8 @@
<form action="{{ url_for('general.first_login') }}" method=post>
<p>
This is your first login on this website. You are about to sign
in with the following OpenID: <a href="{{ openid }}">{{ openid }}</a>
in with the following OpenID: <a href="{{ openid }}">{{
openid|displayopenid }}</a>
<p>
Before you can use this site we need a name for you. This is what
will be displayed next to all of your public contributions to this

View file

@ -7,7 +7,7 @@
{% endblock %}
{% block title %}Login{% endblock %}
{% block body %}
<form action="{{ url_for('general.login') }}" method=post>
<form action="" method=post>
<p>
For some of the features on this site (such as creating snippets
or adding comments) you have to be signed in. You don't need to
@ -18,5 +18,13 @@
<input type=text name=openid class=openid size=30>
<input type=hidden name=next value="{{ next }}">
<input type=submit value=Login>
<p>
Alternatively you can directly sign in by clicking on one of
the providers here in case you don't know the identity URL:
<ul>
<li><a href=?provider=aol>AOL</a>
<li><a href=?provider=google>Google</a>
<li><a href=?provider=yahoo>Yahoo</a>
</ul>
</form>
{% endblock %}

View file

@ -0,0 +1,27 @@
{% extends "layout.html" %}
{% block head %}
{{ super() }}
<style type=text/css>
h1 { background-image: url(/static/login.png); }
</style>
{% endblock %}
{% block title %}Profile{% endblock %}
{% block body %}
<form action="" method=post>
<p>
Here you can change the profile information used for this
website. Please keep in mind that you can only have one
OpenID identity linked to this account, if you change it
the old one will no longer be able to sign in.
<dl class=formlist>
<dt>Name:
<dd><input type=text name=name value="{{ name }}" size=30>
<dt>OpenID:
<dd>
<span class=disabled>{{ g.user.openid|displayopenid }}</span>
(<a href="{{ url_for('change_openid') }}">change</a>)
</dl>
<p>
<input type=submit value="Update profile">
</form>
{% endblock %}

View file

@ -2,7 +2,7 @@
{% block head %}
<title>{% block title %}Welcome{% endblock %} | Flask (A Python Microframework)</title>
<meta charset=utf-8>
<link rel=stylesheet type=text/css href="/static/style.css">
<link rel=stylesheet type=text/css href="{{ url_for('.static', filename='style.css') }}">
<script type=text/javascript
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
{% endblock %}
@ -11,11 +11,11 @@
<h1><span>{{ self.title() }}</span></h1>
{% endblock %}
<p class=nav>
<a href=/>overview</a> //
<a href=/docs/>documentation</a> //
<a href=/mailinglist/>mailinglist</a> //
<a href=/snippets/>snippets</a> //
<a href=/extensions/>extensions</a>
<a href="{{ url_for('general.index') }}">overview</a> //
<a href="{{ url_for('documentation.index') }}">documentation</a> //
<a href="{{ url_for('mailinglist.index') }}">mailinglist</a> //
<a href="{{ url_for('snippets.index') }}">snippets</a> //
<a href="{{ url_for('extensions.index') }}">extensions</a>
{% for message in get_flashed_messages() %}
<p class=message>{{ message }}
{% endfor %}
@ -23,8 +23,11 @@
<p class=footer>
&copy; Copyright 2010 by <a href=http://lucumr.pocoo.org/>Armin Ronacher</a> //
{% if g.user %}
<a href=/logout/ title="logged in as {{ g.user.name }} [{{ g.user.openid }}]">logout</a>
<a href="{{ url_for('general.profile') }}">profile</a> /
<a href="{{ url_for('general.logout') }}" title="signed in as {{
g.user.name }} [{{ g.user.openid }}]{% if g.user.is_admin
%} - Administrator{% endif %}">sign out</a>
{% else %}
<a href=/login/>login</a>
<a href="{{ url_for('general.login') }}">sign in</a>
{% endif %}
</div>

View file

@ -0,0 +1,22 @@
{% extends "snippets/layout.html" %}
{% block title %}Edit Comment {{ comment.title }}{% endblock %}
{% block body %}
<h2>Edit Comment</h2>
<script type=text/javascript>
$(function() {
$('input[name="delete"]').click(function() {
if (!confirm("Do you really want to delete this comment?\n\n" +
"THIS CANNOT BE UNDONE!"))
return false;
});
});
</script>
<form action="" method=post>
<p>Title: <input type=text name=title value="{{ form.title }}" size=30>
<p><textarea name=text cols=40 rows=8>{{ form.text }}</textarea>
<p>
<input type=submit value="Update Comment">
<input type=submit name=delete value="Delete">
<input type=submit name=cancel value="Cancel">
</form>
{% endblock %}

View file

@ -8,7 +8,9 @@
<p>
You're signed in as “<span title="{{ g.user.openid }}">{{ g.user.name
}}</span>”. You can <a href="{{ url_for('general.logout')
}}">sign out</a> here after you're done if you want.
}}">sign out</a> here after you're done if you want. If you want to
change your OpenID login or display name, head over to the
<a href="{{ url_for('general.profile') }}">profile</a>.
{% else %}
<p>
In order to add snippets to this page or to add comments, all you need
@ -24,10 +26,6 @@
<li><a href="{{ category.url }}">{{ category.name }}</a> ({{ category.count }})
{% endfor %}
</ul>
{% if g.user.is_admin %}
<p>
<a href="{{ url_for('manage_categories') }}">manage categories</a>
{% endif %}
{% if recent %}
<h2>Recently Added</h2>
<ul>
@ -37,4 +35,10 @@
{% endfor %}
</ul>
{% endif %}
{% if g.user.is_admin %}
<h2>Admin Tools</h2>
<ul>
<li><a href="{{ url_for('manage_categories') }}">Manage categories</a>
</ul>
{% endif %}
{% endblock %}

View file

@ -17,7 +17,7 @@
with <code>#!python</code>, <code>#!html+jinja</code> or any other
<a href="http://pygments.org/docs/lexers">Pygments lexer name</a>.
<form action="" method=post>
<dl>
<dl class=formlist>
<dt>Title:
<dd><input type=text name=title value="{{ request.form.title }}" size=40>
<dt>Category:

View file

@ -9,7 +9,7 @@
<p class=snippet-author>By {{ snippet.author.name }}
filed in <a href="{{ snippet.category.url }}">{{ snippet.category.name }}</a>
{% if snippet.author == g.user or g.user.is_admin %}
(<a href="{{ url_for('snippets.edit', id=snippet.id) }}">edit</a>)
(<a href="{{ url_for('edit', id=snippet.id) }}">edit</a>)
{% endif %}
{{ snippet.rendered_body }}
{% if snippet.comments or g.user %}
@ -23,14 +23,17 @@
{{ comment.title or "Comment" }}
by {{ comment.author.name }}
on {{ comment.pub_date.strftime('%Y-%m-%d @ %H:%M') }}
{% if g.user.is_admin %}
(<a href="{{ url_for('edit_comment', id=comment.id) }}">edit</a>)
{% endif %}
<div class=body>{{ comment.rendered_text }}</div></li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% if g.user %}
<div id=add-comment>
<h2>Add Comment</h2>
<form action=#add-comment method=post>
<form action="" method=post>
<p>Title: <input type=text name=title value="{{ request.form.title }}" size=30>
<p><textarea name=text cols=40 rows=8>{{ request.form.text }}</textarea>
<p><input type=submit value="Add Comment">