diff options
author | Vincent Ambo <tazjin@gmail.com> | 2017-11-13T21·45+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2017-11-13T21·45+0100 |
commit | 05bdeba85327a491f3a78ec51a975067f528c4d1 (patch) | |
tree | f56d48843b46cc150e504287d07a9dbbe6778cd0 | |
parent | 2ba11f5c038b6cb0aee9c4a48a10a62d63d86887 (diff) |
feat(blog): Let users extend/customize elblog routes
The default elblog route (/{article-name}) can now be extended with user-supplied routes by overriding the elblog-additional-routes customize variable. This variable takes the same format as the alist supplied to elnode-hostpath-dispatcher. The prefix `/en` has been dropped from the default handler because that only existed to be compatible with my old blog, which is no longer required as it can now be handled with a custom legacy route in my personal blog configuration.
-rw-r--r-- | blog.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/blog.el b/blog.el index 0b4c2c333fc2..102aa3791481 100644 --- a/blog.el +++ b/blog.el @@ -32,6 +32,11 @@ :group 'elblog :type 'string) +(defcustom elblog-additional-routes '() + "Additional Elnode routes to register in the Elblog instance" + :group 'elblog + :type '(alist :key-type regexp :value-type function)) + ;; Declare user-configurable variables needed at runtime. (defvar elblog-articles (ht-create) @@ -94,11 +99,15 @@ ;; Web server implementation -(defvar-local elblog-routes - '(("^.*//en/\\(.*\\)" . blog-post-handler))) +(defvar elblog-routes + '(("^.*//\\(.*\\)" . blog-post-handler)) + "The default routes available in elblog. They can be extended by the user +by setting the elblog-additional-routes customize option.") (defun elblog-handler (httpcon) - (elnode-hostpath-dispatcher httpcon elblog-routes)) + (elnode-hostpath-dispatcher + httpcon + (-concat elblog-additional-routes elblog-routes))) (defun start-elblog () (interactive) |