Skip to content

Commit

Permalink
a lot of layout changes to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson H committed Aug 30, 2023
1 parent 5e5dd90 commit 08f33ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 31 deletions.
20 changes: 9 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,26 +317,24 @@ def root():
top_albums = get_top('albums', top=5)
top_songs = get_top('songs', top=5)

return render_template('home.html', top_albums=top_albums, top_songs=top_songs, top_artists=top_artists, year=today.year, month=today.month)

@app.route('/overall/artists/')
def overall_artists():

with open(spotify_times_path + "overall.json", 'r') as f:
data = json.loads(f.read())

total_time = listenTimeFormat(calculate_total_listening_time(data))
artist_count = len(data)

data = sorted(data.items(), key=keyfunc, reverse=True)
return render_template('home.html', top_albums=top_albums, top_songs=top_songs, top_artists=top_artists, year=today.year, month=today.month, artist_count=artist_count, total_time=total_time)

sorted_artists = {}
for artist_tuple in data:
artist_name, artist_info = artist_tuple
@app.route('/overall/')
def overall():
return redirect('/')

sorted_artists[artist_name.replace("-", " ").title()] = (listenTimeFormat(artist_info["overall"]), artist_name)
@app.route('/overall/artists/')
def overall_artists():

top_artists = get_top('artists')

return render_template('overall.html', data=sorted_artists, total_time=total_time, artist_total=artist_count)
return render_template('overall_artists.html', data=top_artists)

@app.route('/overall/albums/')
def overall_albums():
Expand Down
15 changes: 7 additions & 8 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ header {
padding-top: 10pt;
}

.Title {
text-align: center;
.TitleBlock {
font-weight: bold;
font-size: 24px;
padding: 15px;
border-style: solid;
border-radius: 90px;
}

#title {
font-size: 50px;
padding: 20px;
border-color: white;
margin: 5px;
display:inline-block;
}

.Graphs {
Expand Down
16 changes: 7 additions & 9 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
<title>Overview</title>
</header>
<body>
<div class="Title">
<header id="title">Music Stat Display Home</header>
</div>
<div class="TitleBlock">Music Stat Display Home</div>
<div class="TitleBlock"><a href="/month/{{ year }}/{{ month }}/"><u>Check this month's stats</u></a></div>
<div class="TitleBlock">Total Listening Time: {{ total_time[0] }} hours {{ total_time[1] }} minutes</div>
<div class="TitleBlock">Total Artists: {{ artist_count }}</div>

<div class="Summary">
<div class="SummaryBlock">
<header><a href="/overall/artists/"><u>Top Artists</u></a></header>
Expand All @@ -18,13 +20,13 @@
<div class="SummaryBlock">
<header><a href="/overall/albums"><u>Top Albums</u></a></header>
{% for album in top_albums %}
<p>{{ loop.index }}. {{ album }} <u>by</u> <a href="/overall/{{ top_albums[album][2] }}">{{ top_albums[album][1] }}</a>: {{ top_albums[album][0][0] }} hours {{ top_albums[album][0][1] }} minutes</p>
<p>{{ loop.index }}. {{ album }} <b>by</b> <a href="/overall/{{ top_albums[album][2] }}">{{ top_albums[album][1] }}</a>: {{ top_albums[album][0][0] }} hours {{ top_albums[album][0][1] }} minutes</p>
{% endfor %}
</div>
<div class="SummaryBlock">
<header><a href="/overall/songs/"><u>Top Songs</u></a></header>
{% for song in top_songs %}
<p>{{ loop.index }}. {{ song }} <u>by</u> <a href="/overall/{{ top_songs[song][2] }}">{{ top_songs[song][1] }}</a>: {{ top_songs[song][0][0] }} hours {{ top_songs[song][0][1] }} minutes</p>
<p>{{ loop.index }}. {{ song }} <b>by</b> <a href="/overall/{{ top_songs[song][2] }}">{{ top_songs[song][1] }}</a>: {{ top_songs[song][0][0] }} hours {{ top_songs[song][0][1] }} minutes</p>
{% endfor %}
</div>
</div>
Expand All @@ -43,9 +45,5 @@
<img src="{{ url_for('static', filename='month.png') }}">
</div>
</div>

<div>
<header><a href="/month/{{ year }}/{{ month }}/"><u>Check this month's stats</u></a></header>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions templates/overall_albums.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</header>
<body>
<a href=".."><u><< back</u></a>
<div class="TopTen">
<header><b><u>Top Albums</u></b></header>
{% for album in top_albums %}
Expand Down
4 changes: 1 addition & 3 deletions templates/overall.html → templates/overall_artists.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</header>
<body>
<header>Total listening time: <u>{{ total_time[0] }} hours {{ total_time[1] }} minutes</u> </header>
<header>Artists Listened To: <u>{{ artist_total }}</u></header>
<br>
<a href=".."><u><< back</u></a>
<div class="TopTen">
<header><b><u>Top Artists</u></b></header>
{% for artist in data %}
Expand Down
1 change: 1 addition & 0 deletions templates/overall_songs.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</header>
<body>
<a href=".."><u><< back</u></a>
<div class="TopTen">
<header><b><u>Top Songs</u></b></header>
{% for song in top_songs %}
Expand Down

0 comments on commit 08f33ad

Please sign in to comment.