Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-bloggy Reference Manual, version 0.0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 12:05:35 2020 GMT+0.
• Introduction | What cl-bloggy is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
This library implements a simple but highly extensible plugin blogging system for Hunchentoot.
It uses its own custom handler to add routes but but you can still use hunchentoots define-easy-handler.
To get started you need to start up hunchentoot with a new acceptor called 'bloggy- acceptor'
(defparameter *server* (make-instance 'bloggy-acceptor
:blog (make-instance 'blog
:title "Main")
:document-root "./"
:port 4203 :name 'main))
You can see a new initarg called :blog this must be an instance of 'blog or a subclass of blog.
Next add the main blog page and the main index page
(add-blog)
(add-index 'blog-index)
This will produce two pages, one at *blog-root-directory* (default "/blog/") and *blog-index-directory* (default "/blog/index") which you can browse but you will not see much (the argument 'blog-index is provided as it is the class being instantiated, this will come in handy later when learning how to customize the blog).
Next we must add a simple entry using easy-blog-entry
This macro accepts 5 arguments, the first is the class of the blog-entry you want
to create, the next the category, the next the title of the entry the fourth is the
hunchentoot server, and the last and most important variable is a form that
would be valid when passed to spinnerets 'with-html'. Here is an example:
(easy-blog-entry (blog-entry "general" "entry1" *server*)
(:div :class "elp"
(:h1 "A story to tell")
(:p "once upon a time in a land far away")))
As you can see /blog/ and /blog/index have changed.
and the index:
Because this library is built from top to bottom using generic functions it is very easy to modify the behaviour of this library, I will walk you through a few examples of how to do this.
First lets take a look at how we would customize an aspect of how a blog-entry is rendered; this is done by calling these methods in this specific order:
Each of these methods can be specialized for your own subclass in order to customize the behaviour of any of these aspects.
Say for example you wished to add a custom footer for an entry, to do this you would first create a subclass of blog-entry
(defclass new-blog-entry (blog-entry)
())
Then you simply create a new version of html-footer for your new class, specialize html-footer and create a new entry passing new-blog-entry as the first argument to easy-blog-entry.
(defmethod html-footer ((entry new-blog-entry))
(spinneret:with-html
(:p "i'm a different footer!!")))
(easy-blog-entry (new-blog-entry "general" "entryboof" *server*)
(:p "im a new entry"))
You will notice that you have to use spinneret to modify the HTML, thats because at every step in the HTML rendering spinneret:with-html is called, so you must do the same for your variant. If we compile and browse to /blog/general/entryboof we will see:
If you wish to customize the default blog page then simply change the (make-instance ) when creating your hunchentoot server to a subclass of 'blog where you have created your own version of the methods in the HTML rendering pipeline.
This is quite easy, the last method called in html-headers is a method called to-css this method adds inline CSS to the document to control the styling. It is quite easy to overwrite this using the same technique as above, simply create your own subclass of what you wish to modify and add your CSS like so:
(defclass new-blog-entry2 (blog-entry)
((css-rules
:initform '(()))));; removing the default CSS rules
now the default version of to-css for blog-entry and blog (so subsequently blog-index as this is a subclass of blog) simply renders the contents of the slot css-rules and returns that:
(defmethod to-css ((entry blog-entry))
(spinneret:with-html
(:style :type "text/css"
(apply #'lass:compile-and-write (css-rules entry)))))
Both blog, blog-entry and blog-index have default CSS which can be found in *blog-css-rules* *blog-entry-css* and *index-css-rules* respectively, these will serve as examples (see /src/generate-css.lisp) for you to follow on how to properly form the CSS; the CSS is all written using Shinmeras LASS, so you must make (css-rules ..) a list of lists. To understand which classes/id's are used when generating the HTML see /src/generate-html.lisp and browse through the spinneret forms to see what you can modify, *blog-entry-css-rules* also contains all the ids for each main part of an entry.
I will finish with one final example of how you would go about changing the default behaviour of the blog; by default entries are listed from newest to oldest, I will quickly show you how to list them from oldest to newest.
The functionality for controlling the listing of entries is within the method html-body the default is:
(defmethod html-body ((blog blog))
(spinneret:with-html
(:div :id "all-entries"
(dolist (blog (sort (entries blog) #'> :key #'creation-date-universal))
(:div :class "entry"
:id (id blog)
(html-body blog))))))
So we want to reverse the order of listing, this is very simple as you can see all we are doing is creating a div and within it listing all of the entries contained within the object 'blog', but we are sorting this list by the key #'creation-date-universal, so to modify this functionality we will create the following method on our own subclass of blog called new-blog here:
(defmethod html-body ((blog new-blog))
(spinneret:with-html
(:div :id "all-entries"
(dolist (blog (sort (entries blog) #'< :key #'creation-date-universal))
(:div :class "entry"
:id (id blog)
(html-body blog))))))
Now with the new blog you will have to modify the 'blog within your *server* instance to a new instance using new-blog instead of the default blog.
I hope this helps.
Take a look at /src/test-server.lisp for a few examples.
Take a look at /src/generate-html.lisp to see how the default behaviour is implemented.
To modify the index page, subclass blog-index and call (make-index ..) with your version of blog-index.
MIT
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The cl-bloggy system |
K1D77A
MIT
A simple extendable blogging system to use with Hunchentoot
0.0.1
cl-bloggy.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The cl-bloggy/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
/home/quickref/quicklisp/dists/quicklisp/software/cl-bloggy-20201220-git/cl-bloggy.asd
cl-bloggy (system)
Next: The cl-bloggy/classes⅋conditions․lisp file, Previous: The cl-bloggy․asd file, Up: Lisp files [Contents][Index]
Next: The cl-bloggy/hunchentoot-handler․lisp file, Previous: The cl-bloggy/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
cl-bloggy (system)
classes&conditions.lisp
Next: The cl-bloggy/generate-css․lisp file, Previous: The cl-bloggy/classes⅋conditions․lisp file, Up: Lisp files [Contents][Index]
classes&conditions.lisp (file)
cl-bloggy (system)
hunchentoot-handler.lisp
Next: The cl-bloggy/generate-html․lisp file, Previous: The cl-bloggy/hunchentoot-handler․lisp file, Up: Lisp files [Contents][Index]
hunchentoot-handler.lisp (file)
cl-bloggy (system)
generate-css.lisp
Next: The cl-bloggy/cl-bloggy․lisp file, Previous: The cl-bloggy/generate-css․lisp file, Up: Lisp files [Contents][Index]
generate-css.lisp (file)
cl-bloggy (system)
generate-html.lisp
Previous: The cl-bloggy/generate-html․lisp file, Up: Lisp files [Contents][Index]
generate-html.lisp (file)
cl-bloggy (system)
cl-bloggy.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The cl-bloggy package |
package.lisp (file)
bloggy
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported generic functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
The default LASS used to render the main blog page
generate-css.lisp (file)
The default LASS used by each the class ’blog-entry’
generate-css.lisp (file)
The default LASS used to render the main blog index.
generate-css.lisp (file)
Next: Exported classes, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
automatically generated reader method
hunchentoot-handler.lisp (file)
automatically generated writer method
hunchentoot-handler.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
Appends a few CSS links to the render pipeline
generate-html.lisp (file)
Appends a font to the render pipeline
generate-html.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
An amalgamation of title and category
classes&conditions.lisp (file)
Adds specific CSS to the render pipeline. Create your own version of this method for your own subclass to append stylesheets
generate-html.lisp (file)
Adds specific footer to the render pipeline. Create your own version of this method for your own subclass to modify the footer
generate-html.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
automatically generated reader method
classes&conditions.lisp (file)
automatically generated writer method
classes&conditions.lisp (file)
to-css simply appends a the CSS as an inline style tag. See (css-rules e) for the list of CSS, the CSS is infact a list of LASS rules
generate-css.lisp (file)
The entry function used to create HTML pages. This method calls ’html-headers’ html-body’ and ’html-footer’ in that order in order to render a page. You can create your own version of this method to modify the functionality for your own subclasses the same goes for the three methods it calls.
generate-html.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
classes&conditions.lisp (file)
standard-object (class)
blog-index (class)
list
entries (generic function)
(setf entries) (generic function)
cl-bloggy:*blog-css-rules*
css-rules (generic function)
(setf css-rules) (generic function)
string
:title
"main page"
title (generic function)
(setf title) (generic function)
classes&conditions.lisp (file)
standard-object (class)
string
:category
category (generic function)
(setf category) (generic function)
(cl-bloggy::minute-day-month-year-now nil)
creation-date (generic function)
(get-universal-time)
creation-date-universal (generic function)
(setf creation-date-universal) (generic function)
cl-bloggy:*blog-entry-css-rules*
css-rules (generic function)
(setf css-rules) (generic function)
string
:title
title (generic function)
(setf title) (generic function)
An amalgamation of title and category
string
:id
id (generic function)
function
:content
content (generic function)
(setf content) (generic function)
classes&conditions.lisp (file)
blog (class)
cl-bloggy:blog
:blog
blog (generic function)
(setf blog) (generic function)
cl-bloggy:*index-css-rules*
css-rules (generic function)
(setf css-rules) (generic function)
hunchentoot-handler.lisp (file)
easy-acceptor (class)
routes (generic function)
(setf routes) (generic function)
:blog
blog (generic function)
(setf blog) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal macros | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal types |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
classes&conditions.lisp (file)
classes&conditions.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
Takes BLOG-CLASS (a subclass of ’blog-entry’ or an instance of blog-entry)
and creates a new page at the url ’*blog-root-directory*/CATEGORY/TITLE’.
You can add this to any arbitrary running instance of hunchentoot as long as it was
initiated using a subclass of the acceptor bloggy-acceptor. You can use the
variable ’let-bindings-to-override-global-vars’ to modify any global variable
used in the render pipeline however I recommend you simply create subclass and
specialize methods on that subclass instead. BODY must be valid spinneret code, it
is an implicit (spinneret:with-html ,@body ) so you can enter any arbitrary HTML
using spinneret, use wisely.
cl-bloggy.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
Initializes the main blog page at PATH
cl-bloggy.lisp (file)
Initializes the main blog index at PATH
cl-bloggy.lisp (file)
downcases, replaces spaces with hyphens and removes white space
classes&conditions.lisp (file)
classes&conditions.lisp (file)
classes&conditions.lisp (file)
hunchentoot-handler.lisp (file)
classes&conditions.lisp (file)
hunchentoot-handler.lisp (file)
Next: Internal types, Previous: Internal functions, Up: Internal definitions [Contents][Index]
classes&conditions.lisp (file)
Adds a route to your acceptor, the acceptor is what you used to start hunchentoot
hunchentoot-handler.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
generate-html.lisp (file)
classes&conditions.lisp (file)
This method produces a URL used to refer to a blog entry
cl-bloggy.lisp (file)
hunchentoot-handler.lisp (file)
automatically generated reader method
hunchentoot-handler.lisp (file)
automatically generated writer method
hunchentoot-handler.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
hunchentoot-handler.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L |
---|
Jump to: | C F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
A B C E F G H I M N R S T |
---|
Jump to: | (
A B C E F G H I M N R S T |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
B C E I R S T |
---|
Jump to: | *
B C E I R S T |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | B C P R S T |
---|
Jump to: | B C P R S T |
---|