sonolusgo

package module
v0.8.1-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: MIT Imports: 7 Imported by: 2

README

sonolusgo

一个使用Go语言和Gin框架构建Sonolus服务器的框架库

适用版本 V0.8.1 当前版本 V0.8.1-1

基于Go的版本号要求,和本项目修改bug的需要,本框架的版本号将全部以rc结尾。rc越大,版本越新。

正在建设中(With in Progress)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailsHandler

func DetailsHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func GetEmptyItem

func GetEmptyItem[ItemType SonolusItem](name string) (item ItemType, description string, err error)

func GetEmptyList

func GetEmptyList[ItemType SonolusItem](page int, queryMap map[string]string) (pageCount int, items []ItemType)

func GetEmptyRecommend

func GetEmptyRecommend[ItemType SonolusItem](name string) (items []ItemType)

func GetItem

func GetItem[ItemType SonolusItem](name string) (item ItemType, description string, err error)

func GetList

func GetList[ItemType SonolusItem](page int, queryMap map[string]string) (pageCount int, items []ItemType)

func InfoHandler

func InfoHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func ListHandler

func ListHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func ServerInfoHandler

func ServerInfoHandler(server *Server) gin.HandlerFunc

TODO: Localization

func SonolusVersionHandler

func SonolusVersionHandler(ctx *gin.Context)

Types

type Background

type Background struct {
	SonolusItemBase
	Thumbnail     SRL `json:"thumbnail"`
	Data          SRL `json:"data"`
	Image         SRL `json:"image"`
	Configuration SRL `json:"configuration"`
}

func (Background) GetCategory

func (item Background) GetCategory() SonolusCategory

func (Background) GetName

func (item Background) GetName() string

type Effect

type Effect struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Audio     SRL `json:"audio"`
}

func (Effect) GetCategory

func (item Effect) GetCategory() SonolusCategory

func (Effect) GetName

func (item Effect) GetName() string

type Engine

type Engine struct {
	SonolusItemBase
	Skin          Skin       `json:"skin"`
	Background    Background `json:"background"`
	Effect        Effect     `json:"effect"`
	Particle      Particle   `json:"particle"`
	Thumbnail     SRL        `json:"thumbnail"`
	PlayData      SRL        `json:"playData"`
	WatchData     SRL        `json:"watchData"`
	PreviewData   SRL        `json:"previewData"`
	TutorialData  SRL        `json:"tutorialData"`
	Rom           *SRL       `json:"rom,omitempty"`
	Configuration SRL        `json:"configuration"`
}

func (Engine) GetCategory

func (item Engine) GetCategory() SonolusCategory

func (Engine) GetName

func (item Engine) GetName() string

type Handlers

type Handlers struct {
	Posts       SonolusService[Post]
	Playlist    SonolusService[Playlist]
	Levels      SonolusService[Level]
	Skins       SonolusService[Skin]
	Backgrounds SonolusService[Background]
	Effects     SonolusService[Effect]
	Particles   SonolusService[Particle]
	Engines     SonolusService[Engine]
	Replay      SonolusService[Replay]
}

type ItemDetail

type ItemDetail[ItemType SonolusItem] struct {
	Item        ItemType                `json:"item"`
	Description string                  `json:"description"`
	Sections    []ItemSection[ItemType] `json:"sections"`
}

type ItemInfo

type ItemInfo[ItemType SonolusItem] struct {
	Banner   SRL                     `json:"banner"`
	Sections []ItemSection[ItemType] `json:"sections"`
	Searches []ServerOptionSection   `json:"searches"`
}

type ItemList

type ItemList[ItemType SonolusItem] struct {
	PageCount int                 `json:"pageCount"`
	Items     []ItemType          `json:"items"`
	Searches  ServerOptionSection `json:"searches"`
}

type ItemSection

type ItemSection[ItemType SonolusItem] struct {
	Title string     `json:"title"`
	Items []ItemType `json:"items"`
	Icon  string     `json:"icon"`
}

type Level

