-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User configures using a frog.rkt file. For existing projects, do a one-time creation of frog.rkt based on existing .frogrc. Also: - Move most modules under frog/private/, so that it's clearer what someone may require in their frog.rkt. - Start to use scribble/srcdoc to create some of the doc. - Add .dir-locals.el for better indent of xexprs and at-exps. - Bump to v0.27.
- Loading branch information
Greg Hendershott
committed
May 12, 2017
1 parent
26f5b92
commit 005833f
Showing
49 changed files
with
1,471 additions
and
1,219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
((nil | ||
(indent-tabs-mode . nil) | ||
(require-final-newline . t) | ||
(show-trailing-whitespace . t)) | ||
(prog-mode | ||
(comment-column . 40) | ||
(fill-column . 70)) | ||
(makefile-mode | ||
(indent-tabs-mode . t)) | ||
(racket-mode | ||
;; Better indentation for quoted xexprs and for at-exprs: | ||
(racket-indent-sequence-depth . 3) | ||
(racket-indent-curly-as-sequence . t))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#lang frog/config | ||
|
||
;; Called early when Frog launches. Use this to set parameters defined | ||
;; in frog/params. | ||
(define/contract (init) | ||
(-> any) | ||
(current-scheme/host "http://www.example.com") | ||
(current-title "My Blog") | ||
(current-author "The Unknown Author")) | ||
|
||
;; Called once per post and non-post page, on the contents. | ||
(define/contract (enhance-body xs) | ||
(-> (listof xexpr/c) (listof xexpr/c)) | ||
;; Here we pass the xexprs through a series of functions. | ||
(~> xs | ||
(syntax-highlight #:python-executable "python" | ||
#:line-numbers? #t | ||
#:css-class "source") | ||
(auto-embed-tweets #:parents? #t) | ||
(add-racket-doc-links #:code? #t #:prose? #f))) | ||
|
||
;; Called from `raco frog --clean`. | ||
(define/contract (clean) | ||
(-> any) | ||
(void)) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Public | ||
|
||
`.rkt` files in this directory `provide` things a user may `require` | ||
in their blog project files: | ||
|
||
- `frog.rkt` | ||
- templates | ||
- `page-template.html` | ||
- `post-template.html` | ||
- `index-template.html` | ||
- `.scrbl` format sources | ||
|
||
Everything else should go under the `private` directory. | ||
|
||
When in doubt, err on the side of making things private! |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#lang s-exp syntax/module-reader | ||
frog/config/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#lang at-exp racket/base | ||
|
||
(require (for-syntax racket/base | ||
racket/function | ||
racket/match | ||
racket/syntax | ||
syntax/parse) | ||
reprovide/reprovide | ||
"private/load.rkt") | ||
|
||
(provide (except-out (all-from-out racket/base) | ||
#%module-begin | ||
#%provide | ||
provide) | ||
(rename-out [our-#%module-begin #%module-begin])) | ||
|
||
(reprovide racket/contract/base | ||
racket/contract/region | ||
rackjure/threading | ||
xml/xexpr | ||
"../params.rkt" | ||
"../paths.rkt" | ||
"../enhance-body.rkt") | ||
|
||
(define-syntax (our-#%module-begin stx) | ||
(syntax-parse stx | ||
[(_ forms ...) | ||
(with-syntax ([(provides ...) (map (curry format-id stx "~a") provide-syms)]) | ||
;; If we didn't care about error messages, this could simply be: | ||
;; | ||
;; #'(#%module-begin forms ... (provide provides ...)) | ||
;; | ||
;; But if the user has failed to define one of the mandatory functions | ||
;; we want to supply a helpful error message that specifically | ||
;; identifies it. And of course preserve their frog.rkt stx srcloc. | ||
;; | ||
;; So we local-expand their forms, catch the appropriate syntax errors, | ||
;; and re-raise them in a more-helpful form. | ||
(define (fail-sym exn) | ||
(match (exn:fail:syntax-exprs exn) | ||
[(cons stx _) (syntax-e stx)] | ||
[_ #f])) | ||
(with-handlers | ||
([(λ (e) | ||
(and (exn:fail:syntax? e) | ||
(regexp-match? #rx"provided identifier not defined or imported" | ||
(exn-message e)) | ||
(memq (fail-sym e) provide-syms))) | ||
(λ (e) | ||
(raise-syntax-error | ||
'frog/config | ||
(format "You must define a function named \"~a\"" (fail-sym e)) | ||
stx))]) | ||
(local-expand (syntax/loc #'(forms ...) | ||
(#%module-begin forms ... (provide provides ...))) | ||
'module-begin '())))])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#lang racket/base | ||
|
||
(require (for-syntax racket/base | ||
racket/function | ||
racket/syntax)) | ||
|
||
(begin-for-syntax | ||
(define provide-syms '(init | ||
enhance-body | ||
clean)) | ||
(provide provide-syms)) | ||
|
||
(define-syntax (define-the-things stx) | ||
(with-syntax ([(id ...) (map (curry format-id stx "~a") provide-syms)] | ||
[load (format-id stx "load")]) | ||
#'(begin | ||
(define id | ||
(λ _ (error 'id "not yet dynamic-required from frog.rkt"))) ... | ||
(provide id ...) | ||
|
||
(define (load top) | ||
(define frog.rkt (build-path top "frog.rkt")) | ||
(let ([fn (dynamic-require frog.rkt 'id)]) | ||
(when fn (set! id fn))) ...) | ||
(provide load)))) | ||
|
||
(define-the-things) | ||
|
||
(module+ test | ||
(require rackunit | ||
racket/runtime-path) | ||
(test-case "before loading example/frog.rkt" | ||
(check-exn #rx"init: not yet dynamic-required from frog.rkt" | ||
(λ () (init))) | ||
(check-exn #rx"enhance-body: not yet dynamic-required from frog.rkt" | ||
(λ () (enhance-body '((p () "hi"))))) | ||
(check-exn #rx"clean: not yet dynamic-required from frog.rkt" | ||
(λ () (clean)))) | ||
(define-runtime-path example "../../../example/") | ||
(test-case "after loading example/frog.rkt" | ||
(load example) | ||
(check-not-exn (λ () (init))) | ||
(check-not-exn (λ () (enhance-body '((p () "hi"))))) | ||
(check-not-exn (λ () (clean))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#lang racket/base | ||
|
||
(module+ test | ||
(require rackunit) | ||
|
||
(module m frog/config/main | ||
(define init #f) | ||
(define enhance-body #f) | ||
(define clean #f)) | ||
|
||
(check-not-exn (λ () (eval '(module m frog/config/main | ||
(define init #f) | ||
(define enhance-body #f) | ||
(define clean #f)) | ||
(make-base-namespace)))) | ||
|
||
(check-exn #rx"frog/config: You must define a function named \"init\"" | ||
(λ () (eval '(module m frog/config/main | ||
#;(define init #f) | ||
(define enhance-body #f) | ||
(define clean #f)) | ||
(make-base-namespace)))) | ||
|
||
(check-exn #rx"frog/config: You must define a function named \"enhance-body\"" | ||
(λ () (eval '(module m frog/config/main | ||
(define init #f) | ||
#;(define enhance-body #f) | ||
(define clean #f)) | ||
(make-base-namespace)))) | ||
|
||
(check-exn #rx"frog/config: You must define a function named \"clean\"" | ||
(λ () (eval '(module m frog/config/main | ||
(define init #f) | ||
(define enhance-body #f) | ||
#;(define clean #f)) | ||
(make-base-namespace))))) |
Oops, something went wrong.