forked from cadence/breezewiki
Compare commits
3 commits
6e5513a31e
...
710d7d6faa
Author | SHA1 | Date | |
---|---|---|---|
710d7d6faa | |||
20a4043889 | |||
cc138a07aa |
8 changed files with 76 additions and 42 deletions
|
@ -1,10 +1,7 @@
|
|||
#lang racket/base
|
||||
(require web-server/servlet-dispatch
|
||||
(prefix-in pathprocedure: web-server/dispatchers/dispatch-pathprocedure)
|
||||
(prefix-in sequencer: web-server/dispatchers/dispatch-sequencer)
|
||||
(prefix-in lift: web-server/dispatchers/dispatch-lift)
|
||||
(prefix-in filter: web-server/dispatchers/dispatch-filter)
|
||||
"src/config.rkt"
|
||||
"src/dispatcher-tree.rkt"
|
||||
"src/reloadable.rkt")
|
||||
|
||||
(define-syntax-rule (require-reloadable filename varname)
|
||||
|
@ -20,8 +17,6 @@
|
|||
(require-reloadable "src/page-static.rkt" static-dispatcher)
|
||||
(require-reloadable "src/page-wiki.rkt" page-wiki)
|
||||
|
||||
(when (not (config-true? 'debug))
|
||||
(set-reload-poll-interval! #f))
|
||||
(reload!)
|
||||
|
||||
(define ch (make-channel))
|
||||
|
@ -31,13 +26,14 @@
|
|||
#:port (string->number (config-get 'port))
|
||||
(λ (quit)
|
||||
(channel-put ch (lambda () (semaphore-post quit)))
|
||||
(sequencer:make
|
||||
(pathprocedure:make "/" page-home)
|
||||
(pathprocedure:make "/proxy" page-proxy)
|
||||
(filter:make #rx"^/[a-z-]+/wiki/Category:.+$" (lift:make page-category))
|
||||
(filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make page-wiki))
|
||||
(filter:make #rx"^/[a-z-]+/search$" (lift:make page-search))
|
||||
static-dispatcher
|
||||
(lift:make page-not-found)))))
|
||||
(dispatcher-tree
|
||||
; order of these does not matter
|
||||
page-category
|
||||
page-home
|
||||
page-not-found
|
||||
page-proxy
|
||||
page-search
|
||||
page-wiki
|
||||
static-dispatcher))))
|
||||
(define server-t (thread start))
|
||||
(define quit (channel-get ch))
|
||||
|
|
23
dist.rkt
23
dist.rkt
|
@ -1,11 +1,7 @@
|
|||
#lang racket/base
|
||||
(require web-server/servlet-dispatch
|
||||
(prefix-in pathprocedure: web-server/dispatchers/dispatch-pathprocedure)
|
||||
(prefix-in sequencer: web-server/dispatchers/dispatch-sequencer)
|
||||
(prefix-in lift: web-server/dispatchers/dispatch-lift)
|
||||
(prefix-in filter: web-server/dispatchers/dispatch-filter)
|
||||
"src/config.rkt"
|
||||
"src/reloadable.rkt")
|
||||
"src/dispatcher-tree.rkt")
|
||||
|
||||
(require (only-in "src/page-category.rkt" page-category))
|
||||
(require (only-in "src/page-home.rkt" page-home))
|
||||
|
@ -19,11 +15,12 @@
|
|||
#:listen-ip (if (config-true? 'debug) "127.0.0.1" #f)
|
||||
#:port (string->number (config-get 'port))
|
||||
(λ (quit)
|
||||
(sequencer:make
|
||||
(pathprocedure:make "/" page-home)
|
||||
(pathprocedure:make "/proxy" page-proxy)
|
||||
(filter:make #rx"^/[a-z-]+/wiki/Category:.+$" (lift:make page-category))
|
||||
(filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make page-wiki))
|
||||
(filter:make #rx"^/[a-z-]+/search$" (lift:make page-search))
|
||||
static-dispatcher
|
||||
(lift:make page-not-found))))
|
||||
(dispatcher-tree
|
||||
; order of these does not matter
|
||||
page-category
|
||||
page-home
|
||||
page-not-found
|
||||
page-proxy
|
||||
page-search
|
||||
page-wiki
|
||||
static-dispatcher)))
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
`(html
|
||||
(head
|
||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||
(title ,(format "~a | ~a" title (config-get 'application-name)))
|
||||
(title ,(format "~a | ~a" title (config-get 'application_name)))
|
||||
(style ":root { --theme-page-background-color: #dfdfe0 }") ; fallback in case styles don't load fast enough
|
||||
,@(map (λ (url)
|
||||
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
||||
|
@ -53,22 +53,22 @@
|
|||
(img (@ (class "my-logo") (src "/static/breezewiki.svg"))))
|
||||
(p
|
||||
(a (@ (href "https://gitdab.com/cadence/breezewiki"))
|
||||
,(format "~a source code" (config-get 'application-name))))
|
||||
,(format "~a source code" (config-get 'application_name))))
|
||||
(p
|
||||
(a (@ (href "https://lists.sr.ht/~cadence/breezewiki-discuss"))
|
||||
"Discussions / Bug reports / Feature requests"))
|
||||
,(if (config-get 'instance-is-official)
|
||||
`(p ,(format "This instance is run by the ~a developer, " (config-get 'application-name))
|
||||
,(if (config-get 'instance_is_official)
|
||||
`(p ,(format "This instance is run by the ~a developer, " (config-get 'application_name))
|
||||
(a (@ (href "https://cadence.moe/contact"))
|
||||
"Cadence."))
|
||||
`(p
|
||||
,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application-name)))))
|
||||
,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application_name)))))
|
||||
(div
|
||||
(p "This page displays proxied content from "
|
||||
(a (@ (href ,source-url) (rel "noreferrer")) ,source-url)
|
||||
". Text content is available under the Creative Commons Attribution-Share Alike License 3.0 (Unported), "
|
||||
(a (@ (href "https://www.fandom.com/licensing")) "see license info.")
|
||||
" Media files may have different copying restrictions.")
|
||||
(p ,(format "Fandom is a trademark of Fandom, Inc. ~a is not affiliated with Fandom." (config-get 'application-name))))))))))))
|
||||
(p ,(format "Fandom is a trademark of Fandom, Inc. ~a is not affiliated with Fandom." (config-get 'application_name))))))))))))
|
||||
(module+ test
|
||||
(check-not-false (xexp->html (generate-wiki-page "" "test" "test" '(template)))))
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
(hash-ref config key))
|
||||
|
||||
(define default-config
|
||||
'((port . "10416")
|
||||
'((application_name . "BreezeWiki")
|
||||
(canonical_origin . "")
|
||||
(debug . "false")
|
||||
(instance-is-official . "false") ; please don't turn this on, or you will make me very upset
|
||||
(application-name . "BreezeWiki")))
|
||||
(instance_is_official . "false") ; please don't turn this on, or you will make me very upset
|
||||
(port . "10416")))
|
||||
|
||||
(define config
|
||||
(make-hasheq
|
||||
|
|
36
src/dispatcher-tree.rkt
Normal file
36
src/dispatcher-tree.rkt
Normal file
|
@ -0,0 +1,36 @@
|
|||
#lang racket/base
|
||||
(require (for-syntax racket/base)
|
||||
(prefix-in pathprocedure: web-server/dispatchers/dispatch-pathprocedure)
|
||||
(prefix-in sequencer: web-server/dispatchers/dispatch-sequencer)
|
||||
(prefix-in lift: web-server/dispatchers/dispatch-lift)
|
||||
(prefix-in filter: web-server/dispatchers/dispatch-filter))
|
||||
|
||||
(provide
|
||||
; syntax to make the hashmap from names
|
||||
dispatcher-tree
|
||||
; procedure to make the tree from the hashmap
|
||||
make-dispatcher-tree)
|
||||
|
||||
; make a hashmap out of the provided names and call make-dispatcher-tree with it
|
||||
(define-syntax (dispatcher-tree stx)
|
||||
; the arguments, which are names of dispatcher variables
|
||||
(define names (cdr (syntax->list stx)))
|
||||
; map each name to syntax of a '(name . ,name)
|
||||
(define alist (map (λ (xe) ; xe is the syntax of a name
|
||||
; return instead syntax of a cons cell
|
||||
(datum->syntax stx `(cons ',xe ,xe)))
|
||||
names))
|
||||
; make syntax to make the hash
|
||||
(define ds (datum->syntax stx `(make-hasheq (list ,@alist))))
|
||||
; don't forget that I'm returning *code* - return a call to the function
|
||||
(datum->syntax stx `(make-dispatcher-tree ,ds)))
|
||||
|
||||
(define (make-dispatcher-tree ds)
|
||||
(sequencer:make
|
||||
(pathprocedure:make "/" (hash-ref ds 'page-home))
|
||||
(pathprocedure:make "/proxy" (hash-ref ds 'page-proxy))
|
||||
(filter:make #rx"^/[a-z-]+/wiki/Category:.+$" (lift:make (hash-ref ds 'page-category)))
|
||||
(filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make (hash-ref ds 'page-wiki)))
|
||||
(filter:make #rx"^/[a-z-]+/search$" (lift:make (hash-ref ds 'page-search)))
|
||||
(hash-ref ds 'static-dispatcher)
|
||||
(lift:make (hash-ref ds 'page-not-found))))
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
(define data (easy:response-json dest-res))
|
||||
(define body (generate-results-page dest-url wikiname prefixed-category data))
|
||||
(when (config-get 'debug)
|
||||
(when (config-true? 'debug)
|
||||
; used for its side effects
|
||||
; convert to string with error checking, error will be raised if xexp is invalid
|
||||
(xexp->html body))
|
||||
|
|
|
@ -56,20 +56,20 @@
|
|||
(footer (@ (class "custom-footer"))
|
||||
(div (@ (class "internal-footer"))
|
||||
(img (@ (class "my-logo") (src "/static/breezewiki.svg")))
|
||||
,(if (config-get 'instance-is-official)
|
||||
,(if (config-get 'instance_is_official)
|
||||
`(div
|
||||
(p ,(format "This instance is run by the ~a developer, " (config-get 'application-name))
|
||||
(p ,(format "This instance is run by the ~a developer, " (config-get 'application_name))
|
||||
(a (@ (href "https://cadence.moe/contact"))
|
||||
"Cadence."))
|
||||
(p "Hosting generously provided by "
|
||||
(a (@ (href "http://alphamethyl.barr0w.net/"))
|
||||
"alphamethyl.")))
|
||||
`(p
|
||||
,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application-name))))
|
||||
,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application_name))))
|
||||
(p "Text content on wikis run by Fandom is available under the Creative Commons Attribution-Share Alike License 3.0 (Unported), "
|
||||
(a (@ (href "https://www.fandom.com/licensing")) "see license info.")
|
||||
" Media files and official Fandom documents have different copying restrictions.")
|
||||
(p ,(format "Fandom is a trademark of Fandom, Inc. ~a is not affiliated with Fandom." (config-get 'application-name)))))))))))
|
||||
(p ,(format "Fandom is a trademark of Fandom, Inc. ~a is not affiliated with Fandom." (config-get 'application_name)))))))))))
|
||||
(module+ test
|
||||
(check-not-false (xexp->html body)))
|
||||
|
||||
|
|
|
@ -62,7 +62,11 @@ p {
|
|||
}
|
||||
.custom-footer__cols {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
@media (min-width: 560px) {
|
||||
.custom-footer__cols {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
.my-logo {
|
||||
margin-bottom: 8px;
|
||||
|
|
Loading…
Reference in a new issue