event log: create usable breadcrumbs for file paths
This commit is contained in:
parent
549fae56bf
commit
6bcafd3aa1
|
@ -44,8 +44,8 @@ namespace SparkleShare {
|
||||||
string content_path =
|
string content_path =
|
||||||
Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();
|
Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();
|
||||||
|
|
||||||
string app_path = Directory.GetParent (content_path).ToString ();
|
string app_path = Directory.GetParent (content_path).ToString ();
|
||||||
string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");
|
string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");
|
||||||
|
|
||||||
|
|
||||||
// Needed for Growl
|
// Needed for Growl
|
||||||
|
|
|
@ -134,7 +134,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
this.progress_indicator = new NSProgressIndicator () {
|
this.progress_indicator = new NSProgressIndicator () {
|
||||||
Style = NSProgressIndicatorStyle.Spinning,
|
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);
|
this.progress_indicator.StartAnimation (this);
|
||||||
|
@ -226,15 +227,24 @@ namespace SparkleShare {
|
||||||
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
||||||
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
||||||
html = html.Replace ("<!-- $no-buddy-icon-background-image -->",
|
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 -->",
|
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 -->",
|
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 -->",
|
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 -->",
|
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 {
|
InvokeOnMainThread (delegate {
|
||||||
if (this.progress_indicator.Superview == ContentView)
|
if (this.progress_indicator.Superview == ContentView)
|
||||||
|
|
|
@ -297,8 +297,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) {
|
if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) {
|
||||||
existing_set.FirstTimestamp = existing_set.Timestamp;
|
existing_set.FirstTimestamp = existing_set.Timestamp;
|
||||||
existing_set.Timestamp = change_set.Timestamp;
|
existing_set.Timestamp = change_set.Timestamp;
|
||||||
existing_set.Revision = change_set.Revision;
|
existing_set.Revision = change_set.Revision;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
existing_set.FirstTimestamp = change_set.Timestamp;
|
existing_set.FirstTimestamp = change_set.Timestamp;
|
||||||
|
@ -345,37 +345,40 @@ namespace SparkleShare {
|
||||||
} else {
|
} else {
|
||||||
if (change_set.Edited.Count > 0) {
|
if (change_set.Edited.Count > 0) {
|
||||||
foreach (string file_path in change_set.Edited) {
|
foreach (string file_path in change_set.Edited) {
|
||||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
event_entry += "<dd class='document edited'>";
|
||||||
change_set.Folder, file_path}.Combine ();
|
|
||||||
|
event_entry += FormatBreadCrumbs (
|
||||||
if (File.Exists (absolute_file_path))
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
|
||||||
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
file_path
|
||||||
else
|
);
|
||||||
event_entry += "<dd class='document edited'>" + file_path + "</dd>";
|
|
||||||
|
event_entry += "</dd>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_set.Added.Count > 0) {
|
if (change_set.Added.Count > 0) {
|
||||||
foreach (string file_path in change_set.Added) {
|
foreach (string file_path in change_set.Added) {
|
||||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
event_entry += "<dd class='document added'>";
|
||||||
change_set.Folder, file_path}.Combine ();
|
|
||||||
|
event_entry += FormatBreadCrumbs (
|
||||||
if (File.Exists (absolute_file_path))
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
|
||||||
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
file_path
|
||||||
else
|
);
|
||||||
event_entry += "<dd class='document added'>" + file_path + "</dd>";
|
|
||||||
|
event_entry += "</dd>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_set.Deleted.Count > 0) {
|
if (change_set.Deleted.Count > 0) {
|
||||||
foreach (string file_path in change_set.Deleted) {
|
foreach (string file_path in change_set.Deleted) {
|
||||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
event_entry += "<dd class='document deleted'>";
|
||||||
change_set.Folder, file_path}.Combine ();
|
|
||||||
|
event_entry += FormatBreadCrumbs (
|
||||||
if (File.Exists (absolute_file_path))
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
|
||||||
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
file_path
|
||||||
else
|
);
|
||||||
event_entry += "<dd class='document deleted'>" + file_path + "</dd>";
|
|
||||||
|
event_entry += "</dd>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,21 +387,19 @@ namespace SparkleShare {
|
||||||
foreach (string file_path in change_set.MovedFrom) {
|
foreach (string file_path in change_set.MovedFrom) {
|
||||||
string to_file_path = change_set.MovedTo [i];
|
string to_file_path = change_set.MovedTo [i];
|
||||||
|
|
||||||
string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
event_entry += "<dd class='document moved'>";
|
||||||
change_set.Folder, file_path}.Combine ();
|
event_entry += FormatBreadCrumbs (
|
||||||
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
|
||||||
|
file_path
|
||||||
|
);
|
||||||
|
|
||||||
string absolute_to_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath,
|
event_entry += "<br>";
|
||||||
change_set.Folder, to_file_path}.Combine ();
|
event_entry += FormatBreadCrumbs (
|
||||||
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder),
|
||||||
|
to_file_path
|
||||||
|
);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
event_entry += "</dd>";
|
||||||
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>";
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1146,6 +1147,45 @@ namespace SparkleShare {
|
||||||
Byte[] encoded_bytes = md5.ComputeHash (bytes);
|
Byte[] encoded_bytes = md5.ComputeHash (bytes);
|
||||||
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
color: <!-- $a-hover-color -->;
|
color: <!-- $a-hover-color -->;
|
||||||
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-timestamp {
|
.event-timestamp {
|
||||||
|
|
Loading…
Reference in a new issue