瀏覽代碼

Make parse-metadata suck a little less. Many docs updates.

Brit Butler 10 年之前
父節點
當前提交
46e6915ba2
共有 4 個文件被更改,包括 123 次插入30 次删除
  1. 67 19
      README.md
  2. 37 0
      docs/config.md
  3. 6 2
      docs/hacking.md
  4. 13 9
      src/content.lisp

+ 67 - 19
README.md

@@ -10,6 +10,7 @@
10 10
 Coleslaw is Flexible Lisp Blogware similar to [Frog](https://github.com/greghendershott/frog), [Jekyll](http://jekyllrb.com/), or [Hakyll](http://jaspervdj.be/hakyll/).
11 11
 
12 12
 ## Features
13
+
13 14
 * Git for storage
14 15
 * RSS and Atom feeds
15 16
 * Markdown Support with Code Highlighting provided by [colorize](http://www.cliki.net/colorize)
@@ -30,32 +31,68 @@ Coleslaw is Flexible Lisp Blogware similar to [Frog](https://github.com/greghend
30 31
 * There is also a [Heroku buildpack](https://github.com/jsmpereira/coleslaw-heroku) maintained by Jose Pereira.
31 32
 
32 33
 ## Example Sites
33
-  * [redlinernotes](http://redlinernotes.com/blog/)
34
-  * [chip the glasses](http://chiptheglasses.com)
35
-  * [kenan-bolukbasi.log](http://kenanb.com/)
36
-  * [Nothing Really Matters](http://ironhead.xs4all.nl/)
37
-  * [A year and a smile](http://blog.sjas.de)
34
+
35
+See the [wiki][blogroll] for a list of coleslaw-powered blogs.
36
+
37
+[blogroll]: https://github.com/redline6561/coleslaw/wiki/Blog roll
38 38
 
39 39
 ## Hacking
40 40
 
41
-A core goal of *coleslaw* is to be both pleasant to read and easy to hack on and extend. If you want to understand the internals and bend *coleslaw* to do new and interesting things, I strongly encourage you to read the [Hacker's Guide to Coleslaw](https://github.com/redline6561/coleslaw/blob/master/docs/hacking.md).
41
+A core goal of *coleslaw* is to be both pleasant to read and easy to
42
+hack on and extend. If you want to understand the internals and bend
43
+*coleslaw* to do new and interesting things, I strongly encourage you
44
+to read the [Hacker's Guide to Coleslaw][hackers]. You'll find some
45
+current **TODO** items towards the bottom.
46
+
47
+[hackers]: https://github.com/redline6561/coleslaw/blob/master/docs/hacking.md
42 48
 
43 49
 ## Installation
44
-This software should be portable to any conforming Common Lisp implementation but testing is primarily done on [SBCL](http://www.sbcl.org/) and [CCL](http://ccl.clozure.com/).
45
-Server side setup:
46 50
 
47
-1. Setup git and create a bare repo as shown [here](http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server).
48
-2. Install Lisp (we recommend SBCL) and [Quicklisp](http://quicklisp.org/).
49
-3. ```wget -c https://raw.github.com/redline6561/coleslaw/master/examples/example.coleslawrc -O ~/.coleslawrc``` # and edit as necessary
50
-4. ```wget -c https://raw.github.com/redline6561/coleslaw/master/examples/example.post-receive -O your-blog.git/hooks/post-receive``` # and edit as necessary
51
-5. ```chmod +x your-blog/.git/hooks/post-receive```
52
-6. Create or clone your blog repo locally. Add your server as a remote with ```git remote add prod git@my-host.com:path/to/repo.git```
53
-7. Point the web server of your choice at the symlink /path/to/deploy-dir/.curr/
51
+Coleslaw should run on any conforming Common Lisp implementation but
52
+testing is primarily done on [SBCL](http://www.sbcl.org/) and
53
+[CCL](http://ccl.clozure.com/).
54
+
55
+Coleslaw can either be run **manually** on a local machine or
56
+triggered **automatically** on git push to a server.  If you want a
57
+server install, run these commands on your server _after_ setting up a
58
+[git bare repo](http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server).
59
+Otherwise, run the commands on your local machine.
60
+
61
+1. Install a Common Lisp implementation (we recommend SBCL) and
62
+   [Quicklisp](http://quicklisp.org/).
63
+2. Place a config file for coleslaw in your `$HOME` directory. If you
64
+   want to run multiple blogs with coleslaw, you can keep each blog's
65
+   config file in that blog's repo.  Feel free to copy and edit the
66
+   [example config][ex_config] or consult the [config docs][conf_docs]
67
+   to create one from scratch.
68
+3. * Server Install: Copy and `chmod +x` the
69
+     [example post-receive hook][post_hook] to your blog's bare repo.
70
+   * Local Install:  Just run the following commands in the
71
+     REPL whenever you're ready to regenerate your blog:
72
+     ```
73
+     (ql:quickload :coleslaw)
74
+     ;; Note that the incremental plugin currently requires a "last git revision" argument.
75
+     (coleslaw:main "/path/to/my/blog/")
76
+     ```
77
+4. Optionally, point the web server of your liking at your config-specified
78
+   `:deploy-dir`. Or "deploy-dir/.curr" if the `versioned` plugin is enabled.
79
+
80
+Now just write posts, git commit and build by hand or by push.
54 81
 
55
-Now whenever you push a new commit to the server, coleslaw will update your blog automatically! You may need to `git push -u prod master` the first time.
82
+[ex_config]: https://github.com/redline6561/coleslaw/blob/master/examples/example.coleslawrc
83
+[conf_docs]: https://github.com/redline6561/coleslaw/blob/master/docs/config.md
84
+[post_hook]: https://github.com/redline6561/coleslaw/blob/master/examples/example.post-receive
85
+
86
+## The Content Format
87
+
88
+Coleslaw expects content to have a file extension matching the class
89
+of the content. (I.e. `.post` for blog posts, `.page` for static
90
+pages, etc.)
91
+
92
+There should also be a metadata header on all files
93
+starting and ending with the config-specified `:separator`, ";;;;;" by
94
+default. Example:
56 95
 
57
-## The Post Format
58
-Coleslaw expects post files to be formatted as follows:
59 96
 ```
60 97
 ;;;;;
61 98
 title: foo
@@ -66,5 +103,16 @@ format: html (for raw html) or md (for markdown)
66 103
 your post
67 104
 ```
68 105
 
106
+Posts require the `title:` and `format:` fields.
107
+Pages require the `title:` and `url:` fields.
108
+
109
+To omit a field, simply do not have the line present, empty lines and
110
+fields (e.g. "tags:" followed by whitespace) will be ignored.
111
+
69 112
 ## Theming
70
-Two themes are provided: hyde and readable (based on [bootswatch readable](http://bootswatch.com/readable/)). Hyde is the default. A guide to creating themes for coleslaw lives [here](https://github.com/redline6561/coleslaw/blob/master/docs/themes.md).
113
+
114
+Two themes are provided: hyde, the default, and readable (based on
115
+[bootswatch readable](http://bootswatch.com/readable/)).
116
+
117
+A guide to creating themes for coleslaw lives
118
+[here](https://github.com/redline6561/coleslaw/blob/master/docs/themes.md).

+ 37 - 0
docs/config.md

@@ -0,0 +1,37 @@
1
+# Configuration
2
+
3
+## Where
4
+
5
+Coleslaw needs a `.coleslawrc` file to operate properly. That file is usually located at
6
+$HOME/.coleslawrc but may also be placed in the blog repo itself.
7
+
8
+## What
9
+
10
+The only *required* information in the config is:
11
+* `:author`       => to be placed on post pages and in the copyright/CC-BY-SA notice
12
+* `:deploy-dir`   => for Coleslaw's generated HTML to go in
13
+* `:domain`       => to generate absolute links to the site content
14
+* `:routing`      => to determine the URL scheme of content on the site
15
+* `:title`        => to provide a site title
16
+* `:theme`        => to select one of the themes in "coleslaw/themes/"
17
+
18
+**TODO** Make sure this is actually true. Maybe without `:feeds` the publish method blows up? Test!
19
+
20
+It is usually recommend to start from the [example config][ex_config] and pare down from there.
21
+
22
+[ex_config]: https://github.com/redline6561/coleslaw/blob/master/examples/example.coleslawrc
23
+
24
+## Extras
25
+
26
+There are also many *optional* config parameters such as:
27
+* `:charset`       => to set HTML attributes for international characters, default: "UTF-8"
28
+* `:feeds`         => to generate RSS and Atom feeds for certain tagged content
29
+* `:lang`          => to set HTML attributes indicating the site language, default: "en"
30
+* `:license`       => to override the displayed content license, the default is CC-BY-SA
31
+* `:page-ext`      => to set the suffix of generated files, default: "html"
32
+* `:plugins`       => to configure and enable coleslaw's [various plugins][plugin-use]
33
+* `:separator`     => to set the separator for content metadata, default: ";;;;;"
34
+* `:sitenav`       => to provide relevant links and ease navigation
35
+* `:staging-dir`   => for Coleslaw to do intermediate work, default: "/tmp/coleslaw"
36
+
37
+[plugin-use]: https://github.com/redline6561/coleslaw/blob/master/docs/plugin-use.md

+ 6 - 2
docs/hacking.md

@@ -221,8 +221,11 @@ PAGE, a content type for static page support, is available as a plugin.
221 221
 
222 222
 ### TODO for 0.9.6
223 223
 
224
-* Serious updates to README and themes.md. Skim hacking.md but it's probably okay.
225
-* Make read-content/load-content more robust.
224
+* Finish docs updates to:
225
+  * themes.md     -> Note debugging issues. Valid slots. Changed URL handling.
226
+  * plugin-use.md -> Incremental plugin, Versioned plugin. Twitter summary cards.
227
+  * hacking.md    -> Any changes to Document Protocol?
228
+  * config.md     -> Test various empty config slots.
226 229
 * A real test suite with Stefil that at *least* tests:
227 230
   * `read-content`
228 231
   * `load-config`
@@ -235,6 +238,7 @@ PAGE, a content type for static page support, is available as a plugin.
235 238
   * Theme Compilation
236 239
   * Content Publishing
237 240
   * Common Plugins including Injections
241
+* Add proper errors to read-content/load-content. Not just ignoring bad data. Line info, etc.
238 242
 * Improved template debugging? "${" instead of "{$", static checks for valid slots, etc.
239 243
   At least a serious investigation into how such things might be provided.
240 244
 * Some minor scripting conveniences with cl-launch? (Scaffold a post/page, Enable incremental, Build, etc).

+ 13 - 9
src/content.lisp

@@ -50,16 +50,20 @@
50 50
 
51 51
 (defun parse-metadata (stream)
52 52
   "Given a STREAM, parse metadata from it or signal an appropriate condition."
53
-  (flet ((parse-field (str)
54
-           (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+:\\s+(.*)" str)))
55
-         (field-name (line)
56
-           (make-keyword (string-upcase (subseq line 0 (position #\: line))))))
57
-    (unless (string= (read-line stream nil) (separator *config*))
58
-      (error "The provided file lacks the expected header."))
59
-    (loop for line = (read-line stream nil)
53
+  (labels ((get-next-line (input)
54
+             (string-trim '(#\Space #\Newline #\Tab) (read-line input nil)))
55
+           (parse-value (str)
56
+             (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+:\\s+(.*)" str)))
57
+           (parse-initarg-name (line)
58
+             (make-keyword (string-upcase (subseq line 0 (position #\: line)))))
59
+           (extract-initarg (line)
60
+             (list (parse-initarg-name line) (aref (parse-value line) 0))))
61
+    (unless (string= (get-next-line stream) (separator *config*))
62
+      (error "The file lacks the expected header: ~a" (separator *config*)))
63
+    (loop for line = (get-next-line stream)
60 64
        until (string= line (separator *config*))
61
-       appending (list (field-name line)
62
-                       (aref (parse-field line) 0)))))
65
+       when (parse-value line)
66
+       appending (extract-initarg line))))
63 67
 
64 68
 (defun read-content (file)
65 69
   "Returns a plist of metadata from FILE with :text holding the content."