added stuff, broke some other stuff, made admin auth!
Signed-off-by: ari melody <ari@arimelody.me>
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
.idea/
|
.idea/
|
||||||
tmp/
|
tmp/
|
||||||
|
test/
|
||||||
|
|
18
api/api.go
|
@ -1,20 +1,12 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
|
||||||
"arimelody.me/arimelody.me/api/v1/admin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Handle(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
func Handle(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
code := 404;
|
writer.WriteHeader(501)
|
||||||
if req.URL.Path == "/api/v1/admin/login" {
|
writer.Write([]byte("501 Not Implemented"))
|
||||||
code = admin.HandleLogin(writer, req, root)
|
return 501;
|
||||||
}
|
|
||||||
|
|
||||||
if code == 404 {
|
|
||||||
writer.Write([]byte("404 not found"))
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,228 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"math/rand"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"arimelody.me/arimelody.me/discord"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
State struct {
|
Session struct {
|
||||||
Token string
|
UserID string
|
||||||
}
|
Token string
|
||||||
|
}
|
||||||
|
|
||||||
|
loginData struct {
|
||||||
|
UserID string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateState() *State {
|
const TOKEN_LENGTH = 64
|
||||||
return &State{
|
const TOKEN_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
Token: "you are the WINRAR!!",
|
|
||||||
}
|
// TODO: consider relying *entirely* on env vars instead of hard-coded fallbacks
|
||||||
|
var ADMIN_ID_DISCORD = func() string {
|
||||||
|
envvar := os.Getenv("DISCORD_ADMIN_ID")
|
||||||
|
if envvar != "" {
|
||||||
|
return envvar
|
||||||
|
} else {
|
||||||
|
return "356210742200107009"
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
var sessions []*Session
|
||||||
|
|
||||||
|
func CreateSession(UserID string) Session {
|
||||||
|
return Session{
|
||||||
|
UserID: UserID,
|
||||||
|
Token: string(generateToken()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleLogin(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
func Handler() http.Handler {
|
||||||
if req.Method != "POST" {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
return 404;
|
fmt.Println(r.URL.Path)
|
||||||
|
|
||||||
|
w.WriteHeader(200)
|
||||||
|
w.Write([]byte("hello admin!"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func AuthorisedHandler(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
auth := r.Header.Get("Authorization")
|
||||||
|
if auth == "" || !strings.HasPrefix(auth, "Bearer ") {
|
||||||
|
cookie, err := r.Cookie("token")
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(401)
|
||||||
|
w.Write([]byte("Unauthorized"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
auth = cookie.Value
|
||||||
|
}
|
||||||
|
auth = auth[7:]
|
||||||
|
|
||||||
|
var session *Session
|
||||||
|
for _, s := range sessions {
|
||||||
|
if s.Token == auth {
|
||||||
|
session = s
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if session == nil {
|
||||||
|
w.WriteHeader(401)
|
||||||
|
w.Write([]byte("Unauthorized"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := io.ReadAll(req.Body)
|
ctx := context.WithValue(r.Context(), "token", session.Token)
|
||||||
|
next.ServeHTTP(w, r.WithContext(ctx))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoginHandler() http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
code := r.URL.Query().Get("code")
|
||||||
|
|
||||||
|
if code == "" {
|
||||||
|
w.Header().Add("Location", discord.REDIRECT_URI)
|
||||||
|
w.WriteHeader(307)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// let's get an oauth token!
|
||||||
|
req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/oauth2/token", discord.API_ENDPOINT),
|
||||||
|
strings.NewReader(url.Values{
|
||||||
|
"client_id": {discord.CLIENT_ID},
|
||||||
|
"client_secret": {discord.CLIENT_SECRET},
|
||||||
|
"grant_type": {"authorization_code"},
|
||||||
|
"code": {code},
|
||||||
|
"redirect_uri": {discord.MY_REDIRECT_URI},
|
||||||
|
}.Encode()))
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
res, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to parse request body!\n");
|
fmt.Printf("Failed to retrieve OAuth token: %s\n", err)
|
||||||
return 500;
|
w.WriteHeader(500)
|
||||||
|
w.Write([]byte("Internal server error"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(body) != "super epic mega gaming password" {
|
oauth := discord.AccessTokenResponse{}
|
||||||
return 400;
|
|
||||||
|
err = json.NewDecoder(res.Body).Decode(&oauth)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to parse OAuth response data from discord: %s\n", err)
|
||||||
|
w.WriteHeader(500)
|
||||||
|
w.Write([]byte("Internal server error"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.Body.Close()
|
||||||
|
|
||||||
|
discord_access_token := oauth.AccessToken
|
||||||
|
|
||||||
|
// let's get authorisation information!
|
||||||
|
req, err = http.NewRequest(http.MethodGet, fmt.Sprintf("%s/oauth2/@me", discord.API_ENDPOINT), nil)
|
||||||
|
req.Header.Add("Authorization", "Bearer " + discord_access_token)
|
||||||
|
|
||||||
|
res, err = http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to retrieve discord auth information: %s\n", err)
|
||||||
|
w.WriteHeader(500)
|
||||||
|
w.Write([]byte("Internal server error"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state := CreateState();
|
auth_info := discord.AuthInfoResponse{}
|
||||||
|
|
||||||
writer.WriteHeader(200);
|
err = json.NewDecoder(res.Body).Decode(&auth_info)
|
||||||
writer.Write([]byte(state.Token))
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to parse auth information from discord: %s\n", err)
|
||||||
|
w.WriteHeader(500)
|
||||||
|
w.Write([]byte("Internal server error"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.Body.Close()
|
||||||
|
|
||||||
return 200;
|
discord_user_id := auth_info.User.Id
|
||||||
|
|
||||||
|
if discord_user_id != ADMIN_ID_DISCORD {
|
||||||
|
// TODO: unauthorized user. revoke the token
|
||||||
|
w.WriteHeader(401)
|
||||||
|
w.Write([]byte("Unauthorized"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// login success!
|
||||||
|
session := CreateSession(auth_info.User.Username)
|
||||||
|
sessions = append(sessions, &session)
|
||||||
|
|
||||||
|
cookie := http.Cookie{}
|
||||||
|
cookie.Name = "token"
|
||||||
|
cookie.Value = session.Token
|
||||||
|
cookie.Expires = time.Now().Add(24 * time.Hour)
|
||||||
|
// cookie.Secure = true
|
||||||
|
cookie.HttpOnly = true
|
||||||
|
cookie.Path = "/"
|
||||||
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
|
w.WriteHeader(200)
|
||||||
|
w.Write([]byte(session.Token))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func LogoutHandler() http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
token := r.Context().Value("token").(string)
|
||||||
|
|
||||||
|
if token == "" {
|
||||||
|
w.WriteHeader(401)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove this session from the list
|
||||||
|
sessions = func (token string) []*Session {
|
||||||
|
new_sessions := []*Session{}
|
||||||
|
for _, session := range sessions {
|
||||||
|
new_sessions = append(new_sessions, session)
|
||||||
|
}
|
||||||
|
return new_sessions
|
||||||
|
}(token)
|
||||||
|
|
||||||
|
w.WriteHeader(200)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func OAuthCallbackHandler() http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func VerifyHandler() http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// this is an authorised endpoint, so you *must* supply a valid token
|
||||||
|
// before accessing this route.
|
||||||
|
w.WriteHeader(200)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateToken() string {
|
||||||
|
var token []byte
|
||||||
|
|
||||||
|
for i := 0; i < TOKEN_LENGTH; i++ {
|
||||||
|
token = append(token, TOKEN_CHARS[rand.Intn(len(TOKEN_CHARS))])
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(token)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,37 @@
|
||||||
package music
|
package music
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"time"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Releases []*MusicRelease;
|
||||||
|
var Artists []*Artist;
|
||||||
|
|
||||||
func make_date_work(date string) time.Time {
|
func make_date_work(date string) time.Time {
|
||||||
res, err := time.Parse("2-Jan-2006", date)
|
res, err := time.Parse("2-Jan-2006", date)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("somehow we failed to parse %s! falling back to epoch :]\n", date)
|
fmt.Printf("somehow we failed to parse %s! falling back to epoch :]\n", date)
|
||||||
return time.Unix(0, 0)
|
return time.Unix(0, 0)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRelease(id string) (*MusicRelease, error) {
|
||||||
|
for _, release := range Releases {
|
||||||
|
if release.Id == id {
|
||||||
|
return release, nil
|
||||||
}
|
}
|
||||||
return res
|
}
|
||||||
|
return nil, errors.New(fmt.Sprintf("Release %s not found", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRelease(id string) (MusicRelease, bool) {
|
func GetArtist(id string) (*Artist, error) {
|
||||||
for _, album := range placeholders {
|
for _, artist := range Artists {
|
||||||
if album.Id == id {
|
if artist.Id == id {
|
||||||
return album, true
|
return artist, nil
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return MusicRelease{}, false
|
}
|
||||||
|
return nil, errors.New(fmt.Sprintf("Artist %s not found", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueryAllMusic() ([]MusicRelease) {
|
|
||||||
return placeholders
|
|
||||||
}
|
|
||||||
|
|
||||||
func QueryAllArtists() ([]Artist) {
|
|
||||||
return []Artist{ ari, mellodoot, zaire, mae, loudar, red }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
package music
|
|
||||||
|
|
||||||
var ari = Artist{
|
|
||||||
Id: "arimelody",
|
|
||||||
Name: "ari melody",
|
|
||||||
Website: "https://arimelody.me",
|
|
||||||
}
|
|
||||||
var mellodoot = Artist{
|
|
||||||
Id: "mellodoot",
|
|
||||||
Name: "mellodoot",
|
|
||||||
Website: "https://mellodoot.com",
|
|
||||||
}
|
|
||||||
var zaire = Artist{
|
|
||||||
Id: "zaire",
|
|
||||||
Name: "zaire",
|
|
||||||
Website: "https://supitszaire.com",
|
|
||||||
}
|
|
||||||
var mae = Artist{
|
|
||||||
Id: "maetaylor",
|
|
||||||
Name: "mae taylor",
|
|
||||||
Website: "https://mae.wtf",
|
|
||||||
}
|
|
||||||
var loudar = Artist{
|
|
||||||
Id: "loudar",
|
|
||||||
Name: "Loudar",
|
|
||||||
Website: "https://alex.targoninc.com",
|
|
||||||
}
|
|
||||||
var red = Artist {
|
|
||||||
Id: "smoljorb",
|
|
||||||
Name: "smoljorb",
|
|
||||||
}
|
|
||||||
|
|
||||||
var placeholders = []MusicRelease{
|
|
||||||
{
|
|
||||||
Id: "test",
|
|
||||||
Title: "test album",
|
|
||||||
Type: "album",
|
|
||||||
ReleaseDate: make_date_work("18-Mar-2024"),
|
|
||||||
Buyname: "go get it!!",
|
|
||||||
Buylink: "https://arimelody.me/",
|
|
||||||
Links: []MusicLink{
|
|
||||||
{
|
|
||||||
Name: "youtube",
|
|
||||||
Url: "https://youtu.be/dQw4w9WgXcQ",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description:
|
|
||||||
`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas viverra ligula interdum, tempor metus venenatis, tempus est. Praesent semper vulputate nulla, a venenatis libero elementum id. Proin maximus aliquet accumsan. Integer eu orci congue, ultrices leo sed, maximus risus. Integer laoreet non urna non accumsan. Cras ut sollicitudin justo. Vivamus eu orci tempus, aliquet est rhoncus, tempus neque. Aliquam tempor sit amet nibh sed tempus. Nulla vitae bibendum purus. Sed in mi enim. Nam pharetra enim lorem, vel tristique diam malesuada a. Duis dignissim nunc mi, id semper ex tincidunt a. Sed laoreet consequat lacus a consectetur. Nulla est diam, tempus eget lacus ullamcorper, tincidunt faucibus ex. Duis consectetur felis sit amet ante fermentum interdum. Sed pulvinar laoreet tellus.`,
|
|
||||||
Credits: []MusicCredit{
|
|
||||||
{
|
|
||||||
Artist: &ari,
|
|
||||||
Role: "having the swag",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Artist: &zaire,
|
|
||||||
Role: "having the swag",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Artist: &mae,
|
|
||||||
Role: "having the swag",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Artist: &loudar,
|
|
||||||
Role: "having the swag",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Tracks: []MusicTrack{
|
|
||||||
{
|
|
||||||
Number: 0,
|
|
||||||
Title: "track 1",
|
|
||||||
Description: "sample track description",
|
|
||||||
Lyrics: "sample lyrics for track 1!",
|
|
||||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Number: 1,
|
|
||||||
Title: "track 2",
|
|
||||||
Description: "sample track description",
|
|
||||||
Lyrics: "sample lyrics for track 2!",
|
|
||||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Id: "dream",
|
|
||||||
Title: "Dream",
|
|
||||||
Type: "single",
|
|
||||||
ReleaseDate: make_date_work("11-Nov-2022"),
|
|
||||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Dream.webp",
|
|
||||||
Buylink: "https://arimelody.bandcamp.com/track/dream",
|
|
||||||
Links: []MusicLink{
|
|
||||||
{
|
|
||||||
Name: "spotify",
|
|
||||||
Url: "https://open.spotify.com/album/5talRpqzjExP1w6j5LFIAh",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "apple music",
|
|
||||||
Url: "https://music.apple.com/ie/album/dream-single/1650037132",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "soundcloud",
|
|
||||||
Url: "https://soundcloud.com/arimelody/dream2022",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "youtube",
|
|
||||||
Url: "https://www.youtube.com/watch?v=nfFgtMuYAx8",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "living the dream 🌌 ✨",
|
|
||||||
Credits: []MusicCredit{
|
|
||||||
{
|
|
||||||
Artist: &mellodoot,
|
|
||||||
Role: "vocals",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Artist: &mellodoot,
|
|
||||||
Role: "production",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Artist: &mellodoot,
|
|
||||||
Role: "artwork",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Tracks: []MusicTrack{
|
|
||||||
{
|
|
||||||
Number: 0,
|
|
||||||
Title: "Dream",
|
|
||||||
Description: "no description here!",
|
|
||||||
Lyrics:
|
|
||||||
`the truth is what you make of it
|
|
||||||
in the end, what you spend, is the end of it
|
|
||||||
when you're lost in the life
|
|
||||||
the life that you created on your own
|
|
||||||
i'm becoming one
|
|
||||||
with the soul that i see in the mirror
|
|
||||||
blending one and whole
|
|
||||||
this time, i'm real
|
|
||||||
|
|
||||||
i'm living the dream
|
|
||||||
i'm living my best life
|
|
||||||
running out of time
|
|
||||||
i gotta make this right
|
|
||||||
whenever you rise
|
|
||||||
whenever you come down
|
|
||||||
fall away from the light
|
|
||||||
and then fall into our arms
|
|
||||||
|
|
||||||
the truth is what you make of it
|
|
||||||
in the end, what you spend, is the end of it
|
|
||||||
when you're lost in the life
|
|
||||||
the life that you created on your own
|
|
||||||
i'm becoming one
|
|
||||||
with the soul that i see in the mirror
|
|
||||||
blending one and whole
|
|
||||||
this time, i'm real`,
|
|
||||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,136 +1,133 @@
|
||||||
package music
|
package music
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Artist struct {
|
Artist struct {
|
||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
Website string
|
Website string
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicRelease struct {
|
MusicRelease struct {
|
||||||
Id string
|
Id string
|
||||||
Title string
|
Title string
|
||||||
Type string
|
Type string
|
||||||
ReleaseDate time.Time
|
ReleaseDate time.Time
|
||||||
Artwork string
|
Artwork string
|
||||||
Buyname string
|
Buyname string
|
||||||
Buylink string
|
Buylink string
|
||||||
Links []MusicLink
|
Links []MusicLink
|
||||||
Description string
|
Description string
|
||||||
Credits []MusicCredit
|
Credits []MusicCredit
|
||||||
Tracks []MusicTrack
|
Tracks []MusicTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicLink struct {
|
MusicLink struct {
|
||||||
Name string
|
Name string
|
||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicCredit struct {
|
MusicCredit struct {
|
||||||
Artist *Artist
|
Artist *Artist
|
||||||
Role string
|
Role string
|
||||||
Meta bool // for "meta" contributors (i.e. not credited for the musical work, but other related assets)
|
Primary bool
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicTrack struct {
|
MusicTrack struct {
|
||||||
Number int
|
Number int
|
||||||
Title string
|
Title string
|
||||||
Description string
|
Description string
|
||||||
Lyrics string
|
Lyrics string
|
||||||
PreviewUrl string
|
PreviewUrl string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (release MusicRelease) GetUniqueArtists(include_meta bool) []*Artist {
|
func (release MusicRelease) GetUniqueArtists(include_non_primary bool) []*Artist {
|
||||||
res := []*Artist{}
|
res := []*Artist{}
|
||||||
for _, credit := range release.Credits {
|
for _, credit := range release.Credits {
|
||||||
if !include_meta && credit.Meta {
|
if !include_non_primary && !credit.Primary {
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
exists := false
|
|
||||||
for _, a := range res {
|
|
||||||
if a == credit.Artist {
|
|
||||||
exists = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if exists {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
res = append(res, credit.Artist)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now create the actual array to send
|
exists := false
|
||||||
return res
|
for _, a := range res {
|
||||||
|
if a == credit.Artist {
|
||||||
|
exists = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, credit.Artist)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (release MusicRelease) GetUniqueArtistNames(include_meta bool) []string {
|
func (release MusicRelease) GetUniqueArtistNames(include_non_primary bool) []string {
|
||||||
artists := release.GetUniqueArtists(include_meta)
|
artists := release.GetUniqueArtists(include_non_primary)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
for _, artist := range artists {
|
for _, artist := range artists {
|
||||||
names = append(names, artist.Name)
|
names = append(names, artist.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
func (album MusicRelease) PrintPrimaryArtists(include_meta bool) string {
|
func (release MusicRelease) PrintPrimaryArtists(include_non_primary bool, ampersand bool) string {
|
||||||
names := album.GetUniqueArtistNames(include_meta)
|
names := release.GetUniqueArtistNames(include_non_primary)
|
||||||
if len(names) == 1 {
|
if len(names) == 0 {
|
||||||
return names[0]
|
return "Unknown Artist"
|
||||||
}
|
} else if len(names) == 1 {
|
||||||
|
return names[0]
|
||||||
|
}
|
||||||
|
if ampersand {
|
||||||
res := strings.Join(names[:len(names)-1], ", ")
|
res := strings.Join(names[:len(names)-1], ", ")
|
||||||
res += " & " + names[len(names)-1]
|
res += " & " + names[len(names)-1]
|
||||||
return res
|
return res
|
||||||
}
|
} else {
|
||||||
|
|
||||||
func (album MusicRelease) PrintCommaPrimaryArtists(include_meta bool) string {
|
|
||||||
names := album.GetUniqueArtistNames(include_meta)
|
|
||||||
if len(names) == 1 {
|
|
||||||
return names[0]
|
|
||||||
}
|
|
||||||
return strings.Join(names[:], ", ")
|
return strings.Join(names[:], ", ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (album MusicRelease) ResolveType() string {
|
func (release MusicRelease) ResolveType() string {
|
||||||
if album.Type != "" {
|
if release.Type != "" {
|
||||||
return album.Type
|
return release.Type
|
||||||
}
|
}
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (album MusicRelease) ResolveArtwork() string {
|
func (release MusicRelease) ResolveArtwork() string {
|
||||||
if album.Artwork != "" {
|
if release.Artwork != "" {
|
||||||
return album.Artwork
|
return release.Artwork
|
||||||
}
|
}
|
||||||
return "/img/music-artwork/default.png"
|
return "/img/music-artwork/default.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (album MusicRelease) PrintReleaseDate() string {
|
func (release MusicRelease) PrintReleaseDate() string {
|
||||||
return album.ReleaseDate.Format("02 January 2006")
|
return release.ReleaseDate.Format("02 January 2006")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (album MusicRelease) GetReleaseYear() int {
|
func (release MusicRelease) GetReleaseYear() int {
|
||||||
return album.ReleaseDate.Year()
|
return release.ReleaseDate.Year()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (link MusicLink) NormaliseName() string {
|
func (link MusicLink) NormaliseName() string {
|
||||||
re := regexp.MustCompile(`[^a-z0-9]`)
|
re := regexp.MustCompile(`[^a-z0-9]`)
|
||||||
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
|
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (release MusicRelease) IsSingle() bool {
|
func (release MusicRelease) IsSingle() bool {
|
||||||
return len(release.Tracks) == 1;
|
return len(release.Tracks) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (credit MusicCredit) ResolveArtist() Artist {
|
func (credit MusicCredit) ResolveArtist() Artist {
|
||||||
return *credit.Artist
|
return *credit.Artist
|
||||||
}
|
}
|
||||||
|
|
210
db.go
|
@ -1,72 +1,61 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"arimelody.me/arimelody.me/api/v1/music"
|
"arimelody.me/arimelody.me/api/v1/music"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/jmoiron/sqlx"
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
var schema =
|
|
||||||
`CREATE TABLE IF NOT EXISTS artists (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
name TEXT,
|
|
||||||
website TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS musicreleases (
|
|
||||||
id VARCHAR(64) PRIMARY KEY,
|
|
||||||
title TEXT NOT NULL,
|
|
||||||
type TEXT,
|
|
||||||
release_date DATE NOT NULL,
|
|
||||||
artwork TEXT,
|
|
||||||
buyname TEXT,
|
|
||||||
buylink TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS musiclinks (
|
|
||||||
release VARCHAR(64) REFERENCES musicreleases(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
name TEXT,
|
|
||||||
url TEXT,
|
|
||||||
CONSTRAINT musiclinks_pk PRIMARY KEY (release, name)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS musiccredits (
|
|
||||||
release VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE,
|
|
||||||
artist TEXT REFERENCES artists(id) ON DELETE CASCADE,
|
|
||||||
role TEXT,
|
|
||||||
meta BOOLEAN,
|
|
||||||
constraint musiccredits_pk PRIMARY KEY (release, artist)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS musictracks (
|
|
||||||
release VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE,
|
|
||||||
number INT NOT NULL,
|
|
||||||
title TEXT NOT NULL,
|
|
||||||
description TEXT,
|
|
||||||
lyrics TEXT,
|
|
||||||
preview_url TEXT,
|
|
||||||
CONSTRAINT musictracks_pk PRIMARY KEY (release, number)
|
|
||||||
);`
|
|
||||||
|
|
||||||
func PushArtist(db *sqlx.DB, artist music.Artist) {
|
func PushArtist(db *sqlx.DB, artist music.Artist) {
|
||||||
fmt.Printf("syncing artist [%s] to database...", artist.Name)
|
fmt.Printf("pushing artist [%s] to database...", artist.Name)
|
||||||
|
|
||||||
db.MustExec("INSERT INTO artists (id, name, website) VALUES ($1, $2, $3) ON CONFLICT (id) DO UPDATE SET name=$2, website=$3",
|
db.MustExec("INSERT INTO artists (id, name, website) VALUES ($1, $2, $3) ON CONFLICT (id) DO UPDATE SET name=$2, website=$3",
|
||||||
&artist.Id,
|
&artist.Id,
|
||||||
&artist.Name,
|
&artist.Name,
|
||||||
&artist.Website,
|
&artist.Website,
|
||||||
)
|
)
|
||||||
|
|
||||||
fmt.Printf("done!\n")
|
fmt.Printf("done!\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func PullAllArtists(db *sqlx.DB) ([]*music.Artist, error) {
|
||||||
|
artists := []*music.Artist{}
|
||||||
|
|
||||||
|
rows, err := db.Query("SELECT id, name, website FROM artists")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
var artist = music.Artist{}
|
||||||
|
err = rows.Scan(&artist.Id, &artist.Name, &artist.Website)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
artists = append(artists, &artist)
|
||||||
|
}
|
||||||
|
|
||||||
|
return artists, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PullArtist(db *sqlx.DB, artistID string) (music.Artist, error) {
|
||||||
|
artist := music.Artist{}
|
||||||
|
|
||||||
|
err := db.Get(&artist, "SELECT id, name, website FROM artists WHERE id=$1", artistID)
|
||||||
|
if err != nil {
|
||||||
|
return music.Artist{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PushRelease(db *sqlx.DB, release music.MusicRelease) {
|
func PushRelease(db *sqlx.DB, release music.MusicRelease) {
|
||||||
fmt.Printf("syncing release [%s] to database...", release.Id)
|
fmt.Printf("pushing release [%s] to database...", release.Id)
|
||||||
|
|
||||||
tx := db.MustBegin()
|
tx := db.MustBegin()
|
||||||
tx.MustExec("INSERT INTO musicreleases (id, title, type, release_date, artwork, buyname, buylink) VALUES ($1, $2, $3, $4, $5, $6, $7) "+
|
tx.MustExec("INSERT INTO musicreleases (id, title, type, release_date, artwork, buyname, buylink) VALUES ($1, $2, $3, $4, $5, $6, $7) "+
|
||||||
|
@ -78,8 +67,8 @@ func PushRelease(db *sqlx.DB, release music.MusicRelease) {
|
||||||
&release.Id, &link.Name, &link.Url)
|
&release.Id, &link.Name, &link.Url)
|
||||||
}
|
}
|
||||||
for _, credit := range release.Credits {
|
for _, credit := range release.Credits {
|
||||||
tx.MustExec("INSERT INTO musiccredits (release, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",
|
tx.MustExec("INSERT INTO musiccredits (release, artist, role, is_primary) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",
|
||||||
&release.Id, &credit.Artist.Id, &credit.Role, &credit.Meta)
|
&release.Id, &credit.Artist.Id, &credit.Role, &credit.Primary)
|
||||||
}
|
}
|
||||||
for _, track := range release.Tracks {
|
for _, track := range release.Tracks {
|
||||||
tx.MustExec("INSERT INTO musictracks (release, number, title, description, lyrics, preview_url) VALUES ($1, $2, $3, $4, $5, $6) "+
|
tx.MustExec("INSERT INTO musictracks (release, number, title, description, lyrics, preview_url) VALUES ($1, $2, $3, $4, $5, $6) "+
|
||||||
|
@ -92,6 +81,114 @@ func PushRelease(db *sqlx.DB, release music.MusicRelease) {
|
||||||
fmt.Printf("done!\n")
|
fmt.Printf("done!\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PullAllReleases(db *sqlx.DB) ([]*music.MusicRelease, error) {
|
||||||
|
releases := []*music.MusicRelease{}
|
||||||
|
|
||||||
|
rows, err := db.Query("SELECT id, title, type, release_date, artwork, buyname, buylink FROM musicreleases")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
var release = music.MusicRelease{}
|
||||||
|
release.Credits = []music.MusicCredit{}
|
||||||
|
release.Links = []music.MusicLink{}
|
||||||
|
release.Tracks = []music.MusicTrack{}
|
||||||
|
|
||||||
|
err = rows.Scan(
|
||||||
|
&release.Id,
|
||||||
|
&release.Title,
|
||||||
|
&release.Type,
|
||||||
|
&release.ReleaseDate,
|
||||||
|
&release.Artwork,
|
||||||
|
&release.Buyname,
|
||||||
|
&release.Buylink)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull musiccredits for artist data
|
||||||
|
credit_rows, err := db.Query("SELECT artist, role, is_primary FROM musiccredits WHERE release=$1", release.Id)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling credits for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for credit_rows.Next() {
|
||||||
|
var artistID string
|
||||||
|
var credit = music.MusicCredit{}
|
||||||
|
err = credit_rows.Scan(
|
||||||
|
&artistID,
|
||||||
|
&credit.Role,
|
||||||
|
&credit.Primary)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling credit for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
artist, err := music.GetArtist(artistID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling credit for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
credit.Artist = artist
|
||||||
|
release.Credits = append(release.Credits, credit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull musiclinks for link data
|
||||||
|
link_rows, err := db.Query("SELECT name, url FROM musiclinks WHERE release=$1", release.Id);
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling links for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for link_rows.Next() {
|
||||||
|
var link = music.MusicLink{}
|
||||||
|
err = link_rows.Scan(
|
||||||
|
&link.Name,
|
||||||
|
&link.Url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling link for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
release.Links = append(release.Links, link)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull musictracks for track data
|
||||||
|
track_rows, err := db.Query("SELECT number, title, description, lyrics, preview_url FROM musictracks WHERE release=$1", release.Id);
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling tracks for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for track_rows.Next() {
|
||||||
|
var track = music.MusicTrack{}
|
||||||
|
err = track_rows.Scan(
|
||||||
|
&track.Number,
|
||||||
|
&track.Title,
|
||||||
|
&track.Description,
|
||||||
|
&track.Lyrics,
|
||||||
|
&track.PreviewUrl)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error pulling track for %s: %v\n", release.Id, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
release.Tracks = append(release.Tracks, track)
|
||||||
|
}
|
||||||
|
|
||||||
|
releases = append(releases, &release)
|
||||||
|
}
|
||||||
|
|
||||||
|
return releases, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PullRelease(db *sqlx.DB, releaseID string) (music.MusicRelease, error) {
|
||||||
|
release := music.MusicRelease{}
|
||||||
|
|
||||||
|
err := db.Get(&release, "SELECT id, title, type, release_date, artwork, buyname, buylink FROM musicreleases WHERE id=$1", releaseID)
|
||||||
|
if err != nil {
|
||||||
|
return music.MusicRelease{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return release, nil
|
||||||
|
}
|
||||||
|
|
||||||
func InitDatabase() *sqlx.DB {
|
func InitDatabase() *sqlx.DB {
|
||||||
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
|
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -103,8 +200,5 @@ func InitDatabase() *sqlx.DB {
|
||||||
db.SetMaxOpenConns(10)
|
db.SetMaxOpenConns(10)
|
||||||
db.SetMaxIdleConns(10)
|
db.SetMaxIdleConns(10)
|
||||||
|
|
||||||
db.MustExec(schema)
|
|
||||||
fmt.Printf("database schema synchronised.\n")
|
|
||||||
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
44
discord/discord.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package discord
|
||||||
|
|
||||||
|
const API_ENDPOINT = "https://discord.com/api/v10"
|
||||||
|
const CLIENT_ID = "1268013769578119208"
|
||||||
|
// TODO: good GOD change this later please i beg you. we've already broken
|
||||||
|
// the rules by doing this at all
|
||||||
|
const CLIENT_SECRET = "JUEZnixhN7BxmLIHmbECiKETMP85VT0E"
|
||||||
|
const REDIRECT_URI = "https://discord.com/oauth2/authorize?client_id=1268013769578119208&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2Fapi%2Fv1%2Fadmin%2Flogin&scope=identify"
|
||||||
|
// TODO: change before prod
|
||||||
|
const MY_REDIRECT_URI = "http://127.0.0.1:8080/api/v1/admin/login"
|
||||||
|
|
||||||
|
type (
|
||||||
|
AccessTokenResponse struct {
|
||||||
|
TokenType string `json:"token_type"`
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
ExpiresIn int `json:"expires_in"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
Scope string `json:"scope"`
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthInfoResponse struct {
|
||||||
|
Application struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
Icon string
|
||||||
|
Description string
|
||||||
|
Hook bool
|
||||||
|
BotPublic bool
|
||||||
|
botRequireCodeGrant bool
|
||||||
|
VerifyKey bool
|
||||||
|
}
|
||||||
|
Scopes []string
|
||||||
|
Expires string
|
||||||
|
User struct {
|
||||||
|
Id string
|
||||||
|
Username string
|
||||||
|
Avatar string
|
||||||
|
Discriminator string
|
||||||
|
GlobalName string
|
||||||
|
PublicFlags int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
34
global/global.go
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var LAST_MODIFIED = time.Now()
|
||||||
|
|
||||||
|
var MimeTypes = map[string]string{
|
||||||
|
"css": "text/css; charset=utf-8",
|
||||||
|
"png": "image/png",
|
||||||
|
"jpg": "image/jpg",
|
||||||
|
"webp": "image/webp",
|
||||||
|
"html": "text/html",
|
||||||
|
"asc": "text/plain",
|
||||||
|
"pub": "text/plain",
|
||||||
|
"js": "application/javascript",
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsModified(req *http.Request, last_modified time.Time) bool {
|
||||||
|
if len(req.Header["If-Modified-Since"]) == 0 || len(req.Header["If-Modified-Since"][0]) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
request_time, err := time.Parse(http.TimeFormat, req.Header["If-Modified-Since"][0])
|
||||||
|
if err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if request_time.Before(last_modified) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
446
main.go
|
@ -5,278 +5,212 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"arimelody.me/arimelody.me/api"
|
"arimelody.me/arimelody.me/api/v1/admin"
|
||||||
"arimelody.me/arimelody.me/api/v1/music"
|
"arimelody.me/arimelody.me/api/v1/music"
|
||||||
|
|
||||||
"github.com/gomarkdown/markdown"
|
|
||||||
"github.com/gomarkdown/markdown/html"
|
|
||||||
"github.com/gomarkdown/markdown/parser"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const PORT int = 8080
|
const DEFAULT_PORT int = 8080
|
||||||
var LAST_MODIFIED = time.Now()
|
|
||||||
|
|
||||||
var mime_types = map[string]string{
|
|
||||||
"css": "text/css; charset=utf-8",
|
|
||||||
"png": "image/png",
|
|
||||||
"jpg": "image/jpg",
|
|
||||||
"webp": "image/webp",
|
|
||||||
"html": "text/html",
|
|
||||||
"asc": "text/plain",
|
|
||||||
"pub": "text/plain",
|
|
||||||
"js": "application/javascript",
|
|
||||||
}
|
|
||||||
|
|
||||||
var base_template = template.Must(template.ParseFiles(
|
var base_template = template.Must(template.ParseFiles(
|
||||||
"views/base.html",
|
"views/base.html",
|
||||||
"views/header.html",
|
"views/header.html",
|
||||||
"views/footer.html",
|
"views/footer.html",
|
||||||
"views/prideflag.html",
|
"views/prideflag.html",
|
||||||
))
|
))
|
||||||
// var htmx_template = template.Must(template.New("root").Parse(`<head>{{block "head" .}}{{end}}</head>{{block "content" .}}{{end}}`))
|
|
||||||
|
|
||||||
func log_request(req *http.Request, code int, start_time time.Time) {
|
func log_request(req *http.Request, code int, start_time time.Time) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
difference := (now.Nanosecond() - start_time.Nanosecond()) / 1_000_000
|
difference := (now.Nanosecond() - start_time.Nanosecond()) / 1_000_000
|
||||||
elapsed := "<1"
|
elapsed := "<1"
|
||||||
if difference >= 1 {
|
if difference >= 1 {
|
||||||
elapsed = strconv.Itoa(difference)
|
elapsed = strconv.Itoa(difference)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[%s] %s %s - %d (%sms) (%s)\n",
|
fmt.Printf("[%s] %s %s - %d (%sms) (%s)\n",
|
||||||
now.Format(time.UnixDate),
|
now.Format(time.UnixDate),
|
||||||
req.Method,
|
req.Method,
|
||||||
req.URL.Path,
|
req.URL.Path,
|
||||||
code,
|
code,
|
||||||
elapsed,
|
elapsed,
|
||||||
req.Header["User-Agent"][0],
|
req.Header["User-Agent"][0])
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle_request(writer http.ResponseWriter, req *http.Request) {
|
// func handle_request(res http.ResponseWriter, req *http.Request) {
|
||||||
uri := req.URL.Path
|
// uri := req.URL.Path
|
||||||
start_time := time.Now()
|
// start_time := time.Now()
|
||||||
|
//
|
||||||
// hx_request := len(req.Header["Hx-Request"]) > 0 && req.Header["Hx-Request"][0] == "true"
|
// res.Header().Set("Server", "arimelody.me")
|
||||||
//
|
//
|
||||||
// // don't bother fulfilling requests to a page that's already loaded on the client!
|
// code := func(res http.ResponseWriter, req *http.Request) int {
|
||||||
// if hx_request && len(req.Header["Referer"]) > 0 && len(req.Header["Hx-Current-Url"]) > 0 {
|
// var root = template.Must(base_template.Clone())
|
||||||
// regex := regexp.MustCompile(`https?:\/\/[^\/]+`)
|
//
|
||||||
// current_location := regex.ReplaceAllString(req.Header["Hx-Current-Url"][0], "")
|
// if req.URL.Path == "/" {
|
||||||
// if current_location == req.URL.Path {
|
// return handle_index(res, req, root)
|
||||||
// writer.WriteHeader(204);
|
// }
|
||||||
// return
|
//
|
||||||
// }
|
// if uri == "/music" || uri == "/music/" {
|
||||||
// }
|
// return handle_music(res, req, root)
|
||||||
|
// }
|
||||||
writer.Header().Set("Server", "arimelody.me")
|
//
|
||||||
writer.Header().Set("Cache-Control", "max-age=86400")
|
// if strings.HasPrefix(uri, "/music/") {
|
||||||
writer.Header().Set("Last-Modified", LAST_MODIFIED.Format(http.TimeFormat))
|
// return handle_music_gateway(res, req, root)
|
||||||
|
// }
|
||||||
code := func(writer http.ResponseWriter, req *http.Request) int {
|
//
|
||||||
// var root *template.Template
|
// if strings.HasPrefix(uri, "/admin") {
|
||||||
// if hx_request {
|
// return admin.Handle(res, req, root)
|
||||||
// root = template.Must(htmx_template.Clone())
|
// }
|
||||||
// } else {
|
//
|
||||||
// root = template.Must(base_template.Clone())
|
// if strings.HasPrefix(uri, "/api") {
|
||||||
// }
|
// return api.Handle(res, req, root)
|
||||||
|
// }
|
||||||
var root = template.Must(base_template.Clone())
|
//
|
||||||
|
// return static_handler(res, req, root)
|
||||||
if req.URL.Path == "/" {
|
// }(res, req)
|
||||||
return handle_index(writer, req, root)
|
//
|
||||||
}
|
// log_request(req, code, start_time)
|
||||||
|
// }
|
||||||
if uri == "/music" || uri == "/music/" {
|
//
|
||||||
return handle_music(writer, req, root)
|
// func handle_index(res http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
}
|
// if !global.IsModified(req, global.LAST_MODIFIED) {
|
||||||
|
// res.WriteHeader(304)
|
||||||
if strings.HasPrefix(uri, "/music/") {
|
// return 304
|
||||||
return handle_music_gateway(writer, req, root)
|
// }
|
||||||
}
|
//
|
||||||
|
// index_template := template.Must(root.ParseFiles("views/index.html"))
|
||||||
if strings.HasPrefix(uri, "/admin") {
|
// err := index_template.Execute(res, nil)
|
||||||
return handle_admin(writer, req, root)
|
// if err != nil {
|
||||||
}
|
// http.Error(res, err.Error(), http.StatusInternalServerError)
|
||||||
|
// return 500
|
||||||
if strings.HasPrefix(uri, "/api") {
|
// }
|
||||||
return api.Handle(writer, req, root)
|
// return 200
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return static_handler(writer, req, root)
|
// func handle_music(res http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
}(writer, req)
|
// if !global.IsModified(req, global.LAST_MODIFIED) {
|
||||||
|
// res.WriteHeader(304)
|
||||||
log_request(req, code, start_time)
|
// return 304
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func handle_index(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
// music_template := template.Must(root.ParseFiles("views/music.html"))
|
||||||
if !was_modified(req, LAST_MODIFIED) {
|
// err := music_template.Execute(res, music.Releases)
|
||||||
writer.WriteHeader(304)
|
// if err != nil {
|
||||||
return 304
|
// http.Error(res, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
// return 500
|
||||||
|
// }
|
||||||
index_template := template.Must(root.ParseFiles("views/index.html"))
|
// return 200
|
||||||
err := index_template.Execute(writer, nil)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
// func handle_music_gateway(res http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
return 500
|
// if !global.IsModified(req, global.LAST_MODIFIED) {
|
||||||
}
|
// res.WriteHeader(304)
|
||||||
return 200
|
// return 304
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func handle_music(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
// id := req.URL.Path[len("/music/"):]
|
||||||
if !was_modified(req, LAST_MODIFIED) {
|
// release, err := music.GetRelease(id)
|
||||||
writer.WriteHeader(304)
|
// if err != nil {
|
||||||
return 304
|
// return handle_not_found(res, req, root)
|
||||||
}
|
// }
|
||||||
|
// gateway_template := template.Must(root.ParseFiles("views/music-gateway.html"))
|
||||||
music_template := template.Must(root.ParseFiles("views/music.html"))
|
// err = gateway_template.Execute(res, release)
|
||||||
music := music.QueryAllMusic()
|
// if err != nil {
|
||||||
err := music_template.Execute(writer, music)
|
// http.Error(res, err.Error(), http.StatusInternalServerError)
|
||||||
if err != nil {
|
// return 500
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
// }
|
||||||
return 500
|
// return 200
|
||||||
}
|
// }
|
||||||
return 200
|
//
|
||||||
}
|
// func static_handler(res http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
|
// filename := "public/" + req.URL.Path[1:]
|
||||||
func handle_music_gateway(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
//
|
||||||
if !was_modified(req, LAST_MODIFIED) {
|
// // check the file's metadata
|
||||||
writer.WriteHeader(304)
|
// info, err := os.Stat(filename)
|
||||||
return 304
|
// if err != nil {
|
||||||
}
|
// return handle_not_found(res, req, root)
|
||||||
|
// }
|
||||||
id := req.URL.Path[len("/music/"):]
|
//
|
||||||
// http.Redirect(writer, req, "https://mellodoot.com/music/"+title, 302)
|
// if !global.IsModified(req, info.ModTime()) {
|
||||||
// return
|
// res.WriteHeader(304)
|
||||||
release, ok := music.GetRelease(id)
|
// return 304
|
||||||
if !ok {
|
// }
|
||||||
return handle_not_found(writer, req, root)
|
//
|
||||||
}
|
// // set Last-Modified to file modification date
|
||||||
gateway_template := template.Must(root.ParseFiles("views/music-gateway.html"))
|
// res.Header().Set("Last-Modified", info.ModTime().Format(http.TimeFormat))
|
||||||
err := gateway_template.Execute(writer, release)
|
//
|
||||||
if err != nil {
|
// // read the file
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
// body, err := os.ReadFile(filename)
|
||||||
return 500
|
// if err != nil {
|
||||||
}
|
// http.Error(res, err.Error(), http.StatusInternalServerError)
|
||||||
return 200
|
// return 500
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func handle_admin(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
// // setting MIME types
|
||||||
if !was_modified(req, LAST_MODIFIED) {
|
// filetype := filename[strings.LastIndex(filename, ".")+1:]
|
||||||
writer.WriteHeader(304)
|
// if mime_type, ok := global.MimeTypes[filetype]; ok {
|
||||||
return 304
|
// res.Header().Set("Content-Type", mime_type)
|
||||||
}
|
// } else {
|
||||||
|
// res.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
admin_template := template.Must(root.ParseFiles("views/admin.html"))
|
// }
|
||||||
err := admin_template.Execute(writer, nil)
|
//
|
||||||
if err != nil {
|
// res.Write([]byte(body))
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
// return 200
|
||||||
return 500
|
// }
|
||||||
}
|
//
|
||||||
return 200
|
// func handle_not_found(res http.ResponseWriter, req *http.Request, root *template.Template) int {
|
||||||
}
|
// type ErrorData struct {
|
||||||
|
// Target string
|
||||||
func static_handler(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
// }
|
||||||
filename := "public/" + req.URL.Path[1:]
|
// error_data := ErrorData{ Target: req.URL.Path }
|
||||||
|
// res.WriteHeader(404);
|
||||||
// check the file's metadata
|
// error_template := template.Must(root.ParseFiles("views/404.html"))
|
||||||
info, err := os.Stat(filename)
|
// err := error_template.Execute(res, error_data)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return handle_not_found(writer, req, root)
|
// http.Error(res, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
// return 500
|
||||||
|
// }
|
||||||
if !was_modified(req, info.ModTime()) {
|
// return 404
|
||||||
writer.WriteHeader(304)
|
// }
|
||||||
return 304
|
//
|
||||||
}
|
// func parse_markdown(md []byte) []byte {
|
||||||
|
// extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock
|
||||||
// set Last-Modified to file modification date
|
// p := parser.NewWithExtensions(extensions)
|
||||||
writer.Header().Set("Last-Modified", info.ModTime().Format(http.TimeFormat))
|
// doc := p.Parse(md)
|
||||||
|
//
|
||||||
// read the file
|
// htmlFlags := html.CommonFlags
|
||||||
body, err := os.ReadFile(filename)
|
// opts := html.RendererOptions{Flags: htmlFlags}
|
||||||
if err != nil {
|
// renderer := html.NewRenderer(opts)
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
//
|
||||||
return 500
|
// return markdown.Render(doc, renderer)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// setting MIME types
|
|
||||||
filetype := filename[strings.LastIndex(filename, ".")+1:]
|
|
||||||
if mime_type, ok := mime_types[filetype]; ok {
|
|
||||||
writer.Header().Set("Content-Type", mime_type)
|
|
||||||
} else {
|
|
||||||
writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.Write([]byte(body))
|
|
||||||
return 200
|
|
||||||
}
|
|
||||||
|
|
||||||
func handle_not_found(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
|
|
||||||
type ErrorData struct {
|
|
||||||
Target string
|
|
||||||
}
|
|
||||||
error_data := ErrorData{ Target: req.URL.Path }
|
|
||||||
writer.WriteHeader(404);
|
|
||||||
error_template := template.Must(root.ParseFiles("views/404.html"))
|
|
||||||
err := error_template.Execute(writer, error_data)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
|
||||||
return 500
|
|
||||||
}
|
|
||||||
return 404
|
|
||||||
}
|
|
||||||
|
|
||||||
func was_modified(req *http.Request, last_modified time.Time) bool {
|
|
||||||
if len(req.Header["If-Modified-Since"]) == 0 || len(req.Header["If-Modified-Since"][0]) == 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
request_time, err := time.Parse(http.TimeFormat, req.Header["If-Modified-Since"][0])
|
|
||||||
if err != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if request_time.Before(last_modified) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func parse_markdown(md []byte) []byte {
|
|
||||||
extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock
|
|
||||||
p := parser.NewWithExtensions(extensions)
|
|
||||||
doc := p.Parse(md)
|
|
||||||
|
|
||||||
htmlFlags := html.CommonFlags
|
|
||||||
opts := html.RendererOptions{Flags: htmlFlags}
|
|
||||||
renderer := html.NewRenderer(opts)
|
|
||||||
|
|
||||||
return markdown.Render(doc, renderer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func push_to_db_this_is_a_testing_thing_and_will_be_superfluous_later() {
|
|
||||||
db := InitDatabase()
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
for _, artist := range music.QueryAllArtists() {
|
|
||||||
PushArtist(db, artist)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, album := range music.QueryAllMusic() {
|
|
||||||
PushRelease(db, album)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
push_to_db_this_is_a_testing_thing_and_will_be_superfluous_later()
|
db := InitDatabase()
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
music.Artists, err = PullAllArtists(db)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to pull artists from database: %v\n", err);
|
||||||
|
panic(1)
|
||||||
|
}
|
||||||
|
music.Releases, err = PullAllReleases(db)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to pull releases from database: %v\n", err);
|
||||||
|
panic(1)
|
||||||
|
}
|
||||||
|
|
||||||
http.HandleFunc("/", handle_request)
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
fmt.Printf("now serving at http://127.0.0.1:%d\n", PORT)
|
mux.Handle("/api/v1/admin", admin.Handler())
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", PORT), nil))
|
mux.Handle("/api/v1/admin/login", admin.LoginHandler())
|
||||||
|
mux.Handle("/api/v1/admin/callback", admin.OAuthCallbackHandler())
|
||||||
|
mux.Handle("/api/v1/admin/verify", admin.AuthorisedHandler(admin.VerifyHandler()))
|
||||||
|
mux.Handle("/api/v1/admin/logout", admin.AuthorisedHandler(admin.LogoutHandler()))
|
||||||
|
|
||||||
|
port := DEFAULT_PORT
|
||||||
|
fmt.Printf("now serving at http://127.0.0.1:%d\n", port)
|
||||||
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), mux))
|
||||||
}
|
}
|
||||||
|
|
BIN
public/img/buttons/elke.gif
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
public/img/buttons/itzzen.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
public/img/buttons/misc/blink.gif
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
public/img/favicon-256.png
Normal file
After Width: | Height: | Size: 95 KiB |
BIN
public/img/favicon-36.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 944 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 24 KiB |
32
public/img/prideflag.svg
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<!--
|
||||||
|
pride flag - copyright (c) 2024 ari melody
|
||||||
|
|
||||||
|
this code is provided AS-IS, WITHOUT ANY WARRANTY, to be
|
||||||
|
freely redistributed and/or modified as you please, however
|
||||||
|
retaining this license in any redistribution.
|
||||||
|
|
||||||
|
please use this flag to link to an LGBTQI+-supporting page
|
||||||
|
of your choosing!
|
||||||
|
|
||||||
|
web: https://arimelody.me
|
||||||
|
source: https://git.arimelody.me/ari/prideflag
|
||||||
|
-->
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120">
|
||||||
|
<path id="red" d="M120,80 L100,100 L120,120 Z" style="fill:#d20605"/>
|
||||||
|
<path id="orange" d="M120,80 V40 L80,80 L100,100 Z" style="fill:#ef9c00"/>
|
||||||
|
<path id="yellow" d="M120,40 V0 L60,60 L80,80 Z" style="fill:#e5fe02"/>
|
||||||
|
<path id="green" d="M120,0 H80 L40,40 L60,60 Z" style="fill:#09be01"/>
|
||||||
|
<path id="blue" d="M80,0 H40 L20,20 L40,40 Z" style="fill:#081a9a"/>
|
||||||
|
<path id="purple" d="M40,0 H0 L20,20 Z" style="fill:#76008a"/>
|
||||||
|
|
||||||
|
<rect id="black" x="60" width="60" height="60" style="fill:#010101"/>
|
||||||
|
<rect id="brown" x="70" width="50" height="50" style="fill:#603814"/>
|
||||||
|
<rect id="lightblue" x="80" width="40" height="40" style="fill:#73d6ed"/>
|
||||||
|
<rect id="pink" x="90" width="30" height="30" style="fill:#ffafc8"/>
|
||||||
|
<rect id="white" x="100" width="20" height="20" style="fill:#fff"/>
|
||||||
|
|
||||||
|
<rect id="intyellow" x="110" width="10" height="10" style="fill:#fed800"/>
|
||||||
|
<circle id="intpurple" cx="120" cy="0" r="5" stroke="#7601ad" stroke-width="2" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -1,79 +1,73 @@
|
||||||
import "./main.js";
|
import "./main.js";
|
||||||
|
|
||||||
function apply_funny_bob_to_upcoming_tags() {
|
function apply_funny_bob_to_upcoming_tags() {
|
||||||
const upcoming_tags = document.querySelectorAll("#type.upcoming");
|
const upcoming_tags = document.querySelectorAll("#type.upcoming");
|
||||||
for (var i = 0; i < upcoming_tags.length; i++) {
|
for (var i = 0; i < upcoming_tags.length; i++) {
|
||||||
const tag = upcoming_tags[i];
|
const tag = upcoming_tags[i];
|
||||||
const chars = tag.innerText.split("");
|
const chars = tag.innerText.split("");
|
||||||
const result = chars.map((c, i) => `<span style="animation-delay: -${i * 100}ms;">${c}</span>`);
|
const result = chars.map((c, i) => `<span style="animation-delay: -${i * 100}ms;">${c}</span>`);
|
||||||
tag.innerHTML = result.join("");
|
tag.innerHTML = result.join("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_extras_buttons() {
|
function update_extras_buttons() {
|
||||||
const extras_pairs = Array.from(document.querySelectorAll("div#info > div").values()).map(container => {
|
const extras_pairs = Array.from(document.querySelectorAll("div#info > div").values()).map(container => {
|
||||||
return {
|
return {
|
||||||
container,
|
container,
|
||||||
button: document.getElementById("extras").querySelector(`ul li a[href="#${container.id}"]`)
|
button: document.getElementById("extras").querySelector(`ul li a[href="#${container.id}"]`)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const info_container = document.getElementById("info")
|
const info_container = document.getElementById("info")
|
||||||
info_container.addEventListener("scroll", update_extras_buttons);
|
info_container.addEventListener("scroll", update_extras_buttons);
|
||||||
const info_rect = info_container.getBoundingClientRect();
|
const info_rect = info_container.getBoundingClientRect();
|
||||||
const info_y = info_rect.y;
|
const info_y = info_rect.y;
|
||||||
const font_size = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
const font_size = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||||
let current = extras_pairs[0];
|
let current = extras_pairs[0];
|
||||||
extras_pairs.forEach(pair => {
|
extras_pairs.forEach(pair => {
|
||||||
pair.button.classList.remove("active");
|
pair.button.classList.remove("active");
|
||||||
const scroll_diff = pair.container.getBoundingClientRect().y -
|
const scroll_diff = pair.container.getBoundingClientRect().y -
|
||||||
info_rect.y -
|
info_rect.y -
|
||||||
info_rect.height / 2 +
|
info_rect.height / 2 +
|
||||||
4 * font_size;
|
4 * font_size;
|
||||||
if (scroll_diff <= 0) current = pair;
|
if (scroll_diff <= 0) current = pair;
|
||||||
})
|
})
|
||||||
current.button.classList.add("active");
|
current.button.classList.add("active");
|
||||||
|
|
||||||
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
|
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
|
||||||
link.addEventListener("click", event => {
|
link.addEventListener("click", event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
location.replace(link.href);
|
const tag = link.href.split('#').slice(-1)[0];
|
||||||
});
|
document.getElementById(tag).scrollIntoView();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bind_go_back_btn() {
|
function bind_go_back_btn() {
|
||||||
const go_back_btn = document.getElementById("go-back")
|
const go_back_btn = document.getElementById("go-back")
|
||||||
go_back_btn.innerText = "<";
|
go_back_btn.innerText = "<";
|
||||||
go_back_btn.addEventListener("click", () => {
|
go_back_btn.addEventListener("click", () => {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bind_share_btn() {
|
function bind_share_btn() {
|
||||||
const share_btn = document.getElementById("share");
|
const share_btn = document.getElementById("share");
|
||||||
if (navigator.clipboard === undefined) {
|
if (navigator.clipboard === undefined) {
|
||||||
share_btn.onclick = event => {
|
|
||||||
console.error("clipboard is not supported by this browser!");
|
|
||||||
};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
share_btn.onclick = event => {
|
share_btn.onclick = event => {
|
||||||
event.preventDefault();
|
console.error("clipboard is not supported by this browser!");
|
||||||
navigator.clipboard.writeText(window.location.href);
|
};
|
||||||
share_btn.classList.remove('active');
|
return;
|
||||||
void share_btn.offsetWidth;
|
}
|
||||||
share_btn.classList.add('active');
|
share_btn.onclick = event => {
|
||||||
}
|
event.preventDefault();
|
||||||
|
navigator.clipboard.writeText(window.location.href);
|
||||||
|
share_btn.classList.remove('active');
|
||||||
|
void share_btn.offsetWidth;
|
||||||
|
share_btn.classList.add('active');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
bind_share_btn();
|
||||||
bind_share_btn();
|
bind_go_back_btn();
|
||||||
bind_go_back_btn();
|
apply_funny_bob_to_upcoming_tags();
|
||||||
apply_funny_bob_to_upcoming_tags();
|
update_extras_buttons();
|
||||||
update_extras_buttons();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("swap", () => {
|
|
||||||
if (!window.location.pathname.startsWith("/music/")) return;
|
|
||||||
start();
|
|
||||||
});
|
|
||||||
|
|
52
schema.sql
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS artists (
|
||||||
|
id text NOT NULL,
|
||||||
|
name text,
|
||||||
|
website text
|
||||||
|
);
|
||||||
|
ALTER TABLE artists ADD CONSTRAINT artists_pk PRIMARY KEY (id);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS musicreleases (
|
||||||
|
id character varying(64) NOT NULL,
|
||||||
|
title text NOT NULL,
|
||||||
|
type text,
|
||||||
|
release_date DATE NOT NULL,
|
||||||
|
artwork text,
|
||||||
|
buyname text,
|
||||||
|
buylink text
|
||||||
|
);
|
||||||
|
ALTER TABLE musicreleases ADD CONSTRAINT musicreleases_pk PRIMARY KEY (id);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS musiclinks (
|
||||||
|
release character varying(64) NOT NULL,
|
||||||
|
name text NOT NULL,
|
||||||
|
url text,
|
||||||
|
);
|
||||||
|
ALTER TABLE musiclinks ADD CONSTRAINT musiclinks_pk PRIMARY KEY (release, name);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS musiccredits (
|
||||||
|
release character varying(64) NOT NULL,
|
||||||
|
artist text NOT NULL,
|
||||||
|
role text,
|
||||||
|
is_primary boolean,
|
||||||
|
);
|
||||||
|
ALTER TABLE musiccredits ADD CONSTRAINT musiccredits_pk PRIMARY KEY (release, artist);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS musictracks (
|
||||||
|
release character varying(64) NOT NULL,
|
||||||
|
number integer NOT NULL,
|
||||||
|
title text NOT NULL,
|
||||||
|
description text,
|
||||||
|
lyrics text,
|
||||||
|
preview_url text,
|
||||||
|
);
|
||||||
|
ALTER TABLE musictracks ADD CONSTRAINT musictracks_pk PRIMARY KEY (release, number);
|
||||||
|
|
||||||
|
-- foreign keys
|
||||||
|
|
||||||
|
ALTER TABLE public.musiccredits ADD CONSTRAINT musiccredits_artist_fk FOREIGN KEY (artist) REFERENCES public.artists(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE public.musiccredits ADD CONSTRAINT musiccredits_release_fk FOREIGN KEY (release) REFERENCES public.musicreleases(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE public.musiclinks ADD CONSTRAINT musiclinks_release_fk FOREIGN KEY (release) REFERENCES public.musicreleases(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE public.musictracks ADD CONSTRAINT musictracks_release_fk FOREIGN KEY (release) REFERENCES public.musicreleases(id) ON DELETE CASCADE;
|
|
@ -14,7 +14,9 @@
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
bappity boopity
|
whapow! nothing here.
|
||||||
|
<br>
|
||||||
|
nice try, though.
|
||||||
</p>
|
</p>
|
||||||
</main>
|
</main>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<!-- <script type="application/javascript" src="/script/lib/htmx.js"></script> -->
|
<!-- <script type="application/javascript" src="/script/lib/htmx.js"></script> -->
|
||||||
<!-- <script type="application/javascript" src="/script/lib/htmx.min.js"></script> -->
|
<!-- <script type="application/javascript" src="/script/lib/htmx.min.js"></script> -->
|
||||||
<!-- <script type="application/javascript" src="/script/lib/htmx-preload.js"></script> -->
|
<!-- <script type="application/javascript" src="/script/lib/htmx-preload.js"></script> -->
|
||||||
<script type="application/javascript" src="/script/swap.js"></script>
|
<!-- <script type="application/javascript" src="/script/swap.js"></script> -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
311
views/index.html
|
@ -20,169 +20,166 @@
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<main>
|
<main>
|
||||||
<script type="module" src="/script/main.js"></script>
|
<h1>
|
||||||
|
# hello, world!
|
||||||
|
</h1>
|
||||||
|
|
||||||
<h1>
|
<p>
|
||||||
# hello, world!
|
<strong>i'm ari!</strong>
|
||||||
</h1>
|
<br>
|
||||||
|
<small>she/her 🏳️⚧️🏳️🌈💫🦆🇮🇪</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
i'm a <a href="/music">musician</a>, <a href="https://github.com/arimelody?tab=repositories">developer</a>,
|
||||||
|
<a href="https://twitch.tv/arispacegirl">streamer</a>, <a href="https://youtube.com/@arispacegirl">youtuber</a>,
|
||||||
|
and probably a bunch of other things i forgot to mention!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
you're very welcome to take a look around my little space on the internet here,
|
||||||
|
or explore any of the other parts i inhabit!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
if you're looking to support me financially, that's so cool of you!!
|
||||||
|
if you like, you can buy some of my music over on
|
||||||
|
<a href="https://arimelody.bandcamp.com" target="_blank">bandcamp</a>
|
||||||
|
so you can at least get something for your money.
|
||||||
|
thank you very much either way!! 💕
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
for anything else, you can reach me for any and all communications through
|
||||||
|
<a href="mailto:ari@arimelody.me">ari@arimelody.me</a>. if your message
|
||||||
|
contains anything beyond a silly gag, i strongly recommend encrypting
|
||||||
|
your message using my public pgp key, listed below!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
thank you for stopping by- i hope you have a lovely rest of your day! 💫
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<hr>
|
||||||
<strong>i'm ari!</strong>
|
|
||||||
<br>
|
|
||||||
<small>she/her 🏳️⚧️🏳️🌈💫🦆🇮🇪</small>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<h2>
|
||||||
i like to create things on the internet! namely <a href="/music">music</a>,
|
## metadata
|
||||||
<a href="https://youtube.com/mellodoot" target="_blank">videos</a>, art <small><em>(link pending)</em></small>, and the odd
|
</h2>
|
||||||
<a href="https://github.com/mellodoot?tab=repositories" target="_blank">code project</a> from time to time!
|
|
||||||
if it's a thing you can create on a computer, i've probably taken a swing at it.
|
<p>
|
||||||
</p>
|
<strong>my colours 🌈</strong>
|
||||||
<p>
|
</p>
|
||||||
you're very welcome to take a look around my little slice of the internet here,
|
<ul>
|
||||||
or explore any of the other corners i inhabit!
|
<li>primary: <span class="col-primary">#b7fd49</span></li>
|
||||||
</p>
|
<li>secondary: <span class="col-secondary">#f8e05b</span></li>
|
||||||
<p>
|
<li>tertiary: <span class="col-tertiary">#f788fe</span></li>
|
||||||
and if you're looking to support me financially, that's so cool of you!!
|
</ul>
|
||||||
if you like, you can buy one or more of my songs over on
|
|
||||||
<a href="https://arimelody.bandcamp.com" target="_blank">bandcamp</a>,
|
<p>
|
||||||
so you can at least get something for your money.
|
<strong>my keys 🔑</strong>
|
||||||
thank you very much either way!! 💕
|
</p>
|
||||||
</p>
|
<ul>
|
||||||
<p>
|
<li>pgp: <a href="/keys/ari melody_0x92678188_public.asc" target="_blank">[link]</a></li>
|
||||||
for anything else, you can reach me for any and all communications through
|
<li>ssh (ed25519): <a href="/keys/id_ari_ed25519.pub" target="_blank">[link]</a></li>
|
||||||
<a href="mailto:ari@arimelody.me">ari@arimelody.me</a>. if your message
|
</ul>
|
||||||
contains anything beyond a silly gag, i strongly recommend encrypting
|
|
||||||
your message using my public pgp key, listed below!
|
<p>
|
||||||
</p>
|
<strong>where to find me 🛰️</strong>
|
||||||
<p>
|
</p>
|
||||||
thank you for stopping by- i hope you have a lovely rest of your day! 💫
|
<ul class="links">
|
||||||
</p>
|
<li>
|
||||||
|
<a href="https://youtube.com/@arispacegirl" target="_blank">youtube</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://twitch.tv/arispacegirl" target="_blank">twitch</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://sptfy.com/mellodoot" target="_blank">spotify</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://arimelody.bandcamp.com" target="_blank">bandcamp</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/arimelody" target="_blank">github</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>projects i've worked on 🛠️</strong>
|
||||||
|
</p>
|
||||||
|
<ul class="links">
|
||||||
|
<li>
|
||||||
|
<a href="https://catdance.arimelody.me" target="_blank">
|
||||||
|
catdance
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://git.arimelody.me/ari/prideflag" target="_blank">
|
||||||
|
pride flag
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/arimelody/ipaddrgen" target="_blank">
|
||||||
|
ipaddrgen
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://impact.arimelody.me/" target="_blank">
|
||||||
|
impact meme
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://term.arimelody.me/" target="_blank">
|
||||||
|
OpenTerminal
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
## cool people
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div id="web-buttons">
|
||||||
|
<a href="https://arimelody.me">
|
||||||
|
<img src="/img/buttons/ari melody.gif" alt="ari melody web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
<a href="https://supitszaire.com" target="_blank">
|
||||||
|
<img src="/img/buttons/zaire.gif" alt="zaire web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
<a href="https://mae.wtf" target="_blank">
|
||||||
|
<img src="/img/buttons/mae.png" alt="vimae web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
<a href="https://zvava.org" target="_blank">
|
||||||
|
<img src="/img/buttons/zvava.png" alt="zvava web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
<a href="https://elke.cafe" target="_blank">
|
||||||
|
<img src="/img/buttons/elke.gif" alt="elke web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
<a href="https://itzzen.net" target="_blank">
|
||||||
|
<img src="/img/buttons/itzzen.png" alt="itzzen web button" width="88" height="31">
|
||||||
|
</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2>
|
<img src="/img/buttons/misc/debian.gif" alt="powered by debian" width="88" height="31">
|
||||||
## metadata
|
<img src="/img/buttons/misc/girls4notepad.gif" alt="girls 4 notepad" width="88" height="31">
|
||||||
</h2>
|
<img src="/img/buttons/misc/gaywebring.gif" alt="this website is GAY" width="88" height="31">
|
||||||
|
<img src="/img/buttons/misc/graphicdesign.gif" alt="graphic design is my passion" width="88" height="31">
|
||||||
<p>
|
<img src="/img/buttons/misc/gplv3.gif" alt="GPLv3 free software" width="88" height="31">
|
||||||
<strong>my colours 🌈</strong>
|
<img src="/img/buttons/misc/hl.gif" alt="half-life" width="88" height="31">
|
||||||
</p>
|
<img src="/img/buttons/misc/h-free-anim.gif" alt="dis site is hentai FREE" width="88" height="31">
|
||||||
<ul>
|
<img src="/img/buttons/misc/sprunk.gif" alt="sprunk" width="88" height="31">
|
||||||
<li>primary: <span class="col-primary">#b7fd49</span></li>
|
<img src="/img/buttons/misc/tohell.gif" alt="go straight to hell" width="88" height="31">
|
||||||
<li>secondary: <span class="col-secondary">#f8e05b</span></li>
|
<img src="/img/buttons/misc/virusalert.gif" alt="virus alert! click here" onclick="alert('meow :3')" width="88" height="31">
|
||||||
<li>tertiary: <span class="col-tertiary">#f788fe</span></li>
|
<img src="/img/buttons/misc/wii.gif" alt="wii" width="88" height="31">
|
||||||
</ul>
|
<img src="/img/buttons/misc/www2.gif" alt="www" width="88" height="31">
|
||||||
|
<img src="/img/buttons/misc/iemandatory.gif" alt="get mandatory internet explorer" width="88" height="31">
|
||||||
<p>
|
<img src="/img/buttons/misc/learn_html.gif" alt="HTML - learn it today!" width="88" height="31">
|
||||||
<strong>my keys 🔑</strong>
|
<a href="https://smokepowered.com" target="_blank">
|
||||||
</p>
|
<img src="/img/buttons/misc/smokepowered.gif" alt="high on SMOKE" width="88" height="31">
|
||||||
<ul>
|
</a>
|
||||||
<li>pgp: <a href="/keys/ari melody_0x92678188_public.asc" target="_blank">[link]</a></li>
|
<a href="https://epicblazed.com" target="_blank">
|
||||||
<li>ssh (ed25519): <a href="/keys/id_ari_ed25519.pub" target="_blank">[link]</a></li>
|
<img src="/img/buttons/misc/epicblazed.png" alt="epic blazed" width="88" height="31">
|
||||||
</ul>
|
</a>
|
||||||
|
<img src="/img/buttons/misc/blink.gif" alt="closeup anime blink" width="88" height="31">
|
||||||
<p>
|
</div>
|
||||||
<strong>where to find me 🛰️</strong>
|
|
||||||
</p>
|
|
||||||
<ul class="links">
|
|
||||||
<li>
|
|
||||||
<a href="https://youtube.com/@mellodoot" target="_blank">youtube</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://mellodoot.tumblr.com" target="_blank">tumblr</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://twitch.tv/mellodoot" target="_blank">twitch</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://sptfy.com/mellodoot" target="_blank">spotify</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://soundcloud.com/arimelody" target="_blank">soundcloud</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/mellodoot" target="_blank">github</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<strong>projects i've worked on 🛠️</strong>
|
|
||||||
</p>
|
|
||||||
<ul class="links">
|
|
||||||
<li>
|
|
||||||
<a href="https://catdance.xyz" target="_blank">
|
|
||||||
catdance
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/mellodoot/sandblock" target="_blank">
|
|
||||||
sandblock
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/mellodoot/prideflag" target="_blank">
|
|
||||||
pride flag
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/mellodoot/ipaddrgen" target="_blank">
|
|
||||||
ipaddrgen
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://impact.arimelody.me/" target="_blank">
|
|
||||||
impact meme
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://term.arimelody.me/" target="_blank">
|
|
||||||
OpenTerminal
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>## cool people</h2>
|
|
||||||
|
|
||||||
<div id="web-buttons">
|
|
||||||
<a href="https://arimelody.me">
|
|
||||||
<img src="/img/buttons/ari melody.gif" alt="ari melody web button" loading="lazy">
|
|
||||||
</a>
|
|
||||||
<a href="https://supitszaire.com" target="_blank">
|
|
||||||
<img src="/img/buttons/zaire.gif" alt="zaire web button" loading="lazy">
|
|
||||||
</a>
|
|
||||||
<a href="https://mae.wtf" target="_blank">
|
|
||||||
<img src="/img/buttons/mae.png" alt="vimae web button" loading="lazy">
|
|
||||||
</a>
|
|
||||||
<a href="https://zvava.org" target="_blank">
|
|
||||||
<img src="/img/buttons/zvava.png" alt="zvava web button" loading="lazy">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<img src="/img/buttons/misc/debian.gif" alt="powered by debian" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/girls4notepad.gif" alt="girls 4 notepad" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/gaywebring.gif" alt="this website is GAY" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/graphicdesign.gif" alt="graphic design is my passion" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/gplv3.gif" alt="GPLv3 free software" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/hl.gif" alt="half-life" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/h-free-anim.gif" alt="dis site is hentai FREE" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/sprunk.gif" alt="sprunk" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/tohell.gif" alt="go straight to hell" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/virusalert.gif" alt="virus alert! click here" onclick="alert('meow :3')" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/wii.gif" alt="wii" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/www2.gif" alt="www" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/iemandatory.gif" alt="get mandatory internet explorer" loading="lazy">
|
|
||||||
<img src="/img/buttons/misc/learn_html.gif" alt="HTML - learn it today!" loading="lazy">
|
|
||||||
<a href="https://smokepowered.com" target="_blank">
|
|
||||||
<img src="/img/buttons/misc/smokepowered.gif" alt="high on SMOKE" loading="lazy">
|
|
||||||
</a>
|
|
||||||
<a href="https://epicblazed.com" target="_blank">
|
|
||||||
<img src="/img/buttons/misc/epicblazed.png" alt="epic blazed" loading="lazy">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
<title>{{.PrintPrimaryArtists false}} - {{.Title}}</title>
|
<title>{{.Title}} - {{.PrintPrimaryArtists false true}}</title>
|
||||||
<link rel="icon" href="{{.ResolveArtwork}}">
|
<link rel="icon" href="{{.ResolveArtwork}}">
|
||||||
|
|
||||||
<meta name="description" content="Stream "{{.Title}}" by {{.PrintPrimaryArtists false}} on all platforms!">
|
<meta name="description" content="Stream "{{.Title}}" by {{.PrintPrimaryArtists false true}} on all platforms!">
|
||||||
<meta name="author" content="{{.PrintPrimaryArtists false}}">
|
<meta name="author" content="{{.PrintPrimaryArtists false true}}">
|
||||||
<meta name="keywords" content="{{.PrintCommaPrimaryArtists false}}, music, {{.Title}}, {{.Id}}, {{.GetReleaseYear}}">
|
<meta name="keywords" content="{{.PrintPrimaryArtists false false}}, music, {{.Title}}, {{.Id}}, {{.GetReleaseYear}}">
|
||||||
|
|
||||||
<meta property="og:url" content="https://arimelody.me/music/{{.Id}}">
|
<meta property="og:url" content="https://arimelody.me/music/{{.Id}}">
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:locale" content="en_IE">
|
<meta property="og:locale" content="en_IE">
|
||||||
<meta property="og:site_name" content="ari melody music">
|
<meta property="og:site_name" content="ari melody music">
|
||||||
<meta property="og.Title" content="{{.PrintPrimaryArtists false}} - {{.Title}}">
|
<meta property="og.Title" content="{{.Title}} - {{.PrintPrimaryArtists false true}}">
|
||||||
<meta property="og:description" content="Stream "{{.Title}}" by {{.PrintPrimaryArtists false}} on all platforms!">
|
<meta property="og:description" content="Stream "{{.Title}}" by {{.PrintPrimaryArtists false true}} on all platforms!">
|
||||||
<meta property="og:image" content="https://arimelody.me{{.ResolveArtwork}}">
|
<meta property="og:image" content="https://arimelody.me{{.ResolveArtwork}}">
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
<meta name="twitter:creator" content="@funniduck">
|
<meta name="twitter:creator" content="@funniduck">
|
||||||
<meta property="twitter:domain" content="arimelody.me">
|
<meta property="twitter:domain" content="arimelody.me">
|
||||||
<meta property="twitter:url" content="https://arimelody.me/music/{{.Id}}">
|
<meta property="twitter:url" content="https://arimelody.me/music/{{.Id}}">
|
||||||
<meta name="twitter.Title" content="{{.PrintPrimaryArtists false}} - {{.Title}}">
|
<meta name="twitter.Title" content="{{.PrintPrimaryArtists false true}} - {{.Title}}">
|
||||||
<meta name="twitter:description" content="Stream "{{.Title}}" by mellodoot on all platforms!">
|
<meta name="twitter:description" content="Stream "{{.Title}}" by {{.PrintPrimaryArtists false true}} on all platforms!">
|
||||||
<meta name="twitter:image" content="https://arimelody.me{{.ResolveArtwork}}">
|
<meta name="twitter:image" content="https://arimelody.me{{.ResolveArtwork}}">
|
||||||
<meta name="twitter:image:alt" content="Cover art for "{{.Title}}"">
|
<meta name="twitter:image:alt" content="Cover art for "{{.Title}}"">
|
||||||
|
|
||||||
|
@ -30,137 +30,139 @@
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<main>
|
<main>
|
||||||
<script type="module" src="/script/music-gateway.js"></script>
|
<script type="module" src="/script/music-gateway.js"></script>
|
||||||
|
|
||||||
<div id="background" style="background-image: url({{.ResolveArtwork}})"></div>
|
<div id="background" style="background-image: url({{.ResolveArtwork}})"></div>
|
||||||
|
|
||||||
<a href="/music" swap-url="/music" id="go-back" title="back to arimelody.me"><</a>
|
<a href="/music" swap-url="/music" id="go-back" title="back to arimelody.me"><</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<div id="music-container">
|
<div id="music-container">
|
||||||
<div id="art-container">
|
<div id="art-container">
|
||||||
<div class="tilt-topleft"></div>
|
<div class="tilt-topleft"></div>
|
||||||
<div class="tilt-top"></div>
|
<div class="tilt-top"></div>
|
||||||
<div class="tilt-topright"></div>
|
<div class="tilt-topright"></div>
|
||||||
<div class="tilt-right"></div>
|
<div class="tilt-right"></div>
|
||||||
<div class="tilt-bottomright"></div>
|
<div class="tilt-bottomright"></div>
|
||||||
<div class="tilt-bottom"></div>
|
<div class="tilt-bottom"></div>
|
||||||
<div class="tilt-bottomleft"></div>
|
<div class="tilt-bottomleft"></div>
|
||||||
<div class="tilt-left"></div>
|
<div class="tilt-left"></div>
|
||||||
<img id="artwork" src="{{.ResolveArtwork}}" alt="{{.Title}} artwork" width=240 height=240>
|
<img id="artwork" src="{{.ResolveArtwork}}" alt="{{.Title}} artwork" width=240 height=240>
|
||||||
</div>
|
|
||||||
<div id="vertical-line"></div>
|
|
||||||
<div id="info">
|
|
||||||
<div id="overview">
|
|
||||||
<div id="title-container">
|
|
||||||
<h1 id="title">{{.Title}}</h1>
|
|
||||||
<span id="year" title="{{.PrintReleaseDate}}">{{.GetReleaseYear}}</span>
|
|
||||||
</div>
|
|
||||||
<p id="artist">{{.PrintPrimaryArtists false}}</p>
|
|
||||||
<p id="type" class="{{.ResolveType}}">{{.ResolveType}}</p>
|
|
||||||
|
|
||||||
<ul id="links">
|
|
||||||
{{if .Buylink}}
|
|
||||||
<li>
|
|
||||||
<a href="{{.Buylink}}" class="buy">{{or .Buyname "buy"}}</a>
|
|
||||||
</li>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{range .Links}}
|
|
||||||
<li>
|
|
||||||
<a class="{{.NormaliseName}}" href="{{.Url}}">{{.Name}}</a>
|
|
||||||
</li>
|
|
||||||
{{end}}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{{if .Description}}
|
|
||||||
<p id="description">
|
|
||||||
{{.Description}}
|
|
||||||
</p>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
<button id="share">share</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{if .Credits}}
|
|
||||||
<div id="credits">
|
|
||||||
<h2>credits:</h2>
|
|
||||||
<ul>
|
|
||||||
{{range .Credits}}
|
|
||||||
{{$Artist := .ResolveArtist}}
|
|
||||||
{{if $Artist.Website}}
|
|
||||||
<li><strong><a href="{{$Artist.Website}}">{{$Artist.Name}}</a></strong>: {{.Role}}</li>
|
|
||||||
{{else}}
|
|
||||||
<li><strong>{{$Artist.Name}}</strong>: {{.Role}}</li>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if .IsSingle}}
|
|
||||||
{{$Track := index .Tracks 0}}
|
|
||||||
{{if $Track.Lyrics}}
|
|
||||||
<div id="lyrics">
|
|
||||||
<h2>lyrics:</h2>
|
|
||||||
<p>{{$Track.Lyrics}}</p>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<div id="tracks">
|
|
||||||
<h2>tracks:</h2>
|
|
||||||
{{range .Tracks}}
|
|
||||||
<h3>{{.Title}}</h3>
|
|
||||||
<p>{{.Lyrics}}</p>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{if or .Credits not .IsSingle}}
|
|
||||||
<div id="extras">
|
|
||||||
<ul>
|
|
||||||
<li><a href="#overview">overview</a></li>
|
|
||||||
|
|
||||||
{{if .Credits}}
|
|
||||||
<li><a href="#credits">credits</a></li>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if .IsSingle}}
|
|
||||||
{{$Track := index .Tracks 0}}
|
|
||||||
{{if $Track.Lyrics}}
|
|
||||||
<li><a href="#lyrics">lyrics</a></li>
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<li><a href="#tracks">tracks</a></li>
|
|
||||||
{{end}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<!-- <div id="tracks"> -->
|
|
||||||
<!-- <% var file = `/audio/preview/${data.id}.webm` %> -->
|
|
||||||
<!-- <% if (data.tracks && typeof(data.tracks) == typeof([])) { %> -->
|
|
||||||
<!-- <% for( let i = 0; i < data.tracks.length; i++ ) { %> -->
|
|
||||||
<!-- <% -->
|
|
||||||
<!-- songid = data.tracks[i].title.toLowerCase().replace(/[^a-z0-9]/g, ""); -->
|
|
||||||
<!-- file = `/audio/preview/${data.id}-${songid}.webm`; -->
|
|
||||||
<!-- %> -->
|
|
||||||
<!---->
|
|
||||||
<!-- <div class="track-preview" id="preview-<%= songid %>"> -->
|
|
||||||
<!-- <i class="fa-solid fa-play play"></i> -->
|
|
||||||
<!-- <p><%= data.tracks[i].title %></p> -->
|
|
||||||
<!-- <audio src="<%= file %>"></audio> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<!---->
|
|
||||||
<!-- <% } %> -->
|
|
||||||
<!-- <% } else { %> -->
|
|
||||||
<!-- <div class="track-preview" id="preview-<%= data.id %>"> -->
|
|
||||||
<!-- <i class="fa-solid fa-play play"></i> -->
|
|
||||||
<!-- <p>{{.Title}}</p> -->
|
|
||||||
<!-- <audio src="<%= file %>"></audio> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<!-- <% } %> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
<div id="vertical-line"></div>
|
||||||
|
<div id="info">
|
||||||
|
<div id="overview">
|
||||||
|
<div id="title-container">
|
||||||
|
<h1 id="title">{{.Title}}</h1>
|
||||||
|
<span id="year" title="{{.PrintReleaseDate}}">{{.GetReleaseYear}}</span>
|
||||||
|
</div>
|
||||||
|
<p id="artist">{{.PrintPrimaryArtists false true}}</p>
|
||||||
|
<p id="type" class="{{.ResolveType}}">{{.ResolveType}}</p>
|
||||||
|
|
||||||
|
<ul id="links">
|
||||||
|
{{if .Buylink}}
|
||||||
|
<li>
|
||||||
|
<a href="{{.Buylink}}" class="buy">{{or .Buyname "buy"}}</a>
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range .Links}}
|
||||||
|
<li>
|
||||||
|
<a class="{{.NormaliseName}}" href="{{.Url}}">{{.Name}}</a>
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{if .Description}}
|
||||||
|
<p id="description">
|
||||||
|
{{.Description}}
|
||||||
|
</p>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<button id="share">share</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if .Credits}}
|
||||||
|
<div id="credits">
|
||||||
|
<h2>credits:</h2>
|
||||||
|
<ul>
|
||||||
|
{{range .Credits}}
|
||||||
|
{{$Artist := .ResolveArtist}}
|
||||||
|
{{if $Artist.Website}}
|
||||||
|
<li><strong><a href="{{$Artist.Website}}">{{$Artist.Name}}</a></strong>: {{.Role}}</li>
|
||||||
|
{{else}}
|
||||||
|
<li><strong>{{$Artist.Name}}</strong>: {{.Role}}</li>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if .IsSingle}}
|
||||||
|
{{$Track := index .Tracks 0}}
|
||||||
|
{{if $Track.Lyrics}}
|
||||||
|
<div id="lyrics">
|
||||||
|
<h2>lyrics:</h2>
|
||||||
|
<p>{{$Track.Lyrics}}</p>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<div id="tracks">
|
||||||
|
<h2>tracks:</h2>
|
||||||
|
{{range .Tracks}}
|
||||||
|
<details>
|
||||||
|
<summary class="album-track-title">{{.Title}}</summary>
|
||||||
|
{{.Lyrics}}
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if or .Credits not .IsSingle}}
|
||||||
|
<div id="extras">
|
||||||
|
<ul>
|
||||||
|
<li><a href="#overview">overview</a></li>
|
||||||
|
|
||||||
|
{{if .Credits}}
|
||||||
|
<li><a href="#credits">credits</a></li>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if .IsSingle}}
|
||||||
|
{{$Track := index .Tracks 0}}
|
||||||
|
{{if $Track.Lyrics}}
|
||||||
|
<li><a href="#lyrics">lyrics</a></li>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<li><a href="#tracks">tracks</a></li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<!-- <div id="tracks"> -->
|
||||||
|
<!-- <% var file = `/audio/preview/${data.id}.webm` %> -->
|
||||||
|
<!-- <% if (data.tracks && typeof(data.tracks) == typeof([])) { %> -->
|
||||||
|
<!-- <% for( let i = 0; i < data.tracks.length; i++ ) { %> -->
|
||||||
|
<!-- <% -->
|
||||||
|
<!-- songid = data.tracks[i].title.toLowerCase().replace(/[^a-z0-9]/g, ""); -->
|
||||||
|
<!-- file = `/audio/preview/${data.id}-${songid}.webm`; -->
|
||||||
|
<!-- %> -->
|
||||||
|
<!---->
|
||||||
|
<!-- <div class="track-preview" id="preview-<%= songid %>"> -->
|
||||||
|
<!-- <i class="fa-solid fa-play play"></i> -->
|
||||||
|
<!-- <p><%= data.tracks[i].title %></p> -->
|
||||||
|
<!-- <audio src="<%= file %>"></audio> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!---->
|
||||||
|
<!-- <% } %> -->
|
||||||
|
<!-- <% } else { %> -->
|
||||||
|
<!-- <div class="track-preview" id="preview-<%= data.id %>"> -->
|
||||||
|
<!-- <i class="fa-solid fa-play play"></i> -->
|
||||||
|
<!-- <p>{{.Title}}</p> -->
|
||||||
|
<!-- <audio src="<%= file %>"></audio> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- <% } %> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="music-details">
|
<div class="music-details">
|
||||||
<a href="/music/{{$Album.Id}}"><h1 class="music-title">{{$Album.Title}}</h1></a>
|
<a href="/music/{{$Album.Id}}"><h1 class="music-title">{{$Album.Title}}</h1></a>
|
||||||
<h2 class="music-artist">{{$Album.PrintPrimaryArtists false}}</h2>
|
<h2 class="music-artist">{{$Album.PrintPrimaryArtists false true}}</h2>
|
||||||
<h3 class="music-type-{{.ResolveType}}">{{$Album.ResolveType}}</h3>
|
<h3 class="music-type-{{.ResolveType}}">{{$Album.ResolveType}}</h3>
|
||||||
<ul class="music-links">
|
<ul class="music-links">
|
||||||
{{range $Link := $Album.Links}}
|
{{range $Link := $Album.Links}}
|
||||||
|
@ -46,45 +46,46 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 id="usage" class="question" swap-url="/music#usage">
|
<h2 id="usage" class="question">
|
||||||
<a href="#usage">
|
<a href="#usage">
|
||||||
> "can i use your music in my content?"
|
> "can i use your music in my content?"
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="answer">
|
<div class="answer">
|
||||||
<p>
|
<p>
|
||||||
<strong class="big">yes!</strong> well, in most cases...
|
<strong class="big">yes!</strong> well, in most cases...
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
from <a href="/music/dream">Dream (2022)</a> onward, all of my <em>self-released</em> songs are
|
from <a href="/music/dream">Dream (2022)</a> onward, all of my <em>self-released</em> songs are
|
||||||
licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution-ShareAlike 3.0</a>. anyone may use these
|
licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">Creative Commons Attribution-ShareAlike 4.0</a>.
|
||||||
songs freely, so long as they provide credit back to me!
|
anyone may use and remix these songs freely, so long as they provide credit back to me and link back to this license!
|
||||||
</p>
|
please note that all derivative works must inherit this license.
|
||||||
<p>
|
</p>
|
||||||
a great example of some credit text would be as follows:
|
<p>
|
||||||
</p>
|
a great example of some credit text would be as follows:
|
||||||
<blockquote>
|
</p>
|
||||||
music used: mellodoot - Dream<br>
|
<blockquote>
|
||||||
buy it here: <a href="/music/dream">https://arimelody.me/music/dream</a><br>
|
music used: mellodoot - Dream<br>
|
||||||
licensed under CC BY-SA 3.0.
|
<a href="/music/dream">https://arimelody.me/music/dream</a><br>
|
||||||
</blockquote>
|
licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.
|
||||||
<p>
|
</blockquote>
|
||||||
for any songs prior to this, they were all either released by me (in which case, i honestly
|
<p>
|
||||||
don't mind), or in collaboration with chill people who i don't see having an issue with it.
|
for any songs prior to this, they were all either released by me (in which case, i honestly
|
||||||
do be sure to ask them about it, though!
|
don't mind), or in collaboration with chill people who i don't see having an issue with it.
|
||||||
</p>
|
do be sure to ask them about it, though!
|
||||||
<p>
|
</p>
|
||||||
in the event the song you want to use is released under some other label, their usage rights
|
<p>
|
||||||
will more than likely trump whatever i'd otherwise have in mind. i'll try to negotiate some
|
in the event the song you want to use is released under some other label, their usage rights
|
||||||
nice terms, though! ;3
|
will more than likely trump whatever i'd otherwise have in mind. i'll try to negotiate some
|
||||||
</p>
|
nice terms, though! ;3
|
||||||
<p>
|
</p>
|
||||||
i love the idea of other creators using my songs in their work, so if you do happen to use
|
<p>
|
||||||
my stuff in a work you're particularly proud of, feel free to send it my way!
|
i love the idea of other creators using my songs in their work, so if you do happen to use
|
||||||
</p>
|
my stuff in a work you're particularly proud of, feel free to send it my way!
|
||||||
<p>
|
</p>
|
||||||
> <a href="mailto:ari@arimelody.me">ari@arimelody.me</a>
|
<p>
|
||||||
</p>
|
> <a href="mailto:ari@arimelody.me">ari@arimelody.me</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="#" id="backtotop">back to top</a>
|
<a href="#" id="backtotop">back to top</a>
|
||||||
|
|