Permalink
Browse files

updated to 0.7

  • Loading branch information...
Cornu committed Jul 2, 2011
1 parent 18a1b8a commit 5e3b7d44029b3cc660a325314af54d1821b40556
View
@@ -13,8 +13,8 @@
app.config.from_pyfile('../config')
#Module
-app.register_module(auth) # url_prefix='/auth'
-app.register_module(text)
+app.register_blueprint(auth) # url_prefix='/auth'
+app.register_blueprint(text)
oid.init_app(app)
from brain.couchviews import manager
manager.setup(app)
View
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from flask import Module, g, request, session, render_template, flash, redirect, url_for
+from flask import Blueprint, g, request, session, render_template, flash, redirect, url_for
from flaskext.openid import OpenID
from brain.couchviews import *
from brain.helpers import *
-auth = Module(__name__)
+auth = Blueprint('auth', __name__)
oid = OpenID()
@@ -38,15 +38,15 @@ def create_or_login(resp):
session['nickname'] = user['id']
flash(u'Successfully signed in')
return redirect(oid.get_next_url())
- return redirect(url_for('create_profile', next=oid.get_next_url(),
+ return redirect(url_for('.create_profile', next=oid.get_next_url(),
name=resp.fullname, nickname=resp.nickname,
email=resp.email))
@auth.route('/create-profile', methods=['GET', 'POST'])
def create_profile():
# if already logged in or no openid url in session
if g.user is not None or 'openid' not in session:
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
if request.method == 'POST':
name = request.form['name']
email = request.form['email']
@@ -77,7 +77,7 @@ def edit_profile():
g.couch.delete(g.user)
session.pop('openid', None)
flash(u'Profile deleted')
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
form['name'] = request.form['name']
form['email'] = request.form['email']
form['nickname'] = request.form['nickname']
@@ -93,7 +93,7 @@ def edit_profile():
user['email'] = form['email']
user['nickname'] = form['nickname']
g.couch.save(user)
- return redirect(url_for('edit_profile'))
+ return redirect(url_for('.edit_profile'))
return render_template('edit_profile.html', form=form)
@auth.route('/logout')
View
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from flask import Module, render_template, g, request, flash, url_for, \
+from flask import Blueprint, render_template, g, request, flash, url_for, \
redirect, jsonify
from uuid import uuid1
from brain.couchviews import *
from brain.helpers import *
-text = Module(__name__)
+text = Blueprint('text', __name__)
@text.route('/new', methods=['GET', 'POST'])
@login_required
@@ -24,13 +24,13 @@ def new():
document = dict(title=subject, content=text, type=ttype,
user=g.user['nickname'], date=get_date())
g.couch[uuid1().hex] = document # UUID timebased
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
return render_template('new.html')
@text.route('/upload', methods=['GET', 'POST'])
def upload():
if g.user is None:
- return redirect(url_for('login'))
+ return redirect(url_for('.login'))
return render_template('index.html')
@text.route('/view/web')
@@ -52,7 +52,7 @@ def get_doc(doc_id):
def edit_doc(doc_id):
doc = g.couch.get(doc_id)
if doc is None:
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
if request.method == 'POST':
if not request.form['subject']:
flash(u'Error: you have to enter a Subject')
@@ -62,7 +62,7 @@ def edit_doc(doc_id):
doc['content'] = request.form['edit']
doc['type'] = request.form['type']
g.couch.save(doc)
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
return render_template('edit_doc.html', doc=doc)
@text.route('/html')
@@ -78,7 +78,7 @@ def new_html():
document = dict(title=subject, content=text, type=ttype,
user=g.user['nickname'], date=get_date())
g.couch[uuid1().hex] = document # UUID timebased
- return redirect(url_for('index'))
+ return redirect(url_for('.index'))
return render_template('new_html.html')
@text.route('/')
@@ -20,7 +20,7 @@ <h2>Create Profile</h2>
<input type=hidden name=next value="{{ next }}">
</form>
<p>
- If you don't want to proceed, you can <a href="{{ url_for('logout')
+ If you don't want to proceed, you can <a href="{{ url_for('.logout')
}}">sign out</a> again.
</div>
{% endblock %}
@@ -1,6 +1,6 @@
{% extends "layout.html" %}
{% block head %}
-<!-- <script type=text/javascript src="{{ url_for('static', filename='main.js') }}"></script> -->
+<!-- <script type=text/javascript src="{{ url_for('.static', filename='main.js') }}"></script> -->
{% endblock %}
{% block body %}
<div id=center>
@@ -1,6 +1,6 @@
{% extends "layout.html" %}
{% block head %}
-<link rel='stylesheet' type='text/css' href='{{ url_for("static",filename="index.css") }}'>
+<link rel='stylesheet' type='text/css' href='{{ url_for('.static',filename="index.css") }}'>
{% endblock %}
{% block body %}
<!-- <div id=contacts>
@@ -2,19 +2,19 @@
<html>
<head>
<title>{% block title %}Welcome{% endblock %} | Brainedge</title>
-<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/vnd.microsoft.icon">
-<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='layout.css') }}">
+<link rel="icon" href="{{ url_for('.static', filename='favicon.ico') }}" type="image/vnd.microsoft.icon">
+<link rel="stylesheet" type="text/css" href="{{ url_for('.static', filename='layout.css') }}">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
</script>
-<script type="text/javascript" src="{{ url_for('static', filename='main.js') }}"></script>
+<script type="text/javascript" src="{{ url_for('.static', filename='main.js') }}"></script>
{% block head %}{% endblock %}
</head>
<body>
<header>
<a href="{{ url_for('text.index') }}">
- <img id="logo" src="{{ url_for('static', filename='logo.svg') }}" alt></a>
+ <img id="logo" src="{{ url_for('.static', filename='logo.svg') }}" alt></a>
<input id="search" type="search" name="search" size="20" value autofocus>
{% for message in get_flashed_messages() %}
<span class="message">{{ message }}</span>
View
@@ -1,6 +1,6 @@
{% extends "layout.html" %}
{% block head %}
-<!-- <script type=text/javascript src="{{ url_for('static', filename='main.js') }}"></script> -->
+<!-- <script type=text/javascript src="{{ url_for('.static', filename='main.js') }}"></script> -->
{% endblock %}
{% block body %}
<div id=center>
@@ -1,37 +1,37 @@
{% extends "layout.html" %}
{% block head %}
-<script type=text/javascript src="{{ url_for('static', filename='editable.js') }}"></script>
-<link rel='stylesheet' type='text/css' href='{{ url_for('static',filename='new.css') }}'>
+<script type=text/javascript src="{{ url_for('.static', filename='editable.js') }}"></script>
+<link rel='stylesheet' type='text/css' href='{{ url_for('.static',filename='new.css') }}'>
{% endblock %}
{% block body %}
<div id='center'>
<form action="" method=post>
<ul id='controls'>
- <li id='bold' title='Bold'><img src="{{ url_for('static',
+ <li id='bold' title='Bold'><img src="{{ url_for('.static',
filename='icons/format/bold.svg') }}"></li>
- <li id='italic' title='Italic'><img src="{{ url_for('static',
+ <li id='italic' title='Italic'><img src="{{ url_for('.static',
filename='icons/format/italic.svg') }}"></li>
- <li id='line' title='Underline'><img src="{{ url_for('static',
+ <li id='line' title='Underline'><img src="{{ url_for('.static',
filename='icons/format/line.svg') }}"></li>
- <li id='strike' title='Strikethrough'><img src="{{ url_for('static',
+ <li id='strike' title='Strikethrough'><img src="{{ url_for('.static',
filename='icons/format/strike.svg') }}"></li>
- <li id='size' title='Font size'><img src="{{ url_for('static',
+ <li id='size' title='Font size'><img src="{{ url_for('.static',
filename='icons/format/size.svg') }}"></li>
- <li id='heading' title='Paragraph heading'><img src="{{ url_for('static',
+ <li id='heading' title='Paragraph heading'><img src="{{ url_for('.static',
filename='icons/format/head1.svg') }}"></li>
- <li id='nlist' title='Numbered list'><img src="{{ url_for('static',
+ <li id='nlist' title='Numbered list'><img src="{{ url_for('.static',
filename='icons/format/nlist.svg') }}"></li>
- <li id='blist' title='Bulleted list'><img src="{{ url_for('static',
+ <li id='blist' title='Bulleted list'><img src="{{ url_for('.static',
filename='icons/format/blist.svg') }}"></li>
- <li id='iindent' title='Increase Indent'><img src="{{ url_for('static',
+ <li id='iindent' title='Increase Indent'><img src="{{ url_for('.static',
filename='icons/format/iindent.svg') }}"></li>
- <li id='dindent' title='Decrease Indent'><img src="{{ url_for('static',
+ <li id='dindent' title='Decrease Indent'><img src="{{ url_for('.static',
filename='icons/format/dindent.svg') }}"></li>
- <li id='alignl' title='Alignment Left'><img src="{{ url_for('static',
+ <li id='alignl' title='Alignment Left'><img src="{{ url_for('.static',
filename='icons/format/alignl.svg') }}"></li>
- <li id='alignc' title='Alignment Center'><img src="{{ url_for('static',
+ <li id='alignc' title='Alignment Center'><img src="{{ url_for('.static',
filename='icons/format/alignc.svg') }}"></li>
- <li id='alignr' title='Alignment Right'><img src="{{ url_for('static',
+ <li id='alignr' title='Alignment Right'><img src="{{ url_for('.static',
filename='icons/format/alignr.svg') }}"></li>
</ul>
<iframe id='edit'></iframe>
@@ -1,6 +1,6 @@
{% extends "layout.html" %}
{% block head %}
-<!-- <script type=text/javascript src="{{ url_for('static', filename='main.js') }}"></script> -->
+<!-- <script type=text/javascript src="{{ url_for('.static', filename='main.js') }}"></script> -->
{% endblock %}
{% block body %}
<div id=center>

0 comments on commit 5e3b7d4

Please sign in to comment.