/// <summary> /// Executes once LoadRequest has executed. Will also happen when deserializing cached data /// </summary> public override object Deserialize(DayLoadContext loadContext, Type objectType, Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } string html = PageParser.GetHtml(stream); var entries = PageParser.ExtractEntriesFromHtml(html, false); var viewModel = new EventsViewModel(loadContext); if (loadContext.ReverseOrder) { entries.Reverse(); } var groupings = entries.GroupBy(PageParser.GroupByYear()); foreach (IGrouping <string, Entry> grouping in groupings) { var displayGroup = new GroupedEntries { Name = grouping.Key, Entries = grouping.ToList() }; viewModel.Events.Add(displayGroup); } return(viewModel); }
/// <summary> /// Header with directory information /// </summary> private void BuildDirListerHeader() { _sb.AppendLine("<aside>"); _sb.Append( "<a href=\"javascript:void(0)\" onclick=\"var els = document.getElementsByTagName('details');for (var i=0; i < els.length; i++) { els[i].setAttribute('open', 'open');}\">open all</a> | "); _sb.AppendLine( "<a href=\"javascript:void(0)\" onclick=\"var els = document.getElementsByTagName('details');for (var i=0; i < els.length; i++) { els[i].removeAttribute('open');}\">collapse all</a>"); _sb.AppendLine("</aside>"); _sb.AppendLine("<header>"); _sb.AppendLine($"<h2>Directory listing by DirLister, {EndDate.ToLocalTime().ToString(Configuration.DateFormat)}</h2>"); _sb.AppendLine("<ul>"); foreach (var folder in Configuration.InputFolders) { var files = GroupedEntries.Where(x => x.Key.StartsWith(folder, StringComparison.Ordinal)) .SelectMany(x => x.ToList()).ToList(); _sb.AppendLine( $"<li>{WebUtility.HtmlEncode(folder)} <span>files: {files.Count}, size: {Utils.ReadableSize(files.Sum(x => x.Size))}</span></li>"); } _sb.AppendLine("</ul>"); if (Configuration.InputFolders.Count > 1) { _sb.AppendLine( $"<strong>Total: {Entries.Count} files, {Utils.ReadableSize(Entries.Sum(x => x.Size))}</strong>"); } _sb.AppendLine("</header>"); }
private void AppendHeader() { _sb.AppendLine($"## Directory listing by [DirLister](https://github.com/SanderSade/DirLister/), {EndDate.ToLocalTime().ToString(Configuration.DateFormat)}:"); foreach (var folder in Configuration.InputFolders) { var files = GroupedEntries.Where(x => x.Key.StartsWith(folder, StringComparison.Ordinal)) .SelectMany(x => x.ToList()) .ToList(); _sb.AppendLine( $"* {WebUtility.HtmlEncode(folder)} `files: {files.Count}, size: {Utils.ReadableSize(files.Sum(x => x.Size))}`"); } if (Configuration.InputFolders.Count > 1) { _sb.AppendLine(); _sb.AppendLine( $"**Total: {Entries.Count} files, {Utils.ReadableSize(Entries.Sum(x => x.Size))}**"); } }
private void AppendHeader() { _sb.AppendLine($"Directory listing by DirLister, {EndDate.ToLocalTime().ToString(Configuration.DateFormat)}:"); foreach (var folder in Configuration.InputFolders) { var files = GroupedEntries.Where(x => x.Key.StartsWith(folder, StringComparison.Ordinal)) .SelectMany(x => x.ToList()) .ToList(); _sb.AppendLine( $"* {folder} files: {files.Count}, size: {Utils.ReadableSize(files.Sum(x => x.Size))}"); } if (Configuration.InputFolders.Count > 1) { _sb.AppendLine(); _sb.AppendLine($"** Total: {Entries.Count} files, {Utils.ReadableSize(Entries.Sum(x => x.Size))}"); } _sb.AppendLine(); _sb.AppendLine("Source, updates and support: https://github.com/SanderSade/DirLister/"); }