some live bugfixes
This commit is contained in:
parent
24abdc076e
commit
398dd39929
8 changed files with 71 additions and 37 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ celerybeat-schedule*
|
|||
config.py
|
||||
venv
|
||||
*.egg-info
|
||||
*.pyc
|
|
@ -109,7 +109,7 @@ class Feed(db.Model):
|
|||
last_pinged = db.Column(db.DateTime)
|
||||
|
||||
def get_feed_code(self):
|
||||
return binascii.hexlify(self.feed.encode())
|
||||
return self.feed # binascii.hexlify(self.feed.encode())
|
||||
|
||||
def get_or_create_push_secret(self):
|
||||
if not self.push_secret:
|
||||
|
|
|
@ -19,8 +19,8 @@ import sys
|
|||
import time
|
||||
import urllib.parse
|
||||
|
||||
config = FlaskConfig('/home/kmahan/projects/woodwind')
|
||||
config.from_pyfile('/home/kmahan/projects/woodwind.cfg')
|
||||
config = FlaskConfig('/srv/www/kylewm.com/woodwind')
|
||||
config.from_pyfile('woodwind.cfg')
|
||||
|
||||
# normal update interval for polling feeds
|
||||
UPDATE_INTERVAL = datetime.timedelta(hours=1)
|
||||
|
@ -38,8 +38,6 @@ VIDEO_ENCLOSURE_TMPL = '<p><video class="u-video" src="{href}" controls '\
|
|||
'preload=none ><a href="{href}">video</a></video></p>'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||
|
||||
engine = sqlalchemy.create_engine(config['SQLALCHEMY_DATABASE_URI'])
|
||||
|
||||
|
@ -118,7 +116,9 @@ def update_feed(feed_id, content=None, is_polling=True):
|
|||
for entry in result:
|
||||
old = session.query(Entry)\
|
||||
.filter(Entry.feed == feed)\
|
||||
.filter(Entry.uid == entry.uid).first()
|
||||
.filter(Entry.uid == entry.uid)\
|
||||
.order_by(Entry.id.desc())\
|
||||
.first()
|
||||
# have we seen this post before
|
||||
if not old or not is_content_equal(old, entry):
|
||||
# set a default value for published if none is provided
|
||||
|
@ -324,12 +324,12 @@ def process_xml_feed_for_new_entries(session, feed, content, backfill, now):
|
|||
for link in p_entry.get('links', []):
|
||||
if link.type == 'audio/mpeg':
|
||||
audio = AUDIO_ENCLOSURE_TMPL.format(href=link.get('href'))
|
||||
content = audio + (content or '')
|
||||
content = (content or '') + audio
|
||||
if (link.type == 'video/x-m4v'
|
||||
or link.type == 'video/x-mp4'
|
||||
or link.type == 'video/mp4'):
|
||||
video = VIDEO_ENCLOSURE_TMPL.format(href=link.get('href'))
|
||||
content = video + (content or '')
|
||||
content = (content or '') + video
|
||||
|
||||
entry = Entry(
|
||||
published=published,
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
{{ entry.author_name }} -
|
||||
{% endif %}
|
||||
{% if entry.feed %}
|
||||
<a href="{{ url_for('.index', feed=entry.feed.get_feed_code()) }}">
|
||||
{{ entry.feed.name }}
|
||||
</a>
|
||||
<a href="{{ entry.feed.origin }}">{{ entry.feed.name }}</a>
|
||||
<span style="font-size: 0.8em; float: right;">
|
||||
<a href="{{ url_for('.index', feed=entry.feed.get_feed_code()) }}">more from this feed</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
</header>
|
||||
{% if entry.title %}
|
||||
|
@ -49,6 +50,7 @@
|
|||
|
||||
<footer>
|
||||
<a href="{{ entry.permalink }}">{{ entry.published | relative_time }}</a>
|
||||
<a href="{{ url_for('.index', entry=entry.permalink) }}" target="_blank">⇗</a>
|
||||
|
||||
{% if entry._syndicated_copies %}
|
||||
(also on{% for copy in entry._syndicated_copies %} <a href="{{ copy.permalink }}">{{ copy.permalink | domain_for_url }}</a>{% endfor %})
|
||||
|
|
|
@ -63,5 +63,6 @@
|
|||
<main>
|
||||
{% block body %}{% endblock %}
|
||||
</main>
|
||||
{% block foot %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
{% include '_entry.jinja2' with context %}
|
||||
{% endfor %}
|
||||
|
||||
{% if entries %}
|
||||
{% if entries and has_older %}
|
||||
<div class="pager">
|
||||
<a id="older-link" href="{{ url_for_other_page(page=page+1) }}">Older</a>
|
||||
</div>
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
|
||||
{% block body %}
|
||||
<p>
|
||||
<form style="display:inline;"
|
||||
action="{{ url_for('.update_all') }}" method="POST">
|
||||
<button type="submit">Update All</button>
|
||||
<form action="{{ url_for('.update_all') }}" method="POST">
|
||||
<button type="submit">Poll All</button>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
|
@ -22,28 +21,30 @@
|
|||
<a href="{{ url_for('.index', feed=feed.get_feed_code()) }}">View only posts from this feed</a>
|
||||
</div>
|
||||
|
||||
<form style="display:inline"
|
||||
action="{{ url_for('.edit_feed') }}" method="POST">
|
||||
<form action="{{ url_for('.edit_feed') }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ feed.id }}"/>
|
||||
<label>Name</label>
|
||||
<input type="text" name="name" value="{{ feed.name }}"/>
|
||||
<label>URL</label>
|
||||
<input type="text" name="feed" value="{{ feed.feed }}"/>
|
||||
<button type="submit">Save</button>
|
||||
<button type="submit">Save Edits</button>
|
||||
</form>
|
||||
<form style="display:inline;"
|
||||
action="{{ url_for('.update_feed') }}" method="POST">
|
||||
|
||||
<form action="{{ url_for('.update_feed') }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ feed.id }}"/>
|
||||
<button type="submit">Update</button>
|
||||
<button type="submit">Poll Now</button>
|
||||
</form>
|
||||
<form style="display:inline;"
|
||||
action="{{ url_for('.unsubscribe_feed') }}" method="POST">
|
||||
|
||||
<form action="{{ url_for('.unsubscribe_feed') }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ feed.id }}"/>
|
||||
<button type="submit">Unsubscribe</button>
|
||||
</form>
|
||||
|
||||
<div class="feed-details">
|
||||
<h4>Details</h4>
|
||||
|
||||
<a class="show-details" data-target="details-{{loop.index}}" href="#">Show Details</a>
|
||||
|
||||
<div class="feed-details" id="details-{{loop.index}}">
|
||||
<strong>Details</strong>
|
||||
<ul>
|
||||
<li>Last checked: {{feed.last_checked | relative_time}}</li>
|
||||
<li>Last updated: {{feed.last_updated | relative_time}}</li>
|
||||
|
@ -58,3 +59,20 @@
|
|||
{% endfor %}
|
||||
|
||||
{% endblock body %}
|
||||
{% block foot %}
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
$(".feed-details").css({display: "none"});
|
||||
|
||||
$(".show-details").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
var target = $(this).data("target");
|
||||
$("#" + target).css({display: "inherit"});
|
||||
$(this).css({display: "none"});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock foot %}
|
||||
|
|
|
@ -23,6 +23,7 @@ def index():
|
|||
page = int(flask.request.args.get('page', 1))
|
||||
entries = []
|
||||
ws_topic = None
|
||||
has_older = True
|
||||
|
||||
if flask_login.current_user.is_authenticated():
|
||||
per_page = flask.current_app.config.get('PER_PAGE', 30)
|
||||
|
@ -36,24 +37,35 @@ def index():
|
|||
.join(Feed.users)\
|
||||
.filter(User.id == flask_login.current_user.id)
|
||||
|
||||
if 'feed' in flask.request.args:
|
||||
feed_hex = flask.request.args.get('feed').encode()
|
||||
feed_url = binascii.unhexlify(feed_hex).decode('utf-8')
|
||||
feed = Feed.query.filter_by(feed=feed_url).first()
|
||||
if not feed:
|
||||
if 'entry' in flask.request.args:
|
||||
entry_url = flask.request.args.get('entry')
|
||||
entry = Entry.query.filter_by(permalink=entry_url)\
|
||||
.order_by(Entry.retrieved.desc())\
|
||||
.first()
|
||||
if not entry:
|
||||
flask.abort(404)
|
||||
entry_query = entry_query.filter(Feed.feed == feed_url)
|
||||
ws_topic = 'feed:{}'.format(feed.id)
|
||||
entries = [entry]
|
||||
has_older = False
|
||||
else:
|
||||
ws_topic = 'user:{}'.format(flask_login.current_user.id)
|
||||
if 'feed' in flask.request.args:
|
||||
#feed_hex = flask.request.args.get('feed').encode()
|
||||
#feed_url = binascii.unhexlify(feed_hex).decode('utf-8')
|
||||
feed_url = flask.request.args.get('feed')
|
||||
feed = Feed.query.filter_by(feed=feed_url).first()
|
||||
if not feed:
|
||||
flask.abort(404)
|
||||
entry_query = entry_query.filter(Feed.feed == feed_url)
|
||||
ws_topic = 'feed:{}'.format(feed.id)
|
||||
else:
|
||||
ws_topic = 'user:{}'.format(flask_login.current_user.id)
|
||||
|
||||
entries = entry_query.order_by(Entry.retrieved.desc(),
|
||||
Entry.published.desc())\
|
||||
.offset(offset).limit(per_page).all()
|
||||
entries = entry_query.order_by(Entry.retrieved.desc(),
|
||||
Entry.published.desc())\
|
||||
.offset(offset).limit(per_page).all()
|
||||
|
||||
entries = dedupe_copies(entries)
|
||||
return flask.render_template('feed.jinja2', entries=entries, page=page,
|
||||
ws_topic=ws_topic)
|
||||
ws_topic=ws_topic, has_older=has_older)
|
||||
|
||||
|
||||
@views.route('/install')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue