about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-11-12T23·16+0100
committerVincent Ambo <tazjin@gmail.com>2017-11-12T23·16+0100
commitb4dad1526d7a68ca089a22bf01fffa65abc9c5d9 (patch)
treefc81b4057bfacdaf68332bb9f4a47910beca8176
parentba01528a77ad265567b93bb7ba47383cc10be483 (diff)
feat(blog): Add customization group for configuring elblog settings
Adds a customization group which can currently be used to configure
the host and port that elblog should run on.
-rw-r--r--blog.el26
1 files changed, 23 insertions, 3 deletions
diff --git a/blog.el b/blog.el
index 4e7cf91d8e51..20f141fe41a5 100644
--- a/blog.el
+++ b/blog.el
@@ -4,6 +4,24 @@
 (require 'elnode)
 (require 'f)
 
+;; Definition of customization options
+
+(defgroup elblog nil
+  "Configuration for the Emacs Lisp blog software"
+  :link '(url-link "https://github.com/tazjin/elblog"))
+
+(defcustom elblog-port 8010
+  "Port to run elblog's HTTP server on"
+  :group 'elblog
+  :type 'integer)
+
+(defcustom elblog-host "localhost"
+  "Host for elblog's HTTP server to listen on"
+  :group 'elblog
+  :type 'string)
+
+;; Article fetching & rendering functions
+
 (defun render-org-buffer (buffer &optional force)
   "Renders an org-mode buffer as HTML and returns the name of the output buffer."
   (letrec ((input-buffer (get-buffer buffer))
@@ -38,6 +56,8 @@
     (elnode-http-start httpcon  (car response) text-html)
     (elnode-http-return httpcon (cdr response))))
 
+;; Web server implementation
+
 (defvar-local elblog-routes
   '(("^.*//en/\\(.*\\)" . blog-post-handler)))
 
@@ -47,9 +67,9 @@
 (defun start-elblog ()
   (interactive)
   (elnode-start 'elblog-handler
-              :port 8010
-              :host "localhost"))
+              :port elblog-port
+              :host elblog-host))
 
 (defun stop-elblog ()
   (interactive)
-  (elnode-stop 8010))
+  (elnode-stop elblog-port))