Jump to content

Recommended Posts

Hey everybody, it's your old pal Daniel. I just wanted to share a workflow that I threw together this morning. I've gotten a number of requests for an alp tutorial that walks one through the process of making a workflow with Alfred 2 and alp one step at a time, and I needed a sample to look at as I was working. And lo, "Yourls Stats" was born. It's not especially complex, but it makes use of many of alp's more advanced features—some of which got slightly rewritten as I worked—to do something marginally useful. I thought I'd get it out there in advance of writing the tutorial to see if it had any lingering bugs.


Enter "ystat" (or a keyword of your choice) to trigger the workflow. The first time you invoke it, it'll need to be configured; go to your Yourls admin site's "Tools" page and copy your secret signature token, then enter "ystat url=mysite.ly signature=0123456789" into Alfred. You'll note that the workflow guesses the location of the API PHP as you type, and that the feedback item won't be valid till both values are entered. Once they are, hit Return. Your signature token will be stored securely in the Keychain, your URL in cleartext in the workflow's settings JSON. Alfred will pop back up with your custom keyword already entered and begin downloading your Yourls data. Enter a query to search fuzzily through the links' titles and short keywords, and press Return to copy a link to the clipboard.


You can download the workflow here, and, as always, do let me know if it breaks.





Link to post

Hmm, get now "Network error, no JSON object could be decoded". Also can't reconfigure it.


Another question: I'm sure you know the yourls workflow from Andi. I asked him for implementing a custom short url ending but no answer. Would you like to do it? Example:

  • I open Alfred
  • type yourls
  • enter my preferred short url, e.g. alfred

Result: a short url like abc.de/alfred

Edited by Davide
Link to post

The networking code hasn't changed—I suspect that the workflow legitimately can't reach whatever site you'd previously configured it with. In which case you may have to delete the configuration file by hand: navigate to ~/Library/Application Support/Alfred 2/Workflow Data/ and delete the directory com.danielsh.alfred.yourlsstats, then enter the configuration command.


As for customizing the shortened URLs, unfortunately the Yourls API doesn't provide that functionality yet.

Link to post

I'm glad it's working again! However, in addition to having very little PHP, I'm not especially interested in implementing something that would require users to engage in that level of dicking around with their personal configurations. Working with the standard features is about as far as I'm inclined to go.

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.

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...