Browse code
chore: extract intercooler-specific classes
Ed Langley authored on 17/04/2020 07:58:39
Showing 2 changed files
Showing 2 changed files
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
1 |
+(cl:in-package :cl-user) |
|
2 |
+(defpackage :fwoar.intercooler |
|
3 |
+ (:use :cl ) |
|
4 |
+ (:import-from :fw.lu defclass+) |
|
5 |
+ (:import-from :araneus controller) |
|
6 |
+ (:export #:partial-request |
|
7 |
+ #:full-request |
|
8 |
+ #:intercooler-route |
|
9 |
+ #:intercooler-request |
|
10 |
+ #:request)) |
|
11 |
+(in-package :fwoar.intercooler) |
|
12 |
+ |
|
13 |
+(defclass+ intercooler-request () |
|
14 |
+ ((%request :initarg :request :reader request))) |
|
15 |
+(defclass+ partial-request ((intercooler-request (request))) |
|
16 |
+ ()) |
|
17 |
+(defclass+ full-request ((intercooler-request (request))) |
|
18 |
+ ()) |
|
19 |
+(defclass intercooler-route () |
|
20 |
+ ()) |
|
21 |
+(defmethod controller :around ((route intercooler-route) params &key) |
|
22 |
+ (funcall (if (equal (serapeum:assocdr "ic-request" params |
|
23 |
+ :test 'equal) |
|
24 |
+ "true") |
|
25 |
+ 'partial-request |
|
26 |
+ 'full-request) |
|
27 |
+ (call-next-method))) |
... | ... |
@@ -6,19 +6,12 @@ |
6 | 6 |
(defclass rss-reader-route () |
7 | 7 |
((%feed-list :initarg :feed-list :reader feed-list))) |
8 | 8 |
|
9 |
-(defclass+ intercooler-request () |
|
10 |
- ((%request :initarg :request :reader request))) |
|
11 |
-(defclass+ partial-request ((intercooler-request (request))) |
|
12 |
- ()) |
|
13 |
-(defclass+ full-request ((intercooler-request (request))) |
|
14 |
- ()) |
|
15 |
- |
|
16 | 9 |
(defmethod araneus:view :around ((route rss-reader-route) model) |
17 | 10 |
"basic html and javascript for our app, as well as an invocation of |
18 | 11 |
the hook that pulls in CSS" |
19 | 12 |
|
20 | 13 |
(etypecase model |
21 |
- (full-request |
|
14 |
+ (fwoar.intercooler:full-request |
|
22 | 15 |
(spinneret:with-html-string |
23 | 16 |
(:doctype) |
24 | 17 |
(:html |
... | ... |
@@ -36,7 +29,7 @@ the hook that pulls in CSS" |
36 | 29 |
(araneus:styles route))))) |
37 | 30 |
(:body |
38 | 31 |
(call-next-method))))) |
39 |
- (partial-request |
|
32 |
+ (fwoar.intercooler:partial-request |
|
40 | 33 |
(spinneret:with-html-string |
41 | 34 |
(call-next-method))))) |
42 | 35 |
|
... | ... |
@@ -47,7 +40,7 @@ the hook that pulls in CSS" |
47 | 40 |
:margin 0 |
48 | 41 |
:padding 0 |
49 | 42 |
:font-family "\"Lato\", sans" |
50 |
- :box-sizing border-box) |
|
43 |
+ :box-sizing border-box) |
|
51 | 44 |
((:or pre code) |
52 | 45 |
:font-family "\"Source Code Pro\", monospace") |
53 | 46 |
(body |
... | ... |
@@ -67,24 +60,22 @@ the hook that pulls in CSS" |
67 | 60 |
(,layout content))) |
68 | 61 |
(:partial (funcall content))))) |
69 | 62 |
|
70 |
-(defclass+ feed-page ((rss-reader-route (feed-list)) fwoar.default-layout:default-layout) |
|
63 |
+ |
|
64 |
+(defclass+ feed-page ((rss-reader-route (feed-list)) |
|
65 |
+ fwoar.intercooler:intercooler-route |
|
66 |
+ fwoar.default-layout:default-layout) |
|
71 | 67 |
((%feed :initarg :feed :reader feed))) |
72 | 68 |
|
73 | 69 |
(defmethod araneus:controller ((route feed-page) params &key) |
74 |
- (funcall (if (equal (serapeum:assocdr "ic-request" params |
|
75 |
- :test 'equal) |
|
76 |
- "true") |
|
77 |
- 'partial-request |
|
78 |
- 'full-request) |
|
79 |
- (resolve-feed-reference (feed route)))) |
|
70 |
+ (resolve-feed-reference (feed route))) |
|
80 | 71 |
|
81 |
-(defmethod araneus:view ((route feed-page) (model intercooler-request)) |
|
72 |
+(defmethod araneus:view ((route feed-page) (model fwoar.intercooler:intercooler-request)) |
|
82 | 73 |
(spinneret:with-html |
83 | 74 |
(:main#content |
84 |
- (alimenta:render (request model) |
|
75 |
+ (alimenta:render (fwoar.intercooler:request model) |
|
85 | 76 |
(feed route))))) |
86 | 77 |
|
87 |
-(defmethod araneus:view ((route feed-page) (model full-request)) |
|
78 |
+(defmethod araneus:view ((route feed-page) (model fwoar.intercooler:full-request)) |
|
88 | 79 |
(spinneret:with-html |
89 | 80 |
(:h1 "Hello, World!") |
90 | 81 |
(:div.main |
... | ... |
@@ -96,7 +87,7 @@ the hook that pulls in CSS" |
96 | 87 |
collect (:a :data-ic-get-from (format nil "/f/~a" (string-downcase (feed-key feed))) |
97 | 88 |
(feed-key feed)))) |
98 | 89 |
(:main#content |
99 |
- (alimenta:render (request model) |
|
90 |
+ (alimenta:render (fwoar.intercooler:request model) |
|
100 | 91 |
(feed route)))))) |
101 | 92 |
|
102 | 93 |
(defmethod fwoar.default-layout:border-color ((layout rss-reader-route)) |