Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
4.1 KiB

4 years ago
  1. ;;; org-ref-wos.el --- Web of Science functions -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2015 John Kitchin
  3. ;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
  4. ;; Keywords:
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;; Adds a new org-mode link for a search in Web of Science.
  17. ;;; and an org-mode link for a link to an Accession number.
  18. (require 'org)
  19. (require 's)
  20. (require 'org-ref-utils)
  21. ;;; Code:
  22. (org-ref-link-set-parameters "wos"
  23. :follow (lambda (accession-number)
  24. (browse-url
  25. (concat
  26. "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/"
  27. accession-number)))
  28. :export (lambda (accession-number desc format)
  29. (cond
  30. ((eq format 'html)
  31. (format "<a href=\"http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/%s\">%s</a>"
  32. accession-number
  33. (or desc (concat "wos:" accession-number)))))))
  34. (org-ref-link-set-parameters "wos-search"
  35. :follow (lambda (path)
  36. (browse-url
  37. (format "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
  38. (s-join "+" (split-string path)))))
  39. :export (lambda (link desc format)
  40. (cond
  41. ((eq format 'html)
  42. (format "<a href=\"%s\">%s</a>"
  43. (format "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
  44. (s-join "+" (split-string link)))
  45. (or desc link))))))
  46. ;;;###autoload
  47. (defun wos-search ()
  48. "Open the word at point or selection in Web of Science as a topic query."
  49. ;; the url was derived from this page: http://wokinfo.com/webtools/searchbox/
  50. (interactive)
  51. (browse-url
  52. (format "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary"
  53. (if (region-active-p)
  54. (mapconcat 'identity (split-string
  55. (buffer-substring (region-beginning)
  56. (region-end))) "+")
  57. (thing-at-point 'word)))))
  58. ;;;###autoload
  59. (defun wos ()
  60. "Open Web of Science search page in a browser."
  61. (interactive)
  62. (browse-url "http://apps.webofknowledge.com"))
  63. ;;* Accession numbers
  64. ;; see http://kitchingroup.cheme.cmu.edu/blog/2015/06/08/Getting-a-WOS-Accession-number-from-a-DOI/
  65. (defvar *wos-redirect* nil
  66. "Holds the redirect from a `url-retrieve' callback function.")
  67. (defvar *wos-waiting* nil
  68. "Non-nil when waiting for a `url-retrieve' redirect.")
  69. (defun wos-get-wos-redirect (url)
  70. "Return final redirect URL for open-url."
  71. (setq *wos-waiting* t)
  72. (url-retrieve
  73. url
  74. (lambda (status)
  75. (setq *wos-redirect* (car (last status)))
  76. (setq *wos-waiting* nil)))
  77. (while *wos-waiting* (sleep-for 0.1))
  78. (url-unhex-string *wos-redirect*))
  79. (defun wos-doi-to-accession-number (doi)
  80. "Return a WOS Accession number for a DOI."
  81. (let* ((open-url (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/" doi))
  82. (redirect (wos-get-wos-redirect open-url)))
  83. (message redirect)
  84. (string-match "&KeyUT=WOS:\\([^&]*\\)&" redirect)
  85. (match-string 1 redirect)))
  86. (provide 'org-ref-wos)
  87. ;;; org-ref-wos.el ends here