summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Martelli <cocoa@schnuddelhuddel.de>2017-06-28 16:36:45 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-28 17:44:27 +0200
commit37bba84a5e364c5595de6a16fa6fa7d1c701f75e (patch)
tree210040bd5253436b1614038e1242bc6a03315076
parenta9e53e6172ded341da43a13c4e16cefaee048401 (diff)
downloadorg-mode-37bba84a5e364c5595de6a16fa6fa7d1c701f75e.tar.gz
org-protocol: Sources with date URL are supported
lisp/org-protocol.el (org-protocol-project-alist): Date-URL is added as example. (org-protocol-open-source): First match is processed in rewrite. testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-open-source): Configuration displaying a date-style URL is added. TINYCHANGE
-rw-r--r--lisp/org-protocol.el17
-rw-r--r--testing/lisp/test-org-protocol.el7
2 files changed, 20 insertions, 4 deletions
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index cd4b216..d37de11 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -194,7 +194,14 @@ Example:
:working-suffix \".org\"
:base-url \"http://localhost/org/\"
:working-directory \"/home/user/org/\"
- :rewrites ((\"org/?$\" . \"index.php\")))))
+ :rewrites ((\"org/?$\" . \"index.php\")))
+ (\"Hugo based blog\"
+ :base-url \"https://www.site.com/\"
+ :working-directory \"~/site/content/post/\"
+ :online-suffix \".html\"
+ :working-suffix \".md\"
+ :rewrites ((\"\\(https://site.com/[0-9]+/[0-9]+/[0-9]+/\\)\" . \".md\")))))
+
The last line tells `org-protocol-open-source' to open
/home/user/org/index.php, if the URL cannot be mapped to an existing
@@ -556,8 +563,12 @@ The location for a browser's bookmark should look like this:
;; Try to match a rewritten URL and map it to
;; a real file. Compare redirects without
;; suffix.
- (when (string-match-p (car rewrite) f1)
- (throw 'result (concat wdir (cdr rewrite))))))))
+ (when (string-match (car rewrite) f1)
+ (let ((replacement
+ (concat (directory-file-name
+ (replace-match "" nil nil f1 1))
+ (cdr rewrite))))
+ (throw 'result (concat wdir replacement))))))))
;; -- end of redirects --
(if (file-readable-p the-file)
diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-protocol.el
index 8f94686..fc76438 100644
--- a/testing/lisp/test-org-protocol.el
+++ b/testing/lisp/test-org-protocol.el
@@ -137,7 +137,12 @@
:base-url "http://another.example.com/"
:online-suffix ".js"
:working-directory ,(file-name-directory temp-file-name2))
- ))
+ (test3
+ :base-url "https://blog-example.com/"
+ :working-directory ,(file-name-directory temp-file-name2)
+ :online-suffix ".html"
+ :working-suffix ".md"
+ :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\\)" . ".md")))))
(test-cases
(list
;; Old-style URLs