From e6c759857a8228747102516f56c9f21dfe43f189 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 10 Jun 2011 01:01:45 +0100 Subject: [PATCH] Assign colors to folders --- SparkleShare/Mac/SparkleLog.cs | 4 +-- SparkleShare/SparkleController.cs | 41 ++++++++++++++++++++++--------- data/html/event-entry.html | 4 +-- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/SparkleShare/Mac/SparkleLog.cs b/SparkleShare/Mac/SparkleLog.cs index 5bab464a..248ce428 100644 --- a/SparkleShare/Mac/SparkleLog.cs +++ b/SparkleShare/Mac/SparkleLog.cs @@ -105,7 +105,7 @@ namespace SparkleShare { string name = Path.GetFileName (LocalPath); - Title = String.Format ("Events in ‘{0}’", name); + Title = "Recent Events"; Separator = new NSBox (new RectangleF (0, 58, 480, 1)) { BorderColor = NSColor.LightGray, @@ -152,7 +152,7 @@ namespace SparkleShare { private void GenerateHTML () { string folder_name = Path.GetFileName (LocalPath); - HTML = SparkleShare.Controller.GetHTMLLog (folder_name); + HTML = SparkleShare.Controller.GetHTMLLog (); HTML = HTML.Replace ("", "Lucida Grande"); HTML = HTML.Replace ("", "13.6px"); diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index e5874bca..11c84539 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -243,15 +243,15 @@ namespace SparkleShare { public List GetLog () - {Console.WriteLine ("PPPPPPPPPPP"); + { List list = new List (); - foreach (SparkleRepoBase repo in Repositories) { + foreach (SparkleRepoBase repo in Repositories) list.AddRange (repo.GetChangeSets (10)); - Console.WriteLine (">>>" + repo.Name); - } list.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); + list.Reverse (); + return list; } @@ -275,9 +275,9 @@ namespace SparkleShare { public abstract string EventEntryHTML { get; } - public string GetHTMLLog (string name) + public string GetHTMLLog () { - List change_sets = GetLog (name); + List change_sets = GetLog (); List activity_days = new List (); if (change_sets.Count == 0) @@ -325,7 +325,7 @@ namespace SparkleShare { foreach (string file_path in change_set.Edited) { string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); + change_set.Folder, file_path); if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; @@ -339,7 +339,7 @@ namespace SparkleShare { foreach (string file_path in change_set.Added) { string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); + change_set.Folder, file_path); if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; @@ -353,7 +353,7 @@ namespace SparkleShare { foreach (string file_path in change_set.Deleted) { string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); + change_set.Folder, file_path); if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; @@ -369,9 +369,9 @@ namespace SparkleShare { foreach (string file_path in change_set.MovedFrom) { string to_file_path = change_set.MovedTo [i]; string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); + change_set.Folder, file_path); string absolute_to_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, to_file_path); + change_set.Folder, to_file_path); if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
" + @@ -394,7 +394,9 @@ namespace SparkleShare { event_entries += event_entry_html.Replace ("", event_entry) .Replace ("", change_set.UserName) .Replace ("", "file://" + GetAvatar (change_set.UserEmail, 36) ) - .Replace ("", change_set.Timestamp.ToString ("H:mm")); + .Replace ("", change_set.Timestamp.ToString ("H:mm")) + .Replace ("", change_set.Folder) + .Replace ("", AssignColor (change_set.Folder)); } string day_entry = ""; @@ -1030,6 +1032,21 @@ namespace SparkleShare { web_client.DownloadStringAsync (uri); } + + + private string [] tango_palette = new string [] {"#fce94f", "#edd400", + "#c4a000", "#8ae234", "#73d216", "#4e9a06", "#fcaf3e", "#f57900", + "#ce5c00", "#e9b96e", "#c17d11", "#8f5902", "#729fcf", "#3465a4", + "#204a87", "#ad7fa8", "#75507b", "#5c3566", "#888a85", "#555753", + "#2e3436", "#ef2929", "#cc0000", "#a40000"}; + + private string AssignColor (string s) + { + string hash = GetMD5 (s).Substring (0, 6); + string numbers = Regex.Replace (hash, "[a-z]", ""); + int number = int.Parse (numbers); + return this.tango_palette [number % this.tango_palette.Length]; + } } diff --git a/data/html/event-entry.html b/data/html/event-entry.html index 4abcd5ff..38aad61c 100644 --- a/data/html/event-entry.html +++ b/data/html/event-entry.html @@ -1,6 +1,6 @@
-
+
@@ -11,7 +11,7 @@
-
gnome-design •
+