Skip to content

Commit

Permalink
Attempt to better use blueprints
Browse files Browse the repository at this point in the history
Move templates and static assets to corresponding blueprint package,
fixup a few references (url_for calls).

Leave openid at root (instead of moving to sphinxweb.auth) because
pallets/flask#348 (can't mount blueprint
static files to /static) & it is referred to from the root CSS.

Maybe look into e.g. flask-assets to see if it can handle these cases
correctly and/or CSS concatenation so auth CSS can be in auth
blueprint?

Though can also just load multiple CSS (can blueprint override base to
add CSS? Maybe use blueprint-local base?)
  • Loading branch information
masklinn committed Apr 9, 2013
1 parent 73f441a commit 48df1e6
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sphinxweb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def after_request(response):
db_session.remove()
return response

from sphinxweb.views import docs, auth
from . import docs, auth
app.register_blueprint(docs.docs)
app.register_blueprint(auth.auth)
6 changes: 5 additions & 1 deletion sphinxweb/views/auth.py → sphinxweb/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from sphinxweb import support
from sphinxweb.models import User, db_session

auth = Blueprint('auth', __name__)
auth = Blueprint(
'auth', __name__,
template_folder='templates',
static_folder='static',
static_url_path='/auth/static')

# setup flask-openid
oid = OpenID()
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>Create Profile</h1>
</p>
</form>
<p>
If you don't want to proceed, you can <a href="{{ url_for('auth.logout')
If you don't want to proceed, you can <a href="{{ url_for('.logout')
}}">sign out</a> again.
</p>
{% endblock %}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Sign in with your OpenID</h1>
<p>
{%- for name, icon, url in oid_providers %}
<a href="{{ url }}" class="oid">
<img src="{{ url_for('static', filename='oid/' + icon) }}" alt="{{ name }}" />
<img src="{{ url_for('.static', filename='oid/' + icon) }}" alt="{{ name }}" />
</a>
{%- endfor %}
</p>
Expand Down
2 changes: 1 addition & 1 deletion sphinxweb/views/docs.py → sphinxweb/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from sphinxweb import support

docs = Blueprint('docs', __name__)
docs = Blueprint('docs', __name__, template_folder='templates')

@docs.route('/')
def index():
Expand Down
File renamed without changes.
Empty file removed sphinxweb/views/__init__.py
Empty file.

0 comments on commit 48df1e6

Please sign in to comment.