Skip to content

Commit

Permalink
moving skim url from skim-tools to dokuwiki, to be able to access mor…
Browse files Browse the repository at this point in the history
…e chrome functions
  • Loading branch information
houshuang committed Mar 2, 2012
1 parent c7ae837 commit 327d69f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
17 changes: 17 additions & 0 deletions dokuwiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ def clean_bibtex
pbcopy(cleanup_bibtex_string(pbpaste))
end

# opens a given reference as passed by skimx:// URL in Skim
# launched by skimx:// url in Chrome (skimx.app must be registered first)
def url(argv)
arg = argv[8..-1]
arg.gsub!("#","%23")
pdf, page = arg.split("%23")
fname = "#{PDF_path}/#{pdf}.pdf"
if File.exists?(fname)
skim = Appscript.app('skim')
dd = skim.open(fname)
dd.go({:to => dd.pages.get[page.to_i-1]}) unless page == nil
skim.activate
else
growl("File not found", "Cannot find PDF #{fname}")
end
end

#### keyboard commands ####

# if Ctrl+Cmd+Alt+G is invoked, and current tab is not Google Scholar, assume that it is a foreign wiki, and try to
Expand Down
23 changes: 3 additions & 20 deletions skim-tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@
require 'utility-functions'
require 'appscript'

#### utility functions ####
# opens a given reference as passed by skimx:// URL in Skim
# launched by skimx:// url in Chrome (skimx.app must be registered first)
def url(argv)
arg = argv[8..-1]
arg.gsub!("#","%23")
pdf, page = arg.split("%23")
fname = "#{PDF_path}/#{pdf}.pdf"
if File.exists?(fname)
dd = Skim.open(fname)
dd.go({:to => dd.pages.get[page.to_i-1]}) unless page == nil
Skim.activate
else
growl("File not found", "Cannot find PDF #{fname}")
end
end

# stores a link to the last screenshot taken, and the current PDF page. when export to the wiki happens, the picture is
# moved to the wiki media folder, and linked to the notes
def screenshot
Expand All @@ -37,7 +20,7 @@ def screenshot

# pops up a dialogue which asks how many pages, and runs a CLI command (pdfmanipulate) which extracts a piece of the current
# PDF starting with the current page and the number of pages indicated forwards. Useful for extracting articles out of
# proceedings, etc.
# proceedings, etc.
def splitpdf
require 'pashua'
include Pashua
Expand All @@ -46,7 +29,7 @@ def splitpdf
page = Document.get[0].current_page.get.index.get

# configuring Pashua dialogue
config = "
config = "
*.title = researchr
fb.type = textfield
fb.default = 1
Expand All @@ -58,7 +41,7 @@ def splitpdf
db.tooltip = Closes this window without taking action\n"

pagetmp = pashua_run config
exit if pagetmp['cancel'] == 1
exit if pagetmp['cancel'] == 1

startpage = page.to_i
tmppage = pagetmp['fb'].to_i
Expand Down
Binary file modified skimx.app/Contents/Resources/Scripts/main.scpt
Binary file not shown.

0 comments on commit 327d69f

Please sign in to comment.