README.md (12068 bytes)
1 # README 2 3 4 ## Introduction 5 6 cl-yag is a lightweight, static site generator that produces **gopher** 7 and **gemini** sites (and is easily extensible to more formats) as 8 well as **html** websites. The name 'cl-yag' stands for 'Common Lisp 9 - Yet Another website Generator'. It runs without needing Quicklisp 10 (Common LISP library manager). 11 12 13 ## Showcase 14 15 I am using cl-yag to create and maintain my websites in the 16 world-wide-web (visit: *[Solene's percent] 17 (https://dataswamp.org/~solene/)*) as well as [in gopher-space] 18 (gopher://dataswamp.org/1/~solene/). 19 20 21 MASSIVE CHANGE CRAZINESS TOO MUCH (see desc) 22 23 For your testing pleasure. I'm planning to send this up as multiple 24 atomic commits. There are probably some bugs. 25 26 - Add an asdf system 27 - Plug and play/backward compatible (generator.lisp and 28 data/artcles.lisp don't need to be moved or anything) 29 This makes the generators/ directory where new generators can be added. 30 - Generators are now completely separate from the rest of the project 31 (see the generators directory). Adding new ones is as simple as addin 32 the file, registering a new generator in data/articles, and adding the 33 file to the asdf definition so it gets loaded. 34 - Bugfix: :if-does-not-exist :create it 35 - Makefile: changes: split it up in there so it is possible to build 36 smaller bits ad needed. 37 - Makefile: Added all the lisps in order of good-ness to search for. 38 - quit command/portability fix: used Clocc's quit commnd to make the 39 program portable. 40 41 ## Requirements 42 43 To use cl-yag you'll need: 44 45 1. Any Common Lisp Interpreter and the ASDF package system 46 - cl-yag's current default is [Embeddable Common Lisp (ECL)](https://common-lisp.net/project/ecl/). 47 - [Steel Bank Common Lisp (SBCL)](http://www.sbcl.org/) will do fine as well. 48 49 2. A Converter for arbitrary formats 50 - cl-yag's current default is [multimarkdown](http://fletcherpenney.net/multimarkdown/). 51 - pandoc could work fine too 52 - each post can have its own converter as needed (great if importing your site from elsewhere) 53 54 ## Usage 55 56 Go into your project's directory and type ``make``. You'll find your 57 new website/gopher/gemini page in **output/**. If you want to get rid 58 of everything in your **output/** sub directories, type ``make clean``. 59 For further commands: read the Makefile. Read in the following section 60 where to find it. 61 62 It is necessary to edit the ``data/articles.lisp`` file which is the 63 user configuration for the site. 64 65 66 ## Overview: cl-yag's File Hierarchy 67 68 After cloning the repository, your project's directory should contain at 69 least the following files and folders: 70 71 . 72 |-- LICENSE 73 |-- Makefile 74 |-- README.md 75 |-- data/ 76 | |-- 1.md 77 | |-- README.md 78 | `-- articles.lisp 79 |-- generator.lisp 80 |-- output/ 81 | |-- gopher/ 82 | `-- html/ 83 |-- static/ 84 | |-- css/style.css 85 | `-- img/ 86 `-- templates/ 87 |-- article.tpl 88 |-- gopher_head.tpl 89 |-- layout.tpl 90 |-- one-tag.tpl 91 |-- rss-item.tpl 92 `-- rss.tpl 93 94 - **Makefile** 95 - This file exists to simplify the recurring execution of frequently used commands. 96 - **generator.lisp** 97 - This is cl-yag's deploying script. 98 - **generators-util,generator-aux-pre.lisp,generator-aux.lisp** 99 - This is the core library, split into multiple files so things are loaded in the right order. 100 - **cl-yag.asd** 101 - This is the definition of the system. Useful for adding new generators and seeing the order files are loaded. 102 - **generators/(...).lisp** 103 - The output generators. Contribute new ones! 104 - **static/** 105 - This directory holds content, that needs to be published without being changed (e.g. style sheets, js-scripts). 106 - If you come from 'non-static CMS'-Country: **static/** holds, what you would put in your **assets/** directory. 107 - **templates/** 108 - The templates in this directory provide the structural skeleton(s) of the web pages and feeds you want to create. 109 - **output/** 110 - cl-yag puts in this directory everything ready to get deployed. 111 - Because cl-yag generates not only HTML, but gopher-compliant pages as well, **output/** **holds two sub directories**. 112 - **gopher/** contains the website for gopher, 113 - **html/** contains the website in HTML. 114 115 And there is the **data/** directory, which is important enough to get a subsubsection of its own. 116 117 ### The data/ Directory 118 119 This directory is crucial for the usage of cl-yag. 120 121 **data/** contains 122 123 - the **articles.lisp** configuration file, which defines important meta-data for posts and pages. 124 - It also holds **${id}.md** files, which are holding your posts' (or pages') content. You can use markdown to write them. 125 126 For more information: Read section 'Configuration'. 127 128 129 ## Configuration 130 131 cl-yag's main configuration file is **data/articles.lisp**. 132 In order to have a running implementation of cl-yag, you have 133 to set most of the values in this file. 134 135 **data/articles.lisp** has two parts: 136 137 1. A variable called *config*. Its values define your web page. 138 2. "posts" declaration with their meta-data 139 140 Values are assigned by placing a string (e.g. ``"foo"``) or a boolean 141 (i.e. ``t`` or ``nil``) behind a keyword (e.g. ``:title``). 142 143 144 ### The *config* Variable 145 146 The *config* variable is used to assign the following values: 147 148 - **:webmaster** 149 - The name of the default(!) author. 150 - ``:webmaster`` gets used, if ``:author`` is omitted. (See below: 'The **articles** variable'.) 151 - **:title** 152 - The title of the web-page 153 - **:description** 154 - This text is used in the *description* field of the atom/rss feed. 155 - **:url** 156 - This needs to be the full(!) URL of your website, including(!) a final slash. 157 - MIND: If the url contains a tilde (~), it needs to get duplicated. 158 - Example: ``https://mydomain/~~user/`` 159 - **:rss-item-number** 160 - This holds the number of latest(!) RSS items you want to get published. 161 - **html** 162 - ``t`` to export html website. Set ``nil`` to disable. 163 - **gopher** 164 - ``t`` to export gopher website. Set ``nil`` to disable. 165 - **gopher-path** 166 - This is the full path of the directory to access your gopher hole. 167 - **gopher-server** 168 - Hostname of the gopher server. It needs to be included in each link. 169 - **gopher-port** 170 - tcp port of the gopher server. 70 is the default port. It needs to be included in each link. 171 - **gopher-format** 172 - format of the gopher server. default is the geomyidae format, gophernicus format is commented. 173 - **gopher-index** 174 - name of the gopher menu file. default is index.gph for geomyidae, gophermap file is commented. 175 176 177 ### Posts declarations 178 179 Each post is declared with its meta-data using the function "post". 180 So you need to add a new line for each of your posts. 181 182 Of the following keywords, only ``:author`` and ``:short`` can be omitted. 183 184 - **:author** 185 - The ``:author`` field is used to display the article's author. 186 - If you omit it, the generator will take the name from the ``:webmaster`` field of the *config* variable. 187 - **:id** 188 - The ``:id`` field holds the file name of your post/page. 189 - Example: ``:id "2"`` will load file **data/2.md**. Use text instead of numbers, if you want to. 190 - (See section: 'The **data/** Directory'.) 191 - **:tag** 192 - ``:tag`` field is used to create a "view" containing all articles of the same tag. 193 - MIND: White spaces are used to separate tags and are not allowed in(!) tags. 194 - **:tiny** 195 - The ``:tiny`` field's value is used for displaying a really short description of the posts content on your homepage. 196 - If ``:tiny`` doesn't get a value, the full article gets displayed. 197 - Hint: Use ``:tiny "Read the full article for more information."``, if you don't want to display the full text of an article on your index site. 198 - **:title** 199 - The ``:title`` field's value sets your post's title, its first headline, as well as its entry on the index.html. 200 201 ### Generator registering 202 203 Each generator is registered in the user config. To not generate something, just comment out the registry for that 204 generator. 205 206 207 ## How-to Create A New Post 208 209 Edit **data/articles.lisp** and add a new list to the *articles* variable: 210 211 (list :title "How do I use cl-yag" 212 :id "2" 213 :date "29 April 2016" 214 :author "Solène" 215 :tiny "Read more about how I use cl-yag." 216 :tag "example help code") 217 218 Then write a corresponding **data/2.md** file, using markdown. 219 220 221 ## How-to Publish A Post 222 223 I prepared a Makefile to facilitate the process of generating and 224 publishing your static sites. 225 All you need to do in order to publish is to go into your cl-yag 226 directory and type ``make``. 227 228 The make command creates html and gopher files in the defined location. 229 The default is the **output/** directory, but you can use a symbolic link 230 pointing to some other directory as well. 231 232 233 ## How-to Add A New Page 234 235 You may want to have some dedicated pages besides the index or a post. 236 To create one, edit the *generate-site* function in cl-yag's 237 **generator.lisp** and add a function call, like this: 238 239 (generate "somepage.html" (load-file "data/mypage.html")) 240 241 This will produce **output/html/somepage.html**. 242 243 244 ## Further Customization 245 246 ### How-to Use Another Common Lisp Interpreter 247 248 cl-yags default Lisp interpreter is **sbcl**. If you want to use a 249 different interpreter you need to set the variable *LISP* to the name 250 of your binary, when calling ``make``: 251 252 make LISP=ecl 253 254 255 ### Using git Hooks For Publishing 256 257 You may customize your publishing-process further, e.g. by using a git 258 hook to call the make program after each change in the repo so your 259 website gets updated automatically. 260 261 262 ## Page-Includes 263 264 Here is an example code, if you want to include another page in the template: 265 266 1. Create **templates/panel.tpl** containing the html you want to include. 267 2. Add a replacement-string in the target file, where the replacement should occur. 268 In this case, we choose **%%Panel%%** for a string, and, because we want the panel to be displayed on each page, we add this string to **templates/layout.tpl**. 269 270 3. Modify the function *generate-layout* in cl-yag's **generator.lisp** accordingly. 271 This is done by adding the following template function call: 272 273 (template "%%Panel%%" (load-file "templates/panel.tpl")) 274 275 Another valid approach is to writer your html directly into **templates/layout.tpl**. 276 277 ## Known Limitations 278 279 ### Use ~~ To Create ~ 280 281 cl-yag crashes if you use a single "~" character inside 282 **templates/articles.lisp**, because Common Lisp employs the tilde as a 283 prefix to indicate format specifiers in format strings. 284 285 In order to use a literal `~` -- e.g. for creating a ``:title`` or 286 ``:url`` reference -- you have to *escape* the tilde *by 287 duplicating* it: ``~~``. (See ``:url`` in section 'Configuration'). 288 289 290 ### Posting Without Tagging 291 292 cl-yag allows posts without tags, but, using the default 293 **templates/layout.tpl**, you'll get a line below your title that 294 displays: "Tags: ". 295 296 (Note: If you are looking for a way to contribute this may be a task for you.) 297 298 299 ### A Note On Themes 300 301 Although cl-yag may ship with a minimalist template, cl-yag focuses 302 on generating html- and gopher-compliant structural markup - not 303 themed layouts. 304 305 If you want some deeply refined, cross-browser compatible, responsive, 306 webscale style sheets, you need to create them yourself. However, 307 cl-yag will work nicely with them and if you want to make your 308 style sheets a part of cl-yag you're very welcome to contact me. 309 310 ### New Generators 311 312 1. Add a lisp file to generators/ which does the necessary work. See the other ones for comparison. 313 2. Add it to the **cl-yag.asd** file with the other generators (order is important). 314 3. `register` it in **data/articles.lisp** 315 4. Contribute it. 316 317 318 # Hacking cl-yag 319 320 I tried to make cl-yag easy to extend. 321 If you want to contribute, feel free to contact me and/or to send in a patch. 322 323 - If you are looking for a way to contribute: 324 - You could find a way to "sanitize" cl-yag's behaviour regarding the tilde (see: above); 325 - Also see: 'Note' in 'Posting Without Tagging'; 326 - Also see: 'A Note On Themes'. 327