Browse code
misc
Ed Langley authored on 29/10/2020 23:59:13
Showing 10 changed files
Showing 10 changed files
- .gitmodules
- angular.lisp
- demo.lisp
- package.lisp
- parenscript/angular-framework.ps
- parenscript/fold.js
- rss.lisp
- tables.lisp
- utilities/ps_translator.lisp
- whitespace-rss.asd
... | ... |
@@ -1,12 +1,6 @@ |
1 | 1 |
(in-package :cl-user) |
2 |
-(ql:quickload :clack-middleware-postmodern) |
|
3 | 2 |
|
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 |
|
7 |
- :serapeum)) |
|
8 |
- |
|
9 |
-(declaim (optimize (speed 0) (safety 3) (debug 2))) |
|
3 |
+(declaim (optimize (speed 0) (safety 3) (debug 3))) |
|
10 | 4 |
|
11 | 5 |
(define-modify-macro aconsf (key value) |
12 | 6 |
(lambda (place k v) |
... | ... |
@@ -18,10 +12,10 @@ |
18 | 12 |
"application" "rss+xml") |
19 | 13 |
(aconsf drakma:*text-content-types* |
20 | 14 |
"text" "rss+xml") |
15 |
+(aconsf drakma:*text-content-types* |
|
16 |
+ "application" "xml") |
|
21 | 17 |
|
22 | 18 |
;(load "utils.lisp") |
23 |
-(load "package.lisp") |
|
24 |
-(load "rss.lisp") |
|
25 | 19 |
|
26 | 20 |
(in-package plump-dom) |
27 | 21 |
|
... | ... |
@@ -32,8 +26,6 @@ |
32 | 26 |
|
33 | 27 |
|
34 | 28 |
(in-package :whitespace) |
35 |
-(use-package :fwoar.lisputils) |
|
36 |
-(use-package :araneus) |
|
37 | 29 |
(ubiquitous:restore :whitespace) |
38 | 30 |
|
39 | 31 |
|
... | ... |
@@ -59,10 +51,9 @@ |
59 | 51 |
`(let ((plump:*tag-dispatchers* plump:*xml-tags*)) |
60 | 52 |
,@body)) |
61 | 53 |
|
62 |
-(load "base-template.lisp") |
|
63 |
- |
|
64 | 54 |
(defmacro defun-from-value (name value) |
65 |
- `(setf (symbol-function ',name) ,value)) |
|
55 |
+ `(eval-when (:compile-toplevel :load-toplevel :execute) |
|
56 |
+ (setf (symbol-function ',name) ,value))) |
|
66 | 57 |
|
67 | 58 |
(defun-from-value jsonapi-encoder |
68 | 59 |
(jonathan.helper:compile-encoder () (success result) |
... | ... |
@@ -191,7 +182,6 @@ |
191 | 182 |
(declare (ignorable main-right-margin)) ; TODO: use this!!! |
192 | 183 |
`(200 (:content-type "text/css") (,ss)))))) |
193 | 184 |
|
194 |
-(load "route-atoms.lisp") |
|
195 | 185 |
|
196 | 186 |
(define-view json-feed (the-feeds) |
197 | 187 |
`(200 (:content-type "application/json" :cache-control "private, max-age=300") |
... | ... |
@@ -2,20 +2,24 @@ |
2 | 2 |
(in-package :cl-user) |
3 | 3 |
|
4 | 4 |
(defpackage :whitespace.tables |
5 |
+ (:shadowing-import-from :iterate :with) |
|
5 | 6 |
(:use #:cl #:alexandria #:postmodern #:annot.class #:iterate #:fwoar.lisputils)) |
6 | 7 |
|
7 | 8 |
(defpackage :whitespace.feeds.autodiscovery |
9 |
+ (:shadowing-import-from :iterate :with) |
|
8 | 10 |
(:use #:cl #:alexandria #:postmodern #:lquery #:cl-syntax #:cl-annot.syntax #:cl-annot.class |
9 | 11 |
#:whitespace.tables #:iterate #:fwoar.lisputils) |
10 | 12 |
(:import-from anaphora it) |
11 | 13 |
(:export :discover-feeds)) |
12 | 14 |
|
13 | 15 |
(defpackage :whitespace.feeds.opml |
16 |
+ (:shadowing-import-from :iterate :with) |
|
14 | 17 |
(:use #:cl #:alexandria #:postmodern #:lquery #:cl-syntax #:cl-annot.syntax #:cl-annot.class |
15 | 18 |
#:whitespace.tables #:iterate #:fwoar.lisputils) |
16 | 19 |
(:import-from anaphora it)) |
17 | 20 |
|
18 | 21 |
(defpackage :whitespace.feeds.rss |
22 |
+ (:shadowing-import-from :iterate :with) |
|
19 | 23 |
(:use #:cl #:alexandria #:postmodern #:lquery #:cl-syntax #:cl-annot.syntax #:cl-annot.class |
20 | 24 |
#:whitespace.tables #:iterate #:fwoar.lisputils #:whitespace.feeds.autodiscovery) |
21 | 25 |
(:import-from anaphora it) |
... | ... |
@@ -24,6 +28,6 @@ |
24 | 28 |
:make-rss-feed :make-rss-item)) |
25 | 29 |
|
26 | 30 |
(defpackage :whitespace |
27 |
- (:use #:cl #:anaphora #:fwoar.lisputils #:whitespace.feeds.rss #:whitespace.tables)) |
|
31 |
+ (:use #:cl #:anaphora #:araneus #:fwoar.lisputils #:whitespace.feeds.rss #:whitespace.tables)) |
|
28 | 32 |
|
29 | 33 |
|
... | ... |
@@ -1,7 +1,3 @@ |
1 |
-(declaim (optimize (safety 3) (speed 0) (debug 3))) |
|
2 |
- |
|
3 |
-(load "tables.lisp") |
|
4 |
- |
|
5 | 1 |
(in-package :cl-user) |
6 | 2 |
(cl-annot.syntax:enable-annot-syntax) |
7 | 3 |
|
... | ... |
@@ -92,7 +88,7 @@ |
92 | 88 |
|
93 | 89 |
(defun make-rss-item (item fallback-date) |
94 | 90 |
(lquery:initialize item) |
95 |
- (flet ((dehtml (h) (plump:text (plump:parse h))) |
|
91 |
+ (flet (#+null (dehtml (h) (plump:text (plump:parse h))) |
|
96 | 92 |
(get-category-names (it) ;;; TODO: simplify this---Ask Shinmera on IRC |
97 | 93 |
(if (not (equalp #() it)) |
98 | 94 |
(map 'vector |
... | ... |
@@ -101,11 +97,11 @@ |
101 | 97 |
#()))) |
102 | 98 |
(let* ((content-encoded (lquery:$ (children) (tag-name "content:encoded"))) |
103 | 99 |
|
104 |
- (description-element (default-when content-encoded (emptyp content-encoded) |
|
100 |
+ (description-element (default-unless content-encoded (emptyp content-encoded) |
|
105 | 101 |
(lquery:$ (children "description")))) |
106 | 102 |
|
107 | 103 |
(description (normalize-html |
108 |
- (default-when description-element (emptyp description-element) |
|
104 |
+ (default-unless description-element (emptyp description-element) |
|
109 | 105 |
(extract-text "description"))))) |
110 | 106 |
;(enclosure) --- TODO: implement comment / enclosure handling |
111 | 107 |
|
... | ... |
@@ -128,7 +124,7 @@ |
128 | 124 |
(link (if (string= link "") (lquery:$ "channel" (children) (tag-name "atom:link") (attr :href) (node)) link)) |
129 | 125 |
(items (lquery:$ "item")) |
130 | 126 |
(last-build (or (lquery:$ "lastBuildDate" (text) (node)) "")) |
131 |
- (pub-date (default-when last-build (string= last-build "") |
|
127 |
+ (pub-date (default-unless last-build (string= last-build "") |
|
132 | 128 |
(lquery:$ "pubDate" (text) (node)))) |
133 | 129 |
(fallback-date (if (string= pub-date "") "2015-01-01 0:0:0+00" pub-date))) |
134 | 130 |
(format t "fallback-date: ~a~%" fallback-date) |
... | ... |
@@ -156,7 +152,7 @@ |
156 | 152 |
(defmacro get-id-for-object ((table key-column &optional (id-column :id)) key &body body) |
157 | 153 |
"Anaphoric macro: binds id to the id it retrieves!" |
158 | 154 |
(once-only (id-column key) |
159 |
- `(let ((id (anaphora:awhen (postmodern:query (:select ,id-column :from ',table :where (:= ',key-column ,key))) |
|
155 |
+ `(let ((id (alexandria:when-let ((it (postmodern:query (:select ,id-column :from ',table :where (:= ',key-column ,key))))) |
|
160 | 156 |
(caar it)))) |
161 | 157 |
,@body))) |
162 | 158 |
|
... | ... |
@@ -180,14 +176,14 @@ |
180 | 176 |
(defun get-and-possibly-store-feed (rss-feed) |
181 | 177 |
"Given an rss-feed, return the db's feed-id, persisting it if it doesn't already exist." |
182 | 178 |
(postmodern:ensure-transaction |
183 |
- (anaphora:aif (postmodern:select-dao 'rss_feed_store (:= 'link (rss-feed-link rss-feed))) |
|
179 |
+ (alexandria:if-let ((it (postmodern:select-dao 'rss_feed_store (:= 'link (rss-feed-link rss-feed))))) |
|
184 | 180 |
(car anaphora:it) ;; The postmodern query returns a nested list |
185 | 181 |
(store-feed-dao (serialize rss-feed))))) |
186 | 182 |
|
187 | 183 |
(defun store-feed (doc) |
188 |
- (postmodern:with-transaction () |
|
189 |
- (let ((rss-feed (make-rss-feed doc))) |
|
190 |
- (values rss-feed |
|
184 |
+ (let ((rss-feed (make-rss-feed doc))) |
|
185 |
+ (values rss-feed |
|
186 |
+ (postmodern:with-transaction () |
|
191 | 187 |
(get-and-possibly-store-feed rss-feed))))) |
192 | 188 |
|
193 | 189 |
; TODO: this should eventually take a username/userobject rather than ids . . . |
... | ... |
@@ -224,7 +220,7 @@ |
224 | 220 |
result)) |
225 | 221 |
|
226 | 222 |
(defun deserialize (&optional user-info) |
227 |
- (default-when #() (not (null user-info)) |
|
223 |
+ (default-unless #() (not (null user-info)) |
|
228 | 224 |
(let ((feeds |
229 | 225 |
(postmodern:query-dao 'rss_feed_store |
230 | 226 |
(:select 'rss_feed_store.* |
... | ... |
@@ -85,8 +85,8 @@ |
85 | 85 |
(defmacro defserializer ((specializes) &body slots) |
86 | 86 |
(with-gensyms (obj o-t p-t) |
87 | 87 |
`(defmethod serialize ((,obj ,specializes) &optional (,o-t #'identity) (,p-t #'%default-pair-transform)) |
88 |
- (transform-result (,o-t ,p-t) |
|
89 |
- (slots-to-pairs ,obj ,slots))))) |
|
88 |
+ (transform-result (,o-t ,p-t) |
|
89 |
+ (slots-to-pairs ,obj ,slots))))) |
|
90 | 90 |
|
91 | 91 |
(defmethod serialize ((obj sequence) &optional (o-t #'identity) (p-t #'%default-pair-transform)) |
92 | 92 |
(iterate (for item in-sequence obj) |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-(ql:quickload :parenscript) |
|
1 |
+;;(ql:quickload :parenscript) |
|
2 | 2 |
|
3 | 3 |
(defpackage :ps_translator |
4 | 4 |
(:use :parenscript :cl) |
... | ... |
@@ -23,10 +23,10 @@ |
23 | 23 |
,@code)))) |
24 | 24 |
|
25 | 25 |
(defmacro+ps def-event (target event args &body run) |
26 |
- `($ (,target) |
|
27 |
- (,event |
|
28 |
- (lambda ,args |
|
29 |
- ,@run)))) |
|
26 |
+ `($ (,target) |
|
27 |
+ (,event |
|
28 |
+ (lambda ,args |
|
29 |
+ ,@run)))) |
|
30 | 30 |
|
31 | 31 |
(defun translate-file (infile outfile) |
32 | 32 |
(let ((*JS-TARGET-VERSION* 1.9)) |
... | ... |
@@ -0,0 +1,39 @@ |
1 |
+;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Package: ASDF-USER -*- |
|
2 |
+(in-package :asdf-user) |
|
3 |
+ |
|
4 |
+(load "colors/colors.asd") |
|
5 |
+ |
|
6 |
+(defsystem :whitespace |
|
7 |
+ :description "" |
|
8 |
+ :author "Ed L <edward@elangley.org>" |
|
9 |
+ :license "MIT" |
|
10 |
+ :depends-on (#:alexandria |
|
11 |
+ #:uiop |
|
12 |
+ #:serapeum |
|
13 |
+ :clack-middleware-postmodern |
|
14 |
+ :fwoar-lisputils |
|
15 |
+ :araneus |
|
16 |
+ :cl-markup |
|
17 |
+ :parenscript |
|
18 |
+ :colors |
|
19 |
+ :lquery |
|
20 |
+ :plump |
|
21 |
+ :postmodern |
|
22 |
+ :sxql |
|
23 |
+ :clack-middleware-postmodern |
|
24 |
+ :dexador |
|
25 |
+ :spinneret |
|
26 |
+ :ubiquitous |
|
27 |
+ :iterate |
|
28 |
+ :jonathan |
|
29 |
+ :cl-actors |
|
30 |
+ :simple-tasks |
|
31 |
+ :cl-oid-connect |
|
32 |
+ :serapeum) |
|
33 |
+ :serial t |
|
34 |
+ :components ((:file "package") |
|
35 |
+ (:file "tables") |
|
36 |
+ (:file "rss") |
|
37 |
+ (:file "base-template") |
|
38 |
+ (:file "route-atoms") |
|
39 |
+ (:file "angular"))) |