event log: create usable breadcrumbs for file paths

This commit is contained in:
Hylke Bons 2012-02-12 15:44:43 +01:00
parent 549fae56bf
commit 6bcafd3aa1
4 changed files with 95 additions and 44 deletions

View file

@ -44,8 +44,8 @@ namespace SparkleShare {
string content_path =
Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();
string app_path = Directory.GetParent (content_path).ToString ();
string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");
string app_path = Directory.GetParent (content_path).ToString ();
string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");
// Needed for Growl

View file

@ -134,7 +134,8 @@ namespace SparkleShare {
this.progress_indicator = new NSProgressIndicator () {
Style = NSProgressIndicatorStyle.Spinning,
Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20)
Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10,
this.web_view.Frame.Height / 2 + 10, 20, 20)
};
this.progress_indicator.StartAnimation (this);
@ -226,15 +227,24 @@ namespace SparkleShare {
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $no-buddy-icon-background-image -->",
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "avatar-default.png"));
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps","avatar-default.png"));
html = html.Replace ("<!-- $document-added-background-image -->",
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "document-added-12.png"));
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "document-added-12.png"));
html = html.Replace ("<!-- $document-deleted-background-image -->",
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "document-deleted-12.png"));
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "document-deleted-12.png"));
html = html.Replace ("<!-- $document-edited-background-image -->",
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "document-edited-12.png"));
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "document-edited-12.png"));
html = html.Replace ("<!-- $document-moved-background-image -->",
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "document-moved-12.png"));
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "document-moved-12.png"));
InvokeOnMainThread (delegate {
if (this.progress_indicator.Superview == ContentView)

View file

@ -297,8 +297,8 @@ namespace SparkleShare {
if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) {
existing_set.FirstTimestamp = existing_set.Timestamp;
existing_set.Timestamp = change_set.Timestamp;
existing_set.Revision = change_set.Revision;
existing_set.Timestamp = change_set.Timestamp;
existing_set.Revision = change_set.Revision;
} else {
existing_set.FirstTimestamp = change_set.Timestamp;
@ -345,37 +345,40 @@ namespace SparkleShare {
} else {
if (change_set.Edited.Count > 0) {
foreach (string file_path in change_set.Edited) {
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
change_set.Folder, file_path}.Combine ();
if (File.Exists (absolute_file_path))
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
else
event_entry += "<dd class='document edited'>" + file_path + "</dd>";
event_entry += "<dd class='document edited'>";
event_entry += FormatBreadCrumbs (
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
file_path
);
event_entry += "</dd>";
}
}
if (change_set.Added.Count > 0) {
foreach (string file_path in change_set.Added) {
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
change_set.Folder, file_path}.Combine ();
if (File.Exists (absolute_file_path))
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
else
event_entry += "<dd class='document added'>" + file_path + "</dd>";
event_entry += "<dd class='document added'>";
event_entry += FormatBreadCrumbs (
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
file_path
);
event_entry += "</dd>";
}
}
if (change_set.Deleted.Count > 0) {
foreach (string file_path in change_set.Deleted) {
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
change_set.Folder, file_path}.Combine ();
if (File.Exists (absolute_file_path))
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
else
event_entry += "<dd class='document deleted'>" + file_path + "</dd>";
event_entry += "<dd class='document deleted'>";
event_entry += FormatBreadCrumbs (
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
file_path
);
event_entry += "</dd>";
}
}
@ -384,21 +387,19 @@ namespace SparkleShare {
foreach (string file_path in change_set.MovedFrom) {
string to_file_path = change_set.MovedTo [i];
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
change_set.Folder, file_path}.Combine ();
event_entry += "<dd class='document moved'>";
event_entry += FormatBreadCrumbs (
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
file_path
);
string absolute_to_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
change_set.Folder, to_file_path}.Combine ();
event_entry += "<br>";
event_entry += FormatBreadCrumbs (
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
to_file_path
);
if (File.Exists (absolute_file_path))
event_entry += "<dd class='document moved'><a href='" + absolute_file_path + "'>" + file_path + "</a><br/>";
else
event_entry += "<dd class='document moved'>" + file_path + "<br/>";
if (File.Exists (absolute_to_file_path))
event_entry += "<a href='" + absolute_to_file_path + "'>" + to_file_path + "</a></dd>";
else
event_entry += to_file_path + "</dd>";
event_entry += "</dd>";
i++;
}
@ -1146,6 +1147,45 @@ namespace SparkleShare {
Byte[] encoded_bytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
}
private string FormatBreadCrumbs (string path_root, string path)
{
string link = "";
string [] crumbs = path.Split (Path.DirectorySeparatorChar);
int i = 0;
string new_path_root = path_root;
bool previous_was_folder = false;
foreach (string crumb in crumbs) {
if (string.IsNullOrEmpty (crumb))
continue;
string crumb_path = Path.Combine (new_path_root, crumb);
if (Directory.Exists (crumb_path)) {
link += "<a href='" + crumb_path + "'>" + crumb + Path.DirectorySeparatorChar + "</a>";
previous_was_folder = true;
} else if (File.Exists (crumb_path)) {
link += "<a href='" + crumb_path + "'>" + crumb + "</a>";
previous_was_folder = false;
} else {
if (i > 0 && !previous_was_folder)
link += Path.DirectorySeparatorChar;
link += crumb;
previous_was_folder = false;
}
new_path_root = Path.Combine (new_path_root, crumb);
i++;
}
return link;
}
}

View file

@ -139,6 +139,7 @@
a:hover {
color: <!-- $a-hover-color -->;
text-decoration: underline;
}
.event-timestamp {