From 8e4b0c79cea9367a42ecef1f2b610f675eb92a74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 21 Jun 2011 09:34:21 +0200 Subject: [PATCH] Cut off text after 200 characters. --- src/main/resources/static/css/sone.css | 4 +-- src/main/resources/static/javascript/sone.js | 42 ++++++++++++++++++++-- src/main/resources/templates/include/viewPost.html | 5 ++- .../resources/templates/include/viewReply.html | 5 ++- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index d38cea7..c2cc312 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -265,13 +265,13 @@ textarea { font-weight: bold; } -#sone .post .text, #sone .post .raw-text { +#sone .post .text, #sone .post .raw-text, #sone .post .short-text { display: inline; white-space: pre-wrap; word-wrap: break-word; } -#sone .post .text.hidden, #sone .post .raw-text.hidden { +#sone .post .text.hidden, #sone .post .raw-text.hidden, #sone .post .short-text.hidden { display: none; } diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index d6c83ae..6e7184e 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -759,8 +759,27 @@ function ajaxifyPost(postElement) { /* convert “show source” link into javascript function. */ $(postElement).find(".show-source").each(function() { $("a", this).click(function() { + post = getPostElement(this); + rawPostText = $(".post-text.raw-text", post); + rawPostText.toggleClass("hidden"); + if (rawPostText.hasClass("hidden")) { + $(".post-text.short-text", post).removeClass("hidden"); + $(".post-text.text", post).addClass("hidden"); + $(".expand-post-text", post).removeClass("hidden"); + } else { + $(".post-text.short-text", post).addClass("hidden"); + $(".post-text.text", post).addClass("hidden"); + $(".expand-post-text", post).addClass("hidden"); + } + return false; + }); + }); + + /* convert “show more” link into javascript function. */ + $(postElement).find(".expand-post-text").each(function() { + $(this).click(function() { $(".post-text.text", getPostElement(this)).toggleClass("hidden"); - $(".post-text.raw-text", getPostElement(this)).toggleClass("hidden"); + $(".post-text.short-text", getPostElement(this)).toggleClass("hidden"); return false; }); }); @@ -831,8 +850,27 @@ function ajaxifyReply(replyElement) { /* convert “show source” link into javascript function. */ $(replyElement).find(".show-reply-source").each(function() { $("a", this).click(function() { + reply = getReplyElement(this); + rawReplyText = $(".reply-text.raw-text", reply); + rawReplyText.toggleClass("hidden"); + if (rawReplyText.hasClass("hidden")) { + $(".reply-text.short-text", reply).removeClass("hidden"); + $(".reply-text.text", reply).addClass("hidden"); + $(".expand-reply-text", reply).removeClass("hidden"); + } else { + $(".reply-text.short-text", reply).addClass("hidden"); + $(".reply-text.text", reply).addClass("hidden"); + $(".expand-reply-text", reply).addClass("hidden"); + } + return false; + }); + }); + + /* convert “show more” link into javascript function. */ + $(replyElement).find(".expand-reply-text").each(function() { + $(this).click(function() { $(".reply-text.text", getReplyElement(this)).toggleClass("hidden"); - $(".reply-text.raw-text", getReplyElement(this)).toggleClass("hidden"); + $(".reply-text.short-text", getReplyElement(this)).toggleClass("hidden"); return false; }); }); diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index b451f2b..50de490 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -23,8 +23,11 @@ <%/if> <% post.text|html|store key=originalText text=true> <% post.text|parse sone=post.sone|store key=parsedText text=true> + <% post.text|parse sone=post.sone length=200|store key=shortText text=true>
<% originalText>
-
<% parsedText>
+
<% parsedText>
+
<% shortText>
+ <%if !shortText|match key=parsedText><%if !raw>…<%/if><%/if>
diff --git a/src/main/resources/templates/include/viewReply.html b/src/main/resources/templates/include/viewReply.html index 2507917..1a435f1 100644 --- a/src/main/resources/templates/include/viewReply.html +++ b/src/main/resources/templates/include/viewReply.html @@ -11,8 +11,11 @@ <% reply.text|html|store key=originalText text=true> <% reply.text|parse sone=reply.sone|store key=parsedText text=true> + <% reply.text|parse sone=reply.sone length=200|store key=shortText text=true>
<% originalText>
-
<% parsedText>
+
<% parsedText>
+
<% shortText>
+ <%if !shortText|match key=parsedText><%if !raw>…<%/if><%/if>
<% reply.time|date format="MMM d, yyyy, HH:mm:ss">
-- 2.7.4