Jump to content
vitor

PinAdd — Takes arguments as tags, and adds your browser’s frontmost tab as a pinboard bookmark

Recommended Posts

This workflow is officially deprecated in favour of PinPlus. It was released to the public domain, so I leave the record here if anyone is interested. You can still find the old source on Github.

 

Before using this workflow, you need to configure it with your Pinboard account by running :configurepinadd followed by your api token and your preferred browser.


6Wi0mXb.png


You can get the API token of you Pinboard account by visiting https://pinboard.in/settings/password


Your preferred browser may be one of Safari, Webkit, Chrome, ChromeCanary, Chromium, or depends (“depends” uses the browser you have as the frontmost window, provided it’s one of the mentioned ones).


An example configuration would be: configurepinadd username:HSJWJK2HHSKI14QPDOIK safari
When you’re all set, call pin followed by your tags and/or description — both are optional, and descriptions must be preceded by // (two forward slashes and a space). Pick if it should be added as a regular bookmark or as a private one (this is important, as it’ll trump your default options), and you’re done.


lqt0ZnW.png


The title of the bookmark will be the title of the page.


You can also precede your tags with . (a single period), and it will add the bookmark as unread.


79mgk9O.png


There’s also a hotkey you can setup to quickly add bookmaks as unread (without any tags or description).
If adding a bookmark fails for any reason (for example, if the connection drops), you’ll get a notification and a PinAddRetry.command file will be added to your Desktop (if it happens multiple times, it’ll add an entry for each failed attempt). You can double-click this file at a later time to run it, and retry adding the bookmarks.

Edited by vitor

Share this post


Link to post

I love it. :D

 

Glad to know it’s useful to some one else.

 

 

How does one install a workflow that is simply a .plist file and not a .alfredworkflow file?

 

The link was pointing to the source instead of the binary, I apologize. It’s fixed now, you can try again.

Edited by Vítor

Share this post


Link to post

Great idea!

 

Some suggestion: it would be cool if user could set if bookmark should be shared with Action Modifier.

 

