Tweaks
This commit is contained in:
parent
065da7d61e
commit
f046b4d76b
|
@ -39,6 +39,7 @@
|
||||||
#:title-element [title-element `(h1 ,title)]
|
#:title-element [title-element `(h1 ,title)]
|
||||||
#:code [code 200]
|
#:code [code 200]
|
||||||
#:message [message #"Okay"]
|
#:message [message #"Okay"]
|
||||||
|
#:body-class [body-class #f]
|
||||||
.
|
.
|
||||||
body-contents)
|
body-contents)
|
||||||
(response/xexpr
|
(response/xexpr
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
(link ((rel "stylesheet") (href "/style.css") (type "text/css")))
|
(link ((rel "stylesheet") (href "/style.css") (type "text/css")))
|
||||||
,@(for/list ((sheet (bootstrap-page-stylesheets)))
|
,@(for/list ((sheet (bootstrap-page-stylesheets)))
|
||||||
`(link ((rel "stylesheet") (href ,sheet) (type "text/css")))))
|
`(link ((rel "stylesheet") (href ,sheet) (type "text/css")))))
|
||||||
(body
|
(body ,@(maybe-splice body-class `((class ,body-class)))
|
||||||
(nav ((class "navbar navbar-inverse navbar-fixed-top") (role "navigation"))
|
(nav ((class "navbar navbar-inverse navbar-fixed-top") (role "navigation"))
|
||||||
(div ((class "container"))
|
(div ((class "container"))
|
||||||
(div ((class "navbar-header"))
|
(div ((class "navbar-header"))
|
||||||
|
|
20
src/gravatar.rkt
Normal file
20
src/gravatar.rkt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(provide gravatar-hash
|
||||||
|
gravatar-image-url)
|
||||||
|
|
||||||
|
(require file/md5)
|
||||||
|
(require racket/string)
|
||||||
|
|
||||||
|
(define (gravatar-hash email)
|
||||||
|
(bytes->string/utf-8
|
||||||
|
(md5
|
||||||
|
(string-downcase
|
||||||
|
(string-trim email)))))
|
||||||
|
|
||||||
|
(define (gravatar-image-url email [size 80] #:extension [extension ""] #:default [default "identicon"])
|
||||||
|
(format "http://www.gravatar.com/avatar/~a~a?s=~a&d=~a"
|
||||||
|
(gravatar-hash email)
|
||||||
|
extension
|
||||||
|
size
|
||||||
|
default))
|
|
@ -217,7 +217,7 @@
|
||||||
(regexp-match? re (@ pkg _SEARCHABLE-TEXT_))))
|
(regexp-match? re (@ pkg _SEARCHABLE-TEXT_))))
|
||||||
|
|
||||||
(define (package-search text tags)
|
(define (package-search text tags)
|
||||||
(define res (map (lambda (r) (regexp (regexp-quote r))) (string-split text)))
|
(define res (map (lambda (r) (regexp (regexp-quote r #f))) (string-split text)))
|
||||||
(define packages (manager-rpc 'packages))
|
(define packages (manager-rpc 'packages))
|
||||||
(sort-package-names
|
(sort-package-names
|
||||||
(filter (lambda (package-name)
|
(filter (lambda (package-name)
|
||||||
|
|
114
src/site.rkt
114
src/site.rkt
|
@ -10,6 +10,7 @@
|
||||||
(require racket/string)
|
(require racket/string)
|
||||||
(require net/uri-codec)
|
(require net/uri-codec)
|
||||||
(require web-server/servlet)
|
(require web-server/servlet)
|
||||||
|
(require "gravatar.rkt")
|
||||||
(require "bootstrap.rkt")
|
(require "bootstrap.rkt")
|
||||||
(require "html-utils.rkt")
|
(require "html-utils.rkt")
|
||||||
(require "packages.rkt")
|
(require "packages.rkt")
|
||||||
|
@ -121,6 +122,9 @@
|
||||||
(li ((class "dropdown"))
|
(li ((class "dropdown"))
|
||||||
(a ((class "dropdown-toggle")
|
(a ((class "dropdown-toggle")
|
||||||
(data-toggle "dropdown"))
|
(data-toggle "dropdown"))
|
||||||
|
(img ((src ,(gravatar-image-url (session-email session)
|
||||||
|
48))))
|
||||||
|
" "
|
||||||
,(session-email session)
|
,(session-email session)
|
||||||
" "
|
" "
|
||||||
(span ((class "caret"))))
|
(span ((class "caret"))))
|
||||||
|
@ -213,6 +217,9 @@
|
||||||
,(form-group 4 5
|
,(form-group 4 5
|
||||||
`(a ((href ,(embed-url (lambda (req) (register-page)))))
|
`(a ((href ,(embed-url (lambda (req) (register-page)))))
|
||||||
"Need to reset your password?"))
|
"Need to reset your password?"))
|
||||||
|
,(form-group 4 5
|
||||||
|
`(a ((href ,(embed-url (lambda (req) (register-page)))))
|
||||||
|
"Register an account"))
|
||||||
,@(maybe-splice
|
,@(maybe-splice
|
||||||
error-message
|
error-message
|
||||||
(form-group 4 5
|
(form-group 4 5
|
||||||
|
@ -249,27 +256,15 @@
|
||||||
(lambda (embed-url)
|
(lambda (embed-url)
|
||||||
(bootstrap-response "Register/Reset Account"
|
(bootstrap-response "Register/Reset Account"
|
||||||
#:title-element ""
|
#:title-element ""
|
||||||
`(div
|
`(div ((class "registration-step-container"))
|
||||||
(h1 "Got a registration or reset code?")
|
(div ((class "registration-step"))
|
||||||
(p "Great! Enter it below, with your chosen password, to log in.")
|
(div (h1 "Step 1")
|
||||||
(form ((class "form-horizontal")
|
(p "Get a code")))
|
||||||
(method "post")
|
(span ((class "registration-step-arrow")) "→")
|
||||||
(action ,(embed-url apply-account-code))
|
(div ((class "registration-step"))
|
||||||
(role "form"))
|
(div (h1 "Step 2")
|
||||||
,(form-group 2 2 (label "email" "Email address")
|
(p "Use the code"))))
|
||||||
0 5 (email-input "email" email))
|
|
||||||
,(form-group 2 2 (label "code" "Code")
|
|
||||||
0 5 (text-input "code" code))
|
|
||||||
,(form-group 2 2 (label "password" "Password")
|
|
||||||
0 5 (password-input "password"))
|
|
||||||
,(form-group 2 2 (label "password" "Confirm password")
|
|
||||||
0 5 (password-input "confirm_password"))
|
|
||||||
,@(maybe-splice
|
|
||||||
error-message
|
|
||||||
(form-group 4 5
|
|
||||||
`(div ((class "alert alert-danger"))
|
|
||||||
(p ,error-message))))
|
|
||||||
,(form-group 4 5 (primary-button "Continue"))))
|
|
||||||
`(div
|
`(div
|
||||||
(h1 "Need a code?")
|
(h1 "Need a code?")
|
||||||
(p "Enter your email address below, and we'll send you one.")
|
(p "Enter your email address below, and we'll send you one.")
|
||||||
|
@ -277,9 +272,31 @@
|
||||||
(method "post")
|
(method "post")
|
||||||
(action ,(embed-url notify-of-emailing))
|
(action ,(embed-url notify-of-emailing))
|
||||||
(role "form"))
|
(role "form"))
|
||||||
,(form-group 2 2 (label "email" "Email address")
|
,(form-group 1 3 (label "email" "Email address")
|
||||||
0 5 (email-input "email_for_code"))
|
0 5 (email-input "email_for_code"))
|
||||||
,(form-group 4 5 (primary-button "Email me a code")))))))))
|
,(form-group 4 5 (primary-button "Email me a code"))))
|
||||||
|
|
||||||
|
`(div
|
||||||
|
(h1 "Got a registration or reset code?")
|
||||||
|
(p "Great! Enter it below, with your chosen password, to log in.")
|
||||||
|
(form ((class "form-horizontal")
|
||||||
|
(method "post")
|
||||||
|
(action ,(embed-url apply-account-code))
|
||||||
|
(role "form"))
|
||||||
|
,(form-group 1 3 (label "email" "Email address")
|
||||||
|
0 5 (email-input "email" email))
|
||||||
|
,(form-group 1 3 (label "code" "Code")
|
||||||
|
0 5 (text-input "code" code))
|
||||||
|
,(form-group 1 3 (label "password" "Password")
|
||||||
|
0 5 (password-input "password"))
|
||||||
|
,(form-group 1 3 (label "password" "Confirm password")
|
||||||
|
0 5 (password-input "confirm_password"))
|
||||||
|
,@(maybe-splice
|
||||||
|
error-message
|
||||||
|
(form-group 4 5
|
||||||
|
`(div ((class "alert alert-danger"))
|
||||||
|
(p ,error-message))))
|
||||||
|
,(form-group 4 5 (primary-button "Continue")))))))))
|
||||||
|
|
||||||
(define (apply-account-code request)
|
(define (apply-account-code request)
|
||||||
(define-form-bindings request (email code password confirm_password))
|
(define-form-bindings request (email code password confirm_password))
|
||||||
|
@ -347,8 +364,12 @@
|
||||||
(named-url search-page)
|
(named-url search-page)
|
||||||
(alist->form-urlencoded (list (cons 'tags (string-join tags))))))
|
(alist->form-urlencoded (list (cons 'tags (string-join tags))))))
|
||||||
|
|
||||||
(define (author-link author-name)
|
(define (author-link author-name #:gravatar? [gravatar? #f])
|
||||||
`(a ((href ,(tags-page-url (list (format "author:~a" author-name))))) ,author-name))
|
`(a ((href ,(tags-page-url (list (format "author:~a" author-name)))))
|
||||||
|
,@(maybe-splice gravatar?
|
||||||
|
`(img ((src ,(gravatar-image-url author-name 48))))
|
||||||
|
" ")
|
||||||
|
,author-name))
|
||||||
|
|
||||||
(define (tag-link tag-name)
|
(define (tag-link tag-name)
|
||||||
`(a ((href ,(tags-page-url (list tag-name)))) ,tag-name))
|
`(a ((href ,(tags-page-url (list tag-name)))) ,tag-name))
|
||||||
|
@ -357,8 +378,9 @@
|
||||||
`(a (,@attributes
|
`(a (,@attributes
|
||||||
(href ,(format "http://pkg-build.racket-lang.org/~a" url-suffix))) ,label))
|
(href ,(format "http://pkg-build.racket-lang.org/~a" url-suffix))) ,label))
|
||||||
|
|
||||||
(define (authors-list authors)
|
(define (authors-list authors #:gravatars? [gravatars? #f])
|
||||||
`(ul ((class "authors")) ,@(for/list ((author authors)) `(li ,(author-link author)))))
|
`(ul ((class "authors")) ,@(for/list ((author authors))
|
||||||
|
`(li ,(author-link author #:gravatar? gravatars?)))))
|
||||||
|
|
||||||
(define (package-links #:pretty? [pretty? #t] package-names)
|
(define (package-links #:pretty? [pretty? #t] package-names)
|
||||||
(if (and pretty? (null? (or package-names '())))
|
(if (and pretty? (null? (or package-names '())))
|
||||||
|
@ -434,26 +456,37 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define (main-page request)
|
(define (main-page request)
|
||||||
(parameterize ((bootstrap-active-navigation nav-index))
|
(parameterize ((bootstrap-active-navigation nav-index)
|
||||||
|
(bootstrap-page-scripts '("/mainpage.js")))
|
||||||
(define package-name-list (package-search "" '((main-distribution #f))))
|
(define package-name-list (package-search "" '((main-distribution #f))))
|
||||||
(authentication-wrap
|
(authentication-wrap
|
||||||
#:request request
|
#:request request
|
||||||
(bootstrap-response "Racket Package Index"
|
(bootstrap-response "Racket Package Index"
|
||||||
#:title-element ""
|
#:title-element ""
|
||||||
|
#:body-class "main-page"
|
||||||
`(div ((class "jumbotron"))
|
`(div ((class "jumbotron"))
|
||||||
(h1 "Racket Package Index")
|
(h1 "Racket Packages")
|
||||||
(p "These are the packages available via the "
|
(p "These are the packages in the "
|
||||||
(a ((href "http://docs.racket-lang.org/pkg/getting-started.html"))
|
(a ((href "http://docs.racket-lang.org/pkg/getting-started.html"))
|
||||||
"Racket package system") ".")
|
"Racket package system") ".")
|
||||||
(p "Simply run " (kbd "raco pkg install " (var "package-name"))
|
(p (a ((href "http://docs.racket-lang.org/pkg/cmdline.html"))
|
||||||
" to install a package.")
|
(kbd "raco pkg install " (var "package-name")))
|
||||||
(p ((class "text-center"))
|
" installs a package.")
|
||||||
(span ((class "package-count")) ,(~a (length package-name-list)))
|
(p "You can "
|
||||||
" packages in the index.")
|
(a ((id "create-package-link")
|
||||||
|
(href ,(named-url edit-package-page)))
|
||||||
|
(span ((class "label label-success"))
|
||||||
|
,(glyphicon 'plus-sign)
|
||||||
|
" add your own"))
|
||||||
|
" packages to the index."))
|
||||||
|
`(div ((id "search-box"))
|
||||||
(form ((role "form")
|
(form ((role "form")
|
||||||
(action ,(named-url search-page)))
|
(action ,(named-url search-page)))
|
||||||
,(text-input "q" #:placeholder "Search packages")))
|
,(text-input "q" #:placeholder "Search packages")))
|
||||||
(package-summary-table package-name-list)))))
|
`(div
|
||||||
|
(p ((class "package-count"))
|
||||||
|
,(format "~a packages" (length package-name-list)))
|
||||||
|
,(package-summary-table package-name-list))))))
|
||||||
|
|
||||||
(define (logout-page request)
|
(define (logout-page request)
|
||||||
(with-site-config
|
(with-site-config
|
||||||
|
@ -563,7 +596,8 @@
|
||||||
|
|
||||||
`(table ((class "package-details"))
|
`(table ((class "package-details"))
|
||||||
(tr (th "Authors")
|
(tr (th "Authors")
|
||||||
(td ,(authors-list (@ pkg authors))))
|
(td (div ((class "authors-detail"))
|
||||||
|
,(authors-list #:gravatars? #t (@ pkg authors)))))
|
||||||
(tr (th "Documentation")
|
(tr (th "Documentation")
|
||||||
(td ,(doc-links (@ pkg build docs))))
|
(td ,(doc-links (@ pkg build docs))))
|
||||||
(tr (th "Tags")
|
(tr (th "Tags")
|
||||||
|
@ -748,8 +782,8 @@
|
||||||
(define old-name (draft-package-old-name draft))
|
(define old-name (draft-package-old-name draft))
|
||||||
(define has-old-name? (not (equal? old-name "")))
|
(define has-old-name? (not (equal? old-name "")))
|
||||||
(bootstrap-response (if has-old-name?
|
(bootstrap-response (if has-old-name?
|
||||||
(format "Editing package ~a" old-name)
|
(format "Edit package ~a" old-name)
|
||||||
"Creating a new package")
|
"Create a new package")
|
||||||
(if error-message
|
(if error-message
|
||||||
`(div ((class "alert alert-danger"))
|
`(div ((class "alert alert-danger"))
|
||||||
,(glyphicon 'exclamation-sign) " " ,error-message)
|
,(glyphicon 'exclamation-sign) " " ,error-message)
|
||||||
|
@ -1032,7 +1066,7 @@
|
||||||
(match t
|
(match t
|
||||||
[(pregexp #px"!(.*)" (list _ tag)) (list (string->symbol tag) #f)]
|
[(pregexp #px"!(.*)" (list _ tag)) (list (string->symbol tag) #f)]
|
||||||
[tag (list (string->symbol tag) #t)])))
|
[tag (list (string->symbol tag) #t)])))
|
||||||
(bootstrap-response "Search Racket Package Index"
|
(bootstrap-response "Search Package Index"
|
||||||
`(form ((class "form-horizontal")
|
`(form ((class "form-horizontal")
|
||||||
(role "form"))
|
(role "form"))
|
||||||
,(form-group 0 2 (label "q" "Search terms")
|
,(form-group 0 2 (label "q" "Search terms")
|
||||||
|
|
3
static/mainpage.js
Normal file
3
static/mainpage.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
$(document).ready(function () {
|
||||||
|
$("#q").focus();
|
||||||
|
});
|
|
@ -52,6 +52,9 @@ ul.list-inline li { padding-right: 0; }
|
||||||
ul.authors { list-style: none; padding: 0; }
|
ul.authors { list-style: none; padding: 0; }
|
||||||
ul.authors a { color: black; }
|
ul.authors a { color: black; }
|
||||||
|
|
||||||
|
.authors-detail ul { margin: 0; }
|
||||||
|
.authors-detail li { margin: 0 0 0.5em 0; }
|
||||||
|
|
||||||
table.packages h2 { font-size: 160%; margin-top: 0; }
|
table.packages h2 { font-size: 160%; margin-top: 0; }
|
||||||
|
|
||||||
ul.build-results,
|
ul.build-results,
|
||||||
|
@ -59,7 +62,13 @@ ul.module-list {
|
||||||
list-style: none; padding: 0;
|
list-style: none; padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search-box {
|
||||||
|
margin: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
.search-results { margin-top: 3em; }
|
.search-results { margin-top: 3em; }
|
||||||
|
|
||||||
|
.main-page .package-count,
|
||||||
.search-results .package-count {
|
.search-results .package-count {
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
@ -73,10 +82,10 @@ input#new_version {
|
||||||
.confirm-package-deletion {
|
.confirm-package-deletion {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
|
width: 50%;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
width: 50%;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: white;
|
color: white;
|
||||||
border: solid yellow 1em;
|
border: solid yellow 1em;
|
||||||
|
@ -95,6 +104,10 @@ input#new_version {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jumbotron #create-package-link {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sortable tables */
|
/* Sortable tables */
|
||||||
th.headerSortUp::after { content: " ▼"; }
|
th.headerSortUp::after { content: " ▼"; }
|
||||||
th.headerSortDown::after { content: " ▲"; }
|
th.headerSortDown::after { content: " ▲"; }
|
||||||
|
@ -104,3 +117,25 @@ th.headerSortDown::after { content: " ▲"; }
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.registration-step-container {
|
||||||
|
margin: 2em auto;
|
||||||
|
display: block;
|
||||||
|
width: 44em;
|
||||||
|
}
|
||||||
|
.registration-step-arrow {
|
||||||
|
font-size: 300%;
|
||||||
|
}
|
||||||
|
.registration-step {
|
||||||
|
display: inline-block;
|
||||||
|
background: #5CB85C; /* "success" colour */
|
||||||
|
padding: 1em;
|
||||||
|
margin: 2em;
|
||||||
|
width: 16em;
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
text-shadow: 1px 1px 3px #444;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.registration-step h1 { margin: 0.5em; }
|
||||||
|
.registration-step p { font-size: 140%; }
|
Loading…
Reference in New Issue
Block a user