Jump to content
vitor

PinPlus — Interact with your Pinboard bookmarks

Recommended Posts

Add to and view your Pinboard bookmarks.


pa opens Pinboard’s “add bookmark” page in your frontmost browser. You can submit bookmarks with ↵ or dismiss the window with ⎋.


g6wAO6U.png


If you have the PinPlus app installed (get it with :pinplusupdateapp), that opens instead.


0SVjnKs.png


Configure the Hotkey Trigger to add your current browser tab as an unread bookmark.


pin and pun are similar. The former shows all your bookmarks (type to filter), while the latter shows only the unread ones.


hrxtJ54.png


In each case:

  • ↵ opens the bookmark in your default web browser.
  • ⇧↵ opens the bookmark in Pinboard’s website, so you can edit it at will.
  • ⌥↵ copies the bookmark’s URL to your clipboard.
  • ⌘↵ downloads the video on the page, if any. It requires DownVid and will automatically add to WatchList if available)
  • fn shows the bookmark’s description.
  • ⌃ shows the bookmark’s tags.


Unread bookmarks suffer an extra event when acted upon, depending on the unread_action Workflow Environment Variable. archive will mark the bookmark as read and delete will remove it from your account. Any other value (including none) will leave it untouched.


:pinpluslaunchd will install (or later remove, running the same command) a launchd service to seamlessly fetch bookmarks every hour.


onOFCVY.png


Bookmarks are auto-updated in accordance to the requirements of the Pinboard API. :pinplusforceupdate will force an update, but should be avoided.


Lr0iNij.png


If you ever need to update your Pinboard API token, call :pinplusresetapitoken.


XOHDq0q.png

 

Download | Source

Edited by vitor

Share this post


Link to post

Update: the Workflow no longer uses this solution. But I’d like to go back to it if anyone would like to help with the native GUI.

 

You might notice that PinPlus, the specialised GUI, is quite massive (over 100MBs). You may also guess why that’s the case: it’s built with Electron.


In case you’re wondering (and I predict you might be) why I’ve built such monstrosity, it’s because all other Pinboard workflows I’ve used suck (yes, including mine). Adding bookmarks is a convoluted and imprecise process in all of them, to the extent I realised an external GUI is the only sensible approach. But building a good one (all options, tag auto-suggestion, and other goodies) is a ton of work.


So I realised Pinboard’s add page does it all and you can even give it parameters in the URL that will auto-fill the fields! But the interface is ugly, so I inject some CSS to make it a bit better. And then I want other niceties as an app: no titlebar, but still draggable; no dock icon; quit with ⎋). All of those are damn simple and well documented with Electron. With Xcode/Cocoa/Swift, I had a hard time finding answers to them.


Friction matters. As a result of this being so simple with Electron, I now have a working workflow that I use constantly and is sufficiently polished for sharing. I may not be the biggest fan of the JavaScript ecosystem (and the language), but it’s hard to argue with results.


If you want to help rebuild the GUI in Cocoa (it needs to have the same capabilities), I’m open to the idea. I’d prefer it to be native.


Alternatively, if you want to use the Workflow but not get the GUI, simply don’t run the pa command to add bookmarks. Everything else will still work. If you see a GUI to setup your Pinboard API token, worry not — that one is native.


As you might guess, this deprecates both PinAdd and PinUnread. Some of you may have noticed they have already been removed from the GitHub repo a while ago.

Edited by vitor

Share this post


Link to post
1 hour ago, deanishe said:

Is something like MacGap or pywebview not up to the job?

 

If I tried those, I don’t remember. I tried a few different solutions, and none were up to it (missing features). I don’t remember exactly which, since this Workflow has existed for quite some time in an unfinished form. For context, the icon for this Workflow was the first one I made in the new style. Looking at RemoveQuarantine, this has existed in a limited form for between six and twelve months. Most of its existence has been with just the GUI and adding as unread (I used PinUnread to fill the gap I needed).


Quite frankly, I considered not releasing the Workflow at all. On the other hand, in its current state getting the GUI is seamless, and most important, optional. One can still take advantage of all the features and use PinAdd to add bookmarks if they so wish.


Electron has awful tradeoffs, I agree, but realistically my choices were: have it with everything I need, done fast (due to great documentation), and updated (Electron); having it crippled, subpar documentation, abandoned or slow on fixes (other frameworks); not have it at all because I can’t even find the documentation for the features I wanted (Cocoa). I picked “having it with everything”. For people who disagree, I left the option to not have it at all (since the GUI is only downloaded in the single case of adding a bookmark, which is but a tiny part of the Workflow).

 

