From b4dad1526d7a68ca089a22bf01fffa65abc9c5d9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 13 Nov 2017 00:16:26 +0100 Subject: 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. --- blog.el | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'blog.el') 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)) -- cgit 1.4.1