api

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BASE_DIR         string = "/opt/pwebpoint"
	PLUGIN_DIR       string = filepath.Join(BASE_DIR, "plugin")
	CACHE_DIR        string = filepath.Join(BASE_DIR, "caches")
	PLUGIN_CACHE_DIR string = filepath.Join(CACHE_DIR, "plugin")
)
View Source
var (
	PluginIdRe     = regexp.MustCompile(`[0-9a-z_]{1,64}`)
	VersionRe      = regexp.MustCompile(`^((?:[xX*]|\d+)(?:\.(?:[xX*]|\d+))*)([-+][-+.0-9A-Za-z]+)?$`)
	VersionExtraRe = regexp.MustCompile(`^|[-+0-9A-Za-z]+(?:\.[-+0-9A-Za-z]+)*$`)
)
View Source
var DEBUG = os.Getenv("DEBUG") == "true"
View Source
var DefaultOption = &Option{}
View Source
var (
	ErrNotFound = errors.New("ErrNotFound")
)
View Source
var VersionMatchAny = VersionCond{
	Cond: EQ,
}

Functions

func RenderMarkdown added in v0.6.0

func RenderMarkdown(src []byte, opt *Option) (out []byte, err error)

func ReplaceEmoji added in v1.1.0

func ReplaceEmoji(src []byte) (out []byte)

func SetLoggerOutput added in v1.2.0

func SetLoggerOutput(w io.Writer)

Types

type API

type API interface {
	GetLastUpdateTime() (modTime time.Time, err error)
	GetPluginLastUpdateTime(id string) (modTime time.Time, err error)
	GetPluginCounts(opt PluginListOpt) (count PluginCounts, err error)
	GetPluginList(opt PluginListOpt) (infos []*PluginInfo, err error)
	GetPluginIdList(opt PluginListOpt) (ids []string, err error)
	GetPluginInfo(id string, version string) (info *PluginInfo, err error)
	GetPluginInfos(id string) (info []*PluginInfo, err error)
	GetPluginReadme(id string) (content Content, err error)
	GetPluginReleases(id string) (releases []*PluginRelease, err error)
	GetPluginRelease(id string, tag Version) (release *PluginRelease, err error)
	GetPluginReleaseAsset(id string, tag Version, filename string) (rc io.ReadSeekCloser, modTime time.Time, err error)
}

type Cond

type Cond uint8
const (
	InvaildCond Cond = iota
	EQ               // =
	LT               // <
	LE               // <=
	GT               // >
	GE               // >=
	EX               // ^
	TD               // ~
)

func CondFromString

func CondFromString(s string) Cond

func (Cond) String

func (c Cond) String() string

type Content added in v0.6.3

type Content struct {
	Data          func() ([]byte, error)
	CloseFunc     func() error
	ModTime       string
	URLPrefix     string
	DataURLPrefix string
}

func (Content) Close added in v1.0.0

func (c Content) Close() error

type DependMap

type DependMap map[string]VersionCondList

type GToken added in v0.6.1

type GToken struct {
	Token string `json:"access_token"`
	Typ   string `json:"token_type"`
	Scope string `json:"scope"`
}

func (GToken) GetAuth added in v0.6.1

func (t GToken) GetAuth() string

type GhClient added in v0.7.0

type GhClient struct {
	// contains filtered or unexported fields
}

func InitGithubCli added in v0.7.0

func InitGithubCli() (c *GhClient)

func (*GhClient) Get added in v0.7.0

func (c *GhClient) Get(url string) (*http.Response, error)

func (*GhClient) GetWithContext added in v0.7.0

func (c *GhClient) GetWithContext(ctx context.Context, url string) (res *http.Response, err error)

type NopReadSeeker

type NopReadSeeker struct {
	io.ReadSeeker
}

func (NopReadSeeker) Close

func (NopReadSeeker) Close() error

type Option added in v0.6.0

type Option struct {
	URLPrefix       string
	DataURLPrefix   string
	HeadingIDPrefix string
	HeadingIDSuffix string
}

func (*Option) NewPolicy added in v0.6.3

func (o *Option) NewPolicy() (p *bluemonday.Policy)

func (*Option) Transform added in v1.1.0

func (o *Option) Transform(doc *ast.Document, reader text.Reader, ctx parser.Context)

type PluginCounts

type PluginCounts struct {
	Total       int `json:"total"`
	Information int `json:"information"`
	Tool        int `json:"tool"`
	Management  int `json:"management"`
	Api         int `json:"api"`
}

type PluginInfo

