diff --git a/assets/js/blog.js b/assets/js/blog.js
index e1bc4d9..d7e8121 100644
--- a/assets/js/blog.js
+++ b/assets/js/blog.js
@@ -11,10 +11,10 @@
, postCommentURL = function() { return server + 'comment' }
, countCommentsURL = function(post) { return server + 'count/' + post }
- function getComments() {
+ function getComments(cb) {
SJS.request({uri: getCommentsURL(SJS.filename)}, function(err, request, body) {
if (err) {
- $('#comments').text('derp')
+ if (typeof cb === 'function') cb(err)
return
}
var data
@@ -22,16 +22,34 @@
, h = ''
try {
data = JSON.parse(body)
- } catch (e) {
+ }
+ catch (e) {
console.log('not json -> ' + body)
+ return
}
comments = data.comments
- if (comments.length) {
+ if (comments && comments.length) {
h = data.comments.map(function(c) {
return tmpl('comment_tmpl', c)
}).join('')
+ $('#comments').html(h)
+ }
+ if (typeof cb === 'function') cb()
+ })
+ }
+
+ function showComments(cb) {
+ $('#sd-container').remove()
+ getComments(function(err) {
+ if (err) {
+ $('#comments').text('derp')
+ }
+ if (typeof cb === 'function') cb(err)
+ else {
+ $('#comment-stuff').slideDown(1.5, function() {
+ this.scrollIntoView(true)
+ })
}
- $('#comments').html(h)
})
}
@@ -45,18 +63,28 @@
, n
try {
data = JSON.parse(body)
- } catch (e) {
+ }
+ catch (e) {
console.log('not json -> ' + body)
+ return
}
n = data.count
$('#sd').text(n > 0 ? 'show the discussion (' + n + ')' : 'start the discussion')
})
- $('#sd').click(function() {
- $('#sd-container').remove()
- $('#comment-stuff').slideDown(1.5, function() { this.scrollIntoView(true) })
- getComments()
- })
+ // jump to comment if linked directly
+ var hash = window.location.hash || ''
+ if (/^#comment-\d+/.test(hash)) {
+ alert(hash)
+ showComments(function (err) {
+ if (!err) {
+ window.location.hash = ''
+ window.location.hash = hash
+ }
+ })
+ }
+
+ $('#sd').click(showComments)
var showdown = new Showdown.converter()
@@ -73,6 +101,7 @@
document.getElementById('thoughts').focus()
return false
}
+ comment.timestamp = +comment.timestamp
var options = { method: 'POST'
, uri: postCommentURL()
diff --git a/discussd/discussd.js b/discussd/discussd.js
index 4fffe8b..eaf7ad0 100755
--- a/discussd/discussd.js
+++ b/discussd/discussd.js
@@ -194,6 +194,9 @@ function commentServer(context) {
return
}
comments = context.db.get(post) || []
+ comments.forEach(function(c, i) {
+ c.id = c.id || (i + 1)
+ })
res.respond({comments: comments.map(function(c) {
delete c.email
c.html = markdown.parse(c.body)
diff --git a/samhuri.net.tmproj b/samhuri.net.tmproj
index 5bb03ec..2f9e154 100644
--- a/samhuri.net.tmproj
+++ b/samhuri.net.tmproj
@@ -3,7 +3,7 @@
currentDocument
- .gitignore
+ discussd/discussd.js
documents
@@ -15,8 +15,6 @@
!(\.DS_Store|.*\.min\..*|.*\.tmproj)$
regexFolderFilter
!.*/(\.[^/]*|public/blog|node_modules|CVS|_blog|public/proj|Chalk|json-diff|riak-js|f|node|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$
- selected
-
sourceDirectory
@@ -25,7 +23,205 @@
200
metaData
- .gitignore
+ Makefile
+
+ caret
+
+ column
+ 0
+ line
+ 18
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ assets/css/blog.css
+
+ caret
+
+ column
+ 17
+ line
+ 1
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ assets/css/mobile.css
+
+ caret
+
+ column
+ 0
+ line
+ 59
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 10
+
+ assets/js/blog.js
+
+ caret
+
+ column
+ 0
+ line
+ 110
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 78
+
+ bin/blog.rb
+
+ caret
+
+ column
+ 0
+ line
+ 52
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 40
+
+ discussd/discuss.dirty
+
+ caret
+
+ column
+ 476
+ line
+ 1
+
+ firstVisibleColumn
+ 222
+ firstVisibleLine
+ 0
+
+ discussd/discussd.js
+
+ caret
+
+ column
+ 0
+ line
+ 287
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 255
+
+ discussd/posts.json
+
+ caret
+
+ column
+ 517
+ line
+ 0
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ public/discussions.html
+
+ caret
+
+ column
+ 0
+ line
+ 13
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ templates/blog/index.html
+
+ caret
+
+ column
+ 0
+ line
+ 37
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 26
+
+ templates/blog/link.mustache
+
+ caret
+
+ column
+ 0
+ line
+ 2
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ templates/blog/link.rss.html
+
+ caret
+
+ column
+ 9
+ line
+ 3
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 0
+
+ templates/blog/post.html
+
+ caret
+
+ column
+ 0
+ line
+ 39
+
+ columnSelection
+
+ firstVisibleColumn
+ 0
+ firstVisibleLine
+ 16
+ selectFrom
+
+ column
+ 0
+ line
+ 38
+
+ selectTo
+
+ column
+ 0
+ line
+ 39
+
+
+ templates/blog/post.mustache
caret
@@ -39,70 +235,14 @@
firstVisibleLine
0
- Makefile
-
- caret
-
- column
- 0
- line
- 46
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- TODO
-
- caret
-
- column
- 0
- line
- 22
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- bin/blog.rb
-
- caret
-
- column
- 0
- line
- 119
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 91
-
- public/js/iepngfix.htc
-
- caret
-
- column
- 20
- line
- 18
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
templates/proj/index.html
caret
column
- 0
+ 19
line
- 26
+ 73
firstVisibleColumn
0
@@ -113,14 +253,24 @@
openDocuments
bin/blog.rb
- TODO
+ assets/css/blog.css
+ assets/css/mobile.css
+ discussd/discuss.dirty
+ assets/js/blog.js
+ public/discussions.html
+ discussd/discussd.js
+ discussd/posts.json
+ templates/blog/post.html
+ templates/blog/link.rss.html
+ templates/blog/link.mustache
+ templates/blog/post.mustache
+ templates/proj/index.html
+ templates/blog/index.html
Makefile
- public/js/iepngfix.htc
- .gitignore
showFileHierarchyDrawer
windowFrame
- {{840, 4}, {840, 1024}}
+ {{0, 4}, {840, 1024}}
diff --git a/templates/blog/index.html b/templates/blog/index.html
index 6b25eee..1d4cc6d 100644
--- a/templates/blog/index.html
+++ b/templates/blog/index.html
@@ -35,6 +35,7 @@