From fb2b5418df9f6688a13b4da7bc8ae432d0ed9fda Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Wed, 27 Jun 2012 09:19:18 -0400 Subject: [PATCH] More files for all sites. Two verification files for google/bing website tools, and also add a no-op robots.txt file to avoid error-log lines. --- collects/meta/web/common/layout.rkt | 59 ++++++++++++++------------ collects/meta/web/common/resources.rkt | 17 ++++++-- collects/meta/web/stubs/git.rkt | 10 ++--- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/collects/meta/web/common/layout.rkt b/collects/meta/web/common/layout.rkt index c0339134c2..d899e516c4 100644 --- a/collects/meta/web/common/layout.rkt +++ b/collects/meta/web/common/layout.rkt @@ -1,6 +1,6 @@ #lang at-exp racket/base -(require scribble/html (for-syntax racket/base syntax/name) +(require scribble/html (for-syntax racket/base syntax/name syntax/parse) "utils.rkt" "resources.rkt") (define-for-syntax (process-contents who layouter stx xs) @@ -210,33 +210,36 @@ ;; site) to have its own resources (and possibly other customizations). (provide define+provide-context define-context) (define-for-syntax (make-define+provide-context stx provide?) - (define (make-it dir [resources #f]) - (with-syntax ([dir dir] - [page-id (datum->syntax stx 'page)] - [plain-id (datum->syntax stx 'plain)] - [copyfile-id (datum->syntax stx 'copyfile)] - [symlink-id (datum->syntax stx 'symlink)] - [resources-id (datum->syntax stx 'the-resources)]) - (with-syntax ([resources (or resources #'(make-resources - (make-resource-files dir)))] - [provides (if provide? - #'(provide page-id plain-id copyfile-id - symlink-id resources-id) - #'(begin))]) - #'(begin - (define resources-id resources) - (define-syntax-rule (page-id . xs) - (page #:resources resources-id #:dir dir . xs)) - (define-syntax-rule (plain-id . xs) - (plain #:dir dir . xs)) - (define (copyfile-id source [target #f]) - (copyfile-resource source target #:dir dir)) - (define (symlink-id source [target #f]) - (symlink-resource source target #:dir dir)) - provides)))) - (syntax-case stx () - [(_ dir) (make-it #'dir)] - [(_ dir #:resources resources) (make-it #'dir #'resources)])) + (syntax-parse stx + [(_ (~or (~optional dir:expr) + (~optional (~seq #:resources resources)) + (~optional (~seq #:robots.txt robots.txt) + #:defaults ([robots.txt #'#t]))) + ...) + (unless (attribute dir) + (raise-syntax-error 'define-context "missing ")) + (with-syntax ([page-id (datum->syntax stx 'page)] + [plain-id (datum->syntax stx 'plain)] + [copyfile-id (datum->syntax stx 'copyfile)] + [symlink-id (datum->syntax stx 'symlink)] + [resources-id (datum->syntax stx 'the-resources)]) + (with-syntax ([resources (or (attribute resources) + #'(make-resources (make-resource-files + dir robots.txt)))] + [provides (if provide? + #'(provide page-id plain-id copyfile-id + symlink-id resources-id) + #'(begin))]) + #'(begin (define resources-id resources) + (define-syntax-rule (page-id . xs) + (page #:resources resources-id #:dir dir . xs)) + (define-syntax-rule (plain-id . xs) + (plain #:dir dir . xs)) + (define (copyfile-id source [target #f]) + (copyfile-resource source target #:dir dir)) + (define (symlink-id source [target #f]) + (symlink-resource source target #:dir dir)) + provides)))])) (define-syntax (define+provide-context stx) (make-define+provide-context stx #t)) (define-syntax (define-context stx) diff --git a/collects/meta/web/common/resources.rkt b/collects/meta/web/common/resources.rkt index 5af468e8f2..820cf877e9 100644 --- a/collects/meta/web/common/resources.rkt +++ b/collects/meta/web/common/resources.rkt @@ -13,14 +13,25 @@ (provide make-resource-files navbar-style page-sizes font-family) ; needed for the blog template -(define (make-resource-files dir) +(define (make-resource-files dir robots.txt) (define (copyfile file) (copyfile-resource (in-here file) (web-path dir file))) - (define (writefile file contents) + (define (writefile file . contents) (resource (web-path dir file) (file-writer output (list contents "\n")))) `([logo ,(copyfile "logo.png")] [icon ,(copyfile "plticon.ico")] - [style ,(writefile "plt.css" racket-style)])) + [style ,(writefile "plt.css" racket-style)] + [verification:google + @,writefile["google5b2dc47c0b1b15cb.html"]{ + google-site-verification: google5b2dc47c0b1b15cb.html}] + [verification:bing + @,writefile["BingSiteAuth.xml"]{ + + 140BE58EEC31CB97382E1016E21C405A}] + [robots + ;; #t (the default) => no-op file, good to avoid error-log lines + ,(let ([t (if (eq? #t robots.txt) "User-agent: *\nDisallow:" robots.txt)]) + (and t (writefile "robots.txt" t)))])) (define page-sizes @list{ diff --git a/collects/meta/web/stubs/git.rkt b/collects/meta/web/stubs/git.rkt index 7b09345066..0e388eeecc 100644 --- a/collects/meta/web/stubs/git.rkt +++ b/collects/meta/web/stubs/git.rkt @@ -1,6 +1,9 @@ #lang meta/web -(define-context "stubs/git") +(define-context "stubs/git" + #:robots.txt @list{User-agent: * + @(add-newlines (for/list ([d '(plt libs testing play)]) + @list{Disallow: /@|d|/}))}) (provide git) (define git @@ -27,11 +30,6 @@ @p{See the "brief", PLT-oriented @intro{introduction to git}.}})) (define home-file @plain[#:file "home-text.html" home-text]) -(define robots.txt - @plain{User-agent: * - @(add-newlines (for/list ([d '(plt libs testing play)]) - @list{Disallow: /@|d|/}))}) - (define gitweb-config @plain[#:file "gitweb_config.perl"]{ our $projectroot = "repos";