From 21c4819261de874652e7c8be37bde5923758cf4b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 19 Oct 2010 09:19:09 +0200 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cunknown=E2=80=9D=20Sone=20state,?= =?utf8?q?=20initialize=20local=20and=20remote=20Sones=20differently.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/Core.java | 8 ++++++-- .../net/pterodactylus/sone/core/SoneDownloader.java | 2 +- .../pterodactylus/sone/template/SoneAccessor.java | 2 ++ src/main/resources/static/css/sone.css | 20 ++++++++++---------- src/main/resources/templates/include/viewSone.html | 1 + 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 76881ef..0f733b6 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -59,6 +59,9 @@ public class Core extends AbstractService { */ public enum SoneStatus { + /** The Sone is unknown, i.e. not yet downloaded. */ + unknown, + /** The Sone is idle, i.e. not being downloaded or inserted. */ idle, @@ -159,7 +162,7 @@ public class Core extends AbstractService { if (!soneCache.containsKey(soneId)) { Sone sone = new Sone(soneId); soneCache.put(soneId, sone); - setSoneStatus(sone, SoneStatus.idle); + setSoneStatus(sone, SoneStatus.unknown); } return soneCache.get(soneId); } @@ -302,6 +305,7 @@ public class Core extends AbstractService { */ public void addLocalSone(Sone sone) { if (localSones.add(sone)) { + setSoneStatus(sone, SoneStatus.idle); SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone); soneInserter.start(); soneInserters.put(sone, soneInserter); @@ -443,7 +447,7 @@ public class Core extends AbstractService { addSone(parsedSone); } } finally { - setSoneStatus(sone, SoneStatus.idle); + setSoneStatus(sone, (sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle); } } }, "Sone Downloader").start(); diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 07a3755..b7663e5 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -125,7 +125,7 @@ public class SoneDownloader extends AbstractService { core.addSone(parsedSone); } } finally { - core.setSoneStatus(sone, SoneStatus.idle); + core.setSoneStatus(sone, (sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle); } } diff --git a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java index e22738a..ebf2f82 100644 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@ -78,6 +78,8 @@ public class SoneAccessor extends ReflectionAccessor { return sone.getModificationCounter() > 0; } else if (member.equals("status")) { return core.getSoneStatus(sone).toString(); + } else if (member.equals("unknown")) { + return core.getSoneStatus(sone) == SoneStatus.unknown; } else if (member.equals("idle")) { return core.getSoneStatus(sone) == SoneStatus.idle; } else if (member.equals("inserting")) { diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index cc94ce0..25e61c9 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -153,24 +153,24 @@ display: inline; } -#sone .sone .download-marker, #sone .sone .insert-marker, #sone .sone .idle-marker { - display: inline; +#sone .sone .unknown-marker, #sone .sone .download-marker, #sone .sone .insert-marker, #sone .sone .idle-marker, #sone .sone .modified-marker { + display: none; } -#sone .sone.idle .download-marker, #sone .sone.idle .insert-marker { - display: none; +#sone .sone.unknown .unknown-marker { + display: inline; } -#sone .sone.downloading .insert-marker, #sone .sone.downloading .idle-marker { - display: none; +#sone .sone.idle .idle-marker { + display: inline; } -#sone .sone.inserting .download-marker, #sone .sone.inserting .idle-marker { - display: none; +#sone .sone.downloading .download-marker { + display: inline; } -#sone .sone .modified-marker { - display: none; +#sone .sone.inserting .insert-marker { + display: inline; } #sone .sone.modified .modified-marker { diff --git a/src/main/resources/templates/include/viewSone.html b/src/main/resources/templates/include/viewSone.html index 868cd70..615510a 100644 --- a/src/main/resources/templates/include/viewSone.html +++ b/src/main/resources/templates/include/viewSone.html @@ -1,6 +1,7 @@
(<%= View.Sone.Label.LastUpdate|l10n|html> <% sone.time|date format="MMM d, yyyy, HH:mm:ss">)
+
?
!
⬊
⬈
-- 2.7.4