Skip to content

Commit

Permalink
pb: move static directory to xdg data resource provided by pbs
Browse files Browse the repository at this point in the history
If no xdg resource exists, fall back to 'static'.
  • Loading branch information
buhman committed May 22, 2017
1 parent 8afd6f1 commit dc04f7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion pb/pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

from flask import Flask, request
from xdg import BaseDirectory

from pb.paste.views import paste
from pb.namespace.views import namespace
Expand Down Expand Up @@ -39,8 +40,16 @@ class App(Flask):
def request_context(self, environ):
return RequestContext(self, environ)


def xdg_static_folder():
for path in BaseDirectory.load_data_paths('pbs'):
return path
return 'static'


def create_app(config_filename='config.yaml'):
app = App(__name__)

app = App(__name__, static_url_path='/static', static_folder=xdg_static_folder())
app.url_map.converters.update(dict(
sid = SIDConverter,
sha1 = SHA1Converter,
Expand Down
4 changes: 2 additions & 2 deletions pb/templates/asciinema.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% extends "layout.html" %}

{% block head %}
<link href="{{ cdn_prefix }}{{ url_for('static', filename='hack/asciinema.css') }}" type="text/css" rel="stylesheet"/>
<link href="{{ cdn_prefix }}{{ url_for('static', filename='css/asciinema.css') }}" type="text/css" rel="stylesheet"/>
{% endblock %}

{% block body %}
<div id="player-container"></div>
<script src="{{ cdn_prefix }}{{ url_for('static', filename='hack/asciinema.js') }}"></script>
<script src="{{ cdn_prefix }}{{ url_for('static', filename='js/asciinema.js') }}"></script>
<script type="text/javascript">
asciinema_player.core.CreatePlayer(
document.getElementById('player-container'),
Expand Down

0 comments on commit dc04f7f

Please sign in to comment.