git.fiddlerwoaroof.com
Browse code

feature: add hooks for routing and styling

Ed Langley authored on 12/09/2019 07:25:13
Showing 2 changed files
... ...
@@ -16,7 +16,18 @@
16 16
                    renders the model picked out by the controller. Normally, this is
17 17
                    specialized using the DEFINE-VIEW macr"))
18 18
 
19
+
20
+(defgeneric styles (route)
21
+  (:documentation "if you use class-based roues, this method provides
22
+  a hook for generating CSS files with the most specific selectors
23
+  last: it returns a list via the APPEND method complication, suitable
24
+  for use with a system like lass <https://shinmera.github.io/LASS>")
25
+  (:method-combination append :most-specific-last))
26
+
19 27
 (defgeneric routes (app)
28
+  (:documentation "defines routes for some object that represents an
29
+  app: PROGN method combination, with an around method that ensures
30
+  that this returns the app.")
20 31
   (:method-combination progn)
21 32
   (:method :around (app)
22 33
     (call-next-method)
... ...
@@ -27,9 +38,8 @@
27 38
    ((\"/path/to/{route}\" :method :POST) route-callback) the AS-ROUTE macro helps one
28 39
    avoid binding function values to the route for flexibility."
29 40
   (alexandria:once-only (app)
30
-    `(setfs
31
-       ,@(loop for ((target &key method) callback) in routes
32
-               collect `((ningle:route ,app ,target :method ,(or method :GET)) ,callback)))))
41
+    `(setf ,@(loop for ((target &key method) callback) in routes
42
+                   append `((ningle:route ,app ,target :method ,(or method :GET)) ,callback)))))
33 43
 
34 44
 
35 45
 (defvar *view-name*)
... ...
@@ -2,12 +2,13 @@
2 2
 
3 3
 (defpackage #:araneus
4 4
   (:use #:cl #:fw.lu)
5
-  (:export #:defroutes  #:as-route  #:define-controller #:define-view    
6
-           #:controller #:view      #:run-route #:mustache-view    
7
-           #:render-mustache        #:define-spinneret-view
8
-           #:setf1      #:call-current-view
9
-           #:routes))
5
+  (:export #:defroutes             #:as-route        #:define-controller
6
+           #:define-view           #:controller      #:view
7
+           #:run-route             #:mustache-view   #:render-mustache
8
+           #:define-spinneret-view #:setf1           #:call-current-view
9
+           #:routes #:styles))
10 10
 
11
+#+fw.dev
11 12
 (defpackage #:araneus-2
12 13
   (:use #:cl #:fw.lu)
13 14
   (:export #:defroutes  #:as-route  #:define-controller #:define-view