type Level struct {
	Name          string              `json:"name"`
	Source        string              `json:"source"`
	Version       int                 `json:"version"`
	Rating        int                 `json:"rating"`
	Title         string              `json:"title"`
	Artists       string              `json:"artists"`
	Author        string              `json:"author"`
	Tags          []Tag               `json:"tags"`
	Engine        Engine              `json:"engine"`
	UseSkin       UseItem[Skin]       `json:"useSkin"`
	UseBackground UseItem[Background] `json:"useBackground"`
	UseEffect     UseItem[Effect]     `json:"useEffect"`
	UseParticle   UseItem[Particle]   `json:"useParticle"`
	Cover         SRL                 `json:"cover"`
	Bgm           SRL                 `json:"bgm"`
	Preview       *SRL                `json:"preview,omitempty"`
	Data          SRL                 `json:"data"`
}

func (Level) GetCategory

func (item Level) GetCategory() SonolusCategory

func (Level) GetName

func (item Level) GetName() string

type Particle

type Particle struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Texture   SRL `json:"texture"`
}

func (Particle) GetCategory

func (item Particle) GetCategory() SonolusCategory

func (Particle) GetName

func (item Particle) GetName() string

type Playlist

type Playlist struct {
	Name      string  `json:"name"`
	Source    string  `json:"source,omitempty"`
	Version   int     `json:"version"`
	Title     string  `json:"title"`
	Subtitle  string  `json:"subtitle"`
	Author    string  `json:"author"`
	Tags      []Tag   `json:"tags"`
	Levels    []Level `json:"levels"`
	Thumbnail SRL     `json:"thumbnail"`
}

func (Playlist) GetCategory

func (item Playlist) GetCategory() SonolusCategory

func (Playlist) GetName

func (item Playlist) GetName() string

type Post

type Post struct {
	Name      string `json:"name"`
	Source    string `json:"source,omitempty"`
	Version   int    `json:"version"`
	Title     string `json:"title"`
	Time      string `json:"time"`
	Author    string `json:"author"`
	Tags      []Tag  `json:"tags"`
	Thumbnail SRL    `json:"thumbnail"`
}

func (Post) GetCategory

func (item Post) GetCategory() SonolusCategory

func (Post) GetName

func (item Post) GetName() string

type Replay

type Replay struct {
	Name      string  `json:"name"`
	Source    string  `json:"source,omitempty"`
	Version   int     `json:"version"`
	Title     string  `json:"title"`
	Subtitle  string  `json:"subtitle"`
	Author    string  `json:"author"`
	Tags      []Tag   `json:"tags"`
	Levels    []Level `json:"levels"`
	Data      SRL     `json:"data"`
	Thumbnail SRL     `json:"thumbnail"`
}

func (Replay) GetCategory

func (item Replay) GetCategory() SonolusCategory

func (Replay) GetName

func (item Replay) GetName() string

type RouterGroups

type RouterGroups struct {
	Sonolus     *gin.RouterGroup
	Posts       *gin.RouterGroup
	Playlist    *gin.RouterGroup
	Levels      *gin.RouterGroup
	Skins       *gin.RouterGroup
	Backgrounds *gin.RouterGroup
	Effects     *gin.RouterGroup
	Particles   *gin.RouterGroup
	Engines     *gin.RouterGroup
	Replays     *gin.RouterGroup
}

type SRL

type SRL struct {
	Hash string `json:"hash"`
	Url  string `json:"url"`
}

type SearchSelectOption

type SearchSelectOption struct {
	Query  string   `json:"query"`
	Name   string   `json:"name"`
	Type   string   `json:"type"`
	Def    int      `json:"def"`
	Values []string `json:"values,omitempty"`
}

func NewSearchSelectOption

func NewSearchSelectOption(query string, name string, def int, values []string) SearchSelectOption

func (SearchSelectOption) GetQuery

func (o SearchSelectOption) GetQuery() string

func (SearchSelectOption) GetValueStr

func (o SearchSelectOption) GetValueStr(queryResult string) string

type SearchSliderOption

