Skip to content

Commit

Permalink
Fixing citation.rb to work with researchr settings.rb, growl etc
Browse files Browse the repository at this point in the history
  • Loading branch information
houshuang committed Mar 1, 2012
1 parent d4e65aa commit 559884f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions citation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@

$:.push(File.dirname($0))
require 'utility-functions'

@pdf_path = '/Users/ramuller/Dropbox/PDFs/*.pdf'
puts "hello"
@bd = app("BibDesk").document

def send_citation(bibtex, hashkey)
host = 'stormy-leaf-9036.herokuapp.com'
port = '80'
host = Scrobble_server_host
port = Scrobble_server_port

post_ws = "/citations"
token = "CKwyA5hpKUDaxENtu4YM"

token = Scrobble_token
payload ={ "bibtex" => bibtex, "token" => token }.to_json

req = Net::HTTP::Post.new("/citations", initheader = {'Content-Type' =>'application/json'})
req.body = payload
response = Net::HTTP.new(host, port).start {|http| http.request(req) }
Expand All @@ -29,20 +27,22 @@ def send_citation(bibtex, hashkey)

if ARGV[0] == "batch"
c=0
path = @pdf_path
Dir[path].select do |f|
path = PDF_path + "/*.pdf"
growl "Beginning to send citation data to Scrobble server"
Dir[path].select do |f|
puts f
fname = File.basename(f)
citekey = fname[0..-5]
begin
bibtx = @bd.search({:for =>citekey})[0].BibTeX_string.get.to_s
hash = hashsum(f)
send_citation(bibtx, hash)
rescue
puts "Not found"
puts "#{citekey} not found in BibDesk database"
next
end
c = c+1
end
puts "Total #{c} entries sent"
growl "Total #{c} entries sent"
end

0 comments on commit 559884f

Please sign in to comment.