Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

#31 update blog sample with pagination

  • Loading branch information...
commit 9079ce713ab505081842d27f6b9cc00426e93ab5 1 parent 2fe3e13
@liquidz authored
View
4 .gitignore
@@ -9,8 +9,8 @@
/.lein-deps-sum
/blog
/test/public
-/samples/*/public/2011-01
-/samples/*/public/2012-02
+/samples/*/public/201*
+/samples/*/public/page[0-9]*
/samples/*/public/tag
/samples/*/public/atom.xml
/samples/*/public/index.html
View
12 samples/blog/_config.clj
@@ -46,6 +46,18 @@
;; default value: :date-desc
:post-sort-type :date-desc
+ ;; regexp to detect index template
+ ;; default value: #"^index\."
+ :index-template-regexp #"^index\.html\.clj$"
+
+ ;; post number per page
+ ;; default value: nil (disabled pagination)
+ :posts-per-page 2
+
+ ;; filename format to generate index file with pagination
+ ;; default value: "page{{page}}/{{filename}}"
+ :page-filename-format "page{{page}}/{{filename}}"
+
;; clojurescript compile options
;; src-dir base is `:template-dir`
;; output-dir base is `:public-dir`
View
4 samples/blog/template/index.html.clj
@@ -16,6 +16,10 @@
;; Sample posts
(page-header "Sample posts")
(post-list)
+(if-let [url (:prev-page site)]
+ (link "prev page" url))
+(if-let [url (:next-page site)]
+ (link "next page" url))
;; Sample post tags
(page-header "Sample tags")
View
83 samples/blog/template/posts/2011-01-01-post1.html.clj
@@ -1,81 +1,14 @@
; @layout post
-; @title Sample components
-; @tag tag1 tag2
+; @title Pagination
+; @tag tag3
-(h2 "Link")
-#-CLJ
-(link "label" "http://localhost/")
-(link "http://localhost/")
-(link "`code`" "http://localhost/")
-CLJ
-(link "label" "http://localhost/")
-[:br]
-(link "http://localhost/")
-[:br]
-(link "`code`" "http://localhost/")
-
-(h2 "Unordered list")
-#-CLJ
-(ul (range 3))
-(ul #(str "[" % "]") (range 3))
-CLJ
-(ul (range 3))
-(ul #(str "[" % "]") (range 3))
-
-(h2 "Definition list")
-#-CLJ
-(dl {:a 1, :b 2})
-(dl [:hello "world" :foo "`bar`"])
-CLJ
-(dl {:a 1, :b 2})
-(dl [:hello "world" :foo "`bar`"])
-
-(h2 "Block quote")
-#-CLJ
-(blockquote
- "foo
- bar"
- [:a {:href "#"} "baz"])
-CLJ
-(blockquote
- "foo
- bar"
- [:a {:href "#"} "baz"])
+(h1 (:page site))
-(h2 "Inline code")
-#-CLJ
-(code "clojure.core/+")
+(p "Pagination setting.")
+##CLJ
+:index-template-regexp #"^index\.html\.clj$"
+:posts-per-page 2
+:page-filename-format "page{{page}}/{{filename}}"
CLJ
-(code "clojure.core/+")
-(h2 "Source code")
-[:p "Comment out following code."]
-#-CLOJURE
-#-CLJ
-(let [msg "world"]
- (println "hello," msg))
-CLJ
-CLOJURE
-#-CLJ
-(let [msg "world"]
- (println "hello," msg))
-CLJ
-
-(h2 "Paragraph")
-#-CLJ
-(p "hello, world")
-(p "paragraph with `inline` code")
-CLJ
-(p "hello, world")
-(p "paragraph with `inline` code")
-
-(h2 "JavaScript")
-#-CLJ
-(js "a.js" "b.js")
-CLJ
-
-(h2 "Style Sheet")
-#-CLJ
-(css "a.css" "b.css")
-CLJ
View
88 samples/blog/template/posts/2012-02-02-post2.html.clj
@@ -1,21 +1,81 @@
; @layout post
-; @title The quick brown fox
-; @tag tag2 tag3
+; @title Sample components
+; @tag tag1 tag2
-(def MAX 50)
+(h2 "Link")
+#-CLJ
+(link "label" "http://localhost/")
+(link "http://localhost/")
+(link "`code`" "http://localhost/")
+CLJ
+(link "label" "http://localhost/")
+[:br]
+(link "http://localhost/")
+[:br]
+(link "`code`" "http://localhost/")
+(h2 "Unordered list")
+#-CLJ
+(ul (range 3))
+(ul #(str "[" % "]") (range 3))
+CLJ
+(ul (range 3))
+(ul #(str "[" % "]") (range 3))
-(defn int->html-color [max-num n]
- (let [x (int (/ (* 255 n) max-num))
- s (Integer/toHexString (- 255 x))
- s (if (next s) s (str "0" s))]
- (str "#" s s s)))
+(h2 "Definition list")
+#-CLJ
+(dl {:a 1, :b 2})
+(dl [:hello "world" :foo "`bar`"])
+CLJ
+(dl {:a 1, :b 2})
+(dl [:hello "world" :foo "`bar`"])
+(h2 "Block quote")
+#-CLJ
+(blockquote
+ "foo
+ bar"
+ [:a {:href "#"} "baz"])
+CLJ
+(blockquote
+ "foo
+ bar"
+ [:a {:href "#"} "baz"])
-(defn make-paragraph [n s]
- [:p {:style (str "font-size: " n "px; color: " (int->html-color MAX n) ";")} s])
+(h2 "Inline code")
+#-CLJ
+(code "clojure.core/+")
+CLJ
+(code "clojure.core/+")
-(ul
- (map
- #(make-paragraph % "The quick brown fox jumps over the lazy dog")
- (range 10 MAX)))
+(h2 "Source code")
+[:p "Comment out following code."]
+#-CLOJURE
+#-CLJ
+(let [msg "world"]
+ (println "hello," msg))
+CLJ
+CLOJURE
+
+#-CLJ
+(let [msg "world"]
+ (println "hello," msg))
+CLJ
+
+(h2 "Paragraph")
+#-CLJ
+(p "hello, world")
+(p "paragraph with `inline` code")
+CLJ
+(p "hello, world")
+(p "paragraph with `inline` code")
+
+(h2 "JavaScript")
+#-CLJ
+(js "a.js" "b.js")
+CLJ
+
+(h2 "Style Sheet")
+#-CLJ
+(css "a.css" "b.css")
+CLJ
View
21 samples/blog/template/posts/2013-03-03-post3.html.clj
@@ -0,0 +1,21 @@
+; @layout post
+; @title The quick brown fox
+; @tag tag2 tag3
+
+(def MAX 50)
+
+
+(defn int->html-color [max-num n]
+ (let [x (int (/ (* 255 n) max-num))
+ s (Integer/toHexString (- 255 x))
+ s (if (next s) s (str "0" s))]
+ (str "#" s s s)))
+
+
+(defn make-paragraph [n s]
+ [:p {:style (str "font-size: " n "px; color: " (int->html-color MAX n) ";")} s])
+
+(ul
+ (map
+ #(make-paragraph % "The quick brown fox jumps over the lazy dog")
+ (range 10 MAX)))
Please sign in to comment.
Something went wrong with that request. Please try again.