(and it's really easy to add)

Edited by bevesce

Share this post


Link to post

it would be cool if user could set if bookmark should be shared with Action Modifier.

 

Even though I don’t really like the idea of keeping two very similar pieces of code for this, I do think it’s a nice addition that could make this more useful to many people.

 

It’s added (you just need to download the file again, if you had the workflow already installed). Using “opt” (“alt”) as a modifier key adds the bookmark as private. Bear in mind that if you have your Pinboard account set to “save all bookmarks as private”, then this will make no difference to you, as the regular command would already add them as private (it’s just how the API works, the default changes according to your settings).

 

I’ve also removed the “pinset” option. Now, to add/edit the settings you just use the “pin” command but with “shift” as a modifier key. It’s not worth it to have an entirely different option for an action you’ll do once.

Edited by Vítor

Share this post


Link to post

I LOVE YOU VITOR!!  Thank you so much for this!!  I used to use the Social Bookmarks plugin for Quicksilver to do this, but that plugin has been dead for a very long time.  Haha this is AWESOME! 

Edited by AHaghgoo

Share this post


Link to post

Even though I don’t really like the idea of keeping two very similar pieces of code for this, I do think it’s a nice addition that could make this more useful to many people.

 

You can put your code to file that's stored in workflow folder and parameterize it instead of keeping two copies.

Share this post


Link to post

You can put your code to file that's stored in workflow folder and parameterize it instead of keeping two copies.

 

Well, yes, in theory. However, the script doesn’t simply read variables, it also writes them, and those do not survive from one session to the other (one script to the next). Yes, I could also write these variables to a file every time and then read them back, but then instead of having two similar pieces of code, I’d have two slightly smaller pieces that read the variables, a third one that writes them, and another file to keep them. At this point, complexity is being created needlessly. It’s similar code, yes, but it ends up being smaller and more easily maintainable than the alternative. The way the workflows work, it also means that less code needs to run, even, because it’ll either do one or the other without needing to pass through an intermediary.

Edited by Vítor

Share this post


Link to post

Thanks for the great workflow Vítor. I sent you a pull request with Webkit and Chrome Canary support, as I use those as my primary browsers.

 

Thank you for the pull request. Post was edited with the latest changes and credit to you for those additions.

Share this post


Link to post

Another update. I followed a different route from the original thinking and ended up opting for using a script that’s called with different parameters, depending on the bookmark being saved with your default privacy setting, or as private. It will allow for easier editing, which also makes it easier to contribute to.

Edited by Vítor

Share this post


Link to post

Thanks. I had some trouble getting started but it was b/c I didn't realize that username: is part of the pinboard API key.

Share this post


Link to post

Update (hopefully the last one you’ll have to care about, for a while). It should now auto‐update using Alleyoop. It also stores your settings in a non‐volatile directory — this means they won’t sync with the rest of the workflow (if you store it on Dropbox), but you won’t have to reenter your preferences every time you update.

Edited by Vítor

Share this post


Link to post

New update (again, if you use Alleyoop, you can update it from there).

It now supports Opera and Camino. I’d like to add support for Firefox too, but it seems that even though it’s possible to get the window’s title, it’s not possible to get it’s URL. There are some hacky ways that consist of sending keystrokes, but those can be very unreliable, and I think it’s better to scrape a feature than to offer it with a hit‐or‐miss functionality.

Share this post


Link to post

Hi Vitor, this is great, thanks!

 

Two things would make it better:

 

- If text is selected on the page, have it saved as the description

- Description can be set manually from Alfred

 

All the best,

 

Alex

Share this post


Link to post

"Way better to add bookmarks like this than with a bookmarklet"

 

I'm not so sure....I installed this and used it for a couple of days (just dropped into the forum to see the update), but I keep going back to the Delibar bookmarklet (I had shelled out the $9.99 for Delibar years ago and it has been well worth it).  It's not just that old habits die hard - it's just that the bookmarklet has features - already works in any browser, sets selected text as description (or set manually in the Delibar dialog), and tag auto-completion, that are just being added or not available with the Alfred workflow.  

 

Tag auto-completion is the main appeal of Delibar & it seems that there are obstacles to doing this easily in the Alfred interface - 1) you'd need to generate a new list of tags (slow) or cache a full list of the user's tags - which isn't impossible & 2) the only obvious way to do the auto-complete would be a script filter -- then do you chain multiple scripts together? Or present an option in Alfred for every possibility for each tag, repeating for multiple tags?.  I'd love to see it in the workflow, & I like the elegance of Alfred for most tasks, but without tag completion I don't see it replacing Delibar's bookmarklet.

Share this post


Link to post

This is a very long reply to the previous two comments, specially the last one, so keep that in mind.

Thank you for your comments. I’ll actually be releasing an update probably later today (it’s finished, I’ll just add some comments to the code) that changes the way the workflow operates. The thing you’ll notice most is that it’s way faster — as soon as you press return on the workflow, you can close the tab. There are also some interface changes, but I’ll explain everything in a later post.

I very much appreciate your suggestions, but there are reasons as to why I chose to make it work this way. It’ll never be ideal to everyone and tradeoffs have to be made all the time. The fact is Alfred workflows, as great as they are, have several limitations. For example (not applicable to this workflow, but to others I have made), if you want to make a file action that will then receive input, you have to resort to tricks like saving the files’ location, and then calling Alfred via applescript with some text written, that’ll allow you to continue the action. That’s hacky, but it’s also currently the best way to do it right now. Also, if you try to build a workflow, you’ll notice not every module connects to every other, and you can’t chain two of the same “level” together.

Regarding selected text as description, there are some immediate barriers I see. One is that since this is not a native app, I don’t have easy access to those kinds of OS‐features. I could maybe do that with applescript, which is a pain, by telling the browser to activate, and then asking the system to get the selected text. But the way this works, you do not need to have the browser as the frontmost window to add bookmarks, which is useful to the way I work (it’s a niche feature, granted), and by using applescript that could be hindred. Going back to the limitations in Alfred, there are ways it could be done by calling another option, but those are, again, hacky ways that could bring a worse experience to people (like me) who do not use descriptions. However, I’m already thinking of ways to add them at the same time as tags, maybe by enclosing them in certain characters (like {{}}).

