pinboard

package
v0.0.0-...-ed2b4e0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Template = template.Must(
	template.New("").
		Funcs(template.FuncMap{
			"bold": func(s string) string {
				if !isatty.IsTerminal(os.Stdout.Fd()) {
					return s
				}
				return ansi.Color(s, "red+b")
			},
			"underline": func(s string) string {
				if !isatty.IsTerminal(os.Stdout.Fd()) {
					return s
				}
				return ansi.Color(s, "white+u")
			},
		}).
		Parse(
			`
{{- range . -}}
Title: {{ .Title | bold }}{{ with .Description }}
Description: {{ . }}{{ end }}
Date: {{ .Time.Local.Format "Jan. 2, 2006 3:04pm" }}
Tags: {{range .Tags}}{{ . }} {{end}}
URL: {{ .URL.String | underline }}

{{ end -}}`,
		),
)

Functions

func CLI

func CLI(args []string) error

Types

type Client

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

func NewClient

func NewClient() Client

func (Client) GetPosts

func (cl Client) GetPosts(tags []string) ([]Post, error)

func (Client) GetTags

func (cl Client) GetTags() (map[string]int, error)

func (Client) SearchPosts

func (cl Client) SearchPosts(out io.Writer, tags []string) error

func (Client) SearchTags

func (cl Client) SearchTags(out io.Writer, tags []string) error

func (*Client) SetToken

func (cl *Client) SetToken(token string)

func (*Client) SetUsernamePassword

func (cl *Client) SetUsernamePassword(u, p string)

func (Client) TagsLike

func (cl Client) TagsLike(tags ...string) ([]TagCount, error)

type Post

type Post struct {
	Title, Description, Hash string
	Tags                     []string
	Time                     time.Time
	URL                      *url.URL
	Shared, ToRead           bool
}

type RawAllPostsResponse

type RawAllPostsResponse []struct {
	Description string    `json:"description"`
	Extended    string    `json:"extended"`
	Hash        string    `json:"hash"`
	Href        string    `json:"href"`
	Meta        string    `json:"meta"`
	Shared      string    `json:"shared"`
	Tags        string    `json:"tags"`
	Time        time.Time `json:"time"`
	ToRead      string    `json:"toread"`
}

func (RawAllPostsResponse) ToPosts

func (raw RawAllPostsResponse) ToPosts() []Post

type TagCount

type TagCount struct {
	Tag   string
	Count int
}

func (TagCount) String

func (tc TagCount) String() string

Jump to

Keyboard shortcuts

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