-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new-site command-line utility.
- Loading branch information
1 parent
9710473
commit 2e4de7d
Showing
8 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
;;; -*- mode : lisp -*- | ||
(in-package #:staticl-user) | ||
|
||
;; This way you can load all required plugins, | ||
;; which are not included into the Staticl system: | ||
(asdf:load-system "staticl/format/spinneret") | ||
|
||
(site "{{title}}" | ||
:description "{{description}}" | ||
:url "{{url}}" | ||
:navigation (menu (item "Blog" "/blog/") | ||
(item "About" "/about/")) | ||
:pipeline (list (load-content) | ||
(prev-next-links) | ||
(paginated-index :target-path "blog/") | ||
(rss :target-path "blog/rss.xml") | ||
(atom :target-path "blog/atom.xml") | ||
(tags-index :target-path "tags/") | ||
(sitemap)) | ||
:theme "readable") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
;;;;; | ||
title: About this site | ||
created-at: 2024-03-30 | ||
format: spinneret | ||
;;;;; | ||
|
||
(:h2 "Subtitle") | ||
|
||
(:p "This is an example of a page written using Spinneret. It's main advantage is an ability to use Lisp for HTML generation.") | ||
(:p "You can execute any code to get data for the page - access a database or some API. Note that these actions will be performed | ||
during the build stage and site itself will remain static.") | ||
(:p "Using Spinneret you can use any HTML markup. If you want to draw a red square, you just do it:") | ||
|
||
(:div :style "width: 200px; height: 200px; background: red;") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
;;;;; | ||
title: The first post | ||
tags: example, foo | ||
created-at: 2024-04-15 | ||
format: md | ||
;;;;; | ||
|
||
This post contains some *Markdown* markup. | ||
|
||
<!--more--> | ||
|
||
Following part only visible on the post page, not in the indices. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
;;;;; | ||
title: The second post | ||
tags: example, bar | ||
created-at: 2024-04-30 | ||
format: md | ||
;;;;; | ||
|
||
Another post. StatiCL is more versatile than Coleslaw, because of it's modular architecture. | ||
|
||
<!--more--> | ||
|
||
Following part only visible on the post page, not in the indices. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
;;;;; | ||
title: An index page. | ||
created-at: 2024-03-30 | ||
format: md | ||
;;;;; | ||
|
||
This is a front page of example site. The site uses StatiCL generator written in Common Lisp. | ||
|
||
Blog posts are available at [/blog/](/blog/). There is also an [/about/](/about/) page. | ||
|
||
The blog has an rss feed, and all pages are gathered into a | ||
single [sitemap.xml](/sitemap.xml) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(uiop:define-package #:staticl/skeleton | ||
(:use #:cl) | ||
(:import-from #:serapeum | ||
#:->) | ||
(:import-from #:mystic.template.file | ||
#:file-mixin) | ||
(:import-from #:mystic | ||
#:make-option) | ||
(:import-from #:mystic.util | ||
#:read-template-file) | ||
(:import-from #:mystic.template.file | ||
#:file) | ||
(:export | ||
#:create-site)) | ||
(in-package #:staticl/skeleton) | ||
|
||
|
||
(defclass staticl-site (file-mixin) | ||
() | ||
(:default-initargs | ||
:options (list (make-option :title | ||
"Title" | ||
"The site's title." | ||
:requiredp t) | ||
(make-option :description | ||
"Description" | ||
"The site's description." | ||
:requiredp t) | ||
(make-option :url | ||
"URL" | ||
"The site's URL." | ||
:requiredp t)))) | ||
|
||
|
||
(defun read-all-files (from-dir) | ||
(loop with from-dir = (uiop:ensure-directory-pathname from-dir) | ||
for filename in (directory (uiop:wilden from-dir)) | ||
for relative-path = (enough-namestring filename from-dir) | ||
unless (uiop:directory-pathname-p filename) | ||
collect | ||
(make-instance 'file | ||
:path relative-path | ||
:content (alexandria:read-file-into-string filename)))) | ||
|
||
|
||
(-> create-site ((or pathname string) string string &key (:description string)) | ||
(values &optional)) | ||
|
||
(defun create-site (path title url &key (description "")) | ||
"Creates a new site skeleton with a few posts." | ||
(let ((files (read-all-files | ||
(asdf:system-relative-pathname :staticl | ||
(make-pathname | ||
:directory '(:relative "skeleton")))))) | ||
(mystic:render | ||
(make-instance 'staticl-site | ||
:files files) | ||
(list :title title | ||
:url url | ||
:description description) | ||
(uiop:merge-pathnames* | ||
(uiop:ensure-directory-pathname path))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters