Skip to content

Commit 0e4ae01

Browse files
committed
Merge remote-tracking branch 'ogarcia/bootstrap5'
2 parents 09920bc + ecf7878 commit 0e4ae01

33 files changed

+627
-912
lines changed

supysonic/frontend/folder.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ def add_folder_post():
4646
error = False
4747
name, path = map(request.form.get, ("name", "path"))
4848
if name in (None, ""):
49-
flash("The name is required.")
49+
flash("The name is required.", "danger")
5050
error = True
5151
if path in (None, ""):
52-
flash("The path is required.")
52+
flash("The path is required.", "danger")
5353
error = True
5454
if error:
5555
return render_template("addfolder.html")
5656

5757
try:
5858
FolderManager.add(name, path)
5959
except ValueError as e:
60-
flash(str(e), "error")
60+
flash(str(e), "danger")
6161
return render_template("addfolder.html")
6262

63-
flash(f"Folder '{name}' created. You should now run a scan")
63+
flash(f"Folder '{name}' created. You should now run a scan", "success")
6464
return redirect(url_for("frontend.folder_index"))
6565

6666

@@ -69,11 +69,11 @@ def add_folder_post():
6969
def del_folder(id):
7070
try:
7171
FolderManager.delete(id)
72-
flash("Deleted folder")
72+
flash("Deleted folder", "success")
7373
except ValueError as e:
74-
flash(str(e), "error")
74+
flash(str(e), "danger")
7575
except Folder.DoesNotExist:
76-
flash("No such folder", "error")
76+
flash("No such folder", "danger")
7777

7878
return redirect(url_for("frontend.folder_index"))
7979

@@ -90,10 +90,10 @@ def scan_folder(id=None):
9090
DaemonClient(current_app.config["DAEMON"]["socket"]).scan(folders)
9191
flash("Scanning started")
9292
except ValueError as e:
93-
flash(str(e), "error")
93+
flash(str(e), "danger")
9494
except Folder.DoesNotExist:
95-
flash("No such folder", "error")
95+
flash("No such folder", "danger")
9696
except DaemonUnavailableError:
97-
flash("Can't start scan", "error")
97+
flash("Can't start scan", "danger")
9898

9999
return redirect(url_for("frontend.folder_index"))

supysonic/frontend/playlist.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def decorated(uid):
3030
try:
3131
uid = uuid.UUID(uid)
3232
except ValueError:
33-
flash("Invalid playlist id")
33+
flash("Invalid playlist id", "warning")
3434
return redirect(url_for("frontend.playlist_index"))
3535

3636
try:
3737
playlist = Playlist[uid]
3838
except Playlist.DoesNotExist:
39-
flash("Unknown playlist")
39+
flash("Unknown playlist", "warning")
4040
return redirect(url_for("frontend.playlist_index"))
4141

4242
return func(uid, playlist)
@@ -64,9 +64,9 @@ def playlist_export(uid, playlist):
6464
@resolve_and_inject_playlist
6565
def playlist_update(uid, playlist):
6666
if playlist.user_id != request.user.id:
67-
flash("You're not allowed to edit this playlist")
67+
flash("You're not allowed to edit this playlist", "danger")
6868
elif not request.form.get("name"):
69-
flash("Missing playlist name")
69+
flash("Missing playlist name", "danger")
7070
else:
7171
playlist.name = request.form.get("name")
7272
playlist.public = request.form.get("public") in (
@@ -78,7 +78,7 @@ def playlist_update(uid, playlist):
7878
"checked",
7979
)
8080
playlist.save()
81-
flash("Playlist updated.")
81+
flash("Playlist updated.", "success")
8282

8383
return playlist_details(str(uid))
8484

@@ -87,9 +87,9 @@ def playlist_update(uid, playlist):
8787
@resolve_and_inject_playlist
8888
def playlist_delete(uid, playlist):
8989
if playlist.user_id != request.user.id:
90-
flash("You're not allowed to delete this playlist")
90+
flash("You're not allowed to delete this playlist", "danger")
9191
else:
9292
playlist.delete_instance()
93-
flash("Playlist deleted")
93+
flash("Playlist deleted", "success")
9494

9595
return redirect(url_for("frontend.playlist_index"))

supysonic/frontend/user.py

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def decorated_func(*args, **kwargs):
3737
try:
3838
user = UserManager.get(uid)
3939
except ValueError as e:
40-
flash(str(e), "error")
40+
flash(str(e), "danger")
4141
return redirect(url_for("frontend.index"))
4242
except User.DoesNotExist:
43-
flash("No such user", "error")
43+
flash("No such user", "danger")
4444
return redirect(url_for("frontend.index"))
4545

4646
if kwargs:
@@ -111,7 +111,7 @@ def update_clients(uid, user):
111111
)
112112
prefs.save()
113113