Regarding tag auto‐completion, you’re correct, it could be very slow (delibar, if I recall correctly, gets tags from other users as well), but I do think it’s a useful feature, and I’ll look into it. My main issue with it is I’m not sure it can be done right now in Alfred, specially since I’m using bash, and not something that would possibly be more geared towards this, like php.

I also used Delibar (and still have a license for it), but I very much dislike bookmarklets, and extensions I cannot hide and still remain functional. I want my browser to look clean and non‐distracting at all times, and if a piece of software can’t do that, I usually shelve it. What that means is that I had the delibar app setup with the keyboard shortcut, but I needed the app so sparingly that I was constantly finding myself having to wait for it to open just to add a simple bookmark, which soon became boring, which is why I set out to do it another way. I spend so much time in Alfred, that this seemed like the right decision (and I still think it is).

Also bear in mind this workflow is a script that works on top of another app, it’s made and maintained by a single person, who is not a developer full‐time, in his spare time, among other workflows, to scratch a personal itch, whose source is given for free without any kind of strings attached, and is less than one month old. While delibar is, well, I don’t think I need to continue. My point is, when you mention that features are “just being added or not available”, please let it breathe, it barely even had time to exist, let alone improve.

When Martin says “way better to add bookmarks like this than with a bookmarklet, imo”, I take that as “to me, for the way I use and like to add bookmarks to pinboard, this is a better way, as it is more in line with the way I prefer to do it”, and that is what I feel. I use this to add bookmarks, and I see them (also via Alfred) by doing “!pb <something_to_search>“, as I have duckduckgo as my search engine.

Please understand that I’ve built this workflow primarily for myself, for my needs. That is not to say I’m not open to suggestion and contributions, I very much am, and you can even modify this to your liking in any way you want (see the license). However, every bit of polish I’ve added (and in total I’ve spent more time on this than on core functionality), has been for you, the other users. What this entails is that every time I want to make a change, I think both about what works best for me, and what can be added that will not break the experience of the people that already like it the way it works right now.

Pinboard is a very popular service amongst people that have skills to build apps to work with it, so it’s natural there are so many. If you see this as a workflow for people who like Pinboard, then it’s not for you, because this is a workflow for people who like Alfred.

I hope this clarifies why those features have not (yet?) been implemented. Some of them depend on Alfred adding specific features, others depend on my time/mood/interest, and still others depend on its overall goal. Bottom line is this workflow isn’t for everyone, nor does it want to be, it’s supposed to be a lightweight, fast workflow for people that sometimes add bookmarks, and need to do it fast, it’s not a tool for people who add every site they visit, or need every feature under the sun — not only is that not feasible with Alfred without some (possibly major) downsides, like compromising on speed, it’s also not the goal of the project, at least right now.

Edited by Vítor

Share this post


Link to post

Hey Vitor, no stress, it's great already :-)

 

If you can build in descriptions, then I can always copy and paste the text I want into Alfred, so auto setting the description from highlight isn't even necessary.

 

When I add a description, it is normally for two reasons -

 

1) It helps me distinguish between lots of similar links. For example, I was looking for software earlier that allows sharing of a mouse and keyboard between computers, and bookmarked a few, noting in the description the relative advantages of each.

 

2) If I can't really remember a link well and I do a search, tags are great, but the description can be rich in keywords too, without inflating my tag cloud.

 

 

Best,
 
Alex

Share this post


Link to post

Hey Vitor, no stress, it's great already :-)

 

If you can build in descriptions, then I can always copy and paste the text I want into Alfred, so auto setting the description from highlight isn't even necessary.

 

When I add a description, it is normally for two reasons -

 

1) It helps me distinguish between lots of similar links. For example, I was looking for software earlier that allows sharing of a mouse and keyboard between computers, and bookmarked a few, noting in the description the relative advantages of each.

 

2) If I can't really remember a link well and I do a search, tags are great, but the description can be rich in keywords too, without inflating my tag cloud.

 

 

Best,
 
Alex

 

Thank you for your words, and thank you for describing your use cases. It makes sense, and I’ll keep it in mind.

 

