event log: create usable breadcrumbs for file paths
This commit is contained in:
parent
549fae56bf
commit
6bcafd3aa1
|
@ -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)
|
||||
|
|
|
@ -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 ();
|
||||
event_entry += "<dd class='document edited'>";
|
||||
|
||||
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 += 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 ();
|
||||
event_entry += "<dd class='document added'>";
|
||||
|
||||
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 += 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 ();
|
||||
event_entry += "<dd class='document deleted'>";
|
||||
|
||||
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 += 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
|
||||
a:hover {
|
||||
color: <!-- $a-hover-color -->;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.event-timestamp {
|
||||
|
|
Loading…
Reference in a new issue