client

package
v1.0.1-0...-219fbf5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommands

func AddCommands(rootCmd *cobra.Command)

AddCommands ...

func NewConn

func NewConn(api, grpcAddress string) *grpc.ClientConn

Types

type Client

type Client struct {
	// 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) Blog

func (c *Client) Blog() protocols.TaoBlogClient

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) *protocols.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) SetRedirect

func (c *Client) SetRedirect(sourcePath, targetPath string)

func (*Client) Token

func (c *Client) Token() context.Context

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)

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

type FilesSyncer

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

func (*FilesSyncer) ListLocalFilesFromPaths

func (s *FilesSyncer) ListLocalFilesFromPaths(paths []string) ([]*protocols.FileSpec, error)

func (*FilesSyncer) SyncPostFiles

func (s *FilesSyncer) SyncPostFiles(id int64, localFiles []*protocols.FileSpec) error

type HostConfig

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

HostConfig is a per host config.

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 ...

type SyncFileSpec

type SyncFileSpec protocols.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