Code Monkey home page Code Monkey logo

dayonealfred's Introduction

Day One Alfred Tools

Here is my post about this workflow of the Alfred forum. You can request features there. If you have any questions or comments, I'd love to hear them there or by email at [email protected].

What it needs

At this point, this Alfred Workflow requires:

  • The Day One CLI
  • That you're using Safari or Chrome (FF looks like a no-go at the present moment)

(It used to require a Ruby script by Bret Terpstra but I decided the ease of installation beat out his date logic. I assume most people weren't using it.)

When you first import it, change, if you'd like, the variables in the lw script

  • browser: Which browser you want to use. "Safari" or "Chrome". Safari is default.
  • 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>.

The applescript files are just for you to look at and for me to keep track of changes. You only need to download the extension itself to get things working.

What it does

  • log logs to Day One. log example
  • lw and lw!-- "log web" -- log the frontmost website and title as a link. lw! creates a starred entry. lw example
  • lw comment and lw! comment do the same, but with a comment. lw with comment exmaple
  • lwq and lwq! create an entry with a link and the text on the clipboard as a quote. lwq example

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, or
  • You didn't get a notification.

What it doesn't do yet

Features
  • Add a lwq comment function.
  • Combine the log and lw scripts.
Bugs
  • Tick marks don't work.
  • When the script can't get to Safari, it fails silently.

What's changed

2014-05-11b:
  • Added support for Chrome and returned the default formatting options to normal.
2014-05-11:
  • Switched over to just use the Day One CLI. I imagine this will be about three times easier to get set up and doesn't lose much functionality.
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.

dayonealfred's People

Contributors

johnvining avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ak1nor1 skeca

dayonealfred's Issues

Can this be made to work with Firefox?

I am no AppleScript guru, having come from UNIX, Linux, and SunOS, and doing BASH scripting, so I don't know anything.

I love your Alfred workflow, but tend to work in Firefox, due to my university having their websites and online classrooms written to work with that (Safari doesn't work well there). Can you suggest how I could adjust the script to make it work with Firefox?

No error but it isn't logging

I'm trying to get this setup right now and I'm running into a bit of trouble. I've configured both scrips to point to the correct location of logtodayone.rb and when I try to log with either keyword I get a notification with the correct title, no error but also no text and nothing is added to Day One.

logged to day one

If you have any ideas on what might be going on I'd really appreciate it, this looks like a fantastic Alfred workflow!

System

  • OS X 10.9.1
  • Alfred 2.1.1 (227)
  • Day One v1.9.1 (39)

I've installed the Day One CLI and have used it successfully to create an entry in Day One.
I've saved Brett's script and to test it I created the BASH profile alias he specified and successfully used it to create an entry from the Terminal.

Scripts

Note that I've tried both /Users/cwhite/... and ~/...

lw

on alfred_script(q)
    -- Set the location of the Script
    set scriptLocation to/Users/cwhite/Dropbox/Scripts/Day-One/logtodayone.rb"
    -- Set what comes before the link in your entry
    set prefix to "Reading: "
    -- Set what comes after the link in your entry, use `\n\n` to put comments on new line
    set separator to " - "
    -- Set what separates the link and the clipboard text
    set quoteSeparator to ":\n\n>"

    set theCommand to ""    
    set feedback to "NO SCRIPT RAN!"

    tell application "Safari"
        set theTitle to name of front document
        set theURL to URL of front document
    end tell

    if q is equal to ""
        -- Without Comment or Star
        set urlStr to prefix & "[" & theTitle & "](" & theURL & ")"
        set theCommand to scriptLocation & " \"" & urlStr & "\""
        set feedback to theTitle
    else if character 1 of q is equal to "!"
        -- Starred Entries
        if q is equal to "!"
            -- Without Comment
            set urlStr to "!" & prefix & "[" & theTitle & "](" & theURL & ")"
            set theCommand to scriptLocation & " \"" & urlStr & "\""
            set feedback to "" & theTitle
        else
            -- With Comment
            set urlStr to "!" & prefix & "[" & theTitle & "](" & theURL & ")" & separator
            set croppedQ to text 3 through -1 of q
            set theCommand to scriptLocation & " \"" & urlStr & croppedQ & "\""
            set feedback to "" & theTitle & separator & croppedQ
        end if
    else if character 1 of q is equal to "q"
        -- Quote Entries
        set clippy to the clipboard
        if q is equal to "q"
            -- Without Star
            set urlStr to prefix & "[" & theTitle & "](" & theURL & ")"
            set theCommand to scriptLocation & " \"" & urlStr & quoteSeparator & clippy & "\""
            set feedback to theTitle & "\n>" & clippy
        else if q is equal to "q!"
            -- With Star
            set urlStr to "!" & prefix & "[" & theTitle & "](" & theURL & ")"
            set theCommand to scriptLocation & " \"" & urlStr & quoteSeparator & clippy & "\""
            set feedback to "" & theTitle & "\n>" & clippy
        end if
    else
        -- Unstarred, with Comment
        set urlStr to prefix & "[" & theTitle & "](" & theURL & ")" & separator
        set theCommand to scriptLocation & " \"" & urlStr & q & "\""
        set feedback to theTitle & separator & q    
    end if

    try
        do shell script theCommand
    on error errMsg
        set feedback to "ERROR! " & errMsg
    end try
    return feedback
end alfred_script

log

on alfred_script(q)
    try 
        do shell script “~/Dropbox/Scripts/Day-One/logtodayone.rb \"" & q & "\""
        set feedback to q
    on error errorMsg
        set feedback to "Error! " & errorMsg

    end try
    return feedback
end alfred_script

logtodayone.rb

#!/usr/bin/ruby

# logtodayone.rb
# Brett Terpstra (http://brettterpstra.com)
# Use and modify freely, attribution appreciated
# 
# This script works with the Day One[1] command line utility
# It parses an input string for an exclamation point prefix to mark starred
# and/or a [date string] at the beginning to parse natural language dates
# 
# Requirements:
# Chronic ruby gem
#
# Example usage:
# logtodayone.rb "! This is a starred entry."
# logtodayone.rb "[yesterday 3pm] Something I did yesterday at 3:00PM"
# logtodayone.rb "! [-2 1:30am] A starred entry about something I did two days ago"

require 'rubygems'
require 'chronic' # (`gem install chronic`)

if ARGV.length > 0
  input = ARGV.join(" ").strip
else
  print "Log entry: "
  input = gets.strip
end

# If the input starts with an exclamation point, make it starred
starred = input =~ /^!/ ? "true" : "false"
# remove the bang from the input string
input = input.gsub(/^!\s*/,'')

# if there's a [date] specified, parse it
if input =~ /^\[(.*?)\]/
  datestring = $1
  # if the date starts with -X, assume it means X days ago
  if datestring =~ /^\-(\d+)/
    datestring.sub!(/\-(\d+)/,"\\1 days ago ")
  end
  # Replace a single 'y' within the date brackets with "Yesterday" for parsing
  datestring.sub!(/\by\b/,'yesterday')
  # Parse the resulting date string with Chronic
  d = Chronic.parse(datestring, {:context => :past, :ambiguous_time_range => 8})
  d = DateTime.now if d.nil?
else
  # if no [date] specified, make it right now
  d = DateTime.now
end
date = d.strftime("%m/%d/%Y %l:%M%p") # dayone formatted
input = input.gsub(/^\[.*?\]\s*/,'') # remove [date] from input

%x{echo "#{input}"|/usr/local/bin/dayone -d="#{date}" -s=#{starred} new}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.