senecando Posted March 24, 2013 Share Posted March 24, 2013 (edited) Day One Alfred Tools This started out as something for myself, but it looks like there is some interest (and it was just mentioned on MPU), so I thought I'd clean up this page a bit. Please let me know how things are working and if there are any features you'd like to see. Thanks! It can be downloaded on Git Hub by clicking on the workflow and selecting "view raw": https://github.com/senecando/Day-One-Alfred-Tools The README is below, but I find it's a bit easier to read at the Git Hub link above. What it needs At this point, this Alfred Workflow requires: The Day One CLI Brett Terpstra’s logtodayone.rb script, found here That you’re using Safari When you first import it, you will want to: Change the location of logtodayone.rb in the log script Change the location of logtodayone.rb in the lw script Change, if you’d like, the variables for formatting in the lw scriptprefix: What comes before a link. Default is Reading: separator: What separates a link and a comment. Default is -. Change to \n\n if you would like the comment to be on a separate line. quoteSeparator: What separates a link and a quote. Default is :\n\n>. What it doeslog logs to Day One. This can use the time and starring syntax outlined here. lw and lw!– “log web” – log the frontmost website and title as a link. lw!creates a starred entry. lw comment and lw! comment do the same, but with a comment. lwq and lwq! create an entry with a link and the text on the clipboard as a quote. Errors: Everything worked out unless You got a notification with just a title and no text. You got a notification with a title and an error. You didn’t get a notification. What it doesn’t do yet Features Add a lwq comment function. Create an easier way to change the location of logtodayone.rb in each of the scripts, preferably through Alfred itself. Combine the log and lw scripts. Add support for Chrome and Firefox. Incorporate Terpstra’s time functions in the web-logging commands. BugsTick marks don’t work. When the script can’t get to Safari, it fails silently. What’s changed 2013–04–15b: Added a notification letting using know that the script ran successfully. Requested here.2013–04–15a:Added lwq and lwq!, which add a link and any text in your clipboard as a quote. Added an easier way to change the text separating the link and comment. Requested here. Added images to the readme. Edited April 15, 2013 by senecando twinpeaks and arsenty 2 Link to comment
twinpeaks Posted March 24, 2013 Share Posted March 24, 2013 Nice! Thanks for sharing this. I like it a lot. Link to comment
senecando Posted March 25, 2013 Author Share Posted March 25, 2013 (edited) I've updated the commands a bit to make more sense and to allow for starring entries: log logs to Day One. This can use the time and starring syntax outlined here. lw, "log web", logs the frontmost website and title as a link: Reading: Pulled pork - Wikipedia, the free encyclopedia lw delicious! does the same, but with a comment: Reading: Meatloaf - Wikipedia, the free encyclopedia - delicious! lw! does the same as above as a starred entry. It's updated at Git Hub and can be found here: https://github.com/senecando/Day-One-Alfred-Tools Let me know if anyone has any ideas or questions! Edited March 25, 2013 by senecando twinpeaks 1 Link to comment
twinpeaks Posted March 25, 2013 Share Posted March 25, 2013 This workflow is very cool! Thanks for the new update. I have a feature request though that should be pretty easy to add. Can we get notifications? Either by growlnotify or via notification workflow object, just someway to know for sure that the info was written to the day one database. A simple success {query}/failed {query} would be awesome but I'd settle for simple success/failure notification even without {query} - That might actually be cleaner especially with the long web addresses that can be logged. I find myself checking day one to verify the log was actually written... Thanks again! Link to comment
senecando Posted March 26, 2013 Author Share Posted March 26, 2013 I'll add that to a list of things to look into. It seems difficult so far, since I'd have to see first if the Day One CLI gives anything back to the script.rb that is running it, and how I could grab that myself. I'm not sure. Any one have any ideas? Link to comment
twinpeaks Posted March 27, 2013 Share Posted March 27, 2013 I think you could look at the db, maybe if it changed size? Will think about it and send you some feedback about this when I have some more time. Thanks for considering it. Link to comment
nickwild Posted March 27, 2013 Share Posted March 27, 2013 Hi, Can I put a line break in so that the log entry has a title and then body text? Thanks Nick twinpeaks 1 Link to comment
senecando Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) Hola Mr. Nickwild. I think, at some point, I'll make it easier to change this. But for the time being, you can replace the hypens you see in the applescript with \n\n and that will separate your comment and the link with a new line. Is that what you mean? Here is what my script looks like afterwards: on alfred_script(q) -- Set the location of the Script set scriptLocation to "/Users/johnvining/Dropbox/scripts/logtodayone.rb" -- Set what comes before the link in your entry set prefix to "Reading: " tell application "Safari" set theTitle to name of front document set theURL to URL of front document end tell if q is equal to "" set urlStr to prefix & "[" & theTitle & "](" & theURL & ")" do shell script scriptLocation & " \"" & urlStr & "\"" else if character 1 of q is equal to "!" # Starred Entries if q is equal to "!" set urlStr to "!" & prefix & "[" & theTitle & "](" & theURL & ")" do shell script scriptLocation & " \"" & urlStr & "\"" else set urlStr to "!" & prefix & "[" & theTitle & "](" & theURL & ") \n\n " set croppedQ to text 2 through -1 of q do shell script scriptLocation & " \"" & urlStr & croppedQ & "\"" end if else set urlStr to prefix & "[" & theTitle & "](" & theURL & ") \n\n " do shell script scriptLocation & " \"" & urlStr & q & "\"" end if end alfred_script In the next version I'll include an easier way to change the text between the link and your comment. This is what I get: -- JV Edited April 15, 2013 by senecando Link to comment
senecando Posted April 15, 2013 Author Share Posted April 15, 2013 Another update: 2013-04-15:Added lwq and lwq!, which add a link and any text in your clipboard as a quote. Added an easier way to change the text separating the link and comment. Added images to the readme. Link to comment
senecando Posted April 15, 2013 Author Share Posted April 15, 2013 2013-04-15b: Added a notification letting using know that the script ran successfully. Requested here. Twinpeaks, does this work for you? JV Link to comment
twinpeaks Posted April 16, 2013 Share Posted April 16, 2013 2013-04-15b: Added a notification letting using know that the script ran successfully. Requested here. Twinpeaks, does this work for you? JV I gave it a quick test and it is working for me. I got the reminder and when I checked day one it was there. Thanks for putting that feature in, makes me much more at ease about not having to check to make sure whatever I wanted to keep was actually written to the day one. I didn't see, but didn't look too hard for the new features you mentioned above. In a bit of a rush so kind of skimmed through everything but all works well with notifications and grabbing websites in safari. THANK YOU! Much appreciated. Link to comment
daninbrighton Posted April 25, 2013 Share Posted April 25, 2013 Does anyone have - or can anyone help - with a simpler version? I simply want a workflow to take a string of text and create a dayone entry leaving day one to default the date and time to current date and time. It seems like I should be able to do something with a terminal based workflow using the Day One CLI - but after a few hours of trying, I think that it's beyond me! Link to comment
senecando Posted April 25, 2013 Author Share Posted April 25, 2013 If you have this extension and the necessary scripts installed, using "log" and then your text will do just that. Alternatively, if you do not want to download Brett's script, and want to just use the CLI, create a workflow: Keyword → Terminal Action ("echo "{query}" | dayone new") → Notification The main problem with this is that it throws up a terminal window, which isn't ideal. Link to comment
daninbrighton Posted April 26, 2013 Share Posted April 26, 2013 Thanks for that... I have tried to set things up to get your workflow up and running but get a: logtodayone.rb permission denied message error message when running. I guess that there's more to setting up the logtodayone.rb file that I thought; any ideas? (I simply created a file with that name and the script contents and put it in a scripts directoy in my user folder.) Link to comment
daninbrighton Posted April 26, 2013 Share Posted April 26, 2013 Ignore that last entry.. I've figured it out by making the script executable with chmod. The workflow now seems to work: and the notification centre message is positive, but an entry isn't showing up in Day One. Could it be because I use a dropbox folder for the Day One database? Link to comment
senecando Posted May 5, 2013 Author Share Posted May 5, 2013 Ignore that last entry.. I've figured it out by making the script executable with chmod. The workflow now seems to work: and the notification centre message is positive, but an entry isn't showing up in Day One. Could it be because I use a dropbox folder for the Day One database? I use dropbox as well and it is working for me. Have you installed the Day One CLI tools from their website? Link to comment
daninbrighton Posted May 6, 2013 Share Posted May 6, 2013 I use dropbox as well and it is working for me. Have you installed the Day One CLI tools from their website? I have installed the Day One CLI... although now that I've looked into it some more I don't seem to have permission to run that from the terminal and that is probably my problem. I suspect it might be something to do with the fact that my main account is not an admin account (I have an admin accout which I don't actively use - but just use the credentials of when needed). Link to comment
OCnice Posted July 23, 2013 Share Posted July 23, 2013 Any way to hack this to work with Chrome instead of Safari? Link to comment
senecando Posted July 25, 2013 Author Share Posted July 25, 2013 Any way to hack this to work with Chrome instead of Safari? Not off the top of my head. I don't know enough about Chrome's applescript support. It should be doable. You'll just have to rework this block in the applescript attached to the lw command: tell application "Safari" set theTitle to name of front document set theURL to URL of front document end tell Let me know if you get something to work. Link to comment
jarhead Posted July 26, 2013 Share Posted July 26, 2013 This should work for Chrome... tell application "Google Chrome" set theTitle to title of active tab of first window set theURL to URL of active tab of window 1 end tell Link to comment
johsny Posted July 29, 2013 Share Posted July 29, 2013 This is perfect, thanks to senecando, and to jarhead for making it work in Chrome. Link to comment
tomfalk Posted November 1, 2013 Share Posted November 1, 2013 Is there any way to get a code block through the workflow? Link to comment
senecando Posted May 12, 2014 Author Share Posted May 12, 2014 Hey all! It's been a while, but I've just made two smallish updates: * You can now choose either Safari or Chrome and it'll sort it out for you. Set browser to "Chrome" at the top * The extension no longer requires Brett's Ruby script. This may be a step backwards for functionality (not for how I imagine most people to use it), but it'll make it much easier to set up. If this causes any one any trouble, let me know and I'll try to sort it out! Thanks folks! Link to comment
senecando Posted May 12, 2014 Author Share Posted May 12, 2014 Is there any way to get a code block through the workflow? Can you give me an example of something that isn't working? I imagine it has to do with quotes or other symbols that screw with the CLI. Link to comment
Moses Posted October 16, 2015 Share Posted October 16, 2015 Senecando, Thank you for this work flow, it works seemlessly. I commented out Firefox and Safari, the script was opening them when they were not open and I was just working in Chrome. I found your workflow after hours of fiddling to get Brett T's Ruby script to work with Alfred, I learnt some but not enough, I tried to use your applescript in this configaration: on alfred_script(q) try do shell script "/Library/Scripts/OtherScripts/LogToDayOne.rb \"" & message & "\"" set feedback to q on error errorMsg set feedback to "Error! " & errorMsg end try return feedback end alfred_script The debug read is: [iNFO: alfred.workflow.input.keyword] Processing output 'alfred.workflow.action.applescript' with arg 'Help' [iNFO: alfred.workflow.action.applescript] Processing output 'alfred.workflow.output.notification' with arg 'Error! The variable message is not defined.' If anyone has suggestions, please post, my searches are not as yet delivering, I have tweaked Senecando's applescript with no luck, Thanks p.s. Brett T's Ruby script is running just fine in Terminal. p.p.s. With Senecando's workflow, one does not need to use the Ruby script, but I just want to figure out how to navigate the whole caboodle, Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now