From cd039ee6cfddd6d14076bb3f6df38202ea58d9c3 Mon Sep 17 00:00:00 2001 From: Nathan Merritt Date: Thu, 15 Sep 2011 23:09:47 -0400 Subject: [PATCH] added per-post Uid --- css/blog.css | 2 ++ index.markdown | 21 +++++++++++++++------ js/blog.js | 19 ++++++++++--------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/css/blog.css b/css/blog.css index 2c3fee8..18c1850 100644 --- a/css/blog.css +++ b/css/blog.css @@ -7,6 +7,8 @@ nav.left { width:20%; float:left; } #content { width:75%; float:left; margin-left:2.5%; border-top:30px; border-bottom:30px; } #content h4 { text-align: right; } +div.clear { clear:both; } + .post { border:1px inset black; margin:1em; padding:0.5em; } .post.full { border-style:none; } .post h3 { float:left; } /* title */ diff --git a/index.markdown b/index.markdown index 501f4e6..01c3696 100644 --- a/index.markdown +++ b/index.markdown @@ -6,17 +6,26 @@ title: gnmerritt.net - Nathan's home on the web
{% for post in site.posts limit:6 %} -
-

{{ post.title }}

-

{{ post.date | date: "%A, %d %B %Y"}}

+ {% capture postUid %} + {{ post.date | %m%h%d%B%Y }} %} + {% endcapture %} -

{{ post.content | strip_html | truncatewords: 75 }}

+
+
+

{{ post.title }}

+

{{ post.date | date: "%A, %d %B %Y"}}

+
+
+

{{ post.content | strip_html | truncatewords: 75 }}

+ +
{% if post.content.size > 75 %} -

Toggle Post

+

Toggle Post

...Read Full Post

- {% endif %} +
+
{% endfor %} diff --git a/js/blog.js b/js/blog.js index 262ac85..4aa2e9d 100644 --- a/js/blog.js +++ b/js/blog.js @@ -1,21 +1,21 @@ // helper methods -function $(element) +var $ = function(element) { return document.getElementById(element); } -function hasClass(ele,cls) +Element.prototype.hasClass:function(cls) { return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); } -function addClass(ele,cls) +Element.prototype.addClass:function(cls) { if (!this.hasClass(ele,cls)) ele.className += " "+cls; } -function removeClass(ele,cls) +Element.prototype.removeClass:function(cls) { if (hasClass(ele,cls)) { var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); @@ -26,17 +26,18 @@ function removeClass(ele,cls) var gnm = { // toggles the 'closed' class on an item, used to show/hide on demand - toggleOpen:function(source) + toggleOpen:function(elemId) { - if (source != null && source.parentNode != null) + var source = $(elemId); + if (source != null) { - if (hasClass(source.parentNode, 'closed')) + if (source.hasClass('closed')) { - removeClass(source.parentNode, 'closed'); + source.removeClass('closed'); } else { - addClass(source.parentNode, 'closed'); + source.addClass('closed'); } } },