114-
flash("Clients preferences updated.")
114+
flash("Clients preferences updated.", "success")
115115
return user_profile(uid, user)
116116

117117

@@ -121,10 +121,10 @@ def change_username_form(uid):
121121
try:
122122
user = UserManager.get(uid)
123123
except ValueError as e:
124-
flash(str(e), "error")
124+
flash(str(e), "danger")
125125
return redirect(url_for("frontend.index"))
126126
except User.DoesNotExist:
127-
flash("No such user", "error")
127+
flash("No such user", "danger")
128128
return redirect(url_for("frontend.index"))
129129

130130
return render_template("change_username.html", user=user)
@@ -136,20 +136,20 @@ def change_username_post(uid):
136136
try:
137137
user = UserManager.get(uid)
138138
except ValueError as e:
139-
flash(str(e), "error")
139+
flash(str(e), "danger")
140140
return redirect(url_for("frontend.index"))
141141
except User.DoesNotExist:
142-
flash("No such user", "error")
142+
flash("No such user", "danger")
143143
return redirect(url_for("frontend.index"))
144144

145145
username = request.form.get("user")
146146
if username in ("", None):
147-
flash("The username is required")
147+
flash("The username is required", "danger")
148148
return render_template("change_username.html", user=user)
149149
if user.name != username:
150150
try:
151151
User.get(name=username)
152-
flash("This name is already taken")
152+
flash("This name is already taken", "danger")
153153
return render_template("change_username.html", user=user)
154154
except User.DoesNotExist:
155155
pass
@@ -163,7 +163,7 @@ def change_username_post(uid):
163163
user.name = username
164164
user.admin = admin
165165
user.save()
166-
flash(f"User '{username}' updated.")
166+
flash(f"User '{username}' updated.", "success")
167167
else:
168168
flash(f"No changes for '{username}'.")
169169

@@ -199,16 +199,16 @@ def change_password_post(uid, user):
199199
if user.id == request.user.id:
200200
current = request.form.get("current")
201201
if not current:
202-
flash("The current password is required")
202+
flash("The current password is required", "danger")
203203
error = True
204204

205205
new, confirm = map(request.form.get, ("new", "confirm"))
206206

207207
if not new:
208-
flash("The new password is required")
208+
flash("The new password is required", "danger")
209209
error = True
210210
if new != confirm:
211-
flash("The new password and its confirmation don't match")
211+
flash("The new password and its confirmation don't match", "danger")
212212
error = True
213213

214214
if not error:
@@ -218,10 +218,10 @@ def change_password_post(uid, user):
218218
else:
219219
UserManager.change_password2(user.name, new)
220220

221-
flash("Password changed")
221+
flash("Password changed", "success")
222222
return redirect(url_for("frontend.user_profile", uid=uid))
223223
except ValueError as e:
224-
flash(str(e), "error")
224+
flash(str(e), "danger")
225225

226226
return change_password_form(uid, user)
227227

@@ -241,22 +241,22 @@ def add_user_post():
241241
args.pop, ("user", "passwd", "passwd_confirm"), (None,) * 3
242242
)
243243
if not name:
244-
flash("The name is required.")
244+
flash("The name is required.", "danger")
245245
error = True
246246
if not passwd:
247-
flash("Please provide a password.")
247+
flash("Please provide a password.", "danger")
248248
error = True
249249
elif passwd != passwd_confirm:
250-
flash("The passwords don't match.")
250+
flash("The passwords don't match.", "danger")
251251
error = True
252252

253253
if not error:
254254
try:
255255
UserManager.add(name, passwd, **args)
256-
flash(f"User '{name}' successfully added")
256+
flash(f"User '{name}' successfully added", "success")
257257
return redirect(url_for("frontend.user_index"))
258258
except ValueError as e:
259-
flash(str(e), "error")
259+
flash(str(e), "danger")
260260

261261
return add_user_form()
262262

@@ -266,11 +266,11 @@ def add_user_post():
266266
def del_user(uid):
267267
try:
268268
UserManager.delete(uid)
269-
flash("Deleted user")
269+
flash("Deleted user", "success")
270270
except ValueError as e:
271-
flash(str(e), "error")
271+
flash(str(e), "danger")
272272
except User.DoesNotExist:
273-
flash("No such user", "error")
273+
flash("No such user", "danger")
274274

275275
return redirect(url_for("frontend.user_index"))
276276

@@ -280,12 +280,15 @@ def del_user(uid):
280280
def lastfm_reg(uid, user):
281281
token = request.args.get("token")
282282
if not token:
283-
flash("Missing LastFM auth token")
283+
flash("Missing LastFM auth token", "warning")
284284
return redirect(url_for("frontend.user_profile", uid=uid))
285285

