git.fiddlerwoaroof.com
Browse code

cleaning up and restyling.

fiddlerwoaroof authored on 22/05/2016 19:34:08
Showing 8 changed files
... ...
@@ -1,3 +1,5 @@
1 1
 - Make get-dao-for leave id unbound in rss-feeds
2 2
 
3
-- Implement sorting by pub date, rather than by id --- or someting
3
+- Implement sorting by pub date, rather than by id --- or something
4
+- Switch html to spinneret
5
+
... ...
@@ -1 +1 @@
1
-Subproject commit 15a9ca8dd67e8033bd62b559ffee86606fc67e9d
1
+Subproject commit f693da364ea32b34bdd2a3dcce442d565ea8a1d5
... ...
@@ -1,30 +1,22 @@
1 1
 (in-package :cl-user)
2 2
 (ql:quickload :clack-middleware-postmodern)
3 3
 
4
-(ql:quickload :fwoar.lisputils)
5
-(ql:quickload :araneus)
6
-(ql:quickload :cl-markup)
7
-(ql:quickload :colors)
8
-(ql:quickload :lquery)
9
-(ql:quickload :plump)
10
-(ql:quickload :postmodern)
11
-(ql:quickload :sxql)
12
-(ql:quickload :clack-middleware-postmodern)
13
-(ql:quickload :dexador)
14
-(ql:quickload :spinneret)
15
-(ql:quickload :ubiquitous)
16
-(ql:quickload :iterate)
17
-(ql:quickload :jonathan)
18
-(ql:quickload :cl-actors)
19
-(ql:quickload :simple-tasks)
20
-(ql:quickload :cl-oid-connect)
21
-(ql:quickload :fwoar.lisputils)
4
+(ql:quickload '(:fwoar.lisputils :araneus :cl-markup :colors :lquery :plump :postmodern
5
+                :sxql :clack-middleware-postmodern :dexador :spinneret :ubiquitous :iterate
6
+                :jonathan :cl-actors :simple-tasks :cl-oid-connect :fwoar.lisputils))
22 7
 
23 8
 (declaim (optimize (speed 0) (safety 3) (debug 2)))
24 9
 
25
-(push (cons "application" "rdf+xml") drakma:*text-content-types*)
26
-(push (cons "application" "rss+xml") drakma:*text-content-types*)
27
-(push (cons "text" "rss+xml") drakma:*text-content-types*)
10
+(define-modify-macro aconsf (key value)
11
+                     (lambda (place k v)
12
+                       (acons k v place)))
13
+
14
+(aconsf drakma:*text-content-types*
15
+        "application" "rdf+xml")
16
+(aconsf drakma:*text-content-types*
17
+        "application" "rss+xml")
18
+(aconsf drakma:*text-content-types*
19
+        "text" "rss+xml")
28 20
 
29 21
 ;(load "utils.lisp")
30 22
 (load "package.lisp")
... ...
@@ -46,7 +38,6 @@
46 38
 
47 39
 (defparameter *app* (make-instance 'ningle:<app>))
48 40
 
49
-
50 41
 (handler-bind ((warning #'sb-ext::muffle-warning))
51 42
   (let* ((feed-urls (ubiquitous:value 'feed 'urls))
52 43
          (plump-parser:*tag-dispatchers* plump:*xml-tags*)
... ...
@@ -67,60 +58,6 @@
67 58
   `(let ((plump:*tag-dispatchers* plump:*xml-tags*))
68 59
      ,@body))
69 60
 
70
-(defmacro def-markup (name (&rest args) &body body)
71
-  `(defmacro ,name ,args
72
-     (alexandria:once-only ,args
73
-      `(cl-markup:markup
74
-         ,,@body))))
75
-
76
-(defmacro item-markup (item)
77
-  (alexandria:once-only (item)
78
-    `(let ((,item ,item))
79
-       (cl-markup:markup
80
-         (:li :class "link closed"
81
-          (:section :class "link-header"
82
-           (:h4 (rss-item-title ,item))
83
-           (:p :class "link-info"
84
-            (:a :target "_blank" :href (rss-item-link ,item)
85
-             (:span :class "link-url" (rss-item-link ,item)))
86
-            (:span :class "link-date") (rss-item-pub-date ,item)))
87
-          (:section :class "link-content"
88
-           (:div
89
-             (cl-markup:raw (rss-item-description-raw ,item)))))))))
90
-
91
-(defmacro feed-markup (feed-v fc-v)
92
-  (alexandria:with-gensyms (feed fc)
93
-    `(let ((,feed ,feed-v)
94
-           (,fc ,fc-v))
95
-       (cl-markup:markup
96
-         (:section :class "feed closed" :id (format nil "feed-~a" ,fc)
97
-          (:section :class "feed-header"
98
-           (:h2 (rss-feed-title ,feed))
99
-           (:h3 (rss-feed-description ,feed)))
100
-          (:ul :class "post-list"
101
-           (:li :class "link closed" :ng-repeat (format nil "item in feeds.result[~d].items" (- ,fc 1))
102
-            (:section :class "link-header"
103
-             (:h4 "{{item.title}}")
104
-             (:p :class "link-info"
105
-              (:a :target "_blank" :ng-href "{{item.link}}" :class "link-url" "{{item.link}}")
106
-              (:span :class "link-date" "{{item.date}}")))
107
-            (:section :class "link-content"
108
-             (:div
109
-               "{{item.description}}")))
110
-           ))))))
111
-
112
-(defmacro feedlist-markup (feedlist)
113
-  (alexandria:once-only (feedlist)
114
-    `(cl-markup:markup*
115
-       `(:ul :class "menu"
116
-         ,@(loop for feed across ,feedlist
117
-                 count feed into feed-count
118
-                 collect
119
-                 (list :li
120
-                       (list :a
121
-                             :href (format nil "#feed-~a" feed-count)
122
-                             (rss-feed-title feed))))))))
123
-
124 61
 (load "base-template.lisp")
125 62
 
126 63
 (defmacro defun-from-value (name value)
... ...
@@ -147,41 +84,18 @@
147 84
               (multiple-value-bind (added-feed dao-feed) (store-feed doc)
148 85
                 (subscribe-to-feed uid (slot-value dao-feed 'id))
149 86
                 (when api
150
-                  (setf result `(200 (:Content-Type "application/json") ,(jsonapi-encoder t added-feed))))))
87
+                  (setf result `(200 (:Content-Type "application/json")
88
+                                 (,(jsonapi-encoder t added-feed)))))))
151 89
             (cl-postgres-error:unique-violation
152 90
               ()
153 91
               (when api
154 92
                 (setf result
155
-                      `(400 () ',(jsonapi-encoder nil "Feed already saved"))))))))
93
+                      `(400 () (,(jsonapi-encoder nil "Feed already saved")))))))))
156 94
       result)))
157 95
 
158 96
 ;;; TODO: add needs to return the new content, so that angular can append it
159 97
 
160 98
 (defparameter *userasdfs* nil)
161
-(cl-oid-connect:def-route ("/feeds/json" (params) :app *app*)
162
-  (ningle.context:with-context-variables (session)
163
-    (let* ((user-info (gethash :app-user session))
164
-           (*feeds* (if user-info (deserialize user-info) *feeds*)))
165
-      (setf *userasdfs* user-info)
166
-      `(200 (:content-type "application/json" :cache-control "private, max-age=300")
167
-        (,(jsonapi-encoder t *feeds*))))))
168
-
169
-(cl-oid-connect:def-route ("/feeds/:feeds/html" (params) :app *app*)
170
-  (ningle.context:with-context-variables (session)
171
-    (cl-oid-connect:require-login
172
-      (let* ((feedlist-s (cdr (assoc :feeds params)))
173
-             (feedlist (mapcar #'parse-integer (split-sequence:split-sequence #\SPACE feedlist-s)))
174
-             (*feeds* (gethash :feeds session *feeds*))
175
-             (*feeds* (make-array (list (length feedlist))
176
-                                  :initial-contents (loop for x in feedlist
177
-                                                          collect (elt *feeds* x)))))
178
-        (base-template-f)))))
179
-
180
-
181
-
182
-(cl-oid-connect:def-route ("/demo" (params) :app *app*)
183
-  (base-template-f t))
184
-
185 99
 #|(cl-oid-connect:require-login
186 100
     ))|#
187 101
 
... ...
@@ -276,77 +190,28 @@
276 190
         (declare (ignorable main-right-margin)) ; TODO: use this!!!
277 191
         `(200 (:content-type "text/css") (,ss))))))
278 192
 
279
-(define-view dark-css (params)
280
-  (colors:let-palette (make-instance 'colors:palette)
281
-    (eval '(get-theme-css))))
282
-
283
-(define-view light-css (params)
284
-  (colors:let-palette (colors:invert-palette (make-instance 'colors:palette))
285
-    (eval '(get-theme-css))))
286
-
287
-(define-view css (colorscheme)
288
-  (string-case:string-case (colorscheme :default "")
289
-    ("light" (view 'light-css colorscheme))
290
-    ("dark" (view 'dark-css colorscheme))))
291
-
292
-(define-view userinfo (params)
293
-  (declare (ignore params))
294
-  (ningle:with-context-variables (session)
295
-    (cl-oid-connect:require-login
296
-      (cl-oid-connect::with-endpoints (gethash :endpoint-schema session)
297
-        `(200
298
-          (:content-type "application/json")
299
-          (,(cl-json:encode-json-to-string
300
-             (gethash :userinfo session))))))))
301
-
302
-(define-controller css (params)
303
-  (cl-oid-connect.utils:assoc-cdr :scheme params))
304
-
305
-(define-controller id (params)
306
-  params)
307
-
308
-(define-view redirect (destination)
309
-  `(302 (:location ,destination)))
310
-
311
-(define-view login (params)
312
-  (cl-who:with-html-output-to-string (s)
313
-    (:html
314
-      (:head (:title "Login"))
315
-      (:body
316
-        (:div
317
-          :class "login-button facebook"
318
-          (:a :href "/login/facebook" "Facebook"))
319
-        (:div
320
-          :class "login-button google"
321
-          (:a :href "/login/google" "Google"))))))
322
-
323
-(define-controller logout (params)
324
-  (declare (ignore params))
325
-  (ningle:with-context-variables (session)
326
-    (setf (gethash :userinfo session) nil)
327
-    "/"))
328
-
329
-(define-view root (feeds)
330
-  (let ((*feeds* feeds))
331
-    (base-template-f)))
332
-
333
-(define-controller root (params)
334
-  (cl-oid-connect.utils::with-login
335
-    (ningle:with-context-variables (session)
336
-      (cl-oid-connect:redirect-if-necessary session
337
-        (let* ((user-info (gethash :app-user session)))
338
-          (deserialize user-info))))
339
-    (:unauthorized (c)
340
-     (declare (ignore c))
341
-     (format t "hmm...")
342
-     (araneus::switch-view 'redirect)
343
-     "/login")))
193
+(load "route-atoms.lisp")
194
+
195
+(define-view json-feed (the-feeds)
196
+  `(200 (:content-type "application/json" :cache-control "private, max-age=300")
197
+    (,(jsonapi-encoder t the-feeds))))
198
+
199
+(define-controller json-feed (params)
200
+  (ningle.context:with-context-variables (session)
201
+    (let* ((user-info (gethash :app-user session))
202
+           (*feeds* (if user-info (deserialize user-info) *feeds*)))
203
+      (setf *userasdfs* user-info)
204
+      *feeds*)) )
205
+
206
+(cl-oid-connect:def-route ("/demo" (params) :app *app*)
207
+  (base-template-f t))
344 208
 
345 209
 (defroutes *app*
210
+  (("/feeds/json") (araneus:as-route 'json-feed))
346 211
   (("/theme/:scheme.css") (araneus::compose-route (css) css))
347 212
   (("/userinfo.json") (araneus::compose-route (id) userinfo))
348 213
   (("/login") (araneus::compose-route (id) login))
349
-  (("/logout") (araneus::compose-route (logout) redirect)) 
214
+  (("/logout") (araneus::compose-route (logout) redirect))
350 215
   (("/") (araneus:as-route 'root)))
351 216
 
352 217
 (defun assoc-cdr-alternatives (alist alt1 alt2 &optional (test #'eql))
353 218
new file mode 100644
... ...
@@ -0,0 +1,68 @@
1
+(in-package :whitespace)
2
+
3
+(define-view dark-css (params)
4
+  (colors:let-palette (make-instance 'colors:palette)
5
+    (eval '(get-theme-css))))
6
+
7
+(define-view light-css (params)
8
+  (colors:let-palette (colors:invert-palette (make-instance 'colors:palette))
9
+    (eval '(get-theme-css))))
10
+
11
+(define-view css (colorscheme)
12
+  (string-case:string-case (colorscheme :default "")
13
+    ("light" (view 'light-css colorscheme))
14
+    ("dark" (view 'dark-css colorscheme))))
15
+
16
+(define-view userinfo (params)
17
+  (declare (ignore params))
18
+  (ningle:with-context-variables (session)
19
+    (cl-oid-connect:require-login
20
+      (cl-oid-connect::with-endpoints (gethash :endpoint-schema session)
21
+        `(200
22
+          (:content-type "application/json")
23
+          (,(cl-json:encode-json-to-string
24
+             (gethash :userinfo session))))))))
25
+
26
+(define-controller css (params)
27
+  (cl-oid-connect.utils:assoc-cdr :scheme params))
28
+
29
+(define-controller id (params)
30
+  params)
31
+
32
+(define-view redirect (destination)
33
+  `(302 (:location ,destination)))
34
+
35
+(define-view login (params)
36
+  (cl-who:with-html-output-to-string (s)
37
+    (:html
38
+      (:head (:title "Login"))
39
+      (:body
40
+        (:div
41
+          :class "login-button facebook"
42
+          (:a :href "/login/facebook" "Facebook"))
43
+        (:div
44
+          :class "login-button google"
45
+          (:a :href "/login/google" "Google"))))))
46
+
47
+(define-controller logout (params)
48
+  (declare (ignore params))
49
+  (ningle:with-context-variables (session)
50
+    (setf (gethash :userinfo session) nil)
51
+    "/"))
52
+
53
+(define-view root (feeds)
54
+  (let ((*feeds* feeds))
55
+    (base-template-f)))
56
+
57
+(define-controller root (params)
58
+  (cl-oid-connect.utils::with-login
59
+    (ningle:with-context-variables (session)
60
+      (cl-oid-connect:redirect-if-necessary session
61
+        (let* ((user-info (gethash :app-user session)))
62
+          (deserialize user-info))))
63
+    (:unauthorized (c)
64
+     (declare (ignore c))
65
+     (format t "hmm...")
66
+     (araneus::switch-view 'redirect)
67
+     "/login")))
68
+
... ...
@@ -5,6 +5,11 @@ Creative Commons Attribution-Share Alike 3.0 License
5 5
 version 0.5.2
6 6
 */
7 7
 
8
+li.link > section.link-content {
9
+  margin-left: 4em;
10
+  margin-right: 6em;
11
+}
12
+
8 13
 li.link > section.link-content > div {
9 14
 
10 15
   /******************** Base ********************/
... ...
@@ -4,6 +4,10 @@ Copyright (C) 2009 Stephane Curzi, ProjetUrbain.com
4 4
 Creative Commons Attribution-Share Alike 3.0 License
5 5
 version 0.5.2
6 6
 */
7
+li.link > section.link-content {
8
+  margin-left: 4em;
9
+  margin-right: 6em; }
10
+
7 11
 li.link > section.link-content > div {
8 12
   /******************** Base ********************/
9 13
   /* html 5 */
10 14
Binary files a/static/images/Whitespace_favicon.png and b/static/images/Whitespace_favicon.png differ
11 15
new file mode 100644
12 16
Binary files /dev/null and b/static/images/Whitespace_favicon.xcf differ