Add welcome page

This commit is contained in:
pluja 2020-08-26 09:41:34 +02:00
parent 4ddbb7ecec
commit eb0042a694
5 changed files with 32 additions and 7 deletions

3
.gitignore vendored
View File

@ -144,4 +144,5 @@ dmypy.json
# pytype static type analyzer
.pytype/
# End of https://www.toptal.com/developers/gitignore/api/python
# Added
data_export.json

View File

@ -37,6 +37,11 @@ ALLOWED_EXTENSIONS = {'json'}
@app.route('/index')
@login_required
def index():
return render_template('home.html')
@app.route('/twitter')
@login_required
def twitter():
start_time = time.time()
followingList = current_user.twitter_following_list()
followCount = len(followingList)
@ -50,7 +55,7 @@ def index():
else:
profilePic = posts[0].userProfilePic
print("--- {} seconds fetching twitter feed---".format(time.time() - start_time))
return render_template('index.html', title='Home', posts=posts, avatar=avatarPath, profilePic = profilePic, followedCount=followCount, form=form)
return render_template('twitter.html', title='Home', posts=posts, avatar=avatarPath, profilePic = profilePic, followedCount=followCount, form=form)
@app.route('/savePost/<url>', methods=['POST'])
@login_required
@ -300,7 +305,7 @@ def channel(id):
def watch():
id = request.args.get('v', None)
ydl = YoutubeDL()
data = ydl.extract_info("{id}".format(id=id), download=False)
data = ydl.extract_info(id, False)
if data['formats'][-1]['url'].find("manifest.googlevideo") > 0:
flash("Livestreams are not yet supported!")
return redirect(url_for('youtube'))

View File

@ -13,13 +13,13 @@
</head>
<body>
<div class="ui stackable menu">
<div class="item">
<img src="{{ url_for('static',filename='img/logo.png') }}">
</div>
<a href="{{ url_for('index') }}"><div class="item">
<img src="{{ url_for('static',filename='img/logo.png') }}">
</div></a>
{% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}" class="item">Login</a>
{% else %}
<a href="{{ url_for('index') }}" class="twitter item">Twitter</a>
<a href="{{ url_for('twitter') }}" class="twitter item">Twitter</a>
<a href="{{ url_for('search') }}" class="twitter item">Search</a>
<a href="{{ url_for('saved') }}" class="twitter item">Saved</a>
<a href="{{ url_for('youtube') }}" class="youtube item">Youtube</a>

19
app/templates/home.html Normal file
View File

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% block content %}
<div style="margin: 2em" class="ui one column centered grid">
<div class="row">
<div class="column">
<h2 class="ui center aligned header">
Welcome back, {{current_user.username}}!
<div class="sub header">Choose a platform</div>
</h2>
</div>
</div>
<div class="row">
<a style="padding: .2em" href="{{ url_for('twitter') }}"><button class="massive teal ui button">Twitter</button></a>
<a style="padding: .2em" href="{{ url_for('youtube') }}"><button class="massive red ui button">Youtube</button></a>
</div>
</div>
{% endblock %}