Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Adding 'toread' to _description_ will set toread flag for bookmark.
Browse files Browse the repository at this point in the history
  • Loading branch information
spamwax committed Dec 8, 2017
1 parent 44b2b23 commit d81d31c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api_pinboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func postToCloud(args string, ga *Alfred.GoAlfred) (info []string, err error) {
return pinInfo, errors.New("Set your authorization token first!")
}
var payload pinboardPayload
payload.tags, payload.extended = parseTags(args)
payload.tags, payload.extended, payload.toread = parseTags(args)
payload.url = pinInfo[0]
payload.description = pinInfo[1]
payload.replace = "yes"
Expand Down
2 changes: 2 additions & 0 deletions go-pinboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type pinboardPayload struct {
tags string
replace string
shared string
toread string
auth_token string
}

Expand Down Expand Up @@ -278,6 +279,7 @@ func encodeURL(payload pinboardPayload, pathURL string) (req url.URL) {
q.Set("shared", payload.shared)
q.Set("tags", payload.tags)
q.Set("auth_token", payload.auth_token)
q.Set("toread", payload.toread)
u.RawQuery = q.Encode()
return u
}
Expand Down
12 changes: 10 additions & 2 deletions tags_pinboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,20 @@ func getTagsFor(q string, ga *Alfred.GoAlfred) (m sortedTags, err error) {
return m, nil
}

func parseTags(args string) (tags, desc string) {
func parseTags(args string) (tags, desc string, toread string) {
foo_ := strings.Split(args, commentCharacter)
tags = strings.Trim(foo_[0], " ")
desc = ""
toread = "no"
if len(foo_) > 1 {
desc = strings.Trim(foo_[1], " ")
desc_words := strings.Split(desc, " ")
for _, word := range desc_words {
if word == "toread" {
toread = "yes"
break
}
}
}
return tags, desc
return tags, desc, toread
}

0 comments on commit d81d31c

Please sign in to comment.