-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb6fd84
commit ba366b4
Showing
8 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
workflow/.bundle | ||
workflow/bundle | ||
.ruby-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8 | ||
|
||
require 'yaml' | ||
require 'plist' | ||
|
||
config_file = 'config.yml' | ||
|
||
|
||
workflow_home=File.expand_path("~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows") | ||
|
||
$config = YAML.load_file(config_file) | ||
$config["bundleid"] = "#{$config["domain"]}.#{$config["id"]}" | ||
$config["plist"] = File.join($config["path"], "info.plist") | ||
$config["workflow_dbx"] = File.join(File.expand_path($config["dropbox"]), "/Alfred.alfredpreferences/workflows") | ||
|
||
# import sub-rakefiles | ||
FileList['*/Rakefile'].each { |file| | ||
import file | ||
} | ||
|
||
task :config do | ||
|
||
info = Plist::parse_xml($config["plist"]) | ||
unless info['bundleid'].eql?($config["bundleid"]) | ||
info['bundleid'] = $config["bundleid"] | ||
File.open($config["plist"], "wb") { |file| file.write(info.to_plist) } | ||
end | ||
end | ||
|
||
task :chdir => [:config] do | ||
chdir $config['path'] | ||
end | ||
|
||
desc "Install Gems" | ||
task "bundle:install" => [:chdir] do | ||
sh %Q{bundle install --standalone --clean} do |ok, res| | ||
if ! ok | ||
puts "fail to install gems (status = #{res.exitstatus})" | ||
end | ||
end | ||
end | ||
|
||
desc "Update Gems" | ||
task "bundle:update" => [:chdir] do | ||
sh %Q{bundle update && bundle install --standalone --clean} do |ok, res| | ||
if ! ok | ||
puts "fail to update gems (status = #{res.exitstatus})" | ||
end | ||
end | ||
end | ||
|
||
desc "Install to Alfred" | ||
task :install => [:config] do | ||
ln_sf File.expand_path($config["path"]), File.join(workflow_home, $config["bundleid"]) | ||
end | ||
|
||
desc "Unlink from Alfred" | ||
task :uninstall => [:config] do | ||
rm File.join(workflow_home, $config["bundleid"]) | ||
end | ||
|
||
desc "Install to Dropbox" | ||
task :dbxinstall => [:config] do | ||
ln_sf File.expand_path($config["path"]), File.join($config["workflow_dbx"], $config["bundleid"]) | ||
end | ||
|
||
desc "Unlink from Dropbox" | ||
task :dbxuninstall => [:config] do | ||
rm File.join($config["workflow_dbx"], $config["bundleid"]) | ||
end | ||
|
||
desc "Clean up all the extras" | ||
task :clean => [:config] do | ||
end | ||
|
||
desc "Remove any generated file" | ||
task :clobber => [:clean] do | ||
rmtree File.join($config["path"], ".bundle") | ||
rmtree File.join($config["path"], "bundle") | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
path: workflow | ||
domain: com.alfredapp.norder | ||
id: omniref | ||
dropbox: ~/Dropbox/Alfred |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "plist" | ||
gem "alfred-workflow" | ||
gem "nokogiri" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
alfred-workflow (1.8.0) | ||
plist (>= 3.1.0) | ||
mini_portile (0.6.2) | ||
nokogiri (1.6.6.2) | ||
mini_portile (~> 0.6.0) | ||
plist (3.1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
alfred-workflow | ||
nokogiri | ||
plist |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>bundleid</key> | ||
<string>com.alfredapp.norder.omniref</string> | ||
<key>connections</key> | ||
<dict> | ||
<key>21557827-8003-42B7-A042-16D4C9278FEC</key> | ||
<array> | ||
<dict> | ||
<key>destinationuid</key> | ||
<string>BA6E71A9-2AD5-450C-8091-BBF7A19FF9EF</string> | ||
<key>modifiers</key> | ||
<integer>0</integer> | ||
<key>modifiersubtext</key> | ||
<string></string> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>createdby</key> | ||
<string>Andrew King</string> | ||
<key>description</key> | ||
<string>Search Omniref for a method, class, gem, etc...</string> | ||
<key>disabled</key> | ||
<false/> | ||
<key>name</key> | ||
<string>Omniref search</string> | ||
<key>objects</key> | ||
<array> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>plusspaces</key> | ||
<false/> | ||
<key>url</key> | ||
<string>{query}</string> | ||
<key>utf8</key> | ||
<true/> | ||
</dict> | ||
<key>type</key> | ||
<string>alfred.workflow.action.openurl</string> | ||
<key>uid</key> | ||
<string>BA6E71A9-2AD5-450C-8091-BBF7A19FF9EF</string> | ||
<key>version</key> | ||
<integer>0</integer> | ||
</dict> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>argumenttype</key> | ||
<integer>1</integer> | ||
<key>escaping</key> | ||
<integer>62</integer> | ||
<key>keyword</key> | ||
<string>omni</string> | ||
<key>queuedelaycustom</key> | ||
<integer>1</integer> | ||
<key>queuedelayimmediatelyinitially</key> | ||
<false/> | ||
<key>queuedelaymode</key> | ||
<integer>0</integer> | ||
<key>queuemode</key> | ||
<integer>1</integer> | ||
<key>script</key> | ||
<string>/usr/bin/ruby ./main.rb {query}</string> | ||
<key>subtext</key> | ||
<string></string> | ||
<key>title</key> | ||
<string>Search Omniref</string> | ||
<key>type</key> | ||
<integer>0</integer> | ||
<key>withspace</key> | ||
<true/> | ||
</dict> | ||
<key>type</key> | ||
<string>alfred.workflow.input.scriptfilter</string> | ||
<key>uid</key> | ||
<string>21557827-8003-42B7-A042-16D4C9278FEC</string> | ||
<key>version</key> | ||
<integer>0</integer> | ||
</dict> | ||
</array> | ||
<key>readme</key> | ||
<string>Basic Omniref search within Alfred. | ||
Props to: | ||
https://github.com/zhaocai/alfred-workflow</string> | ||
<key>uidata</key> | ||
<dict> | ||
<key>21557827-8003-42B7-A042-16D4C9278FEC</key> | ||
<dict> | ||
<key>ypos</key> | ||
<real>220</real> | ||
</dict> | ||
<key>BA17BE41-176A-4E9A-B958-A3F0BEA36829</key> | ||
<dict> | ||
<key>ypos</key> | ||
<real>370</real> | ||
</dict> | ||
<key>BA6E71A9-2AD5-450C-8091-BBF7A19FF9EF</key> | ||
<dict> | ||
<key>ypos</key> | ||
<real>220</real> | ||
</dict> | ||
</dict> | ||
<key>webaddress</key> | ||
<string>http://github.com/an0nym0use/alfred-omniref</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: utf-8 | ||
|
||
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8 | ||
require_relative "bundle/bundler/setup" | ||
|
||
require "alfred" | ||
require 'open-uri' | ||
require 'nokogiri' | ||
|
||
BASE_URL = 'https://www.omniref.com' | ||
|
||
Alfred.with_friendly_error do |alfred| | ||
fb = alfred.feedback | ||
query = ARGV[0] | ||
|
||
if query && query.length > 2 | ||
response = Nokogiri::HTML(open(BASE_URL + "/?q=#{query}&p=0&r=5")) | ||
results = response.css('li.result').map {|result| [result.css('a')[0].text, result.css('a')[0]['href']]} | ||
results.first(10).each do |result| | ||
fb.add_item({ | ||
:uid => "", | ||
:title => result.first, | ||
:arg => BASE_URL + result.last, | ||
:valid => "yes", | ||
}) | ||
end | ||
end | ||
|
||
puts fb.to_xml unless fb.items.empty? | ||
end | ||
|
||
|
||
|