Skip to content

Commit

Permalink
fixed merge bibdesk.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
houshuang committed Mar 1, 2012
1 parent 5bfd494 commit ea1bb37
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions bibdesk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
require 'utility-functions'
require 'appscript'

#### utilities ####


#### keyboard commands ####

# email selected files to Kindle - needs some polish
Expand Down
4 changes: 2 additions & 2 deletions legacy/doi-lookup/doi-bibtex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def try(&block)

def lookup_doi(doi, crossref_api_key)
debug = false
doi = doi.gsub('doi:','').gsub('http://','').gsub('dx.doi.org/','').strip
doi = doi.gsub('doi:','').gsub('http://','').gsub('dx.doi.org/','').gsub('doi>','').strip
url = "http://www.crossref.org/openurl/?id=doi:#{doi}&noredirect=true&pid=#{crossref_api_key}&format=unixref"
puts url if debug

Expand All @@ -24,7 +24,7 @@ def lookup_doi(doi, crossref_api_key)
return false if html.index("<error>") || html.index("<head>")

doc = XmlSimple.xml_in(html)

p doc
cit = doc['doi_record'][0]['crossref'][0]['journal'][0]
journal_meta = cit["journal_metadata"][0]
journal_title = journal_meta['full_title'][0]
Expand Down
2 changes: 1 addition & 1 deletion legacy/imfeelinglucky-y.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'utility-functions'
require '../utility-functions'
require 'appscript'
include Appscript
dt = app('Google Chrome')
Expand Down
12 changes: 6 additions & 6 deletions legacy/imfeelinglucky.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'pp'
require 'open-uri'
require 'yaml'

curpath = File.dirname(File.expand_path(__FILE__)) + "/"
conf = YAML::load(File.read(curpath + "config.yaml"))


def json_parse(json)
Expand All @@ -21,16 +21,16 @@ def json_parse(json)
stext = search
searchphrase = search
end
a = open("https://www.googleapis.com/customsearch/v1?key=#{conf["googleapi"]}&q=#{searchphrase}").read
pp a
a = open("http://api.bing.net/json.aspx?AppId=A203F8FB37F05FFF4756C5217E1FCCA156AD7D6C&Query=#{searchphrase}&Sources=Web").read
pp json_parse(a)
out = ''
c =0
File.open("/tmp/imfeelinglucky-tmp",'w') do |file|
file << "#{stext}\n"
json_parse(a)["responseData"]["results"].each do |item|
json_parse(a)["SearchResponse"]["Web"]["Results"].each do |item|
c += 1
file << "#{item["unescapedUrl"]}\n"
out << "#{c}: #{item["titleNoFormatting"]}\n\t#{item["unescapedUrl"]}\n"
file << "#{item["Url"]}\n"
out << "#{c}: #{item["Title"]}\n\t#{item["Url"]}\n"
end
end

Expand Down

0 comments on commit ea1bb37

Please sign in to comment.