Skip to content

Commit

Permalink
Merge pull request #60 from mbaraa/dev
Browse files Browse the repository at this point in the history
some fixes ig
  • Loading branch information
mbaraa authored May 29, 2024
2 parents f1afe0e + 7559b4a commit cd488d9
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 115 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ IDK, it would be really nice of you to contribute, check the poorly written [CON
- [ ] View/Edit queue
- [ ] Expandable player
- [x] Mobile
- [ ] Desktop
- [ ] Desktop
- [ ] Share songs
- [ ] Player's menu
- [ ] Import **public** playlists from YouTube
Expand Down Expand Up @@ -86,7 +86,6 @@ docker compose up -f docker-compose-dev.yml
## Acknowledgements

- **This project is not affiliated with YouTube or Google, or anyone to that matter in any sort of ways.**
- The background was taken from [dankpods.net](https://dankpods.net)
- Frank’s original image was taken from [dingusland.biz](https://dingusland.biz)
- Colorscheme is inspired from [Dankpods](https://www.youtube.com/@DankPods)
- youtube-scrape was used to search videos without using the actual YouTube API (small quota): MIT licenses by [Herman Fassett](https://github.com/HermanFassett)
Expand Down
16 changes: 8 additions & 8 deletions app/handlers/apis/email_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (e *emailLoginApi) HandleEmailLogin(w http.ResponseWriter, r *http.Request)
log.Errorf("[EMAIL LOGIN API]: Failed to login user: %+v, error: %s\n", reqBody, err.Error())
// w.WriteHeader(http.StatusInternalServerError)
status.
GenericError(fmt.Sprintf("No account associated with the email \"%s\" was found", reqBody.Email)).
BugsBunnyError(fmt.Sprintf("No account associated with the email \"%s\" was found", reqBody.Email)).
Render(context.Background(), w)
return
}
Expand Down Expand Up @@ -66,7 +66,7 @@ func (e *emailLoginApi) HandleEmailSignup(w http.ResponseWriter, r *http.Request
log.Errorf("[EMAIL LOGIN API]: Failed to sign up a new user: %+v, error: %s\n", reqBody, err.Error())
// w.WriteHeader(http.StatusConflict)
status.
GenericError(fmt.Sprintf("An account associated with the email \"%s\" already exists", reqBody.Email)).
BugsBunnyError(fmt.Sprintf("An account associated with the email \"%s\" already exists", reqBody.Email)).
Render(context.Background(), w)
return
}
Expand Down Expand Up @@ -95,14 +95,14 @@ func (e *emailLoginApi) HandleEmailOTPVerification(w http.ResponseWriter, r *htt
if err != nil {
// w.Write([]byte("Invalid verification token"))
status.
GenericError("Invalid verification token").
BugsBunnyError("Invalid verification token").
Render(context.Background(), w)
return
}
if verificationToken.Expires.After(time.Now().UTC()) {
// w.Write([]byte("Expired verification token"))
status.
GenericError("Expired verification token").
BugsBunnyError("Expired verification token").
Render(context.Background(), w)
return
}
Expand All @@ -113,29 +113,29 @@ func (e *emailLoginApi) HandleEmailOTPVerification(w http.ResponseWriter, r *htt
log.Error(err)
// w.WriteHeader(http.StatusBadRequest)
status.
GenericError("Invalid verification token").
BugsBunnyError("Invalid verification token").
Render(context.Background(), w)
return
}

sessionToken, err := e.service.VerifyOtp(verificationToken.Value, reqBody)
if errors.Is(err, login.ErrExpiredVerificationCode) {
status.
GenericError("Expired verification code!").
BugsBunnyError("Expired verification code!").
Render(context.Background(), w)
return
}
if errors.Is(err, login.ErrInvalidVerificationCode) {
status.
GenericError("Invalid verification code!").
BugsBunnyError("Invalid verification code!").
Render(context.Background(), w)
return
}
if err != nil {
log.Error(err)
// w.WriteHeader(http.StatusInternalServerError)
status.
GenericError("Something went wrong...").
BugsBunnyError("Something went wrong...").
Render(context.Background(), w)
return
}
Expand Down
42 changes: 30 additions & 12 deletions app/handlers/pages/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"dankmuzikk/services/playlists"
"dankmuzikk/services/youtube/download"
"dankmuzikk/services/youtube/search"
"dankmuzikk/views/components/status"
"dankmuzikk/views/layouts"
"dankmuzikk/views/pages"
"errors"
Expand All @@ -21,10 +22,6 @@ import (
_ "github.com/a-h/templ"
)

const (
notFoundMessage = "🤷‍♂️ I have no idea about what you requested!"
)

type pagesHandler struct {
profileRepo db.GetterRepo[models.Profile]
playlistsService *playlists.Service
Expand Down Expand Up @@ -89,7 +86,9 @@ func (p *pagesHandler) HandleLoginPage(w http.ResponseWriter, r *http.Request) {
func (p *pagesHandler) HandlePlaylistsPage(w http.ResponseWriter, r *http.Request) {
profileId, profileIdCorrect := r.Context().Value(handlers.ProfileIdKey).(uint)
if !profileIdCorrect {
w.Write([]byte(notFoundMessage))
status.
BugsBunnyError("I'm not sure what you're trying to do :)").
Render(context.Background(), w)
return
}

Expand All @@ -110,27 +109,46 @@ func (p *pagesHandler) HandlePlaylistsPage(w http.ResponseWriter, r *http.Reques
func (p *pagesHandler) HandleSinglePlaylistPage(w http.ResponseWriter, r *http.Request) {
profileId, profileIdCorrect := r.Context().Value(handlers.ProfileIdKey).(uint)
if !profileIdCorrect {
w.Write([]byte(notFoundMessage))
status.
BugsBunnyError("I'm not sure what you're trying to do :)").
Render(context.Background(), w)
return
}

playlistPubId := r.PathValue("playlist_id")
if playlistPubId == "" {
w.Write([]byte(notFoundMessage))
status.
BugsBunnyError("You need to provide a playlist id!").
Render(context.Background(), w)
return
}

playlist, permission, err := p.playlistsService.Get(playlistPubId, profileId)
htmxReq := handlers.IsNoLayoutPage(r)
switch {
case errors.Is(err, playlists.ErrUnauthorizedToSeePlaylist):
log.Errorln(err)
w.Write([]byte(notFoundMessage))
if htmxReq {
status.
BugsBunnyError("You can't see this playlist! <br/> (don't snoop around other people's stuff or else!)").
Render(context.Background(), w)
} else {
layouts.Default("Error",
status.
BugsBunnyError("You can't see this playlist! <br/> (don't snoop around other people's stuff or else!)")).
Render(r.Context(), w)
}
return
case err != nil:
if playlist.Title == "" {
log.Errorln(err)
w.Write([]byte(notFoundMessage))
return
if htmxReq {
status.
BugsBunnyError("You can't see this playlist! <br/> (it might be John Cena)").
Render(context.Background(), w)
} else {
layouts.Default("Error",
status.
BugsBunnyError("You can't see this playlist! <br/> (it might be John Cena)")).
Render(r.Context(), w)
}
}
ctx := context.WithValue(r.Context(), handlers.PlaylistPermission, permission)
Expand Down
3 changes: 1 addition & 2 deletions app/static/css/themes/black.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
}

body {
background-image: url("/static/images/dankground-dark.svg");
background-color: var(--primary-color);
background-color: #131313;
}
3 changes: 1 addition & 2 deletions app/static/css/themes/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
}

body {
background-image: url("/static/images/dankground.svg");
background-color: var(--primary-color);
background-color: #305922;
}
3 changes: 1 addition & 2 deletions app/static/css/themes/white.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
}

body {
background-image: url("/static/images/dankground-light.svg");
background-color: var(--primary-color);
background-color: #dedede;
}
10 changes: 0 additions & 10 deletions app/static/images/dankground-dark.svg

This file was deleted.

10 changes: 0 additions & 10 deletions app/static/images/dankground-light.svg

This file was deleted.

16 changes: 0 additions & 16 deletions app/static/images/dankground.svg

This file was deleted.

Binary file added app/static/images/error-img.webp
Binary file not shown.
Loading

0 comments on commit cd488d9

Please sign in to comment.