limit display length of paste titles
This commit is contained in:
parent
c6bbec5ffc
commit
cf51352a69
|
@ -25,3 +25,12 @@
|
||||||
|
|
||||||
;; stx utils
|
;; stx utils
|
||||||
(define (stx->string stx) (to-string/s (syntax->datum stx)))
|
(define (stx->string stx) (to-string/s (syntax->datum stx)))
|
||||||
|
|
||||||
|
|
||||||
|
;; string-truncate : String -> String
|
||||||
|
;; Truncates the given str to len-limit chars,
|
||||||
|
;; or returns str unchanged if its length is <= len-limit
|
||||||
|
(define (string-truncate str len-limit)
|
||||||
|
(if (<= (string-length str) len-limit)
|
||||||
|
str
|
||||||
|
(substring str 0 len-limit)))
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
(define scrbl-exe "/home/stchang/racket611/bin/scribble")
|
(define scrbl-exe "/home/stchang/racket611/bin/scribble")
|
||||||
|
|
||||||
|
(define PASTE-TITLE-DISPLAY-LEN 32) ; limit length of displayed title
|
||||||
|
|
||||||
(define (mk-paste-url paste-num) (++ paste-url-base paste-num))
|
(define (mk-paste-url paste-num) (++ paste-url-base paste-num))
|
||||||
|
|
||||||
;(define (mk-link url txt) `(a ((href ,url)) ,txt))
|
;(define (mk-link url txt) `(a ((href ,url)) ,txt))
|
||||||
|
@ -363,8 +365,10 @@
|
||||||
(with-redis-connection
|
(with-redis-connection
|
||||||
(for/list ([pnum recent-pastes] #:when pnum)
|
(for/list ([pnum recent-pastes] #:when pnum)
|
||||||
(define name (HGET/str pnum 'name))
|
(define name (HGET/str pnum 'name))
|
||||||
|
(define trunc-name
|
||||||
|
(string-truncate name PASTE-TITLE-DISPLAY-LEN))
|
||||||
`(tr (td ,(mk-link (mk-paste-url pnum) pnum))
|
`(tr (td ,(mk-link (mk-paste-url pnum) pnum))
|
||||||
(td ((style "width:1px"))) (td ,name)))))))
|
(td ((style "width:1px"))) (td ,trunc-name)))))))
|
||||||
;; middle ------------------------------------------------------------
|
;; middle ------------------------------------------------------------
|
||||||
(div ((style ,(~~ "position:absolute;left:14em;top:2em")))
|
(div ((style ,(~~ "position:absolute;left:14em;top:2em")))
|
||||||
(center
|
(center
|
||||||
|
|
Loading…
Reference in New Issue
Block a user