lib/hook/hookapp.rb
# Get a bookmark from the foreground document of specified app.
Get a bookmark from the foreground document of specified app.
Get a bookmark from the foreground document of specified app .
def bookmark_from_app(app, opts)
    mark = `osascript <<'APPLESCRIPT'
      tell application "System Events" to set front_app to name of first application process whose frontmost is true
      tell application "#{app}" to activate
      delay 2
      tell application "Hook"
        set _hook to (bookmark from active window)
        set _output to (name of _hook & "||" & address of _hook & "||" & path of _hook)
      end tell
      tell application front_app to activate
      return _output
    APPLESCRIPT`.strip.split_hook
    title = mark[:name].empty? ? "#{app.cap} link" : mark[:name]
    output = opts[:markdown] ? "[#{title}](#{mark[:url]})" : mark[:url]
    if opts[:copy]
      "Copied Markdown link for '#{title}' to clipboard" if output.clip
    else
      output
    end
  end
def bookmark_from_app ( app , opts ) mark = ` osascript <<'APPLESCRIPT'
      tell application "System Events" to set front_app to name of first application process whose frontmost is true
      tell application " #{ app } " to activate
      delay 2
      tell application "Hook"
        set _hook to (bookmark from active window)
        set _output to (name of _hook & "||" & address of _hook & "||" & path of _hook)
      end tell
      tell application front_app to activate
      return _output
    APPLESCRIPT ` . strip . split_hook title = mark [ :name ] . empty? ? "#{app.cap} link" : mark [ :name ] output = opts [ :markdown ] ? "[#{title}](#{mark[:url]})" : mark [ :url ] if opts [ :copy ] "Copied Markdown link for '#{title}' to clipboard" if output . clip else output end end
Get a bookmark from the foreground document of specified app.
Get a bookmark from the foreground document of specified app .
app
<not_specific>
opts
<not_specific>