This is one of those rare Workflows where the primary user is myself, and it’s one of my most used ones (together with DownVid and WatchList). I hope to one day have the GUI be native. Following this post is likely the best way to know if that ever happens.

Share this post


Link to post

Thanks for the interesting explanation.

 

On 28/07/2017 at 10:02 PM, vitor said:

Following this post is likely the best way to know if that ever happens.

 

TBH, I just use a script that runs the Pinboard bookmarklet in the same tab. Have it mapped to ⌘⇧P in Safari and Chrome.

 

I have my own (unreleased) workflow for browsing my bookmarks (because who doesn't?), but yeah, like you say, Alfred isn't really suitable for making a great "add" UI. I might have a crack at it one day, though. I've already written a decent "tagging" UI in MailTo, which is the critical bit, imo.

 

The big problem with a native GUI (apart from figuring out how Cocoa works) is that it'd presumably have to have some level of integration with Pinboard in order to suggest tags, rather than just be a big, dumb form.

 

The huge advantage of a native Cocoa version vs Electron/QT/etc. is that it would start instantly.

 

Edited by deanishe
Grammar is hard

Share this post


Link to post
On 28/07/2017 at 11:06 PM, deanishe said:

TBH, I just use a script that runs the Pinboard bookmarklet in the same tab.

 

Dammit, that’s a good idea. And with AlfredBookmarklet I’ve already done all the work to running Javascript in Chrome and Safari. I may just change the solution to that.

 

On 28/07/2017 at 11:06 PM, deanishe said:

but yeah, like you say, Alfred isn't really suitable for making a great "add" UI

 

A big issue is that we have several things we might want to change from the default when adding a bookmark: title, URL (to remove utm parameters, for example), tags, description (I sometimes add it, sometimes I don’t). And when using Alfred we need to optimise for some of those in detriment of the others. Trouble is no two additions are the same. Most of the time I care more about tags, but when I care about the description or title, I really care for it.

 

On 28/07/2017 at 11:06 PM, deanishe said:

The big problem with a native GUI (apart from figuring out how Cocoa works) is that it'd presumably have to have some level of integration with Pinboard in order to suggest tags, rather than just be a big, dumb form.

 

That’s part of the reason I like loading the add page directly (which can also be done in Cocoa, naturally). We get all the suggestion goodness for free. But Pinboard’s API does also have an endpoint for suggested tags (https://api.pinboard.in/v1/posts/suggest).

Edited by deanishe
Hidin' my typos in Vítor's post…

Share this post


Link to post

Updates:

  • pa now calls bookmarklet instead of PinPlus GUI. That means no more huge download, and no reason for anyone to not use pa. Pinboard’s GUI is awful, though, so I’m still up for the native GUI solution if anyone wants to help.
  • Don’t run the unread action when opening bookmark on site.


To update, download the latest version (same URL) or wait a few days (15 or less) and it’ll prompt you to on next usage, since it uses OneUpdater.

Share this post


Link to post
1 hour ago, deanishe said:

Can't you release the theme you made for the PinPlus GUI as a userscript?

 

Not an option I like. I wouldn’t use it myself. In Chrome we used to be able to just drag a user style into the Extensions page and it would work, but now you can’t (you have to convert it to an extension).

 

Just like I use JXA to open the new window, I could use it to introduce the styling. But I don’t really like that as well since there needs to be a delay between running the bookmarklet and running the styling code (to account for Chrome opening the new window that we have to detect). That will cause a flash of unstyled content. In principle, such a flash isn’t that bad and actually good for usability. In practice, in this case you’d see it every time, and that’ll get annoying really fast.

Share this post


Link to post
20 minutes ago, vitor said:

used to be able to just drag a user style into the Extensions page and it would work

 

Have you tried Tampermonkey or does that not work any more?

Share this post


Link to post
16 minutes ago, deanishe said:

Have you tried Tampermonkey or does that not work any more?

 

Probably does, but I don’t want to install an extension to use userscripts. I like to have as few as possible installed, and I don’t have enough userscripts that I want to use to justify that.

Share this post


Link to post

This seems very useful, but I can't get it to work. I am able to use the PinPlus.app GUI to add a bookmark to my Pinboard account. But when using the 'pa', 'pin, 'pun' and ':pinplusforceupdate' keywords in Alfred nothing happens. I was prompted once for the Pinboard token and haven't been prompted again. I'm on macOS 10.12.6, Alfred 3.4.1 and use version 1.1.1 of the PinPlus workflow. Below I paste the debugging info after running "pin". Any ideas?

 

 

[2017-08-09 13:54:25][ERROR: input.scriptfilter] Code 1: /Users/MyUserName/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.4064276A-EABF-45AA-8CC9-180353BE7304/pinplus.rb:94:in `read': No such file or directory - /Users/MyUserName/Library/Application Support/Alfred 3/Workflow Data/com.vitorgalvao.alfred.pinplus/last_access_file.txt (Errno::ENOENT)
    from /Users/MyUserName/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.4064276A-EABF-45AA-8CC9-180353BE7304/pinplus.rb:94:in `unsynced_with_website?'
    from /Users/MyUserName/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.4064276A-EABF-45AA-8CC9-180353BE7304/pinplus.rb:145:in `fetch_bookmarks'
    from /Users/MyUserName/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.4064276A-EABF-45AA-8CC9-180353BE7304/pinplus.rb:137:in `show_bookmarks'
    from /Users/MyUserName/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/FD178B43-92E4-4B99-A710-7A20C7CDDAE7:3:in `<main>' 

Edited by cands

Share this post


Link to post

@sepulchra Please don’t say “I can’t get it to work”, as that doesn’t help in finding the problem and solution. How is it not working? Does nothing happen? Does an error show? Which one? And how can’t you get it to work? What exactly were your steps? What does the debugger show?

Edited by vitor

Share this post


Link to post

@vitor this is what i get when I run the debugger:

 

[2017-09-09 11:30:53][input.keyword] Processing output of 'action.script' with arg ''
[2017-09-09 11:30:53][action.script] Processing output of 'action.script' with arg ''

 

When i use the pa command and hit enter. A browser window never pops up to input links or tabs.  

Share this post


Link to post

Have you enabled the “Allow JavaScript from Apple Events” option in Safari's “Develop” menu?

 

Which version of Safari? And which version of macOS?

Share this post


Link to post

Update.


Takes advantage of the upcoming match feature in Script Filters for more powerful filtering. You’ll need to be using a pre-release version of Alfred to take advantage of the feature now. Keep in mind it’s subject to change.


To update, download the latest version (same URL) or wait a few days (15 or less) and it’ll prompt you to on next usage, since it uses OneUpdater.
 

Edited by vitor

Share this post


Link to post

Hi,

 

Great work on this :)

 

I wanted to give you a little bit of feedback. I have created a trigger for searching and I noticed that it seems to start by downloading the favourites. It says something like "Fetching bookmarks". It just takes a few milliseconds, but stops me from being immediately able to write my search. Because if I write while it is fetching the bookmarks the characters will not register. So if I click on shortcut and start writing "devianart" it will miss the first character.

 

I wonder if the result could simply be cached. And perform the update maybe every 1 hour. Or maybe make the update only after I actually select a result.

 

I see here (https://github.com/vitorgalvao/alfred-workflows/blob/master/PinPlus/source/pinplus.rb#L142)  that the first thing it does it fetching the results. Isn't it possible to store this in memory so that there is no delay?

 

Secondly, is there a way to have fuzzy search for the url?    If I search for "art" then I would expect "https://www.deviantart.com" to show.

 

Thanks!

Share this post


Link to post
55 minutes ago, Nerian said:

Because if I write while it is fetching the bookmarks the characters will not register. So if I click on shortcut and start writing "devianart" it will miss the first character.

 

What do you mean "trigger"? How are you executing the workflow? It sounds very much like you're trying to enter your query before Alfred is ready to accept it. If the first character is missing in Alfred's search box, that's between you and Alfred: no workflow has any influence over that.

 

If you look more closely at the code, you'll see that the workflow does cache your bookmarks for 10 minutes. After that, it queries the Pinboard API to ask if your bookmarks have been updated since it last cached them. Only if they have will it download your bookmarks again. The "Fetching bookmarks…" text is the placeholder Alfred shows until the workflow returns results.

 

58 minutes ago, Nerian said:

Isn't it possible to store this in memory so that there is no delay?

 

No: Workflows don't work that way. The workflow script is run anew each time you use the workflow. Basically, this workflow is as fast as a workflow written in a scripting language can be.

 

1 hour ago, Nerian said:

Secondly, is there a way to have fuzzy search for the url?

 

Short answer: No. Your best bet here is to ensure that your deviantart.com bookmark has the individual word "art" in its title or to tag it with "art" and do the same, mutatis mutandis, for your other bookmarks.

 

Long answer: The workflow makes a fundamental trade-off between lightning fast search (using Alfred's search) and the odd delay while it updates, plus the limited flexibility of Alfred's search (i.e. not fuzzy). The delays could be removed and fuzzy search implemented, but at the cost of a ~25x reduction in search speed.

 

Personally, I'd increase the between-checks time to an hour or more to reduce the frequency of API calls, but that's about the only dial there is to twist.

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...