added stuff, broke some other stuff, made admin auth!

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-07-31 04:09:22 +01:00
parent 0d1e694b59
commit 5631c4bd87
26 changed files with 1615 additions and 1401 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
**/.DS_Store
.idea/
tmp/
test/

View file

@ -3,18 +3,10 @@ package api
import (
"net/http"
"html/template"
"arimelody.me/arimelody.me/api/v1/admin"
)
func Handle(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
code := 404;
if req.URL.Path == "/api/v1/admin/login" {
code = admin.HandleLogin(writer, req, root)
}
if code == 404 {
writer.Write([]byte("404 not found"))
}
return code;
writer.WriteHeader(501)
writer.Write([]byte("501 Not Implemented"))
return 501;
}

View file

@ -1,43 +1,228 @@
package admin
import (
"context"
"encoding/json"
"fmt"
"html/template"
"io"
"math/rand"
"net/http"
"net/url"
"os"
"strings"
"time"
"arimelody.me/arimelody.me/discord"
)
type (
State struct {
Session struct {
UserID string
Token string
}
loginData struct {
UserID string
Password string
}
)
func CreateState() *State {
return &State{
Token: "you are the WINRAR!!",
const TOKEN_LENGTH = 64
const TOKEN_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
// 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 {
if req.Method != "POST" {
return 404;
}
func Handler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path)
body, err := io.ReadAll(req.Body)
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 {
fmt.Printf("failed to parse request body!\n");
return 500;
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 string(body) != "super epic mega gaming password" {
return 400;
if session == nil {
w.WriteHeader(401)
w.Write([]byte("Unauthorized"))
return
}
state := CreateState();
writer.WriteHeader(200);
writer.Write([]byte(state.Token))
return 200;
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 {
fmt.Printf("Failed to retrieve OAuth token: %s\n", err)
w.WriteHeader(500)
w.Write([]byte("Internal server error"))
return
}
oauth := discord.AccessTokenResponse{}
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
}
auth_info := discord.AuthInfoResponse{}
err = json.NewDecoder(res.Body).Decode(&auth_info)
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()
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)
}

View file

@ -1,10 +1,14 @@
package music
import (
"errors"
"fmt"
"time"
)
var Releases []*MusicRelease;
var Artists []*Artist;
func make_date_work(date string) time.Time {
res, err := time.Parse("2-Jan-2006", date)
if err != nil {
@ -14,20 +18,20 @@ func make_date_work(date string) time.Time {
return res
}
func GetRelease(id string) (MusicRelease, bool) {
for _, album := range placeholders {
if album.Id == id {
return album, true
func GetRelease(id string) (*MusicRelease, error) {
for _, release := range Releases {
if release.Id == id {
return release, nil
}
}
return MusicRelease{}, false
return nil, errors.New(fmt.Sprintf("Release %s not found", id))
}
func QueryAllMusic() ([]MusicRelease) {
return placeholders
func GetArtist(id string) (*Artist, error) {
for _, artist := range Artists {
if artist.Id == id {
return artist, nil
}
}
return nil, errors.New(fmt.Sprintf("Artist %s not found", id))
}
func QueryAllArtists() ([]Artist) {
return []Artist{ ari, mellodoot, zaire, mae, loudar, red }
}

View file

@ -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",
},
},
},
}

View file

@ -35,7 +35,7 @@ type (
MusicCredit struct {
Artist *Artist
Role string
Meta bool // for "meta" contributors (i.e. not credited for the musical work, but other related assets)
Primary bool
}
MusicTrack struct {
@ -47,10 +47,10 @@ type (
}
)
func (release MusicRelease) GetUniqueArtists(include_meta bool) []*Artist {
func (release MusicRelease) GetUniqueArtists(include_non_primary bool) []*Artist {
res := []*Artist{}
for _, credit := range release.Credits {
if !include_meta && credit.Meta {
if !include_non_primary && !credit.Primary {
continue
}
@ -68,12 +68,11 @@ func (release MusicRelease) GetUniqueArtists(include_meta bool) []*Artist {
res = append(res, credit.Artist)
}
// now create the actual array to send
return res
}
func (release MusicRelease) GetUniqueArtistNames(include_meta bool) []string {
artists := release.GetUniqueArtists(include_meta)
func (release MusicRelease) GetUniqueArtistNames(include_non_primary bool) []string {
artists := release.GetUniqueArtists(include_non_primary)
names := []string{}
for _, artist := range artists {
names = append(names, artist.Name)
@ -82,44 +81,42 @@ func (release MusicRelease) GetUniqueArtistNames(include_meta bool) []string {
return names
}
func (album MusicRelease) PrintPrimaryArtists(include_meta bool) string {
names := album.GetUniqueArtistNames(include_meta)
if len(names) == 1 {
func (release MusicRelease) PrintPrimaryArtists(include_non_primary bool, ampersand bool) string {
names := release.GetUniqueArtistNames(include_non_primary)
if len(names) == 0 {
return "Unknown Artist"
} else if len(names) == 1 {
return names[0]
}
if ampersand {
res := strings.Join(names[:len(names)-1], ", ")
res += " & " + names[len(names)-1]
return res
}
func (album MusicRelease) PrintCommaPrimaryArtists(include_meta bool) string {
names := album.GetUniqueArtistNames(include_meta)
if len(names) == 1 {
return names[0]
}
} else {
return strings.Join(names[:], ", ")
}
}
func (album MusicRelease) ResolveType() string {
if album.Type != "" {
return album.Type
func (release MusicRelease) ResolveType() string {
if release.Type != "" {
return release.Type
}
return "unknown"
}
func (album MusicRelease) ResolveArtwork() string {
if album.Artwork != "" {
return album.Artwork
func (release MusicRelease) ResolveArtwork() string {
if release.Artwork != "" {
return release.Artwork
}
return "/img/music-artwork/default.png"
}
func (album MusicRelease) PrintReleaseDate() string {
return album.ReleaseDate.Format("02 January 2006")
func (release MusicRelease) PrintReleaseDate() string {
return release.ReleaseDate.Format("02 January 2006")
}
func (album MusicRelease) GetReleaseYear() int {
return album.ReleaseDate.Year()
func (release MusicRelease) GetReleaseYear() int {
return release.ReleaseDate.Year()
}
func (link MusicLink) NormaliseName() string {

198
db.go
View file

@ -7,66 +7,55 @@ import (
"os"
"time"
_ "github.com/lib/pq"
"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) {
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",
&artist.Id,
&artist.Name,
&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) {
fmt.Printf("syncing release [%s] to database...", release.Id)
fmt.Printf("pushing release [%s] to database...", release.Id)
tx := db.MustBegin()
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)
}
for _, credit := range release.Credits {
tx.MustExec("INSERT INTO musiccredits (release, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",
&release.Id, &credit.Artist.Id, &credit.Role, &credit.Meta)
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.Primary)
}
for _, track := range release.Tracks {
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")
}
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 {
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
if err != nil {
@ -103,8 +200,5 @@ func InitDatabase() *sqlx.DB {
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
db.MustExec(schema)
fmt.Printf("database schema synchronised.\n")
return db
}

44
discord/discord.go Normal file
View 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
View 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
}

410
main.go
View file

@ -5,32 +5,14 @@ import (
"html/template"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
"arimelody.me/arimelody.me/api"
"arimelody.me/arimelody.me/api/v1/admin"
"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
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",
}
const DEFAULT_PORT int = 8080
var base_template = template.Must(template.ParseFiles(
"views/base.html",
@ -38,7 +20,6 @@ var base_template = template.Must(template.ParseFiles(
"views/footer.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) {
now := time.Now()
@ -54,229 +35,182 @@ func log_request(req *http.Request, code int, start_time time.Time) {
req.URL.Path,
code,
elapsed,
req.Header["User-Agent"][0],
)
req.Header["User-Agent"][0])
}
func handle_request(writer http.ResponseWriter, req *http.Request) {
uri := req.URL.Path
start_time := time.Now()
// func handle_request(res http.ResponseWriter, req *http.Request) {
// uri := req.URL.Path
// start_time := time.Now()
//
// res.Header().Set("Server", "arimelody.me")
//
// code := func(res http.ResponseWriter, req *http.Request) int {
// var root = template.Must(base_template.Clone())
//
// if req.URL.Path == "/" {
// return handle_index(res, req, root)
// }
//
// if uri == "/music" || uri == "/music/" {
// return handle_music(res, req, root)
// }
//
// if strings.HasPrefix(uri, "/music/") {
// return handle_music_gateway(res, req, root)
// }
//
// if strings.HasPrefix(uri, "/admin") {
// return admin.Handle(res, req, root)
// }
//
// if strings.HasPrefix(uri, "/api") {
// return api.Handle(res, req, root)
// }
//
// return static_handler(res, req, root)
// }(res, req)
//
// log_request(req, code, start_time)
// }
//
// func handle_index(res http.ResponseWriter, req *http.Request, root *template.Template) int {
// if !global.IsModified(req, global.LAST_MODIFIED) {
// res.WriteHeader(304)
// return 304
// }
//
// index_template := template.Must(root.ParseFiles("views/index.html"))
// err := index_template.Execute(res, nil)
// if err != nil {
// http.Error(res, err.Error(), http.StatusInternalServerError)
// return 500
// }
// return 200
// }
//
// func handle_music(res http.ResponseWriter, req *http.Request, root *template.Template) int {
// if !global.IsModified(req, global.LAST_MODIFIED) {
// res.WriteHeader(304)
// return 304
// }
//
// music_template := template.Must(root.ParseFiles("views/music.html"))
// err := music_template.Execute(res, music.Releases)
// if err != nil {
// http.Error(res, err.Error(), http.StatusInternalServerError)
// return 500
// }
// return 200
// }
//
// func handle_music_gateway(res http.ResponseWriter, req *http.Request, root *template.Template) int {
// if !global.IsModified(req, global.LAST_MODIFIED) {
// res.WriteHeader(304)
// return 304
// }
//
// id := req.URL.Path[len("/music/"):]
// release, err := music.GetRelease(id)
// if err != nil {
// return handle_not_found(res, req, root)
// }
// gateway_template := template.Must(root.ParseFiles("views/music-gateway.html"))
// err = gateway_template.Execute(res, release)
// if err != nil {
// http.Error(res, err.Error(), http.StatusInternalServerError)
// return 500
// }
// return 200
// }
//
// func static_handler(res http.ResponseWriter, req *http.Request, root *template.Template) int {
// filename := "public/" + req.URL.Path[1:]
//
// // check the file's metadata
// info, err := os.Stat(filename)
// if err != nil {
// return handle_not_found(res, req, root)
// }
//
// if !global.IsModified(req, info.ModTime()) {
// res.WriteHeader(304)
// return 304
// }
//
// // set Last-Modified to file modification date
// res.Header().Set("Last-Modified", info.ModTime().Format(http.TimeFormat))
//
// // read the file
// body, err := os.ReadFile(filename)
// if err != nil {
// http.Error(res, err.Error(), http.StatusInternalServerError)
// return 500
// }
//
// // setting MIME types
// filetype := filename[strings.LastIndex(filename, ".")+1:]
// if mime_type, ok := global.MimeTypes[filetype]; ok {
// res.Header().Set("Content-Type", mime_type)
// } else {
// res.Header().Set("Content-Type", "text/plain; charset=utf-8")
// }
//
// res.Write([]byte(body))
// return 200
// }
//
// func handle_not_found(res http.ResponseWriter, req *http.Request, root *template.Template) int {
// type ErrorData struct {
// Target string
// }
// error_data := ErrorData{ Target: req.URL.Path }
// res.WriteHeader(404);
// error_template := template.Must(root.ParseFiles("views/404.html"))
// err := error_template.Execute(res, error_data)
// if err != nil {
// http.Error(res, err.Error(), http.StatusInternalServerError)
// return 500
// }
// return 404
// }
//
// 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)
// }
// hx_request := len(req.Header["Hx-Request"]) > 0 && req.Header["Hx-Request"][0] == "true"
//
// // don't bother fulfilling requests to a page that's already loaded on the client!
// if hx_request && len(req.Header["Referer"]) > 0 && len(req.Header["Hx-Current-Url"]) > 0 {
// regex := regexp.MustCompile(`https?:\/\/[^\/]+`)
// current_location := regex.ReplaceAllString(req.Header["Hx-Current-Url"][0], "")
// if current_location == req.URL.Path {
// writer.WriteHeader(204);
// return
// }
// }
writer.Header().Set("Server", "arimelody.me")
writer.Header().Set("Cache-Control", "max-age=86400")
writer.Header().Set("Last-Modified", LAST_MODIFIED.Format(http.TimeFormat))
code := func(writer http.ResponseWriter, req *http.Request) int {
// var root *template.Template
// if hx_request {
// root = template.Must(htmx_template.Clone())
// } else {
// root = template.Must(base_template.Clone())
// }
var root = template.Must(base_template.Clone())
if req.URL.Path == "/" {
return handle_index(writer, req, root)
}
if uri == "/music" || uri == "/music/" {
return handle_music(writer, req, root)
}
if strings.HasPrefix(uri, "/music/") {
return handle_music_gateway(writer, req, root)
}
if strings.HasPrefix(uri, "/admin") {
return handle_admin(writer, req, root)
}
if strings.HasPrefix(uri, "/api") {
return api.Handle(writer, req, root)
}
return static_handler(writer, req, root)
}(writer, req)
log_request(req, code, start_time)
}
func handle_index(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
if !was_modified(req, LAST_MODIFIED) {
writer.WriteHeader(304)
return 304
}
index_template := template.Must(root.ParseFiles("views/index.html"))
err := index_template.Execute(writer, nil)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return 500
}
return 200
}
func handle_music(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
if !was_modified(req, LAST_MODIFIED) {
writer.WriteHeader(304)
return 304
}
music_template := template.Must(root.ParseFiles("views/music.html"))
music := music.QueryAllMusic()
err := music_template.Execute(writer, music)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return 500
}
return 200
}
func handle_music_gateway(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
if !was_modified(req, LAST_MODIFIED) {
writer.WriteHeader(304)
return 304
}
id := req.URL.Path[len("/music/"):]
// http.Redirect(writer, req, "https://mellodoot.com/music/"+title, 302)
// return
release, ok := music.GetRelease(id)
if !ok {
return handle_not_found(writer, req, root)
}
gateway_template := template.Must(root.ParseFiles("views/music-gateway.html"))
err := gateway_template.Execute(writer, release)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return 500
}
return 200
}
func handle_admin(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
if !was_modified(req, LAST_MODIFIED) {
writer.WriteHeader(304)
return 304
}
admin_template := template.Must(root.ParseFiles("views/admin.html"))
err := admin_template.Execute(writer, nil)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return 500
}
return 200
}
func static_handler(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
filename := "public/" + req.URL.Path[1:]
// check the file's metadata
info, err := os.Stat(filename)
if err != nil {
return handle_not_found(writer, req, root)
}
if !was_modified(req, info.ModTime()) {
writer.WriteHeader(304)
return 304
}
// set Last-Modified to file modification date
writer.Header().Set("Last-Modified", info.ModTime().Format(http.TimeFormat))
// read the file
body, err := os.ReadFile(filename)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return 500
}
// 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() {
func main() {
db := InitDatabase()
defer db.Close()
for _, artist := range music.QueryAllArtists() {
PushArtist(db, artist)
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)
}
for _, album := range music.QueryAllMusic() {
PushRelease(db, album)
}
}
func main() {
push_to_db_this_is_a_testing_thing_and_will_be_superfluous_later()
http.HandleFunc("/", handle_request)
fmt.Printf("now serving at http://127.0.0.1:%d\n", PORT)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", PORT), nil))
mux := http.NewServeMux()
mux.Handle("/api/v1/admin", admin.Handler())
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
public/img/favicon-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
public/img/favicon-36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 944 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 24 KiB

32
public/img/prideflag.svg Normal file
View 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

View file

@ -36,7 +36,8 @@ function update_extras_buttons() {
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
link.addEventListener("click", event => {
event.preventDefault();
location.replace(link.href);
const tag = link.href.split('#').slice(-1)[0];
document.getElementById(tag).scrollIntoView();
});
});
}
@ -66,14 +67,7 @@ function bind_share_btn() {
}
}
function start() {
bind_share_btn();
bind_go_back_btn();
apply_funny_bob_to_upcoming_tags();
update_extras_buttons();
}
document.addEventListener("swap", () => {
if (!window.location.pathname.startsWith("/music/")) return;
start();
});
bind_share_btn();
bind_go_back_btn();
apply_funny_bob_to_upcoming_tags();
update_extras_buttons();

View file

@ -10,7 +10,8 @@ html,
body {
margin: 0;
padding: 0;
font-size: 18px;
font-size: 16px;
line-height: 1.5em;
color: #fff;
background-color: #111;
font-family: "Monaspace Argon", monospace;
@ -427,31 +428,31 @@ div#extras ul li a.active {
margin-bottom: 1rem;
}
#tracks h3 {
margin-bottom: .5rem;
padding: 1rem;
#tracks details[open] {
margin-bottom: 2em;
}
#tracks summary {
margin-bottom: 1em;
padding: 1em;
background-color: #0008;
cursor: pointer;
transition: background-color .1s linear;
}
#tracks h3:hover {
#tracks summary:hover {
background-color: #2228;
}
#tracks h3:active {
#tracks summary:active {
background-color: #4448;
}
#tracks h3.active {
#tracks summary.active {
color: #000;
background-color: var(--primary);
}
#tracks p {
margin-bottom: 3em;
}
footer {
position: fixed;
left: 0;

52
schema.sql Normal file
View 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;

View file

@ -14,7 +14,9 @@
</h1>
<p>
bappity boopity
whapow! nothing here.
<br>
nice try, though.
</p>
</main>
{{end}}

View file

@ -13,7 +13,7 @@
<!-- <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-preload.js"></script> -->
<script type="application/javascript" src="/script/swap.js"></script>
<!-- <script type="application/javascript" src="/script/swap.js"></script> -->
</head>
<body>

View file

@ -20,13 +20,10 @@
{{define "content"}}
<main>
<script type="module" src="/script/main.js"></script>
<h1>
# hello, world!
</h1>
<p>
<strong>i'm ari!</strong>
<br>
@ -34,19 +31,18 @@
</p>
<p>
i like to create things on the internet! namely <a href="/music">music</a>,
<a href="https://youtube.com/mellodoot" target="_blank">videos</a>, art <small><em>(link pending)</em></small>, and the odd
<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.
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 slice of the internet here,
or explore any of the other corners i inhabit!
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>
and if you're looking to support me financially, that's so cool of you!!
if you like, you can buy one or more of my songs over on
<a href="https://arimelody.bandcamp.com" target="_blank">bandcamp</a>,
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>
@ -88,22 +84,19 @@
</p>
<ul class="links">
<li>
<a href="https://youtube.com/@mellodoot" target="_blank">youtube</a>
<a href="https://youtube.com/@arispacegirl" 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>
<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://soundcloud.com/arimelody" target="_blank">soundcloud</a>
<a href="https://arimelody.bandcamp.com" target="_blank">bandcamp</a>
</li>
<li>
<a href="https://github.com/mellodoot" target="_blank">github</a>
<a href="https://github.com/arimelody" target="_blank">github</a>
</li>
</ul>
@ -112,22 +105,17 @@
</p>
<ul class="links">
<li>
<a href="https://catdance.xyz" target="_blank">
<a href="https://catdance.arimelody.me" 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">
<a href="https://git.arimelody.me/ari/prideflag" target="_blank">
pride flag
</a>
</li>
<li>
<a href="https://github.com/mellodoot/ipaddrgen" target="_blank">
<a href="https://github.com/arimelody/ipaddrgen" target="_blank">
ipaddrgen
</a>
</li>
@ -145,44 +133,53 @@
<hr>
<h2>## cool people</h2>
<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">
<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" loading="lazy">
<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" loading="lazy">
<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" loading="lazy">
<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>
<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">
<img src="/img/buttons/misc/debian.gif" alt="powered by debian" width="88" height="31">
<img src="/img/buttons/misc/girls4notepad.gif" alt="girls 4 notepad" width="88" height="31">
<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">
<img src="/img/buttons/misc/gplv3.gif" alt="GPLv3 free software" width="88" height="31">
<img src="/img/buttons/misc/hl.gif" alt="half-life" width="88" height="31">
<img src="/img/buttons/misc/h-free-anim.gif" alt="dis site is hentai FREE" width="88" height="31">
<img src="/img/buttons/misc/sprunk.gif" alt="sprunk" width="88" height="31">
<img src="/img/buttons/misc/tohell.gif" alt="go straight to hell" width="88" height="31">
<img src="/img/buttons/misc/virusalert.gif" alt="virus alert! click here" onclick="alert('meow :3')" width="88" height="31">
<img src="/img/buttons/misc/wii.gif" alt="wii" width="88" height="31">
<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">
<img src="/img/buttons/misc/learn_html.gif" alt="HTML - learn it today!" width="88" height="31">
<a href="https://smokepowered.com" target="_blank">
<img src="/img/buttons/misc/smokepowered.gif" alt="high on SMOKE" loading="lazy">
<img src="/img/buttons/misc/smokepowered.gif" alt="high on SMOKE" width="88" height="31">
</a>
<a href="https://epicblazed.com" target="_blank">
<img src="/img/buttons/misc/epicblazed.png" alt="epic blazed" loading="lazy">
<img src="/img/buttons/misc/epicblazed.png" alt="epic blazed" width="88" height="31">
</a>
<img src="/img/buttons/misc/blink.gif" alt="closeup anime blink" width="88" height="31">
</div>
</main>
{{end}}

View file

@ -1,17 +1,17 @@
{{define "head"}}
<title>{{.PrintPrimaryArtists false}} - {{.Title}}</title>
<title>{{.Title}} - {{.PrintPrimaryArtists false true}}</title>
<link rel="icon" href="{{.ResolveArtwork}}">
<meta name="description" content="Stream &quot;{{.Title}}&quot; by {{.PrintPrimaryArtists false}} on all platforms!">
<meta name="author" content="{{.PrintPrimaryArtists false}}">
<meta name="keywords" content="{{.PrintCommaPrimaryArtists false}}, music, {{.Title}}, {{.Id}}, {{.GetReleaseYear}}">
<meta name="description" content="Stream &quot;{{.Title}}&quot; by {{.PrintPrimaryArtists false true}} on all platforms!">
<meta name="author" content="{{.PrintPrimaryArtists false true}}">
<meta name="keywords" content="{{.PrintPrimaryArtists false false}}, music, {{.Title}}, {{.Id}}, {{.GetReleaseYear}}">
<meta property="og:url" content="https://arimelody.me/music/{{.Id}}">
<meta property="og:type" content="website">
<meta property="og:locale" content="en_IE">
<meta property="og:site_name" content="ari melody music">
<meta property="og.Title" content="{{.PrintPrimaryArtists false}} - {{.Title}}">
<meta property="og:description" content="Stream &quot;{{.Title}}&quot; by {{.PrintPrimaryArtists false}} on all platforms!">
<meta property="og.Title" content="{{.Title}} - {{.PrintPrimaryArtists false true}}">
<meta property="og:description" content="Stream &quot;{{.Title}}&quot; by {{.PrintPrimaryArtists false true}} on all platforms!">
<meta property="og:image" content="https://arimelody.me{{.ResolveArtwork}}">
<meta name="twitter:card" content="summary_large_image">
@ -19,8 +19,8 @@
<meta name="twitter:creator" content="@funniduck">
<meta property="twitter:domain" content="arimelody.me">
<meta property="twitter:url" content="https://arimelody.me/music/{{.Id}}">
<meta name="twitter.Title" content="{{.PrintPrimaryArtists false}} - {{.Title}}">
<meta name="twitter:description" content="Stream &quot;{{.Title}}&quot; by mellodoot on all platforms!">
<meta name="twitter.Title" content="{{.PrintPrimaryArtists false true}} - {{.Title}}">
<meta name="twitter:description" content="Stream &quot;{{.Title}}&quot; by {{.PrintPrimaryArtists false true}} on all platforms!">
<meta name="twitter:image" content="https://arimelody.me{{.ResolveArtwork}}">
<meta name="twitter:image:alt" content="Cover art for &quot;{{.Title}}&quot;">
@ -56,7 +56,7 @@
<h1 id="title">{{.Title}}</h1>
<span id="year" title="{{.PrintReleaseDate}}">{{.GetReleaseYear}}</span>
</div>
<p id="artist">{{.PrintPrimaryArtists false}}</p>
<p id="artist">{{.PrintPrimaryArtists false true}}</p>
<p id="type" class="{{.ResolveType}}">{{.ResolveType}}</p>
<ul id="links">
@ -110,8 +110,10 @@
<div id="tracks">
<h2>tracks:</h2>
{{range .Tracks}}
<h3>{{.Title}}</h3>
<p>{{.Lyrics}}</p>
<details>
<summary class="album-track-title">{{.Title}}</summary>
{{.Lyrics}}
</details>
{{end}}
</div>
{{end}}

View file

@ -32,7 +32,7 @@
</div>
<div class="music-details">
<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>
<ul class="music-links">
{{range $Link := $Album.Links}}
@ -46,7 +46,7 @@
{{end}}
</div>
<h2 id="usage" class="question" swap-url="/music#usage">
<h2 id="usage" class="question">
<a href="#usage">
&gt; "can i use your music in my content?"
</a>
@ -57,16 +57,17 @@
</p>
<p>
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
songs freely, so long as they provide credit back to me!
licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">Creative Commons Attribution-ShareAlike 4.0</a>.
anyone may use and remix these songs freely, so long as they provide credit back to me and link back to this license!
please note that all derivative works must inherit this license.
</p>
<p>
a great example of some credit text would be as follows:
</p>
<blockquote>
music used: mellodoot - Dream<br>
buy it here: <a href="/music/dream">https://arimelody.me/music/dream</a><br>
licensed under CC BY-SA 3.0.
<a href="/music/dream">https://arimelody.me/music/dream</a><br>
licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.
</blockquote>
<p>
for any songs prior to this, they were all either released by me (in which case, i honestly