type PluginInfo struct {
	Id           string       `json:"id"`
	Name         string       `json:"name"`
	Version      Version      `json:"version"`
	Authors      []string     `json:"authors"`
	Desc         string       `json:"desc,omitempty"`
	Desc_zhCN    string       `json:"desc_zhCN,omitempty"`
	CreateAt     time.Time    `json:"createAt"`
	LastRelease  *time.Time   `json:"lastRelease,omitempty"`
	Repo         string       `json:"repo,omitempty"`
	RepoBranch   string       `json:"repoBranch,omitempty"`
	RepoSubdir   string       `json:"repoSubdir,omitempty"`
	Link         string       `json:"link,omitempty"`
	Labels       PluginLabels `json:"labels"`
	Downloads    int64        `json:"downloads"`
	Dependencies DependMap    `json:"dependencies,omitempty"`
	Requirements RequireMap   `json:"requirements,omitempty"`
	GithubSync   bool         `json:"github_sync"`
	GhRepoOwner  string       `json:"ghRepoOwner,omitempty"`
	GhRepoName   string       `json:"ghRepoName,omitempty"`
	LastSync     *time.Time   `json:"last_sync,omitempty"`
}

type PluginLabels

type PluginLabels struct {
	Information bool `json:"information,omitempty"`
	Tool        bool `json:"tool,omitempty"`
	Management  bool `json:"management,omitempty"`
	Api         bool `json:"api,omitempty"`
}

type PluginListOpt

type PluginListOpt struct {
	FilterBy string   `json:"filterBy,omitempty"`
	Tags     []string `json:"tags,omitempty"`
	SortBy   string   `json:"sortBy,omitempty"`
	Reversed bool     `json:"reversed,omitempty"`
	Limit    int      `json:"limit,omitempty"`
	Offset   int      `json:"offset,omitempty"`
}

type PluginRelease

type PluginRelease struct {
	Id        string    `json:"id"`
	Tag       Version   `json:"tag"`
	Enabled   bool      `json:"enabled"`
	Stable    bool      `json:"stable"`
	Size      int64     `json:"size"`
	Uploaded  time.Time `json:"uploaded"`
	FileName  string    `json:"filename"`
	Downloads int       `json:"downloads"`
	GithubUrl string    `json:"github_url"`
}

type RequireMap added in v0.8.0

type RequireMap map[string]string

type StatusCodeErr

type StatusCodeErr struct {
	Code int
}

func (*StatusCodeErr) Error

func (e *StatusCodeErr) Error() string

type Version

type Version struct {
	Comps       []int
	HasWildcard bool

	Pre   string
	Build string
}

func VersionFromString

func VersionFromString(data string) (v Version, err error)

func (Version) Equal added in v1.3.0

func (v Version) Equal(o Version) bool

func (Version) Get added in v1.3.0

func (v Version) Get(i int) int

func (Version) Less added in v1.3.0

func (v Version) Less(o Version) bool

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (*Version) Scan

func (v *Version) Scan(d any) (err error)

func (Version) String

func (v Version) String() (s string)

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(data []byte) (err error)

func (Version) Value

func (v Version) Value() (driver.Value, error)

type VersionCond

type VersionCond struct {
	Cond Cond
	Ver  Version
}

func VersionCondFromString

func VersionCondFromString(s string) (v VersionCond, err error)

func (VersionCond) IsMatch

func (vc VersionCond) IsMatch(v Version) bool

func (VersionCond) MarshalJSON

func (v VersionCond) MarshalJSON() ([]byte, error)

func (*VersionCond) Scan

func (v *VersionCond) Scan(d any) (err error)

func (VersionCond) String

func (v VersionCond) String() (s string)

func (*VersionCond) UnmarshalJSON

func (v *VersionCond) UnmarshalJSON(data []byte) (err error)

func (VersionCond) Value

func (v VersionCond) Value() (driver.Value, error)

type VersionCondList added in v1.3.0

type VersionCondList []VersionCond

func VersionCondListFromString added in v1.3.0

func VersionCondListFromString(s string) (v VersionCondList, err error)

func (VersionCondList) IsMatch added in v1.3.0

func (vl VersionCondList) IsMatch(v Version) bool

func (VersionCondList) MarshalJSON added in v1.3.0

func (v VersionCondList) MarshalJSON() ([]byte, error)

func (*VersionCondList) Scan added in v1.3.0

func (v *VersionCondList) Scan(d any) (err error)

func (VersionCondList) String added in v1.3.0

func (v VersionCondList) String() (s string)

func (*VersionCondList) UnmarshalJSON added in v1.3.0

func (v *VersionCondList) UnmarshalJSON(data []byte) (err error)

func (VersionCondList) Value added in v1.3.0

func (v VersionCondList) Value() (driver.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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