type SearchSliderOption struct {
	Query string  `json:"query"`
	Name  string  `json:"name"`
	Type  string  `json:"type"`
	Def   float64 `json:"def"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
	Step  float64 `json:"step"`
	Unit  string  `json:"unit"`
}

func NewSearchSliderOption

func NewSearchSliderOption(query string, name string, def float64, min float64, max float64, step float64, unit string) SearchSliderOption

func (SearchSliderOption) GetQuery

func (o SearchSliderOption) GetQuery() string

func (SearchSliderOption) GetValueStr

func (o SearchSliderOption) GetValueStr(queryResult string) string

type SearchTextOption

type SearchTextOption struct {
	Query       string `json:"query"`
	Name        string `json:"name"`
	Type        string `json:"type"`
	PlaceHolder string `json:"placeHolder"`
}

func NewSearchTextOption

func NewSearchTextOption(query string, name string, placeHolder string) SearchTextOption

func (SearchTextOption) GetQuery

func (o SearchTextOption) GetQuery() string

func (SearchTextOption) GetValueStr

func (o SearchTextOption) GetValueStr(queryResult string) string

type SearchToggleOption

type SearchToggleOption struct {
	Query string `json:"query"`
	Name  string `json:"name"`
	Type  string `json:"type"`
	Def   int    `json:"def"`
}

func NewSearchToggleOption

func NewSearchToggleOption(query string, name string, def int) SearchToggleOption

func (SearchToggleOption) GetQuery

func (o SearchToggleOption) GetQuery() string

func (SearchToggleOption) GetValueStr

func (o SearchToggleOption) GetValueStr(queryResult string) string

type Server

type Server struct {
	RepoDir      string
	ServerName   string
	ServerBanner SRL
	ServerInfo   ServerInfoFilePath
	Handlers     Handlers
	RouterGroups RouterGroups
}

func DefaultConfig

func DefaultConfig() *Server

func (*Server) LoadHandlers

func (server *Server) LoadHandlers(parentHandler *gin.Engine)

type ServerInfo

type ServerInfo struct {
	Title             string `json:"title"`
	Description       string `json:"description,omitempty"`
	HasAuthentication bool   `json:"hasAuthentication"`
	HasMultiplayer    bool   `json:"hasMultiplayer"`
	Banner            SRL    `json:"banner"`
}

type ServerInfoFilePath

type ServerInfoFilePath struct {
	Posts       string
	Playlist    string
	Levels      string
	Skins       string
	Backgrounds string
	Effects     string
	Particles   string
	Engines     string
	Replays     string
}
var InfoFilePath *ServerInfoFilePath

type ServerOption

type ServerOption interface {
	GetQuery() string
	GetValueStr(queryResult string) string
}

type ServerOptionSection

type ServerOptionSection struct {
	Type    string         `json:"string"`
	Title   string         `json:"title"`
	Icon    string         `json:"icon"`
	Options []ServerOption `json:"options"`
}

func GetEmptySearch

func GetEmptySearch() (search ServerOptionSection)

type Skin

type Skin struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Texture   SRL `json:"texture"`
}

func (Skin) GetCategory

func (item Skin) GetCategory() SonolusCategory

func (Skin) GetName

func (item Skin) GetName() string

type SonolusCategory

type SonolusCategory int
const (
	CategoryPostItem SonolusCategory = iota
	CategoryPlaylist
	CategoryLevels
	CategorySkins
	CategoryBackgrounds
	CategoryEffect
	CategoryParticle
	CategoryEngine
	CategoryReplayItem
	TotalCategoryCnt
)

type SonolusItem

type SonolusItem interface {
	Post | Playlist | Level | Skin | Background | Effect | Particle | Engine | Replay
	GetName() string
	GetCategory() SonolusCategory
}

type SonolusItemBase

type SonolusItemBase struct {
	Name     string `json:"name"`
	Source   string `json:"source,omitempty"`
	Version  int    `json:"version"`
	Title    string `json:"title"`
	Subtitle string `json:"subtitle"`
	Author   string `json:"author"`
	Tags     []Tag  `json:"tags"`
}

type SonolusService

type SonolusService[ItemType SonolusItem] struct {
	List      func(page int, queryMap map[string]string) (pageCount int, items []ItemType)
	Search    func() (search ServerOptionSection)
	Item      func(name string) (item ItemType, description string, err error)
	Recommend func(name string) (items []ItemType)
	Banner    SRL
}

type Tag

type Tag struct {
	Title string `json:"title"`
	Icon  string `json:"icon,omitempty"`
}

type UseItem

type UseItem[ItemType Skin | Background | Effect | Particle] struct {
	UseDefault bool      `json:"useDefault"`
	Item       *ItemType `json:"item"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL