A website inspired by Last.fm that will keep track of your listening statistics
lastfm music statistics
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Small updates

oscar345 354265bb f9384858

+51 -38
+10 -1
TODOS.md
··· 3 3 ## General 4 4 5 5 - [ ] pagination component 6 - - [ ] 7 6 8 7 ## Social 9 8 ··· 27 26 - [ ] release list item 28 27 - [ ] recording list item 29 28 - [ ] scrobble count (for inside list item) 29 + 30 + ## Recommandation 31 + 32 + - [ ] a small recommendation page 33 + - [ ] recommandation system based on user's listening history 34 + 35 + ## Services 36 + 37 + - [ ] link spotify account to keeptrack 38 + - [ ] keep track of users history on spotify
+3 -2
internal/server/server.go
··· 13 13 "github.com/oscar345/keeptrack/internal/repo/db" 14 14 "github.com/oscar345/keeptrack/internal/services" 15 15 "github.com/oscar345/keeptrack/internal/web/router" 16 + "github.com/oscar345/keeptrack/pkg/database" 16 17 storagesvc "github.com/oscar345/keeptrack/pkg/storage" 17 18 "github.com/oscar345/keeptrack/pkg/utilities" 18 19 ) ··· 32 33 } 33 34 34 35 func (s *Server) Start() error { 35 - musicbrainzDB := utilities.OpenDatabase("sqlite3", s.config.MusicbrainzDatabase.Path, func(db *sql.DB) { 36 + musicbrainzDB := database.Open("sqlite3", s.config.MusicbrainzDatabase.Path, func(db *sql.DB) { 36 37 db.Exec("PRAGMA journal_mode = WAL") 37 38 db.Exec("PRAGMA synchronous = NORMAL") 38 39 }) 39 40 defer musicbrainzDB.Close() 40 41 41 - statisticsDB := utilities.OpenDatabase("duckdb", s.config.StatisticsDatabase.Path, func(d *sql.DB) { 42 + statisticsDB := database.Open("duckdb", s.config.StatisticsDatabase.Path, func(d *sql.DB) { 42 43 d.Exec("SET threads TO 4") 43 44 }) 44 45 defer statisticsDB.Close()
+16 -16
pkg/utilities/db.go pkg/database/connection.go
··· 1 - package utilities 1 + package database 2 2 3 3 import ( 4 4 "database/sql" ··· 8 8 "path/filepath" 9 9 ) 10 10 11 + // Opens a database connection, otherwise fails. Also a setup function is needed for the database to 12 + // set connection based settings. 13 + func Open(driver string, dsn string, setupfunc func(*sql.DB)) *sql.DB { 14 + db, err := sql.Open(driver, dsn) 15 + 16 + if err != nil { 17 + log.Panicln(err) 18 + } 19 + 20 + setupfunc(db) 21 + 22 + return db 23 + } 24 + 11 25 // For this application, we use multiple database that do have to interact with each other. This 12 26 // function opens the databases with correct names and paths to the database. The databases will be 13 27 // opened with WAL mode and normal synchronous mode. 14 - func OpenDatabaseWithAttachments(path string, attachments map[string]string) (*sql.DB, error) { 28 + func OpenWithAttachments(path string, attachments map[string]string) (*sql.DB, error) { 15 29 statements := make(map[string]string) 16 30 17 31 for name, dbPath := range attachments { ··· 58 72 59 73 return db, nil 60 74 } 61 - 62 - // Opens a database connection, otherwise fails. Also a setup function is needed for the database to 63 - // set connection based settings. 64 - func OpenDatabase(driver string, dsn string, setupfunc func(*sql.DB)) *sql.DB { 65 - db, err := sql.Open(driver, dsn) 66 - 67 - if err != nil { 68 - log.Panicln(err) 69 - } 70 - 71 - setupfunc(db) 72 - 73 - return db 74 - }
+12 -10
resources/css/components/navigation.css
··· 43 43 width: 100%; 44 44 display: flex; 45 45 flex-direction: column; 46 - gap: var(--spacing-0_5); 46 + gap: var(--spacing-1); 47 47 } 48 48 49 49 .item > a { ··· 57 57 display: inline-flex; 58 58 align-items: center; 59 59 gap: var(--spacing-1); 60 + transition: 61 + background-color 100ms ease, 62 + padding-inline 100ms ease; 60 63 } 61 64 62 - .item > a:hover { 63 - text-decoration: underline; 65 + .item > a:where([aria-current="page"], :hover) { 66 + padding-inline: var(--spacing-2); 64 67 } 65 68 66 - .item > a[aria-current="page"]::before { 67 - content: ""; 68 - display: inline-block; 69 - height: var(--spacing-4); 70 - width: var(--spacing-0_5); 71 - background-color: currentColor; 72 - transform: translateY(1px); 69 + .item > a[aria-current="page"] { 70 + background-color: var(--color-base-200); 71 + } 72 + 73 + .item > a:hover { 74 + background-color: var(--color-muted-100); 73 75 } 74 76 }
+1
resources/css/layouts/library.css
··· 2 2 :scope { 3 3 display: grid; 4 4 grid-template-columns: 1fr 4fr; 5 + column-gap: var(--spacing-8); 5 6 } 6 7 7 8 .library {
+2 -2
resources/views/library/artists.html
··· 1 - {{ define "title" }}Library{{ end }} 1 + {{ define "title" }}Artists{{ end }} 2 2 3 3 {{ define "content"}} 4 4 ··· 21 21 <img src="{{ .ImageURL }}" alt="Logo"> 22 22 {{ end }} 23 23 <a href="/catalog/artists/{{ .MBID }}" class="name">{{ .Name }}</a> 24 - <p class="scrobbles">{{ .Count }} songs</p> 24 + <p class="scrobbles">{{ .Count }}</p> 25 25 </article> 26 26 {{ end }} 27 27 </section>
+5 -5
resources/views/partials/header.html
··· 1 1 {{ define "partials/header" }} 2 2 3 3 {{ $items := (slice 4 - (dict "label" "Home" "href" "/") 5 - (dict "label" "Dashboard" "href" "/dashboard") 6 - (dict "label" "Friends" "href" "/friends") 7 - (dict "label" "Library" "href" "/library") 4 + (dict "label" "Home" "href" "/" "name" "home") 5 + (dict "label" "Dashboard" "href" "/dashboard" "name" "dashboard") 6 + (dict "label" "Friends" "href" "/friends" "name" "friends") 7 + (dict "label" "Library" "href" "/library" "name" "library") 8 8 ) }} 9 9 10 10 <header> ··· 15 15 {{ range $index, $item := $items }} 16 16 <li class="item"> 17 17 <a 18 - {{ if eq .href "/library" }} aria-current="page" {{ end }} 18 + {{ if eq .name "library" }} aria-current="page" {{ end }} 19 19 href="{{ $item.href }}" 20 20 >{{ $item.label }}</a> 21 21 </li>
+2 -2
test/test_repo/main_test.go
··· 7 7 "testing" 8 8 9 9 _ "github.com/mattn/go-sqlite3" 10 - "github.com/oscar345/keeptrack/pkg/utilities" 10 + "github.com/oscar345/keeptrack/pkg/database" 11 11 "github.com/oscar345/keeptrack/test/testutilities" 12 12 ) 13 13 ··· 23 23 var err error 24 24 log.Println("Setting up test database") 25 25 26 - DBmb, err = utilities.OpenDatabaseWithAttachments( 26 + DBmb, err = database.OpenWithAttachments( 27 27 testutilities.FromRoot("private/database/musicbrainz.dev.db"), map[string]string{}, 28 28 ) 29 29 UnwrapError(err)