added support for dt-deleted posts, hide them from the stream
This commit is contained in:
parent
6c26ff1b3c
commit
81af42f1a2
4 changed files with 23 additions and 17 deletions
|
@ -17,8 +17,8 @@ idna==2.1
|
||||||
itsdangerous==0.24
|
itsdangerous==0.24
|
||||||
Jinja2==2.8
|
Jinja2==2.8
|
||||||
MarkupSafe==0.23
|
MarkupSafe==0.23
|
||||||
mf2py==1.0.4
|
mf2py==1.0.5
|
||||||
mf2util==0.4.1
|
mf2util==0.4.2
|
||||||
psycopg2==2.6.1
|
psycopg2==2.6.1
|
||||||
pyasn1==0.1.9
|
pyasn1==0.1.9
|
||||||
pycparser==2.14
|
pycparser==2.14
|
||||||
|
|
|
@ -115,6 +115,7 @@ class Entry(db.Model):
|
||||||
feed = db.relationship(Feed, backref='entries')
|
feed = db.relationship(Feed, backref='entries')
|
||||||
published = db.Column(db.DateTime)
|
published = db.Column(db.DateTime)
|
||||||
updated = db.Column(db.DateTime)
|
updated = db.Column(db.DateTime)
|
||||||
|
deleted = db.Column(db.DateTime)
|
||||||
retrieved = db.Column(db.DateTime, index=True)
|
retrieved = db.Column(db.DateTime, index=True)
|
||||||
uid = db.Column(db.String(512))
|
uid = db.Column(db.String(512))
|
||||||
permalink = db.Column(db.String(512), index=True)
|
permalink = db.Column(db.String(512), index=True)
|
||||||
|
|
|
@ -471,6 +471,18 @@ def process_html_feed_for_new_entries(feed, content, backfill, now):
|
||||||
|
|
||||||
|
|
||||||
def hentry_to_entry(hentry, feed, backfill, now):
|
def hentry_to_entry(hentry, feed, backfill, now):
|
||||||
|
def normalize_datetime(dt):
|
||||||
|
if (dt and hasattr(dt, 'year') and hasattr(dt, 'month')
|
||||||
|
and hasattr(dt, 'day')):
|
||||||
|
# make sure published is in UTC and strip the timezone
|
||||||
|
if hasattr(dt, 'tzinfo') and dt.tzinfo:
|
||||||
|
return dt.astimezone(datetime.timezone.utc).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
# convert datetime.date to datetime.datetime
|
||||||
|
elif not hasattr(dt, 'hour'):
|
||||||
|
return datetime.datetime(year=dt.year, month=dt.month,
|
||||||
|
day=dt.day)
|
||||||
|
|
||||||
permalink = url = hentry.get('url')
|
permalink = url = hentry.get('url')
|
||||||
uid = hentry.get('uid') or url
|
uid = hentry.get('uid') or url
|
||||||
if not uid:
|
if not uid:
|
||||||
|
@ -494,20 +506,9 @@ def hentry_to_entry(hentry, feed, backfill, now):
|
||||||
content = title
|
content = title
|
||||||
title = None
|
title = None
|
||||||
|
|
||||||
published = hentry.get('published')
|
published = normalize_datetime(hentry.get('published'))
|
||||||
updated = hentry.get('updated')
|
updated = normalize_datetime(hentry.get('updated'))
|
||||||
|
deleted = normalize_datetime(hentry.get('deleted'))
|
||||||
if published:
|
|
||||||
# make sure published is in UTC and strip the timezone
|
|
||||||
if hasattr(published, 'tzinfo') and published.tzinfo:
|
|
||||||
published = published.astimezone(datetime.timezone.utc)\
|
|
||||||
.replace(tzinfo=None)
|
|
||||||
# convert datetime.date to datetime.datetime
|
|
||||||
elif not hasattr(published, 'hour'):
|
|
||||||
published = datetime.datetime(
|
|
||||||
year=published.year,
|
|
||||||
month=published.month,
|
|
||||||
day=published.day)
|
|
||||||
|
|
||||||
# retrieved time is now unless we're backfilling old posts
|
# retrieved time is now unless we're backfilling old posts
|
||||||
retrieved = now
|
retrieved = now
|
||||||
|
@ -525,6 +526,7 @@ def hentry_to_entry(hentry, feed, backfill, now):
|
||||||
permalink=permalink,
|
permalink=permalink,
|
||||||
published=published,
|
published=published,
|
||||||
updated=updated,
|
updated=updated,
|
||||||
|
deleted=deleted,
|
||||||
title=title,
|
title=title,
|
||||||
content=content,
|
content=content,
|
||||||
content_cleaned=util.clean(content),
|
content_cleaned=util.clean(content),
|
||||||
|
|
|
@ -32,6 +32,7 @@ def index():
|
||||||
ws_topic = None
|
ws_topic = None
|
||||||
solo = False
|
solo = False
|
||||||
all_tags = set()
|
all_tags = set()
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
|
||||||
if flask_login.current_user.is_authenticated:
|
if flask_login.current_user.is_authenticated:
|
||||||
for subsc in flask_login.current_user.subscriptions:
|
for subsc in flask_login.current_user.subscriptions:
|
||||||
|
@ -48,7 +49,9 @@ def index():
|
||||||
.join(Entry.feed)\
|
.join(Entry.feed)\
|
||||||
.join(Feed.subscriptions)\
|
.join(Feed.subscriptions)\
|
||||||
.join(Subscription.user)\
|
.join(Subscription.user)\
|
||||||
.filter(User.id == flask_login.current_user.id)
|
.filter(User.id == flask_login.current_user.id)\
|
||||||
|
.filter(db.or_(Entry.deleted == None,
|
||||||
|
Entry.deleted >= now))
|
||||||
|
|
||||||
if 'entry' in flask.request.args:
|
if 'entry' in flask.request.args:
|
||||||
entry_url = flask.request.args.get('entry')
|
entry_url = flask.request.args.get('entry')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue