diff options
author | dan <[email protected]> | 2023-02-28 10:44:28 -0500 |
---|---|---|
committer | dan <[email protected]> | 2023-02-28 10:44:28 -0500 |
commit | cb1b352f44655a5ac0d4113b32b8b42a7f7e9dc5 (patch) | |
tree | c8720d03ef5ca6e29d4e48f8329fb0cc00cd8d0e | |
parent | 37db988e1aa49411e6000df64220aeebf8c4a198 (diff) | |
download | 54-cb1b352f44655a5ac0d4113b32b8b42a7f7e9dc5.tar.gz 54-cb1b352f44655a5ac0d4113b32b8b42a7f7e9dc5.tar.bz2 54-cb1b352f44655a5ac0d4113b32b8b42a7f7e9dc5.zip |
fix vhosts map; fix mobile width; increase text field font size; restyle login form; stylesheet is downloaded separately to html
-rw-r--r-- | main.scm | 68 | ||||
-rw-r--r-- | makefile | 17 | ||||
-rw-r--r-- | nginx.conf | 2 | ||||
-rw-r--r-- | style.css | 19 |
4 files changed, 75 insertions, 31 deletions
@@ -50,7 +50,7 @@ ; (port (request-port request))) ; (read-u8vector len port))) -(define style (read-string #f +(define stylesheet (read-string #f (open-input-file "./style.css" #:text))) (define (top-posts) (map-row list db @@ -59,7 +59,7 @@ LEFT JOIN posts c ON c.id = p.parent_id WHERE c.parent_id IS NULL GROUP BY p.id, p.user_id, p.content, p.created_at, p.parent_id - ORDER BY count(c.id) DESC LIMIT 25")) + ORDER BY count(c.id) DESC, p.created_at DESC LIMIT 25")) @@ -80,7 +80,7 @@ LEFT JOIN posts c ON c.id = p.parent_id WHERE c.parent_id IS ? GROUP BY p.id, p.user_id, p.content, p.created_at, p.parent_id - ORDER BY count(c.id) DESC LIMIT 25" post-id)) + ORDER BY count(c.id) DESC, p.created_at DESC LIMIT 25" post-id)) ;(define (top-posts) (map-row list db ; "SELECT id, user_id, content, created_at @@ -96,7 +96,7 @@ (define (parent-id p) (fifth p)) (define (children-count p) (sixth p)) -(define users (alist->hash-table '(("dan" . "pw")))) +(define users (alist->hash-table '(("lawrence" . "pw") ("demo" . "pw") ("dan" . "pw")))) (define apikeys (make-hash-table)) @@ -134,7 +134,9 @@ (define (page inner) (with-output-to-string (lambda () (sxml-display-as-html - `(html (head (style ,style)) + `(html (head + (link (@ [rel "stylesheet"] [href "/style.css"])) + (meta (@ [name "viewport"] [content "width=device-width, initial-scale=1"]))) (body ; (h1 "Title") ; (a (@ [href "/"]) "Back") @@ -151,7 +153,10 @@ (input (@ [id "submit"] [type "submit"] [value "Submit"]))))) (define (vote-to-flush-prompt) - (let ([prompts '("Flush it all away!")]) ; "Drain the swamp!" "Unclog the bog!")]) + (let ([prompts '("Flush it all away!" + "Drain the swamp!" + "Unclog the bog!" + "Vote for a Purge!")]) (list-ref prompts (pseudo-random-integer (length prompts))))) @@ -186,6 +191,12 @@ (define routes `( + (GET (/ "style.css") ,(lambda (rt) + (send-response + headers: `((content-type text/css)) + status: 'ok + body: stylesheet + ))) (GET (/ "unvote") ,(lambda (rt) (unvote (get-current-user)) (send-response @@ -239,24 +250,22 @@ status: 'ok body: (posts-page current-user displayed-posts))))) - - -(GET (/ "posts" ":id") ,(lambda (rt) - (let* ([current-user (get-current-user)] - [post-id (get-route-param rt "id")] - [post (get-post post-id)] - [comments (get-child-posts post-id)] - [displayed-posts (cons post comments)]) - (send-response - headers: '((content-type text/html)) - status: 'ok - body: (posts-page current-user displayed-posts))))) - -(GET (/ "posts") ,(lambda (rt) - (send-response - headers: `((location "/")) - status: 'see-other - ))) + (GET (/ "posts" ":id") ,(lambda (rt) + (let* ([current-user (get-current-user)] + [post-id (get-route-param rt "id")] + [post (get-post post-id)] + [comments (get-child-posts post-id)] + [displayed-posts (cons post comments)]) + (send-response + headers: '((content-type text/html)) + status: 'ok + body: (posts-page current-user displayed-posts))))) + + (GET (/ "posts") ,(lambda (rt) + (send-response + headers: `((location "/")) + status: 'see-other + ))) )) @@ -281,12 +290,13 @@ (second r)))) routes)) -(define (handle-greeting continue) +(define (handle continue) (let* ((uri (request-uri (current-request))) (method (request-method (current-request))) - (route (find-route uri method)) - (handler (third route))) - (handler route))) + (route (find-route uri method))) + (if route + ((third route) route) + (begin (display uri ) (display method) (send-status 'not-found "Page Not Found"))))) -(vhost-map `(("localhost" . ,handle-greeting))) +(vhost-map `((".*" . ,handle))) (start-server port: 7080) @@ -1,2 +1,17 @@ build: ./main.scm - chicken-csc ./main.scm + mkdir -p ./build + chicken-csc -static ./main.scm -L -lsqlite3 + mv ./main ./build/main +deploy: build + cp ./style.css ./build/style.css + scp ./build/* dotemgo-tasks_root:/root/ + ssh dotemgo-tasks_root 'systemctl stop itter.service \ + && mv /root/main /root/54itter \ + && systemctl start itter.service' +upload-service: + scp itter.service dotemgo-tasks_root:/etc/systemd/system/ + ssh dotemgo-tasks_root 'systemctl daemon-reload && systemctl restart itter.service' +clean: + rm -r build/ +status: + ssh dotemgo-tasks_root 'systemctl status itter.service' @@ -10,6 +10,6 @@ server { ssl_certificate_key /root/dotemgo.com.pem.key; location / { - proxy_pass http://itter; + proxy_pass http://itter/; } } @@ -133,3 +133,22 @@ tr:nth-child(even) { #submit:active { box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6), inset 2px 2px 3px rgba(0, 0, 0, 0.6); } + +input[type=text], input[type=password] { + width: 100%; + padding: 12px 20px; + margin: 8px 0; + display: inline-block; + border: 1px solid #ccc; + box-sizing: border-box; + font-size: 1em; +} + +.login-form { + max-width: 20em; +} + +textarea { + font-size: 1em; + font-family: Lato, FreeSans, Roboto, Helvetica, Sans-Serif; +} |