goog 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/goog +17 -6
  2. data/lib/goog.rb +1 -1
  3. data/plugin/goog.vim +3 -1
  4. metadata +2 -2
data/bin/goog CHANGED
@@ -7,6 +7,17 @@ require 'uri'
7
7
  require 'optparse'
8
8
 
9
9
  $vimscript_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'plugin', 'goog.vim'))
10
+
11
+ html_dump_program = if (`which w3m` != "")
12
+ "w3m -dump"
13
+ elsif (`which elinks` != "")
14
+ "elinks -dump -no-numbering"
15
+ elsif (`which links` != "")
16
+ "links -dump"
17
+ elsif (`which lynx` != "")
18
+ "lynx -dump -nonumber"
19
+ end
20
+
10
21
  orig_query = "query: #{ARGV.join(' ')}\n\n"
11
22
  options = {}
12
23
  OptionParser.new do |opts|
@@ -24,7 +35,7 @@ DATE RANGE options for -d option:
24
35
 
25
36
  VIM KEY MAPPINGS
26
37
  <leader>o open URL on or after cursor in default external web browser
27
- <leader>O open URL on or after cursor in split Vim window using elinks, links, or lynx
38
+ <leader>O open URL on or after cursor in split Vim window using w3m, elinks, links, or lynx
28
39
 
29
40
  VIM PLUGIN COMMANDS
30
41
 
@@ -41,7 +52,7 @@ In the GoogSearchResults buffer:
41
52
  CTRL-j jumps to the next URL
42
53
  CTRL-k jumps to the previous URL
43
54
  <leader>o open URL on or after cursor in default external web browser
44
- <leader>O open URL on or after cursor in split Vim window using elinks, links, or lynx
55
+ <leader>O open URL on or after cursor in split Vim window using w3m, elinks, links, or lynx
45
56
 
46
57
  goog #{Goog::VERSION}
47
58
  http://github.com/danchoi/goog
@@ -53,7 +64,7 @@ END
53
64
  opts.on("-n", '--num-pages [NUM PAGES]', 'Show NUM PAGES pages of results') {|pages| options[:pages] = pages.to_i }
54
65
  opts.on("-c", '--color', 'Force color output') {options[:color] = true}
55
66
  opts.on("-x", '--expand', 'Expand all results into web page text') { options[:expand] = true }
56
- opts.on("-e", '--elinks', 'Open results in elinks') { options[:elinks] = true }
67
+ opts.on("-e", '--elinks', 'Open results in text browser') { options[:elinks] = true }
57
68
  opts.on("-i", '--interactive', 'Prompt for selection') { options[:interactive] = true }
58
69
  opts.on("-v", '--vim', 'Open results in Vim and bind <leader>o to open URL on or after cursor') { options[:vim] = true }
59
70
  opts.on('--install-plugin', 'Install Goog as a Vim plugin') {
@@ -135,7 +146,7 @@ links = []
135
146
  if options[:expand]
136
147
  $stderr.puts "Fetching #{title}: #{link}"
137
148
  puts "#{title}: #{link}"
138
- puts `elinks -dump -no-numbering '#{link}'`
149
+ puts `#{html_dump_program} '#{link}'`
139
150
  puts '-' * 80
140
151
  puts
141
152
  end
@@ -166,13 +177,13 @@ if options[:interactive]
166
177
  n = s[/\d+/,0].to_i
167
178
  pipe = s[/[|>].*$/,0] || '| less'
168
179
  link = links[n - 1]
169
- cmd = "(echo \"#{link}\n\n\"; elinks -dump -no-numbering '#{link}') #{pipe}"
180
+ cmd = "(echo \"#{link}\n\n\"; #{html_dump_program} '#{link}') #{pipe}"
170
181
  system cmd
171
182
  }
172
183
  end
173
184
 
174
185
  if options[:elinks]
175
186
  $stdout.close
176
- exec "mv #{$tempfile.path}{,.html} && elinks #{$tempfile.path}.html"
187
+ exec "mv #{$tempfile.path}{,.html} && #{html_dump_program.split(' ')[0]} #{$tempfile.path}.html"
177
188
  end
178
189
 
@@ -1,3 +1,3 @@
1
1
  module Goog
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
@@ -12,7 +12,9 @@ let s:http_link_pattern = '^https\?:[^ >)\]]\+'
12
12
 
13
13
  let g:gui_web_browser = system("echo -n $(which gnome-open || which open)")
14
14
  if ! exists("g:text_web_browser")
15
- if executable("elinks")
15
+ if executable("w3m")
16
+ let g:text_web_browser = 'w3m -dump'
17
+ elseif executable("elinks")
16
18
  let g:text_web_browser = 'elinks -dump -no-numbering'
17
19
  elseif executable("lynx")
18
20
  let g:text_web_browser = 'lynx -dump -nonumbers'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-25 00:00:00.000000000 Z
12
+ date: 2014-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri