Documentation ¶
Index ¶
- Constants
- func AddCommands(rootCmd *cobra.Command)
- func SavePostConfig(path string, config *PostConfig) error
- func UploadPostFiles(client *clients.ProtoClient, id int64, root fs.FS, files []string)
- type Client
- func (c *Client) BackupFiles(cmd *cobra.Command)
- func (c *Client) BackupPosts(cmd *cobra.Command)
- func (c *Client) CreatePost() error
- func (c *Client) DeletePost(id int64) error
- func (c *Client) GetComment(cmdID int64) *proto.Comment
- func (c *Client) GetConfig(path string) string
- func (c *Client) GetPost()
- func (c *Client) InitPost() error
- func (c *Client) SaveConfig()
- func (c *Client) SetCommentPostID(commentID int64, postID int64)
- func (c *Client) SetConfig(path string, value string)
- func (c *Client) SetPostStatus(id int64, public bool, touch bool)
- func (c *Client) UpdateComment(cmtID int64)
- func (c *Client) UpdatePost() error
- func (c *Client) UploadPostFiles(id int64, files []string)
- type FilesSyncer
- type HostConfig
- type PostConfig
- type SyncFileSpec
Constants ¶
View Source
const ConfigFileName = `config.yml`
View Source
const IndexFileName = `README.md`
Variables ¶
This section is empty.
Functions ¶
func SavePostConfig ¶
func SavePostConfig(path string, config *PostConfig) error
func UploadPostFiles ¶
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 ¶
Backup backups all blog database.
func (*Client) BackupPosts ¶
BackupPosts backups all blog database.
func (*Client) GetComment ¶
func (*Client) SaveConfig ¶
func (c *Client) SaveConfig()
func (*Client) SetCommentPostID ¶
SetCommentPostID ...
func (*Client) SetPostStatus ¶
SetPostStatus ...
func (*Client) UpdateComment ¶
更新一条评论。 非 Markdown 评论会被转换为 Markdown。
func (*Client) UploadPostFiles ¶
type FilesSyncer ¶
type FilesSyncer struct {
// contains filtered or unexported fields
}
func NewFilesSyncer ¶
func NewFilesSyncer(client proto.Management_FileSystemClient) *FilesSyncer
func (*FilesSyncer) SyncPostFiles ¶
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 ¶
func (*SyncFileSpec) DeepEqual ¶
func (s *SyncFileSpec) DeepEqual(to *SyncFileSpec) bool
func (*SyncFileSpec) Less ¶
func (s *SyncFileSpec) Less(than *SyncFileSpec) bool
Click to show internal directories.
Click to hide internal directories.