From cc1a116dc23b24595ce2a0f68a8aad8bdae62a4c Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 29 Jan 2016 17:16:46 -0800 Subject: [PATCH] rename certain setup values --- pollen/pagetree.rkt | 2 +- pollen/private/command.rkt | 2 +- pollen/private/project-server-routes.rkt | 6 +++--- pollen/private/project-server.rkt | 2 +- pollen/render.rkt | 2 +- pollen/scribblings/raco.scrbl | 2 +- pollen/scribblings/render.scrbl | 2 +- pollen/scribblings/setup.scrbl | 8 ++++---- pollen/scribblings/tutorial-first.scrbl | 2 +- pollen/setup.rkt | 8 ++++---- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pollen/pagetree.rkt b/pollen/pagetree.rkt index 7c28d89..a3564fc 100644 --- a/pollen/pagetree.rkt +++ b/pollen/pagetree.rkt @@ -112,7 +112,7 @@ (define+provide/contract (make-project-pagetree project-dir) (pathish? . -> . pagetree?) (with-handlers ([exn:fail? (λ(exn) (directory->pagetree project-dir))]) - (define pagetree-source (build-path project-dir (setup:default-pagetree))) + (define pagetree-source (build-path project-dir (setup:main-pagetree))) (load-pagetree pagetree-source))) diff --git a/pollen/private/command.rkt b/pollen/private/command.rkt index 85c19eb..046e686 100644 --- a/pollen/private/command.rkt +++ b/pollen/private/command.rkt @@ -120,7 +120,7 @@ version print the version (~a)" (setup:current-server-port) setup (when (not (directory-exists? directory-maybe)) (error (format "~a is not a directory" directory-maybe))) (parameterize ([setup:current-project-root directory-maybe] - [setup:current-server-port (or port setup:default-default-port)]) + [setup:current-server-port (or port setup:default-project-server-port)]) (displayln "Starting project server ...") ((dynamic-require 'pollen/private/project-server 'start-server)))) diff --git a/pollen/private/project-server-routes.rkt b/pollen/private/project-server-routes.rkt index 323d248..6f1f818 100644 --- a/pollen/private/project-server-routes.rkt +++ b/pollen/private/project-server-routes.rkt @@ -42,7 +42,7 @@ (define localhost-client "::1") (define url-string (url->string (request-uri req))) (when (not (ends-with? url-string "favicon.ico")) - (message "request:" (string-replace url-string (setup:default-pagetree) " dashboard") + (message "request:" (string-replace url-string (setup:main-pagetree) " dashboard") (if (not (equal? client localhost-client)) (format "from ~a" client) "")))) ;; pass string args to route, then @@ -152,14 +152,14 @@ (define dirlinks (cons "/" (map (λ(ps) (format "/~a/" (apply build-path ps))) (for/list ([i (in-range (length (cdr dirs)))]) (take (cdr dirs) (add1 i)))))) - `(tr (th ((colspan "3")) ,@(add-between (map (λ(dir dirlink) `(a ((href ,(format "~a~a" dirlink (setup:default-pagetree)))) ,(->string dir))) dirs dirlinks) "/")))) + `(tr (th ((colspan "3")) ,@(add-between (map (λ(dir dirlink) `(a ((href ,(format "~a~a" dirlink (setup:main-pagetree)))) ,(->string dir))) dirs dirlinks) "/")))) (define (make-path-row filename source indent-level) `(tr ,@(map make-link-cell (append (list (let ([main-cell (cond ; main cell [(directory-exists? (build-path dashboard-dir filename)) ; links subdir to its dashboard - (cons (format "~a/~a" filename (setup:default-pagetree)) (format "~a/" filename))] + (cons (format "~a/~a" filename (setup:main-pagetree)) (format "~a/" filename))] [(and source (equal? (get-ext source) "scrbl")) ; scribble source (cons #f `(a ((href ,filename)) ,filename (span ((class "file-ext")) " (from " ,(->string (find-relative-path dashboard-dir source)) ")")))] [source ; ordinary source. use remove-ext because source may have escaped extension in it diff --git a/pollen/private/project-server.rkt b/pollen/private/project-server.rkt index d74e625..db3f16d 100755 --- a/pollen/private/project-server.rkt +++ b/pollen/private/project-server.rkt @@ -24,7 +24,7 @@ (define server-name (format "http://localhost:~a" (setup:current-server-port))) (message (format "Project server is ~a" server-name) "(Ctrl-C to exit)") - (message (format "Project dashboard is ~a/~a" server-name (setup:default-pagetree))) + (message (format "Project dashboard is ~a/~a" server-name (setup:main-pagetree))) (message "Ready to rock") (parameterize ([error-print-width 1000]) diff --git a/pollen/render.rkt b/pollen/render.rkt index f471a79..a6c3de0 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -225,7 +225,7 @@ (define (get-default-template) (and output-path-ext - (let ([default-template-filename (add-ext (setup:default-template-prefix source-path) output-path-ext)]) + (let ([default-template-filename (add-ext (setup:template-prefix source-path) output-path-ext)]) (find-upward-from source-path default-template-filename file-exists-or-has-source?)))) (define (get-fallback-template) diff --git a/pollen/scribblings/raco.scrbl b/pollen/scribblings/raco.scrbl index feda8d7..ae8a91c 100644 --- a/pollen/scribblings/raco.scrbl +++ b/pollen/scribblings/raco.scrbl @@ -47,7 +47,7 @@ Displays a list of available commands. @section{@exec{raco pollen start}} -Start the project server from the current directory using the default port, which is the value of the parameter @racket[setup:current-server-port] (by default, port @(format "~a" setup:default-default-port)). +Start the project server from the current directory using the default port, which is the value of the parameter @racket[setup:current-server-port] (by default, port @(format "~a" setup:default-project-server-port)). This command can be invoked with two optional arguments. diff --git a/pollen/scribblings/render.scrbl b/pollen/scribblings/render.scrbl index 817a6f4..7cf734b 100644 --- a/pollen/scribblings/render.scrbl +++ b/pollen/scribblings/render.scrbl @@ -88,7 +88,7 @@ If your project has @seclink["fourth-tutorial"]{multiple output targets}, you ca } -@item{If this key doesn't exist, or refers to a nonexistent file, look for a default template with the name @code[(format "~a.[output extension]" setup:default-default-template-prefix)]. Meaning, if @racket[_source-path] is @code[(format "intro.html.~a" setup:default-markup-source-ext)], the output path would be @code["intro.html"], so the default template would be @code[(format "~a.html" setup:default-default-template-prefix)]. Look for this default template in the same directory as the source file, and then search upwards within successive parent directories. (Corollary: a default template in the project root will apply to all files in the project unless overridden within a subdirectory.)} +@item{If this key doesn't exist, or refers to a nonexistent file, look for a default template with the name @code[(format "~a.[output extension]" setup:default-template-prefix)]. Meaning, if @racket[_source-path] is @code[(format "intro.html.~a" setup:default-markup-source-ext)], the output path would be @code["intro.html"], so the default template would be @code[(format "~a.html" setup:default-template-prefix)]. Look for this default template in the same directory as the source file, and then search upwards within successive parent directories. (Corollary: a default template in the project root will apply to all files in the project unless overridden within a subdirectory.)} @item{If this file doesn't exist, use the fallback template as a last resort. (See @secref["Templates" #:tag-prefixes '("tutorial-2") diff --git a/pollen/scribblings/setup.scrbl b/pollen/scribblings/setup.scrbl index 2dd0f7d..b6f0cd0 100644 --- a/pollen/scribblings/setup.scrbl +++ b/pollen/scribblings/setup.scrbl @@ -16,7 +16,7 @@ Global values that are used throughout the Pollen system. I mean @italic{parameters} in the Racket sense, i.e. values that can be fed to @racket[parameterize]. @defparam[setup:current-server-port port integer?]{ -A parameter that sets the HTTP port for the project server. Initialized to @racket[setup:default-default-port].} +A parameter that sets the HTTP port for the project server. Initialized to @racket[setup:default-project-server-port].} @defparam[setup:current-project-root port path?]{ @@ -68,7 +68,7 @@ Of course, you can restore the defaults simply by removing these defined values These values are each equipped with a corresponding @racket[setup:]@racket[_name] function that will return the value loaded from the @racket[setup] submodule (if @racket[_name] was defined there), otherwise it returns the original value for @racket[setup:]@racket[_name]. For instance, @racket[setup:default-command-char] will always be @litchar{◊}, but in the example above, @racket[setup:command-char] would return @litchar{🎸}. -@defoverridable[default-port integer?]{ +@defoverridable[project-server-port integer?]{ Determines the default HTTP port for the project server. Initialized to @racket[8080].} @@ -106,7 +106,7 @@ File extensions for Pollen source files, initialized to the following values: @defoverridable[decodable-extensions (listof symbol?)]{File extensions that are eligible for decoding.} -@defoverridable[default-pagetree string?]{Pagetree that Pollen dashboard loads by default in each directory. Initialized to @filepath{index.ptree}.} +@defoverridable[main-pagetree string?]{Pagetree that Pollen dashboard loads by default in each directory. Initialized to @filepath{index.ptree}.} @defoverridable[pagetree-root-node symbol?]{Name of the root node in a decoded pagetree. It's ignored by the code, so its only role is to clue you in that you're looking at something that came out of the pagetree decoder. Initialized to @code{'pagetree-root}.} @@ -124,7 +124,7 @@ File extensions for Pollen source files, initialized to the following values: @defoverridable[command-char char?]{The magic character that indicates a Pollen command, function, or variable. Initialized to @racket[#\◊].} -@defoverridable[default-template-prefix string?]{Prefix of the default template. Initialized to @code{"template"}.} +@defoverridable[template-prefix string?]{Prefix of the default template. Initialized to @code{"template"}.} @defoverridable[fallback-template-prefix string?]{Used to generate the name of the fallback template (i.e., the template used to render a Pollen markup file when no other template can be found). Prefix is combined with the output suffix of the source file. Initialized to @code{"fallback"}.} diff --git a/pollen/scribblings/tutorial-first.scrbl b/pollen/scribblings/tutorial-first.scrbl index ad0cd21..3165a7a 100644 --- a/pollen/scribblings/tutorial-first.scrbl +++ b/pollen/scribblings/tutorial-first.scrbl @@ -234,7 +234,7 @@ Though port @tt{8080} is the default, you can start the project server on any po > raco pollen start /path/to/tutorial 8088 } -@margin-note{You can also change the default port by altering @racket[setup:default-default-port], or parameterizing it with @racket[setup:current-server-port].} +@margin-note{You can also change the default port by altering @racket[setup:default-project-server-port], or parameterizing it with @racket[setup:current-server-port].} Note that when you pass a port argument, you also have to pass a path argument. (Without it, you'll get an error, as illustrated below.) If you want the project server to start in the current directory, you can use the usual @litchar{.} shorthand: diff --git a/pollen/setup.rkt b/pollen/setup.rkt index 0a599f6..cb44db0 100644 --- a/pollen/setup.rkt +++ b/pollen/setup.rkt @@ -62,14 +62,14 @@ (define-settable decodable-extensions (list (markup-source-ext) (pagetree-source-ext))) -(define-settable default-pagetree (format "index.~a" (pagetree-source-ext))) +(define-settable main-pagetree (format "index.~a" (pagetree-source-ext))) (define-settable pagetree-root-node 'pagetree-root) (define-settable main-root-node 'root) (define-settable command-char #\◊) (define-settable template-command-char #\∂) -(define-settable default-template-prefix "template") +(define-settable template-prefix "template") (define-settable fallback-template-prefix "fallback") (define-settable template-meta-key "template") @@ -88,9 +88,9 @@ (define-settable paths-excluded-from-dashboard (map string->path (list "poldash.css" "compiled"))) -(define-settable default-port 8080) +(define-settable project-server-port 8080) -(define current-server-port (make-parameter (default-port))) +(define current-server-port (make-parameter (project-server-port))) (define-settable dashboard-css "poldash.css")