Jump to content

Day One Tools: Logging, and Logging from Safari


Recommended Posts

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 script
    • prefix: 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 does
  • log logs to Day One. This can use the time and starring syntax outlined here
    log-hungry.png
  • lw and lw!– “log web” – log the frontmost website and title as a link. lw!creates a starred entry. 
    lw-pulled-pork.png
  • lw comment and lw! comment do the same, but with a comment. 
    lwc-coleslaw.png
  • lwq and lwq! create an entry with a link and the text on the clipboard as a quote.
    lwq-brisket.png

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.
Bugs
  • Tick 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 by senecando
Link to comment

I've updated the commands a bit to make more sense and to allow for starring entries:

 

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 by senecando
Link to comment

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
  • 3 weeks later...

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:

 

vuEOYGQ.png

 

-- JV

Edited by senecando
Link to comment

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
  • 2 weeks later...

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

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

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
  • 2 weeks later...

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

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
  • 2 months later...

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
  • 3 months later...
  • 6 months later...

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
  • 1 year later...
 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

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
×
×
  • Create New...