model

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DirMine is the directory of saving posts in Qiita. (Not for posts in Qiita:Team)
	DirMine = "mine"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreationOptions

type CreationOptions struct {
	Tweet bool `json:"tweet"`
	Gist  bool `json:"gist"`
}

CreationOptions is options for creating a post.

type CreationPost

type CreationPost struct {
	Post
	CreationOptions
}

CreationPost is sent to Qiita server when creating post.

type EmptyIDError

type EmptyIDError struct{}

EmptyIDError occurs when operate a post without ID.

func (EmptyIDError) Error

func (err EmptyIDError) Error() (msg string)

type ITime

type ITime interface {
	Format(layout string) string
}

ITime should have a format function.

type InvalidError

type InvalidError map[string]InvalidStatus

InvalidError occurs when some fields are wrong.

func (InvalidError) Error

func (err InvalidError) Error() (msg string)

type InvalidStatus

type InvalidStatus struct {
	Name     string
	Required bool
}

InvalidStatus suggests what is wrong.

func (InvalidStatus) String

func (s InvalidStatus) String() (msg string)

type Meta

type Meta struct {
	ID        string `json:"id" yaml:"id"`                 // 投稿の一意なID
	URL       string `json:"url" yaml:"url"`               // 投稿のURL
	CreatedAt Time   `json:"created_at" yaml:"created_at"` // データが作成された日時
	UpdatedAt Time   `json:"updated_at" yaml:"updated_at"` // データが最後に更新された日時
	Private   bool   `json:"private" yaml:"private"`       // 限定共有状態かどうかを表すフラグ (Qiita:Teamでは無効)
	Coediting bool   `json:"coediting" yaml:"coediting"`   // この投稿が共同更新状態かどうか (Qiita:Teamでのみ有効)
	Tags      Tags   `json:"tags" yaml:"tags"`             // 投稿に付いたタグ一覧
	Team      *Team  `json:"-"`                            // チーム
}

Meta is meta data of post.

func (*Meta) Decode

func (meta *Meta) Decode(s string) (err error)

Decode unmarshals encoded meta.

func (Meta) Encode

func (meta Meta) Encode() (out string)

Encode marshals meta as YAML.

type Post

type Post struct {
	Meta
	User         User   `json:"user"`
	Title        string `json:"title"`         // 投稿のタイトル
	Body         string `json:"body"`          // Markdown形式の本文
	RenderedBody string `json:"rendered_body"` // HTML形式の本文
	Path         string `json:"-"`
}

Post is a post in Qiita.

func FetchPost

func FetchPost(client api.Client, team *Team, id string) (post Post, err error)

FetchPost fetches a post from Qiita.

func NewPost

func NewPost(title string, createdAt *Time, team *Team) (post Post)

NewPost create a Post.

func NewPostWithFile

func NewPostWithFile(path string) (post Post, err error)

NewPostWithFile loads local file and create a Post from the content of the file.

func NewPostWithOSFile added in v0.1.1

func NewPostWithOSFile(f *os.File) (post Post, err error)

func (*Post) Create

func (post *Post) Create(client api.Client, opts CreationOptions) (err error)

Create creates a new post in Qiita.

func (*Post) Decode

func (post *Post) Decode(b []byte) (err error)

Decode decodes Post from bytes.

func (*Post) Delete

func (post *Post) Delete(client api.Client) (err error)

Delete deletes a post in Qiita.

func (Post) Encode

func (post Post) Encode(w io.Writer) (err error)

Encode encodes Post from bytes.

func (*Post) Save

func (post *Post) Save(cachedPaths map[string]string) (err error)

Save saves a post as a markdown file in local.

func (*Post) Update

func (post *Post) Update(client api.Client) (err error)

Update updates a post in Qiita.

func (Post) Validate

func (post Post) Validate() (err InvalidError)

Validate validates fields in Post.

type Posts

type Posts []Post

Posts is a collection of post.

func FetchPosts

func FetchPosts(client api.Client, team *Team) (posts Posts, err error)

FetchPosts fetches posts from Qiita and Qiita:Team.

func (Posts) Save

func (posts Posts) Save() (err error)

Save saves posts into current working directory as markdown files.

type Tag

type Tag struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions"`
}

Tag is a label for a content of a post.

func (Tag) MarshalJSON

func (tag Tag) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Tag into JSON formatted bytes.

type Tags

type Tags []Tag

Tags is slice of Tag.

func (Tags) MarshalYAML

func (tags Tags) MarshalYAML() (data interface{}, err error)

MarshalYAML encodes Tags to YAML encoded string.

func (*Tags) UnmarshalYAML

func (tags *Tags) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

UnmarshalYAML decodes YAML encoded string to Tag struct.

type Team

type Team struct {
	Active bool   `json:"active"` // チームが利用可能な状態かどうか
	ID     string `json:"id"`     // チームの一意なID
	Name   string `json:"name"`   // チームに設定されている名前を表します。
}

Team is a team data of Qiita:Team.

type Teams

type Teams []Team

Teams is a collection of team.

func FetchTeams

func FetchTeams(client api.Client) (teams Teams, err error)

FetchTeams fetches teams that the authenticated user belongs.

type Time

type Time struct {
	time.Time
}

Time is a wrapper of time.Time.

func (Time) FormatDate

func (t Time) FormatDate() (s string)

FormatDate formats only date as slashed style.

func (Time) MarshalYAML

func (t Time) MarshalYAML() (data interface{}, err error)

MarshalYAML marshals time as YAML.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals time as JSON.

type User

type User struct {
	Description       string `json:"description"`         // 自己紹介文
	FacebookID        string `json:"facebook_id"`         // Facebook ID
	FolloweesCount    int    `json:"followees_count"`     // このユーザがフォローしているユーザの数
	FollowersCount    int    `json:"followers_count"`     // このユーザをフォローしているユーザの数
	GithubLoginName   string `json:"github_login_name"`   // GitHub ID
	ID                string `json:"id"`                  // ユーザID
	ItemsCount        int    `json:"items_count"`         // このユーザが qiita.com 上で公開している投稿の数 (Qiita:Teamでの投稿数は含まれません)
	LinkedinID        string `json:"linkedin_id"`         // LinkedIn ID
	Location          string `json:"location"`            // 居住地
	Name              string `json:"name"`                // 設定している名前
	Organization      string `json:"organization"`        // 所属している組織
	PermanentID       int    `json:"permanent_id"`        // ユーザごとに割り当てられる整数のID
	ProfileImageURL   string `json:"profile_image_url"`   // 設定しているプロフィール画像のURL
	TwitterScreenName string `json:"twitter_screen_name"` // Twitterのスクリーンネーム
	WebsiteURL        string `json:"website_url"`         // 設定しているWebサイトのURL
}

User is data of user in Qiita.

Jump to

Keyboard shortcuts

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