Cache all articles in IndexedDB

This commit is contained in:
2019-10-12 23:41:31 +00:00
parent 7cb87b59fe
commit 0f5b2a5ff9
10 changed files with 88 additions and 30 deletions

View File

@@ -14,7 +14,7 @@ from prawcore.exceptions import PrawcoreException
from utils import render_md
SUBREDDITS = 'Economics+Foodforthought+Futurology+TrueReddit+business+science+technology'
SUBREDDITS = 'Economics+Foodforthought+TrueReddit+business+technology'
SITE_LINK = lambda x : 'https://old.reddit.com/{}'.format(x)
SITE_AUTHOR_LINK = lambda x : 'https://old.reddit.com/u/{}'.format(x)

View File

@@ -0,0 +1,25 @@
beautifulsoup4==4.8.0
certifi==2019.6.16
chardet==3.0.4
Click==7.0
commonmark==0.9.0
feedparser==5.2.1
Flask==1.1.1
Flask-Cors==3.0.8
future==0.17.1
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
pkg-resources==0.0.0
praw==6.3.1
prawcore==1.0.1
requests==2.22.0
six==1.12.0
soupsieve==1.9.3
update-checker==0.16
urllib3==1.25.3
webencodings==0.5.1
websocket-client==0.56.0
Werkzeug==0.15.5
Whoosh==2.7.4

View File

@@ -43,10 +43,11 @@ cors = CORS(flask_app)
@flask_app.route('/api')
def api():
front_page = [news_cache[news_ref_to_id[ref]] for ref in news_list]
front_page = [x for x in front_page if 'title' in x and x['title']]
front_page = [copy.copy(x) for x in front_page if 'title' in x and x['title']]
front_page = front_page[:100]
to_remove = ['text', 'comments']
front_page = [{k:v for k,v in s.items() if k not in to_remove} for s in front_page]
for story in front_page:
story.pop('text', None)
story.pop('comments', None)
return {'stories': front_page}