From 0079039b42e82267b30018162f5be611d80d6b0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 18:01:45 +0200 Subject: [PATCH 01/16] Only download remote Sones. --- src/main/java/net/pterodactylus/sone/core/Core.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 362df22..b0dadbe 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -245,7 +245,9 @@ public class Core extends AbstractService { */ public void addSone(Sone sone) { soneCache.put(sone.getId(), sone); - soneDownloader.addSone(sone); + if (!localSones.contains(sone)) { + soneDownloader.addSone(sone); + } } /** -- 2.7.4 From 1f44c357b7498dc284829defc0309f308e5a9b6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 18:01:57 +0200 Subject: [PATCH 02/16] Add method to reload a known Sone. --- .../java/net/pterodactylus/sone/core/Core.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index b0dadbe..d098456 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -350,6 +350,28 @@ public class Core extends AbstractService { } /** + * Loads and updates the given Sone. + * + * @param sone + * The Sone to load + */ + public void loadSone(final Sone sone) { + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + FreenetURI realRequestUri = sone.getRequestUri().setMetaString(new String[] { "sone.xml" }); + FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri); + Sone parsedSone = soneDownloader.parseSone(sone, fetchResult, realRequestUri); + if (parsedSone != null) { + addSone(parsedSone); + } + } + }, "Sone Downloader").start(); + } + + /** * Deletes the given Sone from this plugin instance. * * @param sone -- 2.7.4 From 62361f7814c1ad34bfa182c8f84b4f484b13241b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 18:02:10 +0200 Subject: [PATCH 03/16] Only load remote Sones after loading configuration. --- src/main/java/net/pterodactylus/sone/core/Core.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index d098456..6ecd5fc 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -536,7 +536,6 @@ public class Core extends AbstractService { String friendKey = configuration.getStringValue(friendPrefix + "/Key").getValue(null); String friendName = configuration.getStringValue(friendPrefix + "/Name").getValue(null); friendSone.setRequestUri(new FreenetURI(friendKey)).setName(friendName); - loadSone(friendKey); sone.addFriend(friendSone); } @@ -548,6 +547,11 @@ public class Core extends AbstractService { } while (true); logger.log(Level.INFO, "Loaded %d Sones.", getSones().size()); + /* load all remote Sones. */ + for (Sone remoteSone : getRemoteSones()) { + loadSone(remoteSone); + } + logger.exiting(Core.class.getName(), "loadConfiguration()"); } -- 2.7.4 From e2cae8504eea6b4c833e9aa87ccd70d897e5f0f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 18:02:23 +0200 Subject: [PATCH 04/16] =?utf8?q?Don=E2=80=99t=20add=20the=20new=20Post=20t?= =?utf8?q?o=20the=20Sone=20ourselves,=20Core=20does=20that.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/web/CreatePostPage.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java index 58fd74e..bed96a4 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java @@ -53,8 +53,7 @@ public class CreatePostPage extends SoneTemplatePage { String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim(); if (text.length() != 0) { Sone currentSone = getCurrentSone(request.getToadletContext()); - Post post = webInterface.core().createPost(currentSone, System.currentTimeMillis(), text); - currentSone.addPost(post); + webInterface.core().createPost(currentSone, System.currentTimeMillis(), text); throw new RedirectException("index.html"); } template.set("errorTextEmpty", true); -- 2.7.4 From 7105c9338f9c7ec88da8044645482ecc09458cd0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 17 Oct 2010 18:26:13 +0200 Subject: [PATCH 05/16] Store the time of the last update in the Sone. --- .../java/net/pterodactylus/sone/data/Sone.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 9219e99..2efb90d 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -57,6 +57,9 @@ public class Sone { /* This will be null for remote Sones! */ private FreenetURI insertUri; + /** The time of the last inserted update. */ + private long time; + /** The profile of this Sone. */ private Profile profile; @@ -159,6 +162,27 @@ public class Sone { } /** + * Return the time of the last inserted update of this Sone. + * + * @return The time of the update (in milliseconds since Jan 1, 1970 UTC) + */ + public long getTime() { + return time; + } + + /** + * Sets the time of the last inserted update of this Sone. + * + * @param time + * The time of the update (in milliseconds since Jan 1, 1970 UTC) + * @return This Sone (for method chaining) + */ + public Sone setTime(long time) { + this.time = time; + return this; + } + + /** * Returns a copy of the profile. If you want to update values in the * profile of this Sone, update the values in the returned {@link Profile} * and use {@link #setProfile(Profile)} to change the profile in this Sone. -- 2.7.4 From 08f0784ec6247da055b3d07835aa089333de0bcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 17 Oct 2010 18:26:48 +0200 Subject: [PATCH 06/16] Update time when inserting, store time in insert. --- src/main/java/net/pterodactylus/sone/core/SoneInserter.java | 1 + src/main/resources/templates/insert/sone.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index ac2cb3f..259667b 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -99,6 +99,7 @@ public class SoneInserter extends AbstractService { synchronized (sone) { modificationCounter = sone.getModificationCounter(); if (modificationCounter > 0) { + sone.setTime(System.currentTimeMillis()); insertInformation = new InsertInformation(sone.getRequestUri(), sone.getInsertUri()); } } diff --git a/src/main/resources/templates/insert/sone.xml b/src/main/resources/templates/insert/sone.xml index 704c415..2469e49 100644 --- a/src/main/resources/templates/insert/sone.xml +++ b/src/main/resources/templates/insert/sone.xml @@ -3,6 +3,7 @@ <% currentSone.id> <% currentSone.name|xml> + <% currentSone.profile.firstName|xml> -- 2.7.4 From 4c8206d682ad612e640209bc378cc6f0bb695ea5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 17 Oct 2010 18:26:55 +0200 Subject: [PATCH 07/16] Parse time from downloaded Sone. --- .../java/net/pterodactylus/sone/core/SoneDownloader.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index da33b0b..04fc37f 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -171,6 +171,20 @@ public class SoneDownloader extends AbstractService { } sone.setName(soneName); + String soneTime = soneXml.getValue("time", null); + if (soneTime == null) { + /* TODO - mark Sone as bad. */ + logger.log(Level.WARNING, "Downloaded time for Sone %s was null!", new Object[] { sone }); + return null; + } + try { + sone.setTime(Long.parseLong(soneTime)); + } catch (NumberFormatException nfe1) { + /* TODO - mark Sone as bad. */ + logger.log(Level.WARNING, "Downloaded Sone %s with invalid time: %s", new Object[] { sone, soneTime }); + return null; + } + SimpleXML profileXml = soneXml.getNode("profile"); if (profileXml == null) { /* TODO - mark Sone as bad. */ -- 2.7.4 From 068db5a4bf905702943e9cdf20fc13cc8d85b36c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 06:38:53 +0200 Subject: [PATCH 08/16] Add toadlet to deliver images. --- src/main/java/net/pterodactylus/sone/web/WebInterface.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 143f67d..b2fc56b 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -216,6 +216,7 @@ public class WebInterface extends AbstractService { pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("javascript/", "/static/javascript/", "text/javascript"))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("images/", "/static/images/", "image/png"))); ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer(); toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Name", "Navigation.Menu.Tooltip", sonePlugin); -- 2.7.4 From 55479b7bdd317aefedcf2094f442a63d10d36bdd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 06:39:42 +0200 Subject: [PATCH 09/16] Prepare for larger HTML/CSS rework. --- src/main/resources/i18n/sone.en.properties | 2 + src/main/resources/static/css/sone.css | 91 +++++++++++++++++++-- src/main/resources/static/images/sone.png | Bin 0 -> 1404 bytes src/main/resources/templates/include/head.html | 19 +++++ src/main/resources/templates/include/tail.html | 2 + src/main/resources/templates/include/viewPost.html | 38 +++++---- src/main/resources/templates/index.html | 8 +- 7 files changed, 133 insertions(+), 27 deletions(-) create mode 100644 src/main/resources/static/images/sone.png create mode 100644 src/main/resources/templates/include/head.html create mode 100644 src/main/resources/templates/include/tail.html diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 9b95cb8..9bc974d 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -118,5 +118,7 @@ Page.NoPermission.Text.NoPermission=You tried to do something that you do not ha Page.Logout.Title=Logout - Sone +View.Head.ProfileLink.Text=Your Profile + View.Post.DeleteLink=Delete Post View.Post.SendReply=Post Reply! diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index 4b9928d..ab4d8a5 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -1,16 +1,48 @@ /* Sone Main CSS File */ -#sone h1 { - font-family: inherit; - font-size: 200%; +#sone { + width: 50em; + margin: auto; +} + +#sone a { + color: inherit; + text-decoration: none; +} + +#sone a:visited { + color: inherit; +} + +#sone #sidebar { + width: 200px; + position: absolute; +} + +#sone .profile-link { font-weight: bold; + color: #23e; } -#sone .error label { - color: red; +#sone #profile .picture { + float: left; +} + +#sone .nice-name { font-weight: bold; } +#sone #main { + margin-left: 200px; + padding-left: 1em; +} + +#sone .post { + padding: 1ex 0px; + border-bottom: solid 1px #ccc; + margin-bottom: 1ex; +} + #sone .post .author { display: inline; font-weight: bold; @@ -20,6 +52,53 @@ display: inline; } +#sone .post .time { + color: #666; + float: left; + font-size: 85%; +} + +#sone .post .delete { + float: right; +} + +#sone .post .replies { + clear: both; +} + +#sone .post .reply { + clear: both; + background-color: #eef; + font-size: 85%; + margin: 1ex 0px; + padding: 1ex; +} + +#sone .post .reply div { + font-size: inherit; /* or else fproxy's css rules will fuck us. */ +} + +#sone .post .reply .time { + float: none; + color: #666; + font-size: inherit; +} + +#sone .post .create-reply { + clear: both; +} + +#sone h1 { + font-family: inherit; + font-size: 200%; + font-weight: bold; +} + +#sone .error label { + color: red; + font-weight: bold; +} + #sone input.createpost.default { color: #888; -} +} \ No newline at end of file diff --git a/src/main/resources/static/images/sone.png b/src/main/resources/static/images/sone.png new file mode 100644 index 0000000000000000000000000000000000000000..e69aad1dbc7a292a85bc7e220a0ce01e94209c35 GIT binary patch literal 1404 zcmV-?1%vvDP)$(jh00004b3#c}2nYxW zdXaeHld)I4E__BE8 zVYbt&s?bF?1h(V=+(CL+6mH+*ERvnqgo>5^(|1z%^_3qYx- zto2p}0RvWOzJNXADW_1XAfR7*F@@`f#H>kd;vRW@J#R~b5t9=6HEcH&EOqkmM0nK zA5$M7;2MF`o5)t+3)o)<&pxU-&%D8VH+2Ba^R3fcO%;>u0X{SIK}hf-%29{!IuMsn z6+at}&7vDgv`< zj3m!!r~Xm|=2jXO6fgR@C5&dm0)GS7dV^;Wm_kh6ApoQICh(2X3vd!ydD@eqSpa4@ ztowC3vtU)gq>q@kkN`#u_Gwzp-r4YI@g{)j&^xNCHyyqBm#vQ6d1e5X!h%%*lWrPO z;=o71WkZ#Hztc9SQa>2^bA>dDI!v)aeOFl=21rA^lV4d=^5FWxUS|7UTdH z1=fO8^}4Dy1MR@)++Jtgy#OScCQn!Z5^hggUhpvwP~w0!!-(!@GG_xK+ez(X_yhP4 zc+k+VtKo5n!FvU`3%K89RMlbWlbE(>)CWtwm05gfE?4P zTRIyaE#4ErcHn7)x5wbgsqB+)%lJ$ + + + + + + +
diff --git a/src/main/resources/templates/include/tail.html b/src/main/resources/templates/include/tail.html new file mode 100644 index 0000000..0e7d491 --- /dev/null +++ b/src/main/resources/templates/include/tail.html @@ -0,0 +1,2 @@ +
+ diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index 5d44274..e0d1e83 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -1,21 +1,27 @@
- -
<% post.text|html>
+
+ +
<% post.text|html>
+
<%if post.sone.isCurrent><%/if> -
-<%foreach post.replies reply> -
- -
<% reply.text|html>
-
<% reply.time|date format="MMM d, yyyy, HH:mm:ss">
+
+ <%foreach post.replies reply> +
+
+ +
<% reply.text|html>
+
+
<% reply.time|date format="MMM d, yyyy, HH:mm:ss">
+
+ <%/foreach> +
+
+ + + + +
+
-<%/foreach> -
-
- - - - -
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 3db413d..3a5bb70 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,7 +1,4 @@ -
- - - +<%include include/head.html> -- 2.7.4 From d4d356a040c0787b2062c686ee8f02f7b63f0660 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 09:10:54 +0200 Subject: [PATCH 15/16] =?utf8?q?Hide=20all=20reply=20input=20fields,=20add?= =?utf8?q?=20=E2=80=9Ccomment=E2=80=9D=20button.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/css/sone.css | 14 +++++++++++++- src/main/resources/templates/index.html | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index 0947c72..9e44830 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -5,6 +5,10 @@ margin: auto; } +#sone .hidden { + display: none; +} + #sone a { color: inherit; text-decoration: none; @@ -83,7 +87,7 @@ padding: 1ex; } -#sone .post .reply div, #sone .post .time, #sone .post .delete { +#sone .post .reply div, #sone .post .time, #sone .post .delete, #sone .post .show-reply-form { font-size: inherit; /* or else fproxy's css rules will fuck us. */ } @@ -94,6 +98,14 @@ font-size: inherit; } +#sone .post .show-reply-form { + display: inline; +} + +#sone .post .show-reply-form:before { + content: ' ‧ '; +} + #sone .post .reply .status-line .delete { float: none; display: inline; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 579281b..2b21e91 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -5,6 +5,12 @@ $(document).ready(function() { registerInputTextareaSwap("#sone input.createpost", "What are you doing?"); registerInputTextareaSwap("#sone input.create-reply", "Write a Reply…"); + + /* hide all the “create reply” forms until a link is clicked. */ + commentElement = $("
Comment
").addClass("show-reply-form").click(function() { + }); + $("#sone .post > .status-line .time").after(commentElement); + $("#sone .post .create-reply").addClass("hidden"); }); -- 2.7.4 From 097bb365454bb0471463fc610621deac63679884 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 09:52:18 +0200 Subject: [PATCH 16/16] =?utf8?q?Hide=20reply=20creation=20input=20text=20f?= =?utf8?q?ields=20until=20=E2=80=9Ccomment=E2=80=9D=20link=20is=20clicked.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/include/viewPost.html | 4 ++-- src/main/resources/templates/index.html | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index 00ee653..74fe29a 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -1,4 +1,4 @@ -
+
<% post.text|html>
@@ -20,7 +20,7 @@
<%/foreach> -
+
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 2b21e91..8cbf77e 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -7,10 +7,16 @@ registerInputTextareaSwap("#sone input.create-reply", "Write a Reply…"); /* hide all the “create reply” forms until a link is clicked. */ - commentElement = $("
Comment
").addClass("show-reply-form").click(function() { + $("#sone .post").each(function() { + postId = $(this).attr("id"); + (function(postId) { + commentElement = $("
Comment
").addClass("show-reply-form").click(function() { + $("#sone .post#" + postId + " .create-reply").removeClass("hidden"); + }); + })(postId); + $(this).find(".create-reply").addClass("hidden"); + $(this).find(".status-line .time").after(commentElement); }); - $("#sone .post > .status-line .time").after(commentElement); - $("#sone .post .create-reply").addClass("hidden"); }); -- 2.7.4