diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 1ae4593e..3460b3c7 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -22,6 +22,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using System.Xml; namespace SparkleLib { @@ -117,8 +118,20 @@ namespace SparkleLib { public override bool SyncDown () { - SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master"); + // Check if note fetching is set up + SparkleGit git_config = new SparkleGit (LocalPath, "config --get remote.origin.fetch"); + git_config.Start (); + git_config.WaitForExit (); + // Add configuration for note fetching if it's + // not there yet + if (git_config.ExitCode != 0) { + git_config = new SparkleGit (LocalPath, "config --add remote.origin.fetch +refs/notes/*:refs/notes/*"); + git_config.Start (); + git_config.WaitForExit (); + } + + SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master"); git.Start (); git.WaitForExit (); @@ -349,7 +362,7 @@ namespace SparkleLib { List change_sets = new List (); - SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso"); + SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso --show-notes=*"); Console.OutputEncoding = System.Text.Encoding.Unicode; git_log.Start (); @@ -407,11 +420,12 @@ namespace SparkleLib { if (match.Success) { SparkleChangeSet change_set = new SparkleChangeSet (); - change_set.Folder = Name; - change_set.Revision = match.Groups [1].Value; - change_set.UserName = match.Groups [2].Value; - change_set.UserEmail = match.Groups [3].Value; - change_set.IsMerge = is_merge_commit; + change_set.Folder = Name; + change_set.Revision = match.Groups [1].Value; + change_set.UserName = match.Groups [2].Value; + change_set.UserEmail = match.Groups [3].Value; + change_set.IsMerge = is_merge_commit; + change_set.SupportsNotes = true; change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value), @@ -451,6 +465,26 @@ namespace SparkleLib { change_set.MovedFrom.Add (file_path); change_set.MovedTo.Add (to_file_path); } + + } else if (entry_line.StartsWith (" ")) { + + Regex regex_notes = new Regex (@"(.+).*" + + "(.+).*" + + "([0-9]+).*" + + "(.+)", RegexOptions.Compiled); + + Match match_notes = regex_notes.Match (entry_line); + + if (match_notes.Success) { + SparkleNote note = new SparkleNote () { + UserName = match_notes.Groups [1].Value, + UserEmail = match_notes.Groups [2].Value, + Timestamp = new DateTime (1970, 1, 1).AddSeconds (int.Parse (match_notes.Groups [3].Value)), + Body = match_notes.Groups [4].Value + }; + + change_set.Notes.Add (note); + } } } @@ -560,13 +594,20 @@ namespace SparkleLib { git_notes.Start (); git_notes.WaitForExit (); + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Added note to " + revision); + while (Status != SyncStatus.Idle) { System.Threading.Thread.Sleep (5 * 20); } - SparkleGit git_push = new SparkleGit (LocalPath, "git push origin refs/notes/*"); + SparkleGit git_push = new SparkleGit (LocalPath, "push origin refs/notes/*"); git_push.Start (); git_push.WaitForExit (); + + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Notes pushed"); + + SparkleAnnouncement announcement = new SparkleAnnouncement (Identifier, note_namespace); + base.listener.Announce (announcement); } diff --git a/SparkleLib/SparkleChangeSet.cs b/SparkleLib/SparkleChangeSet.cs index 5b71a1b9..c0ddbf48 100644 --- a/SparkleLib/SparkleChangeSet.cs +++ b/SparkleLib/SparkleChangeSet.cs @@ -28,8 +28,8 @@ namespace SparkleLib { public string Folder; public string Revision; public DateTime Timestamp; - public bool FolderSupportsNotes = false; - public bool IsMerge = false; + public bool SupportsNotes = false; + public bool IsMerge = false; public List Added = new List (); public List Deleted = new List (); diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index a32a6c82..9aff8aff 100644 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -38,7 +38,6 @@ namespace SparkleLib { private TimeSpan long_interval = new TimeSpan (0, 0, 10, 0); private SparkleWatcher watcher; - private SparkleListenerBase listener; private TimeSpan poll_interval; private Timer local_timer = new Timer () { Interval = 0.25 * 1000 }; private Timer remote_timer = new Timer () { Interval = 10 * 1000 }; @@ -47,6 +46,7 @@ namespace SparkleLib { private bool has_changed = false; private Object change_lock = new Object (); + protected SparkleListenerBase listener; protected SyncStatus status; protected bool is_buffering = false; protected bool server_online = true; diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index a07c9943..a9a61da2 100644 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; +using System.Text.RegularExpressions; using System.Threading; using MonoMac.Foundation; @@ -221,19 +222,29 @@ namespace SparkleShare { NSUrlRequest request, WebFrame frame, NSObject decision_token) { string url = request.Url.ToString (); - Console.WriteLine (url); - string id = url.Substring (0, url.IndexOf ("%20")); - string note = url.Substring (url.IndexOf ("%20") + 3); - Console.WriteLine (id + " " + note); - SparkleShare.Controller.Repositories [0].AddNote (id, note); - return; + if (url.StartsWith (Path.VolumeSeparatorChar.ToString ())) { + string file_path = request.Url.ToString (); + file_path = file_path.Replace ("%20", " "); + NSWorkspace.SharedWorkspace.OpenFile (file_path); - string file_path = request.Url.ToString (); - file_path = file_path.Replace ("%20", " "); - - NSWorkspace.SharedWorkspace.OpenFile (file_path); + } else { + Regex regex = new Regex (@"(.+)~(.+)~(.+)"); + Match match = regex.Match (url); + + if (match.Success) { + string folder_name = match.Groups [1].Value; + string revision = match.Groups [2].Value; + string note = match.Groups [3].Value; + + Thread thread = new Thread (new ThreadStart (delegate { + SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note); + })); + + thread.Start (); + } + } } } } diff --git a/SparkleShare/Mac/SparkleMacController.cs b/SparkleShare/Mac/SparkleMacController.cs index 7b68a116..5c0d462a 100644 --- a/SparkleShare/Mac/SparkleMacController.cs +++ b/SparkleShare/Mac/SparkleMacController.cs @@ -141,8 +141,8 @@ namespace SparkleShare { html = html.Replace ("", "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "jquery.js")); - Console.WriteLine (html); - return html; + + return html; } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 413fd1b3..60531a81 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -389,7 +389,25 @@ namespace SparkleShare { } } } - + + string comments = ""; + if (change_set.SupportsNotes) { + comments = ""; + + foreach (SparkleNote note in change_set.Notes) { + comments += "" + + " " + + " " + + "" + + "" + + " " + + " " + + ""; + } + + comments += "
" + note.UserName + "" + note.Body + "
" + note.Timestamp + "
"; + } + event_entry += ""; event_entries += event_entry_html.Replace ("", event_entry) .Replace ("", change_set.UserName) @@ -397,7 +415,8 @@ namespace SparkleShare { .Replace ("", change_set.Timestamp.ToString ("H:mm")) .Replace ("", change_set.Folder) .Replace ("", change_set.Revision) - .Replace ("", AssignColor (change_set.Folder)); + .Replace ("", AssignColor (change_set.Folder)) + .Replace ("", comments); } string day_entry = ""; @@ -1021,6 +1040,15 @@ namespace SparkleShare { } + public void AddNoteToFolder (string folder_name, string revision, string note) + { + foreach (SparkleRepoBase repo in Repositories) { + if (repo.Name.Equals (folder_name)) + repo.AddNote (revision, note); + } + } + + public void CheckForNewVersion () { WebClient web_client = new WebClient (); diff --git a/data/html/event-entry.html b/data/html/event-entry.html index 6aec7a04..84af42d6 100644 --- a/data/html/event-entry.html +++ b/data/html/event-entry.html @@ -16,12 +16,7 @@ -webkit-box-sizing:border-box; -moz-box-sizing: border-box; margin-top: 3px;width:100%;padding:12px;'> - - - - - -
Hylke Bonsthis looks awesome!
date
Hylke Bonsthis looks awesome!
date
+
+ value="Add note" id="~">
diff --git a/data/html/event-log.html b/data/html/event-log.html index af2dae75..2d08eb4b 100644 --- a/data/html/event-log.html +++ b/data/html/event-log.html @@ -21,7 +21,7 @@ table.html (comments); - location = this.id + ' ' + text; + location = this.id + '~' + text; }); }); @@ -159,6 +159,20 @@ font-size: 12px; background-color: #fff; border-bottom: 1px #ccc solid; } + + .comments { + width: 100%; + } + + .comment-author { + font-weight: bold; + width: 25%; + } + + .comment-timestamp { + color: ; + padding-bottom: 12px; + }