Method: HookApp#bookmark_from_app
- Defined in:
- lib/hook/hookapp.rb
#bookmark_from_app(app, opts) ⇒ Object
Get a bookmark from the foreground document of specified app.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/hook/hookapp.rb', line 83 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_APP}" 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 |