-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.el
executable file
·46 lines (34 loc) · 1.28 KB
/
utilities.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env elscript
;;; utilites.el --- Utilities -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Koki Fukuda
;; Author: Koki Fukuda <[email protected]>
;; Licensed under the AGPL v3 or later.
;;; Code:
(defun header-status (code msg)
"Print status line for CGI"
(princ (concat "Status: " (number-to-string code) " " msg "\n")))
(defun header-entry (key value)
"Print HTTP header entry with specified key and value"
(princ (concat key ": " value "\n")))
(defun header-content-type (type)
"Print HTTP header to indicate content type"
(header-entry "Content-Type" type))
(defun header-html ()
"Print HTTP header to indicate body is text/html"
(header-content-type "text/html"))
(defun header-end ()
(princ "\n"))
(defun not-found ()
(load (concat (file-name-directory load-file-name) "not-found-handler.el")))
(defun get-entry-title (entry)
(with-temp-buffer
(insert-file-contents (concat (file-name-directory load-file-name)
"posts/" entry "/post.org") nil 0 100)
(goto-char (point-min))
(if (search-forward "#+TITLE:" nil t)
(progn
(let ((title-start (point)))
(move-end-of-line 1)
(buffer-substring title-start (point))))
"No Title")))
;;; entry.el ends here