Remove the notes feature
This commit is contained in:
parent
47c2bcb8f4
commit
30b1b4a1bf
|
@ -658,7 +658,7 @@ namespace SparkleLib.Git {
|
|||
file_path = file_path.Substring (0,
|
||||
file_path.Length - ".empty".Length);
|
||||
|
||||
if (change_type.Equals ("A") && !file_path.Contains (".notes")) {
|
||||
if (change_type.Equals ("A")) {
|
||||
change_set.Added.Add (file_path);
|
||||
|
||||
} else if (change_type.Equals ("M")) {
|
||||
|
@ -692,7 +692,6 @@ namespace SparkleLib.Git {
|
|||
change_set.Deleted.Count +
|
||||
change_set.MovedFrom.Count) > 0) {
|
||||
|
||||
change_set.Notes.AddRange (GetNotes (change_set.Revision));
|
||||
change_sets.Add (change_set);
|
||||
}
|
||||
}
|
||||
|
@ -722,9 +721,6 @@ namespace SparkleLib.Git {
|
|||
|
||||
continue;
|
||||
|
||||
} else if (child_path.EndsWith (".notes")) {
|
||||
continue;
|
||||
|
||||
} else if (child_path.EndsWith (".git")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -784,9 +780,6 @@ namespace SparkleLib.Git {
|
|||
if (file_name.EndsWith (".empty"))
|
||||
file_name = file_name.Substring (0, file_name.Length - 6);
|
||||
|
||||
if (file_name.StartsWith (".notes"))
|
||||
message += "added a note";
|
||||
else
|
||||
message += "+ ‘" + file_name + "’" + n;
|
||||
|
||||
count++;
|
||||
|
|
|
@ -64,9 +64,6 @@ namespace SparkleLib {
|
|||
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set);
|
||||
public event NewChangeSetEventHandler NewChangeSet;
|
||||
|
||||
public delegate void NewNoteEventHandler (SparkleUser user);
|
||||
public event NewNoteEventHandler NewNote;
|
||||
|
||||
public delegate void ConflictResolvedEventHandler ();
|
||||
public event ConflictResolvedEventHandler ConflictResolved;
|
||||
|
||||
|
@ -259,82 +256,6 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
public List<SparkleNote> GetNotes (string revision) {
|
||||
List<SparkleNote> notes = new List<SparkleNote> ();
|
||||
|
||||
string notes_path = Path.Combine (LocalPath, ".notes");
|
||||
|
||||
if (!Directory.Exists (notes_path)) {
|
||||
Directory.CreateDirectory (notes_path);
|
||||
File.SetAttributes (notes_path, FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
Regex regex_notes = new Regex (@"<name>(.+)</name>.*" +
|
||||
"<email>(.+)</email>.*" +
|
||||
"<timestamp>([0-9]+)</timestamp>.*" +
|
||||
"<body>(.+)</body>", RegexOptions.Compiled);
|
||||
|
||||
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);
|
||||
|
||||
if (match_notes.Success) {
|
||||
SparkleNote note = new SparkleNote () {
|
||||
User = new SparkleUser (match_notes.Groups [1].Value,
|
||||
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
|
||||
};
|
||||
|
||||
notes.Add (note);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
|
||||
public void AddNote (string revision, string note)
|
||||
{
|
||||
string notes_path = Path.Combine (LocalPath, ".notes");
|
||||
|
||||
if (!Directory.Exists (notes_path))
|
||||
Directory.CreateDirectory (notes_path);
|
||||
|
||||
// Add a timestamp in seconds since unix epoch
|
||||
int timestamp = (int) (DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;
|
||||
|
||||
string n = Environment.NewLine;
|
||||
note = "<note>" + n +
|
||||
" <user>" + n +
|
||||
" <name>" + SparkleConfig.DefaultConfig.User.Name + "</name>" + n +
|
||||
" <email>" + SparkleConfig.DefaultConfig.User.Email + "</email>" + n +
|
||||
" </user>" + n +
|
||||
" <timestamp>" + timestamp + "</timestamp>" + n +
|
||||
" <body>" + note + "</body>" + n +
|
||||
"</note>" + n;
|
||||
|
||||
string note_name = revision + SHA1 (timestamp.ToString () + note);
|
||||
string note_path = Path.Combine (notes_path, note_name);
|
||||
|
||||
StreamWriter writer = new StreamWriter (note_path);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
private void SyncUpBase ()
|
||||
{
|
||||
try {
|
||||
|
@ -411,23 +332,8 @@ namespace SparkleLib {
|
|||
List<SparkleChangeSet> change_sets = GetChangeSets (1);
|
||||
|
||||
if (change_sets != null && change_sets.Count > 0) {
|
||||
SparkleChangeSet change_set = change_sets [0];
|
||||
|
||||
bool note_added = false;
|
||||
foreach (string added in change_set.Added) {
|
||||
if (added.Contains (".notes")) {
|
||||
if (NewNote != null)
|
||||
NewNote (change_set.User);
|
||||
|
||||
note_added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!note_added) {
|
||||
if (NewChangeSet != null)
|
||||
NewChangeSet (change_set);
|
||||
}
|
||||
NewChangeSet (change_sets [0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,12 +359,6 @@ namespace SparkleLib {
|
|||
|
||||
this.progress_percentage = 0.0;
|
||||
this.progress_speed = "";
|
||||
|
||||
string notes_path = Path.Combine (LocalPath, ".notes");
|
||||
|
||||
if (Directory.Exists (notes_path))
|
||||
File.SetAttributes (notes_path,
|
||||
FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -629,12 +629,6 @@ namespace SparkleShare {
|
|||
NotificationRaised (change_set);
|
||||
};
|
||||
|
||||
repo.NewNote += delegate (SparkleUser user) {
|
||||
if (NoteNotificationRaised != null)
|
||||
NoteNotificationRaised (user, repo.Name);
|
||||
|
||||
};
|
||||
|
||||
repo.ConflictResolved += delegate {
|
||||
if (AlertNotificationRaised != null)
|
||||
AlertNotificationRaised ("Conflict detected.",
|
||||
|
@ -1141,20 +1135,6 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void AddNoteToFolder (string folder_name, string revision, string note)
|
||||
{
|
||||
folder_name = folder_name.Replace ("%20", " ");
|
||||
note = note.Replace ("%20", " ");
|
||||
|
||||
lock (this.repo_lock) {
|
||||
foreach (SparkleRepoBase repo in Repositories) {
|
||||
if (repo.Name.Equals (folder_name))
|
||||
repo.AddNote (revision, note);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string [] tango_palette = new string [] {"#eaab00", "#e37222",
|
||||
"#3892ab", "#33c2cb", "#19b271", "#9eab05", "#8599a8", "#9ca696",
|
||||
"#b88454", "#cc0033", "#8f6678", "#8c6cd0", "#796cbf", "#4060af",
|
||||
|
|
|
@ -202,22 +202,6 @@ namespace SparkleShare {
|
|||
url.Substring (1, 1).Equals (":")) {
|
||||
|
||||
Program.Controller.OpenFile (url);
|
||||
|
||||
} 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 {
|
||||
Program.Controller.AddNoteToFolder (folder_name, revision, note);
|
||||
}));
|
||||
|
||||
thread.Start ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
|
||||
<div class="clearer"></div>
|
||||
<div class="event-timestamp"><!-- $event-time --></div>
|
||||
<div class="action note">Add note</div>
|
||||
<div class="action show">Show all</div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
|
||||
<div class="comments-section">
|
||||
<!-- $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>
|
||||
|
|
|
@ -28,24 +28,12 @@
|
|||
}
|
||||
}, 60 * 1000);
|
||||
|
||||
|
||||
$('.comments-section').each (function () {
|
||||
if ($(this).find ('.comments').children ().size () < 1) {
|
||||
$(this).hide ();
|
||||
}
|
||||
});
|
||||
|
||||
$('.buddy-icon').each (function () {
|
||||
if ($(this).css('backgroundImage').indexOf ('@') != -1) {
|
||||
$(this).css ('backgroundColor', '#fff');
|
||||
}
|
||||
});
|
||||
|
||||
// Show the form when 'Add note' is clicked
|
||||
$('.note').click(function () {
|
||||
$(this).parent ().find ('.comments-section').show ();
|
||||
});
|
||||
|
||||
// Hide the 'Show all' link when there are less than 10 events
|
||||
$('.show').each (function () {
|
||||
var entries = $(this).parent ().find ('dl').children ().length;
|
||||
|
@ -63,33 +51,6 @@
|
|||
$(this).parent ().find ('dl').children ().show ();
|
||||
$(this).hide ();
|
||||
});
|
||||
|
||||
$("input").click(function () {
|
||||
textarea = $(this).parent ().find ('textarea');
|
||||
text = textarea.val ();
|
||||
|
||||
if (text == '')
|
||||
return;
|
||||
|
||||
// Clear the textarea
|
||||
textarea.val ('');
|
||||
|
||||
table = $(this).parent ().find (".comments");
|
||||
comments = table.html ();
|
||||
|
||||
// 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;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -118,13 +79,6 @@
|
|||
color: <!-- $secondary-font-color -->;
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
font-size: 90%;
|
||||
padding: 12px;
|
||||
background-color: #FFF4DB;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.day-entry-header {
|
||||
color: #aaa;
|
||||
margin-left: auto;
|
||||
|
@ -183,7 +137,6 @@
|
|||
float: right;
|
||||
}
|
||||
|
||||
|
||||
.event-entry {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 24px;
|
||||
|
@ -288,60 +241,6 @@
|
|||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.comments {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.comment-author {
|
||||
font-size: 90%;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
margin-bottom: 9px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: bottom left;
|
||||
background-size: 24px;
|
||||
height: 24px;
|
||||
padding-left: 30px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.comment-timestamp {
|
||||
color: <!-- $secondary-font-color -->;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.comment-button {
|
||||
float:right;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.comment-textarea {
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 3em;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.comments-section {
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.comments-wrapper {
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Reference in a new issue