client

package
v1.0.1-0...-45e5b3b Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileName = `config.yml`
View Source
const IndexFileName = `README.md`

Variables

This section is empty.

Functions

func AddCommands

func AddCommands(rootCmd *cobra.Command)

AddCommands ...

func SavePostConfig

func SavePostConfig(path string, config *PostConfig) error

func UploadPostFiles

func UploadPostFiles(client *clients.ProtoClient, id int64, root fs.FS, files []string)

UploadPostFiles 上传文章附件。 TODO 应该像 Backup 那样改成带进度的 protocol buffer 方式上传。 NOTE 路径列表,相对于工作目录,相对路径。 TODO 由于评论中可能也带有图片引用,但是不会被算计到。所以远端的多余文件总是不会被删除。 NOTE 会自动去重本地文件。 NOTE 会自动排除 config.yml 文件。

Types

type Client

type Client struct {
	*clients.ProtoClient
	// contains filtered or unexported fields
}

Client ... TODO: close client connection.

func NewClient

func NewClient(config HostConfig) *Client

NewClient creates a new client that interacts with server.

func (*Client) BackupFiles

func (c *Client) BackupFiles(cmd *cobra.Command)

Backup backups all blog database.

func (*Client) BackupPosts

func (c *Client) BackupPosts(cmd *cobra.Command)

BackupPosts backups all blog database.

func (*Client) CreatePost

func (c *Client) CreatePost() error

CreatePost ...

func (*Client) DeletePost

func (c *Client) DeletePost(id int64) error

DeletePost ...

func (*Client) GetComment

func (c *Client) GetComment(cmdID int64) *proto.Comment

func (*Client) GetConfig

func (c *Client) GetConfig(path string) string

func (*Client) GetPost

func (c *Client) GetPost()

GetPost ...

func (*Client) InitPost

func (c *Client) InitPost() error

InitPost ...

func (*Client) SaveConfig

func (c *Client) SaveConfig()

func (*Client) SetCommentPostID

func (c *Client) SetCommentPostID(commentID int64, postID int64)

SetCommentPostID ...

func (*Client) SetConfig

func (c *Client) SetConfig(path string, value string)

func (*Client) SetPostStatus

func (c *Client) SetPostStatus(id int64, public bool, touch bool)

SetPostStatus ...

func (*Client) UpdateComment

func (c *Client) UpdateComment(cmtID int64)

更新一条评论。 非 Markdown 评论会被转换为 Markdown。

func (*Client) UpdatePost

func (c *Client) UpdatePost() error

UpdatePost ...

func (*Client) UploadPostFiles

func (c *Client) UploadPostFiles(id int64, files []string)

type FilesSyncer

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

func NewFilesSyncer

func NewFilesSyncer(client proto.Management_FileSystemClient) *FilesSyncer

func (*FilesSyncer) SyncPostFiles

func (s *FilesSyncer) SyncPostFiles(id int64, root fs.FS, files []string) error

type HostConfig

type HostConfig struct {
	API   string `yaml:"api"`
	GRPC  string `yaml:"grpc"`
	Token string `yaml:"token"`
}

HostConfig is a per host config.

func InitHostConfigs

func InitHostConfigs() HostConfig

type PostConfig

type PostConfig struct {
	ID       int64           `json:"id" yaml:"id"`
	Title    string          `json:"title" yaml:"title"`
	Modified int32           `json:"modified" yaml:"modified"`
	Tags     []string        `json:"tags" yaml:"tags"`
	Metas    models.PostMeta `json:"metas" yaml:"metas"`
	Slug     string          `json:"slug" yaml:"slug,omitempty"`
	Type     string          `json:"type" yaml:"type"`
}

PostConfig ...

func ReadPostConfig

func ReadPostConfig(path string) (*PostConfig, error)

func ReadPostConfigReader

func ReadPostConfigReader(r io.Reader) (*PostConfig, error)

type SyncFileSpec

type SyncFileSpec proto.FileSpec

func (*SyncFileSpec) DeepEqual

func (s *SyncFileSpec) DeepEqual(to *SyncFileSpec) bool

func (*SyncFileSpec) Less

func (s *SyncFileSpec) Less(than *SyncFileSpec) bool

Jump to

Keyboard shortcuts

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