Merge branch 'dev' into feature/blog
This commit is contained in:
commit
dd8e503b61
39 changed files with 452 additions and 448 deletions
|
@ -1,23 +1,23 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
const COOKIE_TOKEN string = "AM_SESSION"
|
||||
const MAX_LOGIN_FAIL_ATTEMPTS int = 3
|
||||
|
||||
type (
|
||||
Account struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Password string `json:"password" db:"password"`
|
||||
Email sql.NullString `json:"email" db:"email"`
|
||||
AvatarURL sql.NullString `json:"avatar_url" db:"avatar_url"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
FailAttempts int `json:"fail_attempts" db:"fail_attempts"`
|
||||
Locked bool `json:"locked" db:"locked"`
|
||||
Account struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Password string `json:"password" db:"password"`
|
||||
Email sql.NullString `json:"email" db:"email"`
|
||||
AvatarURL sql.NullString `json:"avatar_url" db:"avatar_url"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
FailAttempts int `json:"fail_attempts" db:"fail_attempts"`
|
||||
Locked bool `json:"locked" db:"locked"`
|
||||
|
||||
Privileges []AccountPrivilege `json:"privileges"`
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
"arimelody-web/log"
|
||||
)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package model
|
||||
|
||||
type (
|
||||
Artist struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Website string `json:"website"`
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
Artist struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Website string `json:"website"`
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
)
|
||||
|
||||
func (artist Artist) GetAvatar() string {
|
||||
if artist.Avatar == "" {
|
||||
return "/img/default-avatar.png"
|
||||
}
|
||||
return artist.Avatar
|
||||
if artist.Avatar == "" {
|
||||
return "/img/default-avatar.png"
|
||||
}
|
||||
return artist.Avatar
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
func (link Link) NormaliseName() string {
|
||||
rgx := regexp.MustCompile(`[^a-z0-9\-]`)
|
||||
return rgx.ReplaceAllString(strings.ToLower(link.Name), "")
|
||||
rgx := regexp.MustCompile(`[^a-z0-9\-]`)
|
||||
return rgx.ReplaceAllString(strings.ToLower(link.Name), "")
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
"time"
|
||||
"html/template"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -73,23 +73,23 @@ func (release Release) GetUniqueArtistNames(only_primary bool) []string {
|
|||
names = append(names, credit.Artist.Name)
|
||||
}
|
||||
|
||||
return names
|
||||
return names
|
||||
}
|
||||
|
||||
func (release Release) PrintArtists(only_primary bool, ampersand bool) string {
|
||||
names := release.GetUniqueArtistNames(only_primary)
|
||||
|
||||
if len(names) == 0 {
|
||||
return "Unknown Artist"
|
||||
} else if len(names) == 1 {
|
||||
return names[0]
|
||||
}
|
||||
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
|
||||
} else {
|
||||
return strings.Join(names[:], ", ")
|
||||
}
|
||||
if ampersand {
|
||||
res := strings.Join(names[:len(names)-1], ", ")
|
||||
res += " & " + names[len(names)-1]
|
||||
return res
|
||||
} else {
|
||||
return strings.Join(names[:], ", ")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Test_Release_DescriptionHTML(t *testing.T) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TOTP struct {
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
"html/template"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
Track struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Track struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Lyrics string `json:"lyrics" db:"lyrics"`
|
||||
PreviewURL string `json:"previewURL" db:"preview_url"`
|
||||
PreviewURL string `json:"previewURL" db:"preview_url"`
|
||||
|
||||
Number int
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
func (track Track) GetDescriptionHTML() template.HTML {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue