From: David ‘Bombe’ Roden Date: Tue, 19 Oct 2010 07:19:09 +0000 (+0200) Subject: Add “unknown” Sone state, initialize local and remote Sones differently. X-Git-Tag: 0.1-RC1~198 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=21c4819261de874652e7c8be37bde5923758cf4b;p=Sone.git Add “unknown” Sone state, initialize local and remote Sones differently. --- 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">)
+
?
!
⬊
⬈