Permalink
Browse files

misc

  • Loading branch information...
1 parent f6abea9 commit d39e4d597023a62cde76fc68934b0694b2ab2426 Mike Travers committed Jul 6, 2012
Showing with 56 additions and 21 deletions.
  1. +3 −2 public/index.thtml
  2. +7 −0 public/style.css
  3. +40 −19 src/server.lisp
  4. +6 −0 src/website.lisp
View
@@ -14,14 +14,15 @@
<table>
<tr>
<td width="50%" >
-<h2>Introduction</h2>LinkBack is a browser extension for Chrome that will automatically display incoming links for any web page you visit. Incoming links show up in an overlay window. For example, here's the <a href="http://en.wikipedia.org/wiki/Hypertext">Wikipedia entry for Hypertext</a> with LinkBack operating in the lower-right corner.
+LinkBack is a browser extension for Chrome that will automatically display incoming links for any web page you visit. Incoming links show up in an overlay window. For example, here's the <a href="http://en.wikipedia.org/wiki/Hypertext">Wikipedia entry for Hypertext</a> with LinkBack operating in the lower-right corner.
+<p>
<a href="hypertext.png"><img src="hypertext.png" style="width:450px;"/></a>
<td >
<h2>Installation</h2>
<!-- #if expr="wu::*chrome?*" -->
-<p>To install the Chrome extension, click the nice big button:</p>
+<p>Click the nice big button:</p>
<p style="margin-top:50px;margin-left:auto;margin-right:auto;width:200px"> <a class="signup_button" href="/linkback.crx">Install</a></p>
<!--#else -->
For now, LinkBack only works on Chrome.
View
@@ -30,6 +30,8 @@ td {
background: #161652;
font: normal normal normal 10pt Calibri;
color: white;
+ list-style: none;
+ padding: 20 px;
}
.morelinks a:link {
color: #F1F5A0;
@@ -39,3 +41,8 @@ td {
.morelinks a:visited {
color: #EEE474;
}
+
+.morelinks a:hover {
+ background: #EEEEEE;
+ color: #161652;
+}
View
@@ -137,8 +137,11 @@
(defparameter *page-size* 40)
(defun linkback-html-service (req ent)
- (let* ((page (trim-page-url (request-query-value "page" req)))
+ (let* (;; page is URL, not page #
+ (page (trim-page-url (request-query-value "page" req)))
(offset (ignore-errors (parse-integer (request-query-value "offset" req))))
+ ;; zero-based page #
+ (pagen (or (and offset (/ offset *page-size*)) 0))
(results (seomoz-query page :limit *page-size* :offset offset)))
(with-http-response (req ent)
(with-http-body (req ent)
@@ -148,22 +151,40 @@
(:body
(:h2 "Links to "
(link-to page page))
-
- (if results
- (progn
- (when offset (html
- (:h3 (:princ (format nil "Page ~A" (1+ (/ offset *page-size*)))))))
- (html
- ((:ul :class "morelinks")
- (dolist (result results)
- (html
- (:li
- ((:a :href (mt:string+ "http://" (car result)))
- (:princ (if (zerop (length (cadr result)))
- (car result)
- (de-unicode-string (cadr result))))))))))
- (when (= (length results) *page-size*)
- (link-to "More" (format nil "/linkback.html?~A"
- (query-to-form-urlencoded `(("page" . ,page) ("offset" . ,(+ (or offset 0) *page-size*))))))))
- (html "No more results"))))))))
+ (if results
+ (progn
+ (when offset (html
+ (:h3 (:princ (format nil "Page ~A" (1+ pagen))))))
+ (html
+ ((:ul :class "morelinks")
+ (dolist (result results)
+ (html
+ (:li
+ ((:a :href (mt:string+ "http://" (car result)))
+ (:princ (if (zerop (length (cadr result)))
+ (car result)
+ (de-unicode-string (cadr result))))))))))
+ (flet ((pageurl (pagen)
+ (format nil "/linkback.html?~A"
+ (query-to-form-urlencoded
+ `(("page" . ,page)
+ ("offset" . ,(* *page-size* pagen))))))) ; (+ (or offset 0) *page-size*)))))
+ (when offset
+ (link-to (format nil "&larr; Page ~A" (1+ (1- pagen)))
+ (pageurl (1- pagen))))
+ (when (or offset (= (length results) *page-size*))
+ (html "&emsp;&bull;&emsp;"))
+ (when (= (length results) *page-size*)
+ (link-to (format nil "Page ~A &rarr;" (1+ (1+ pagen)))
+ (pageurl (1+ pagen))))))
+ (html "No more results"))
+ (html
+ ((:div :style "top-margin: 5px;")
+ "Brought to you by "
+ ((:a :href "/") "LinkBack") :br
+ "Data kindly provided by "
+ ((:a :href "http://seomoz.org/")
+ "seomoz.org"
+ ((:img :src "linkscape.png")))))
+ ))))))
View
@@ -2,9 +2,15 @@
(defvar *linkback-public-directory*)
+(defun cache-control-headers (&optional (spec 31536000))
+ (unless (eq spec :no-header)
+ ;; no-cache ought to be enough, but isn't
+ `(("Cache-control" . ,(if (eq spec :no-cache) "no-cache,no-store,must-revalidate" (format nil "max-age=~A, public" spec))))))
+
(defun publish-website (&optional (from "/app/public/"))
(setq *linkback-public-directory* from)
(publish-directory :destination from
+ :headers (cache-control-headers)
:prefix "/"))
;;; Want to put in a check for Chrome, but that requires either a templating engine or pulling the static page into code...

0 comments on commit d39e4d5

Please sign in to comment.