Documentation ¶
Index ¶
- Constants
- func DefaultHandler(r *http.Response) (string, error)
- func WriteBack(saveType SaveType, mark *markdown.Mark, params *ContentParams, isCreate bool) error
- type Article
- type ArticleType
- type Category
- type Client
- func (c *Client) AddCategory(name string) error
- func (c *Client) BuildArticleURL(id string) string
- func (c *Client) BuildDraftEditorURL(id string) string
- func (c *Client) BuildURL(path string) string
- func (c *Client) DeleteArticle(id string) error
- func (c *Client) DeleteDraft(id string) error
- func (c *Client) Get(rawurl string, params *url.Values, ...) (string, error)
- func (c *Client) GetCategoryByName(name string) (*Category, error)
- func (c *Client) GetDraftDetail(id string) (*ContentParams, error)
- func (c *Client) GetTechnicalFieldByName(name string) (*TechnicalField, error)
- func (c *Client) ListArticles(page int, keyword string) (articles []*Article, hasNext bool, err error)
- func (c *Client) ListCategories() ([]*Category, error)
- func (c *Client) ListDrafts(page int) (drafts []*Draft, hasNext bool, err error)
- func (c *Client) ListTechnicalFields() ([]*TechnicalField, error)
- func (c *Client) ParseMark(mark *markdown.Mark) (*ContentParams, error)
- func (c *Client) Post(path string, values url.Values, handler func(r *http.Response) (string, error)) (string, error)
- func (c *Client) PublishDraft(id string) (articleID string, err error)
- func (c *Client) SaveArticle(params *ContentParams) error
- func (c *Client) SaveDraft(params *ContentParams) error
- type ContentParams
- type Draft
- type MarkdownOptions
- type SaveType
- type TechnicalField
Constants ¶
View Source
const ( ArticleTypeOriginal ArticleType = "1" // 原创 ArticleTypeReship ArticleType = "4" // 转载 ContentTypeMarkdown = "3" ContentTypeHTML = "4" )
View Source
const ArticleURLFormat = "https://my.oschina.net/%s/blog/%s"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArticleType ¶ added in v0.3.0
type ArticleType string
type Client ¶
type Client struct { BaseURL string Cookie string UserCode string UserID string SpaceID string UserName string }
func (*Client) AddCategory ¶
AddCategory add a new category
func (*Client) BuildArticleURL ¶ added in v0.3.0
func (*Client) BuildDraftEditorURL ¶ added in v0.4.0
func (*Client) DeleteArticle ¶
func (*Client) DeleteDraft ¶ added in v0.3.0
func (*Client) Get ¶
func (c *Client) Get(rawurl string, params *url.Values, handler func(r *http.Response) (string, error)) (string, error)
Get request with GET method and support response handler
func (*Client) GetCategoryByName ¶ added in v0.3.0
func (*Client) GetDraftDetail ¶ added in v0.3.0
func (c *Client) GetDraftDetail(id string) (*ContentParams, error)
func (*Client) GetTechnicalFieldByName ¶ added in v0.3.0
func (c *Client) GetTechnicalFieldByName(name string) (*TechnicalField, error)
func (*Client) ListArticles ¶ added in v0.2.0
func (*Client) ListCategories ¶ added in v0.3.0
ListCategories list all categories
func (*Client) ListDrafts ¶ added in v0.3.0
func (*Client) ListTechnicalFields ¶ added in v0.3.0
func (c *Client) ListTechnicalFields() ([]*TechnicalField, error)
ListTechnicalFields list all technical fields
func (*Client) ParseMark ¶ added in v0.4.0
func (c *Client) ParseMark(mark *markdown.Mark) (*ContentParams, error)
func (*Client) PublishDraft ¶ added in v0.3.0
func (*Client) SaveArticle ¶
func (c *Client) SaveArticle(params *ContentParams) error
SaveArticle create an article if id is empty, otherwise update existed article.
func (*Client) SaveDraft ¶
func (c *Client) SaveDraft(params *ContentParams) error
SaveDraft create a new draft if id is empty, otherwise update draft
type ContentParams ¶ added in v0.3.0
type ContentParams struct { ID string `url:"id"` // 文章 ID DraftID string `url:"draft"` // 草稿 ID Title string `url:"title"` // 文章标题 Content string `url:"content"` // 文章内容 Category string `url:"catalog"` // 文章分类 TechnicalField string `url:"groups"` // 技术领域,草稿无法设置 OriginalURL string `url:"origin_url"` // 原文链接 Privacy int `url:"privacy"` // 仅自己可见 DenyComment int `url:"deny_comment"` // 禁止评论 Top int `url:"as_top"` // 置顶 DownloadImage int `url:"downloadImg"` // 下载外站图片 Type ArticleType `url:"type"` // 原创、转载 ContentType string `url:"content_type"` PublishAsBlog int `url:"publish_as_blog"` }
func (*ContentParams) Validate ¶ added in v0.3.0
func (p *ContentParams) Validate() error
type MarkdownOptions ¶
type MarkdownOptions struct { Publish bool `yaml:"publish"` Title string `yaml:"title"` Category string `yaml:"category"` Field string `yaml:"field"` OriginURL string `yaml:"origin_url"` Original bool `yaml:"original"` Privacy bool `yaml:"privacy"` DownloadImage bool `yaml:"download_image"` Top bool `yaml:"top"` DenyComment bool `yaml:"deny_comment"` }
type TechnicalField ¶ added in v0.3.0
Click to show internal directories.
Click to hide internal directories.