From: Mario Martelli <tlmtr@schnuddelhuddel.de>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-protocol: fixes open-source and extends rewriting of URLs
Date: Tue, 27 Jun 2017 08:54:08 +0200 [thread overview]
Message-ID: <92533F36-7529-496B-BA7B-8ED49FBFB3D2@schnuddelhuddel.de> (raw)
In-Reply-To: <87mv8uv5ns.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
Hi,
> OK. Could you wrap up the patches needed so far, with appropriate commit
> messages, so I can apply them?
Sorry for producing noise. Just read the contribution guidelines once again ;)
Hope everything is now according to the guidelines.
[-- Attachment #2: 0001-org-protocol.el-Fix-for-failing-open-source-subproto.patch --]
[-- Type: application/octet-stream, Size: 1128 bytes --]
From 0605063662ef6ae92abe75956dc2432f5028a041 Mon Sep 17 00:00:00 2001
From: Mario Martelli <cocoa@schnuddelhuddel.de>
Date: Fri, 23 Jun 2017 18:32:49 +0200
Subject: [PATCH 1/4] org-protocol.el: Fix for failing open-source subprotocol
* (org-protocol-open-source): make sure url is
sanitised before processing
TINYCHANGE
---
lisp/org-protocol.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 825435674..7e986a9ed 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -520,7 +520,7 @@ The location for a browser's bookmark should look like this:
;; As we enter this function for a match on our protocol, the return value
;; defaults to nil.
(let ((result nil)
- (f (plist-get (org-protocol-parse-parameters fname nil '(:url)) :url)))
+ (f (org-protocol-sanitize-uri (plist-get (org-protocol-parse-parameters fname nil '(:url)) :url))))
(catch 'result
(dolist (prolist org-protocol-project-alist)
(let* ((base-url (plist-get (cdr prolist) :base-url))
--
2.11.0 (Apple Git-81)
[-- Attachment #3: 0002-org-protocol.el-Fix-for-silently-failing-open-source.patch --]
[-- Type: application/octet-stream, Size: 1014 bytes --]
From 44d0ea97c452ed5f5cd0f358b75115a029a28487 Mon Sep 17 00:00:00 2001
From: Mario Martelli <cocoa@schnuddelhuddel.de>
Date: Sat, 24 Jun 2017 16:01:20 +0200
Subject: [PATCH 2/4] org-protocol.el: Fix for silently failing open-source
subprotocol
* (org-protocol-open-source): tests URL against
base-url and not the filename
TINYCHANGE
---
lisp/org-protocol.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 7e986a9ed..6744fc0ac 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -554,7 +554,7 @@ 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) f2)
+ (when (string-match-p (car rewrite) f1)
(throw 'result (concat wdir (cdr rewrite))))))))
;; -- end of redirects --
--
2.11.0 (Apple Git-81)
[-- Attachment #4: 0003-org-protocol.el-sources-with-date-URL-are-supported.patch --]
[-- Type: application/octet-stream, Size: 2180 bytes --]
From dd9d41cfb6d48cc03a71c8604f3d913c35df4844 Mon Sep 17 00:00:00 2001
From: Mario Martelli <cocoa@schnuddelhuddel.de>
Date: Sun, 25 Jun 2017 01:03:34 +0200
Subject: [PATCH 3/4] org-protocol.el sources with date URL are supported
* (org-protocol-project-alist): date-URL is added as example
* (org-protocol-open-source): first match is processed in rewrite
TINYCHANGE
---
lisp/org-protocol.el | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 6744fc0ac..5d4baae34 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://themes.gohugo.io/theme/hugo-icarus/\"
+ :working-directory \"~/Documents/MyBlog/themes/hugo-icarus-theme/exampleSite/content/post/\"
+ :online-suffix \".html\"
+ :working-suffix \".md\"
+ :rewrites ((\"\\(https://themes.gohugo.io/theme/hugo-icarus/[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
@@ -554,8 +561,13 @@ 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)
+ (setq replacement (cdr rewrite))
+ (if (match-string 0 f1)
+ (setq replacement (concat
+ (directory-file-name (replace-match "" nil nil f1 1))
+ replacement )))))
+ (throw 'result (concat wdir replacement)))))
;; -- end of redirects --
(if (file-readable-p the-file)
--
2.11.0 (Apple Git-81)
[-- Attachment #5: 0004-test-org-protocol.el-date-style-URL-support.patch --]
[-- Type: application/octet-stream, Size: 1139 bytes --]
From ec444303c239bc6d82bd8566e3fb283ea580070d Mon Sep 17 00:00:00 2001
From: Mario Martelli <cocoa@schnuddelhuddel.de>
Date: Sun, 25 Jun 2017 10:14:40 +0200
Subject: [PATCH 4/4] test-org-protocol.el: date style URL support
* (test-org-protocol/org-protocol-open-source): configuration
displaying a date-style URL is added
TINYCHANGE
---
testing/lisp/test-org-protocol.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-protocol.el
index 8f946864c..b11c72a68 100644
--- a/testing/lisp/test-org-protocol.el
+++ b/testing/lisp/test-org-protocol.el
@@ -137,6 +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
--
2.11.0 (Apple Git-81)
[-- Attachment #6: Type: text/plain, Size: 135 bytes --]
> BTW, have you signed FSF papers?
Applied for it just now. Have marked the changes as tiny.
Kind regards
Mario
—
next prev parent reply other threads:[~2017-06-27 6:54 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 10:14 org-protocol documentation Mario Martelli
2017-06-19 10:41 ` Nicolas Goaziou
2017-06-19 12:37 ` Mario Martelli
2017-06-19 13:41 ` Chunyang Xu
2017-06-21 17:29 ` Nicolas Goaziou
2017-06-21 18:58 ` Mario Martelli
2017-06-21 19:12 ` Nicolas Goaziou
2017-06-22 8:40 ` Mario Martelli
2017-06-22 19:32 ` Mario Martelli
2017-06-22 20:03 ` Nicolas Goaziou
2017-06-23 7:50 ` Mario Martelli
2017-06-23 16:46 ` Mario Martelli
2017-06-25 6:49 ` [PATCH] org-protocol: fixes open-source and extends rewriting of URLs Mario Martelli
2017-06-25 7:17 ` Nicolas Goaziou
2017-06-25 8:21 ` Mario Martelli
2017-06-26 20:46 ` Nicolas Goaziou
2017-06-27 6:54 ` Mario Martelli [this message]
2017-06-28 9:32 ` Nicolas Goaziou
2017-06-28 14:44 ` Mario Martelli
2017-06-28 15:49 ` Nicolas Goaziou
2017-06-29 8:28 ` Mario Martelli
2017-06-29 12:47 ` Nicolas Goaziou
2017-06-25 10:15 ` org-protocol documentation Mario Martelli
2017-06-29 12:42 ` Nicolas Goaziou
2017-06-29 18:30 ` Mario Martelli
2017-06-30 12:05 ` Mario Martelli
2017-07-01 10:34 ` Nicolas Goaziou
2017-07-01 13:13 ` Mario Martelli
2017-07-01 16:42 ` Nicolas Goaziou
2017-07-01 16:44 ` Nicolas Goaziou
2017-07-01 19:24 ` Mario Martelli
2017-07-03 17:21 ` Nick Dokos
2017-07-03 18:09 ` Mario Martelli
2017-07-06 17:54 ` Nicolas Goaziou
2017-07-23 16:18 ` Mario Martelli
2017-07-23 20:49 ` Nicolas Goaziou
2017-07-23 22:39 ` Adam Porter
2017-07-24 6:17 ` Colin Baxter
2017-07-24 23:53 ` Adam Porter
2017-07-25 8:13 ` Colin Baxter
2017-06-30 4:42 ` Mario Martelli
2017-06-19 12:26 ` Chunyang Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92533F36-7529-496B-BA7B-8ED49FBFB3D2@schnuddelhuddel.de \
--to=tlmtr@schnuddelhuddel.de \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).