286286
lfm = LastFm(current_app.config["LASTFM"], user)
287287
status, error = lfm.link_account(token)
288-
flash(error if not status else "Successfully linked LastFM account")
288+
if not status:
289+
flash(error, "danger")
290+
else:
291+
flash("Successfully linked LastFM account", "success")
289292

290293
return redirect(url_for("frontend.user_profile", uid=uid))
291294

@@ -295,7 +298,7 @@ def lastfm_reg(uid, user):
295298
def lastfm_unreg(uid, user):
296299
lfm = LastFm(current_app.config["LASTFM"], user)
297300
lfm.unlink_account()
298-
flash("Unlinked LastFM account")
301+
flash("Unlinked LastFM account", "success")
299302
return redirect(url_for("frontend.user_profile", uid=uid))
300303

301304

@@ -304,12 +307,15 @@ def lastfm_unreg(uid, user):
304307
def listenbrainz_reg(uid, user):
305308
token = request.args.get("token")
306309
if not token:
307-
flash("Missing ListenBrainz auth token")
310+
flash("Missing ListenBrainz auth token", "warning")
308311
return redirect(url_for("frontend.user_profile", uid=uid))
309312

310313
lbz = ListenBrainz(current_app.config["LISTENBRAINZ"], user)
311314
status, error = lbz.link_account(token)
312-
flash(error if not status else "Successfully linked ListenBrainz account")
315+
if not status:
316+
flash(error, "danger")
317+
else:
318+
flash("Successfully linked ListenBrainz account", "success")
313319

314320
return redirect(url_for("frontend.user_profile", uid=uid))
315321

@@ -319,7 +325,7 @@ def listenbrainz_reg(uid, user):
319325
def listenbrainz_unreg(uid, user):
320326
lbz = ListenBrainz(current_app.config["LISTENBRAINZ"], user)
321327
lbz.unlink_account()
322-
flash("Unlinked ListenBrainz account")
328+
flash("Unlinked ListenBrainz account", "success")
323329
return redirect(url_for("frontend.user_profile", uid=uid))
324330

325331

@@ -336,30 +342,30 @@ def login():
336342
name, password = map(request.form.get, ("user", "password"))
337343
error = False
338344
if not name:
339-
flash("Missing user name")
345+
flash("Missing user name", "danger")
340346
error = True
341347
if not password:
342-
flash("Missing password")
348+
flash("Missing password", "danger")
343349
error = True
344350

345351
if not error:
346352
user = UserManager.try_auth(name, password)
347353
if user:
348354
logger.info("Logged user %s (IP: %s)", name, request.remote_addr)
349355
session["userid"] = str(user.id)
350-
flash("Logged in!")
356+
flash("Logged in!", "success")
351357
return redirect(return_url)
352358
else:
353359
logger.error(
354360
"Failed login attempt for user %s (IP: %s)", name, request.remote_addr
355361
)
356-
flash("Wrong username or password")
362+
flash("Wrong username or password", "danger")
357363

358364
return render_template("login.html")
359365

360366

361367
@frontend.route("/user/logout")
362368
def logout():
363369
session.clear()
364-
flash("Logged out!")
370+
flash("Logged out!", "success")
365371
return redirect(url_for("frontend.login"))

supysonic/static/css/bootstrap-theme.min.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

supysonic/static/css/bootstrap-theme.min.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

supysonic/static/css/bootstrap.min.css

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

supysonic/static/css/bootstrap.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

supysonic/static/css/supysonic.css

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* This file is part of Supysonic.
33
* Supysonic is a Python implementation of the Subsonic server API.
44
*
5-
* Copyright (C) 2017 Óscar García Amor
6-
* 2017 Alban 'spl0k' Féron
5+
* Copyright (C) 2017-2024 Óscar García Amor
6+
* 2017-2024 Alban 'spl0k' Féron
77
*
88
* Distributed under terms of the GNU AGPLv3 license.
99
*/
@@ -12,30 +12,8 @@ body {
1212
padding-top: 60px;
1313
}
1414

15-
#loginbox {
16-
margin-top: 30px;
17-
}
18-
19-
#loginform > div {
20-
margin-bottom: 20px;
21-
}
22-
23-
#adduserform label {
24-
margin-bottom: 0;
25-
}
26-
27-
#clients td,
28-
#playlist td {
29-
vertical-align: middle;
30-
}
31-
32-
.first-header {
33-
margin-top: 20px;
34-
}
35-
36-
.placeholders {
37-
text-align: center;
38-
padding-top: 15px;
15+
.bi-va-fix {
16+
vertical-align: -.125em;
3917
}
4018

4119
.stats {
Binary file not shown.

0 commit comments

Comments
 (0)