Permalink
Browse files

Update with Racket 5.1 changes.

Remove link to I Read Like.
  • Loading branch information...
dchest committed Jul 27, 2011
1 parent a4a2b08 commit 74b026e83eb306b48493ba76cb17ca65e2571275
Showing with 26 additions and 13 deletions.
  1. +25 −10 app.rkt
  2. +1 −1 templates/base.html
  3. +0 −2 templates/index.html
View
35 app.rkt
@@ -41,9 +41,12 @@
(get-category (safe-substring text 0 3000))))
(define (index-template short?)
(list TEXT/HTML-MIME-TYPE
(base-template "" "analyzer"
(include-template "templates/index.html"))))
(response/full
200 #"Okay"
(current-seconds) TEXT/HTML-MIME-TYPE
empty
(list (string->bytes/utf-8 (base-template "" "analyzer"
(include-template "templates/index.html"))))))
(define (badge-url author)
(string-append "/b/" (string->crc32/hex author)))
@@ -56,7 +59,11 @@
(index-template #f)))
(define (json-out s)
(list #"application/json; charset=utf-8" (string->bytes/utf-8 s)))
(response/full
200 #"Okay"
(current-seconds) #"application/json; charset=utf-8"
empty
(list (string->bytes/utf-8 s))))
(define (json-error desc)
(json-out (format "{\"error\": \"~a\"}" desc)))
@@ -83,17 +90,21 @@
(json-error "not enough arguments"))))
(define (not-found req)
(make-response/full 404 #"Not Found" (current-seconds)
TEXT/HTML-MIME-TYPE null (list #"not found")))
(response/full 404 #"Not Found" (current-seconds)
TEXT/HTML-MIME-TYPE empty (list #"not found")))
(define (crc->author crc)
(hash-ref *authors-hash* crc #f))
(define-macro (badge-template req crc tpl)
`(let ([writer (crc->author ,crc)])
(if writer
(list TEXT/HTML-MIME-TYPE
(base-template writer "" (include-template ,tpl)))
(response/full
200 #"Okay"
(current-seconds) TEXT/HTML-MIME-TYPE
empty
(list (string->bytes/utf-8
(base-template writer "" (include-template ,tpl)))))
(not-found ,req))))
(define (show-badge req crc)
@@ -112,9 +123,13 @@
(not-found req)))
(define (show-newsletter req)
(list TEXT/HTML-MIME-TYPE
(response/full
200 #"Okay"
(current-seconds) TEXT/HTML-MIME-TYPE
empty
(list (string->bytes/utf-8
(base-template "Newsletter" "newsletter"
(include-template "templates/show-newsletter.html"))))
(include-template "templates/show-newsletter.html"))))))
(define (start req)
(app-dispatch req))
View
@@ -36,4 +36,4 @@ <h1><a href="/">I Write Like</a></h1>
@include-template{analytics.html}
</body>
</html>
</html>
View
@@ -1,7 +1,5 @@
<div class="content">
<p><span style="color:red">New!</span> <a href="/read/">I Read Like - check which famous reader you read like.</a></p>
<p><b>Check <em style="background:#FFFFE0">which famous writer you write like</em> with this statistical analysis tool, which analyzes your word choice and writing style and compares them with those of the famous writers.</b>
<p>Any text in English will do: your latest blog post, journal entry, comment, chapter of your unfinished book, etc.
@when{@short? <span style="background:red; color:white">}

0 comments on commit 74b026e

Please sign in to comment.