move models, views, and controllers to root
This commit is contained in:
parent
f0d29126ab
commit
96cc64464f
21 changed files with 190 additions and 203 deletions
|
@ -6,15 +6,15 @@ import (
|
|||
"strings"
|
||||
|
||||
"arimelody-web/global"
|
||||
"arimelody-web/music/model"
|
||||
"arimelody-web/music/controller"
|
||||
"arimelody-web/model"
|
||||
"arimelody-web/controller"
|
||||
)
|
||||
|
||||
func serveArtist() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
slices := strings.Split(r.URL.Path[1:], "/")
|
||||
id := slices[0]
|
||||
artist, err := music.GetArtist(global.DB, id)
|
||||
artist, err := controller.GetArtist(global.DB, id)
|
||||
if err != nil {
|
||||
if artist == nil {
|
||||
http.NotFound(w, r)
|
||||
|
@ -25,7 +25,7 @@ func serveArtist() http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
credits, err := music.GetArtistCredits(global.DB, artist.ID, true)
|
||||
credits, err := controller.GetArtistCredits(global.DB, artist.ID, true)
|
||||
if err != nil {
|
||||
fmt.Printf("Error rendering admin track page for %s: %s\n", id, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
|
||||
"arimelody-web/discord"
|
||||
"arimelody-web/global"
|
||||
musicDB "arimelody-web/music/controller"
|
||||
musicModel "arimelody-web/music/model"
|
||||
"arimelody-web/controller"
|
||||
"arimelody-web/model"
|
||||
)
|
||||
|
||||
type loginData struct {
|
||||
|
@ -41,21 +41,21 @@ func Handler() http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
releases, err := musicDB.GetAllReleases(global.DB, false, 0, true)
|
||||
releases, err := controller.GetAllReleases(global.DB, false, 0, true)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull releases: %s\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
artists, err := musicDB.GetAllArtists(global.DB)
|
||||
artists, err := controller.GetAllArtists(global.DB)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull artists: %s\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
tracks, err := musicDB.GetOrphanTracks(global.DB)
|
||||
tracks, err := controller.GetOrphanTracks(global.DB)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull orphan tracks: %s\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
@ -63,9 +63,9 @@ func Handler() http.Handler {
|
|||
}
|
||||
|
||||
type IndexData struct {
|
||||
Releases []*musicModel.Release
|
||||
Artists []*musicModel.Artist
|
||||
Tracks []*musicModel.Track
|
||||
Releases []*model.Release
|
||||
Artists []*model.Artist
|
||||
Tracks []*model.Track
|
||||
}
|
||||
|
||||
err = pages["index"].Execute(w, IndexData{
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"arimelody-web/global"
|
||||
db "arimelody-web/music/controller"
|
||||
"arimelody-web/music/model"
|
||||
"arimelody-web/controller"
|
||||
"arimelody-web/model"
|
||||
)
|
||||
|
||||
func serveRelease() http.Handler {
|
||||
|
@ -15,7 +15,7 @@ func serveRelease() http.Handler {
|
|||
slices := strings.Split(r.URL.Path[1:], "/")
|
||||
releaseID := slices[0]
|
||||
|
||||
release, err := db.GetRelease(global.DB, releaseID, true)
|
||||
release, err := controller.GetRelease(global.DB, releaseID, true)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
http.NotFound(w, r)
|
||||
|
@ -81,7 +81,7 @@ func serveEditCredits(release *model.Release) http.Handler {
|
|||
|
||||
func serveAddCredit(release *model.Release) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
artists, err := db.GetArtistsNotOnRelease(global.DB, release.ID)
|
||||
artists, err := controller.GetArtistsNotOnRelease(global.DB, release.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull artists not on %s: %s\n", release.ID, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
@ -108,7 +108,7 @@ func serveAddCredit(release *model.Release) http.Handler {
|
|||
func serveNewCredit() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
artistID := strings.Split(r.URL.Path, "/")[3]
|
||||
artist, err := db.GetArtist(global.DB, artistID)
|
||||
artist, err := controller.GetArtist(global.DB, artistID)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull artists %s: %s\n", artistID, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
@ -152,7 +152,7 @@ func serveEditTracks(release *model.Release) http.Handler {
|
|||
|
||||
func serveAddTrack(release *model.Release) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
tracks, err := db.GetTracksNotOnRelease(global.DB, release.ID)
|
||||
tracks, err := controller.GetTracksNotOnRelease(global.DB, release.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull tracks not on %s: %s\n", release.ID, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
@ -180,7 +180,7 @@ func serveAddTrack(release *model.Release) http.Handler {
|
|||
func serveNewTrack() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
trackID := strings.Split(r.URL.Path, "/")[3]
|
||||
track, err := db.GetTrack(global.DB, trackID)
|
||||
track, err := controller.GetTrack(global.DB, trackID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error rendering new track component for %s: %s\n", trackID, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
|
|
@ -6,15 +6,15 @@ import (
|
|||
"strings"
|
||||
|
||||
"arimelody-web/global"
|
||||
"arimelody-web/music/model"
|
||||
"arimelody-web/music/controller"
|
||||
"arimelody-web/model"
|
||||
"arimelody-web/controller"
|
||||
)
|
||||
|
||||
func serveTrack() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
slices := strings.Split(r.URL.Path[1:], "/")
|
||||
id := slices[0]
|
||||
track, err := music.GetTrack(global.DB, id)
|
||||
track, err := controller.GetTrack(global.DB, id)
|
||||
if err != nil {
|
||||
fmt.Printf("Error rendering admin track page for %s: %s\n", id, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
@ -25,7 +25,7 @@ func serveTrack() http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
releases, err := music.GetTrackReleases(global.DB, track.ID, true)
|
||||
releases, err := controller.GetTrackReleases(global.DB, track.ID, true)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Failed to pull releases for %s: %s\n", id, err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue