fix notes

This commit is contained in:
Hylke Bons 2011-07-17 01:22:39 +01:00
parent f496a3b854
commit 6cf8eca2b7
6 changed files with 54 additions and 54 deletions

View file

@ -444,7 +444,6 @@ namespace SparkleLib {
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),
@ -467,7 +466,7 @@ namespace SparkleLib {
string file_path = entry_line.Substring (39);
string to_file_path;
if (change_type.Equals ("A")) {
if (change_type.Equals ("A") && !file_path.Contains (".notes")) {
change_set.Added.Add (file_path);
} else if (change_type.Equals ("M")) {
@ -487,8 +486,12 @@ namespace SparkleLib {
}
}
change_set.Notes.AddRange (GetNotes (change_set.Revision));
change_sets.Add (change_set);
if ((change_set.Added.Count + change_set.Edited.Count +
change_set.Deleted.Count) > 0) {
change_set.Notes.AddRange (GetNotes (change_set.Revision));
change_sets.Add (change_set);
}
}
}

View file

@ -28,7 +28,6 @@ namespace SparkleLib {
public string Folder;
public string Revision;
public DateTime Timestamp;
public bool SupportsNotes = false;
public bool IsMerge = false;
public List<string> Added = new List<string> ();

View file

@ -308,7 +308,8 @@ namespace SparkleLib {
if (!this.watcher.EnableRaisingEvents)
return;
if (args.FullPath.Contains (Path.DirectorySeparatorChar + "."))
if (args.FullPath.Contains (Path.DirectorySeparatorChar + ".") &&
!args.FullPath.Contains (Path.DirectorySeparatorChar + ".notes"))
return;
WatcherChangeTypes wct = args.ChangeType;
@ -348,9 +349,9 @@ namespace SparkleLib {
"<timestamp>([0-9]+)</timestamp>.*" +
"<body>(.+)</body>", RegexOptions.Compiled);
foreach (string file_name in Directory.GetFiles (notes_path)) {
if (file_name.StartsWith (revision)) {
string note_xml = String.Join ("", File.ReadAllLines (file_name));
foreach (string file_path in Directory.GetFiles (notes_path)) {
if (Path.GetFileName (file_path).StartsWith (revision)) {
string note_xml = String.Join ("", File.ReadAllLines (file_path));
Match match_notes = regex_notes.Match (note_xml);
@ -513,6 +514,13 @@ namespace SparkleLib {
writer.Write (note);
writer.Close ();
// The watcher doesn't like .*/ so we need to trigger
// a change manually
FileSystemEventArgs args = new FileSystemEventArgs (WatcherChangeTypes.Changed,
notes_path, note_name);
OnFileActivity (args);
SparkleHelpers.DebugInfo ("Note", "Added note to " + revision);
}

View file

@ -325,7 +325,7 @@ namespace SparkleShare {
foreach (SparkleChangeSet change_set in activity_day) {
string event_entry = "<dl>";
if (change_set.IsMerge) {
event_entry += "<dd>Did something magical</dd>";
@ -391,25 +391,23 @@ namespace SparkleShare {
}
string comments = "";
if (change_set.SupportsNotes) {
comments = "<div class=\"comments\">";
comments = "<div class=\"comments\">";
if (change_set.Notes != null) {
change_set.Notes.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp)));
foreach (SparkleNote note in change_set.Notes) {
comments += "<div class=\"comment-text\">" +
"<p class=\"comment-author\"" +
" style=\"background-image: url('file://" + GetAvatar (note.UserEmail, 48) + "');\">" +
note.UserName + "</p>" +
note.Body +
"</div>";
}
if (change_set.Notes != null) {
change_set.Notes.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp)));
foreach (SparkleNote note in change_set.Notes) {
comments += "<div class=\"comment-text\">" +
"<p class=\"comment-author\"" +
" style=\"background-image: url('file://" + GetAvatar (note.UserEmail, 48) + "');\">" +
note.UserName + "</p>" +
note.Body +
"</div>";
}
comments += "</div>";
}
comments += "</div>";
string avatar_email = "";
if (File.Exists (GetAvatar (change_set.UserEmail, 48)))
avatar_email = change_set.UserEmail;
@ -458,7 +456,8 @@ namespace SparkleShare {
}
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
.Replace ("<!-- $username -->", UserName);
.Replace ("<!-- $username -->", UserName)
.Replace ("<!-- $user-avatar-url -->", "file://" + GetAvatar (UserEmail, 48));
return html;
}

View file

@ -12,17 +12,11 @@
<div class="clearer"></div>
<div class="comments-section">
<div class="comments-wrapper">
<!-- $event-comments -->
<div class="comment-text">
<textarea class="comment-textarea"></textarea>
<input class="comment-button" type="button" value="Add note"
id="<!-- $event-folder -->~<!-- $event-revision -->">
<div style='clear: both'></div>
</div>
<div style='clear: both'></div>
</div>
<div class="clearer"></div>
<!-- $event-comments -->
<textarea class="comment-textarea"></textarea>
<input class="comment-button" type="button" value="Add note"
id="<!-- $event-folder -->~<!-- $event-revision -->">
<div style='clear: both'></div>
</div>
<div class="clearer"></div>
</div>

View file

@ -5,11 +5,9 @@
<script type="text/javascript" src="<!-- $jquery-url -->"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.comments-wrapper').each (function () {
$('.comments-section').each (function () {
if ($(this).find ('.comments').children ().size () < 1) {
$(this).hide ();
} else {
$(this).css ('cursor', 'default');
}
});
@ -21,8 +19,7 @@
// Show the form when 'Add note' is clicked
$('.note').click(function () {
$(this).parent ().find ('.comments-wrapper').show ();
//$(this).parent ().find ('.comments-wrapper').css ('cursor', 'default');
$(this).parent ().find ('.comments-section').show ();
});
// Hide the 'Show all' link when there are less than 10 events
@ -50,19 +47,23 @@
if (text == '')
return;
// Clear the textarea
textarea.val ('');
table = $(this).parent ().find ("table");
table = $(this).parent ().find (".comments");
comments = table.html ();
comments += '<tr>' +
' <td class=\"comment-author\"><!-- $username --></td>' +
' <td class=\"comment-timestamp\">just now</td>' +
'</tr>' +
'<tr>' +
' <td class=\"comment-text\" colspan=\"2\">' + text + '</td>' +
'</tr>';
// Add the note to the html
comments += '<div class="comment-text">' +
'<p class="comment-author"' +
' style="background-image: url(\'<!-- $user-avatar-url -->\');">' +
'<!-- $username --></p>' +
text +
'</div>';
table.html (comments);
// Feed the note to the backend
location = this.id + '~' + text;
});
});
@ -297,10 +298,6 @@
margin-top: 12px;
}
.comments-section:hover {
cursor: pointer;
}
.comment-text {
padding-bottom: 15px;
}