As I’ve said, I’m already thinking of ways to do it, so you can mix it with tags, and still be usable. Do you think the proposed solution (something like “pin onetag anothertag {{input a description between these}}) would work acceptably? I’ve finished editing the top post for the new update, I’ll follow this with a post explaining the differences from the old implementation.

Share this post


Link to post

So, this is a huge update to how PinAdd works. If you just want to know how it works now, read the top post, as I’ve updated it. If you want to know a bit more of the differences, read on.

The first thing you’ll notice is speed. Those of you who thought it was already fast, are in for a treat; if you thought it was slow, you’ll like to know it now feels pretty much instantaneous, even on slow connections. For the ones interested in knowing how that was achieved, I’ll explain it at the end.

Another thing you’ll notice is that now it always shows you the options for adding a bookmark, and adding a boomark as private (if you have your Pinboard account set to always add as private, both will work the same). No more pressing “alt” to add as private, and since Alfred learns and prioritizes what you use more, I think it’ll be a more pleasant way to do it, for those of you who add a lot of private bookmarks.

You probably won’t notice, those of you who have it already set up, but pressing “shift” to input your settings is no longer present. I always felt that needed some work, as even I constantly forgot to do it (I reset my settings a lot, for testing purposes). What it does now, is it first checks to see if you have it already setup — if you don’t, it’ll let you do that, if you do, it just switchs to bookmark adding. If, however, you want to delete your settings, run “pin resetpinaddsettings”, and it’ll delete them (it’s intentionally descriptive and verbose, so you won’t do it by mistake).

If you want to know how the speed improvements were acheived, continue reading, otherwise, you may stop now.

To explain how the new way is different, I’ll first have to explain how it worked before. When you typed “pin”, the workflow would just wait for you to finish typing your tags, and after you pressed “return”, it’d run a script that would do something like

1. Read your settings (browser and token)

2. Run the applescript to get your browser’s tab title and url, storing them

3. Set your tags

4. Access the Pinboard API, giving it the relevant information

5. Output a notification

Realistically, you could close your tab before getting the “added” notification (as soon as the second point finished), but there was no clear way to know when that was. If you did it before the second part ran, you’d be getting the wrong tab. However, I usually add a bookmark after I’ve gotten what I wanted from the page, so I’d like to add it, close the page, and be on my way. The way it worked, I had to wait for the notification, just to be sure.

Now, it starts working as soon as you type “pin”, and it works something closer to

1. Check if you’ve already configured it

2. If not, show you the configuration options

3. If yes, it’ll get you browser’s tab title and url, and add them to a temporary file

4. After you’ve finished typing your tags and press “return”, it’ll both output a “done” message, and start running the rest of the script, that

5. Reads your settings (browser and token)

6. Sets your tags

7. Accesses the Pinboard API, giving it the relevant information

So in global terms, it’s not necessarily faster. It may even be slower. But it feels faster, and more importantly, it’ll actually let you go on to other things sooner, because now it’ll get all the information it needs from you beforehand, and it’ll be left to work after that. I believe this is a major improvement — even if you’re on a slow connection, after you see that “done” message you can go about your day, and it’ll just call Pinboard’s API in the background.

Edited by Vítor

Share this post


Link to post

This is amazing!  Works great for me and I was actually quite shocked to see how speedy it is. Thank you.

Edited by drking

Share this post


Link to post

This is amazing!  Works great for me and I was actually quite shocked to see how speedy it is. Thank you.

 

Thank you, that is what I intended, glad to see it’s working fast for you.

Edited by Vítor

Share this post


Link to post

Wow, Vitor, it's crazy quick now!

 

Thank you for your words, and thank you for describing your use cases. It makes sense, and I’ll keep it in mind.

 

As I’ve said, I’m already thinking of ways to do it, so you can mix it with tags, and still be usable. Do you think the proposed solution (something like “pin onetag anothertag {{input a description between these}}) would work acceptably? I’ve finished editing the top post for the new update, I’ll follow this with a post explaining the differences from the old implementation.

 

I think squiggly brackets would work but something quicker to type would be perhaps splitting the description from tags with a forward slash,

 

e.g. pin onetag anothertag / This is my description, and if there is no slash then there is no description.

 

 

Best,
 
Alex

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×