@using Mediaparts.Features.PublicationExporting.DAL.Razor @using Mediaparts.Features.PublicationExporting.DAL.Razor.Contexts @using Mediaparts.Features.PublicationExporting.DAL.Razor.PageContent @using Mediaparts.Features.PublicationExporting.DAL.Razor.Settings @{ RazorBaseContext PublicationModel = null; string tocURL = "./toc.html"; var IS_DEBUG = false; if (Model is RazorBaseContext) { PublicationModel = (RazorBaseContext)Model; //Костыль, потому что basic находится в папке assets/basic-html PublicationModel.DynamicFilesFolder = new Uri("./..", UriKind.Relative); PublicationModel.StaticFilesFolder = new Uri(".", UriKind.Relative); } else { //Fill this to debug PublicationModel = new RazorBaseContext(); PublicationModel.DynamicFilesFolder = new Uri("./debug", UriKind.Relative); PublicationModel.StaticFilesFolder = new Uri(".", UriKind.Relative); using (var fs = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "debug/model.bin"))) { var deserializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); PublicationModel.ProjectModel = (RazorProjectModel)deserializer.Deserialize(fs); } tocURL = "./toc.cshtml"; IS_DEBUG = true; } if (PublicationModel.ProjectModel.TableOfContents == null || !PublicationModel.ProjectModel.TableOfContents.Children.Any()) { tocURL = String.Empty; } } @{ int lastIndex = PublicationModel.ProjectModel.Pages.Count() - 1; var bgColor = System.Drawing.ColorTranslator.ToHtml(PublicationModel.ProjectModel.Styles.PublicationBackgroundColor); var textColor = System.Drawing.ColorTranslator.ToHtml(PublicationModel.ProjectModel.Styles.BackgroundTextСolor); string coverPath = PublicationModel.DynamicFilesFolder + "/flash/pages/page0001_s." + ImageFormat(PublicationModel.ProjectModel.Pages.ElementAt(0).ThumbnailImageType); string bgImage = (PublicationModel.ProjectModel.Styles.PublicationBackgroundImage == null) ? "" : (PublicationModel.DynamicFilesFolder + "/" + PublicationModel.ProjectModel.Styles.PublicationBackgroundImage.OriginalString); } @helper RenderTOCLevel(RazorBaseContext publicationModel, RazorTocItem item, int level) {

@item.Name
@(PageModelById(publicationModel,item.PageId).UrlHeader)
foreach (var child in item.Children) { @Html.Raw(RenderTOCLevel(publicationModel, child, level + 1).ToString()) } } @PublicationModel.ProjectModel.PublicationName @if (PublicationModel.ProjectModel.Styles.FavIcon != null) { } @if (!String.IsNullOrEmpty(PublicationModel.ProjectModel.Analytics.GoogleUANumber)) { if (PublicationModel.ProjectModel.Analytics.UseUniversalAnalytics) { } } @if (!String.IsNullOrEmpty(bgImage)) { Background Image }
Table of Contents Table of Contents @{ var downloads = PublicationModel.ProjectModel.Downloads; var hasDownloads = downloads != null && (downloads.Mac != null || downloads.Windows != null || (downloads.Pdf != null && PublicationModel.ProjectModel.PublicationType != RazorPublicationType.PhotoAlbum) || (downloads.UserFiles != null && downloads.UserFiles.Any())); } @if (hasDownloads) { }
@{ var next = PageUrl(PublicationModel.ProjectModel.Pages.ElementAt(0)); } @if (PublicationModel.ProjectModel.Settings.RtlModeEnabled) { Next Page @PublicationModel.ProjectModel.PublicationName } else { @PublicationModel.ProjectModel.PublicationName Next Page } @if (PublicationModel.ProjectModel.IsShareEnabled) { }
Information
@{ var mobileButtonStyle = "display:none;"; if (!String.IsNullOrEmpty(tocURL) || PublicationModel.ProjectModel.IsShareEnabled || PublicationModel.ProjectModel.Downloads != null) { mobileButtonStyle = ""; } } Show Menu
@if (PublicationModel.ProjectModel.Settings.RtlModeEnabled) { Next Page @PublicationModel.ProjectModel.PublicationName } else { @PublicationModel.ProjectModel.PublicationName Next Page }

 



@foreach (var child in PublicationModel.ProjectModel.TableOfContents.Children) { @RenderTOCLevel(PublicationModel, child, 0); }
@functions{ public static int DEFAULT_SIZE = 20; public RazorPageModel PageModelById(RazorBaseContext PublicationModel, int id) { return PublicationModel.ProjectModel.Pages.First(x => x.Id == id); } public static string PageUrl(RazorPageModel model) { return String.Format("./page-{0}.html", model.UrlHeader); } public static string ImageFormat(RazorImageFormatType format) { switch (format) { case RazorImageFormatType.Jpeg: return "jpg"; case RazorImageFormatType.Png: return "png"; } return ""; } public static string JavaScriptStringEncode(string value, bool addDoubleQuotes) { if (String.IsNullOrEmpty(value)) return addDoubleQuotes ? "\"\"" : String.Empty; int len = value.Length; bool needEncode = false; char c; for (int i = 0; i < len; i++) { c = value[i]; if (c >= 0 && c <= 31 || c == 34 || c == 39 || c == 60 || c == 62 || c == 92) { needEncode = true; break; } } if (!needEncode) return addDoubleQuotes ? "\"" + value + "\"" : value; var sb = new System.Text.StringBuilder(); if (addDoubleQuotes) sb.Append('"'); for (int i = 0; i < len; i++) { c = value[i]; if (c >= 0 && c <= 7 || c == 11 || c >= 14 && c <= 31 || c == 39 || c == 60 || c == 62) sb.AppendFormat("\\u{0:x4}", (int)c); else switch ((int)c) { case 8: sb.Append("\\b"); break; case 9: sb.Append("\\t"); break; case 10: sb.Append("\\n"); break; case 12: sb.Append("\\f"); break; case 13: sb.Append("\\r"); break; case 34: sb.Append("\\\""); break; case 92: sb.Append("\\\\"); break; default: sb.Append(c); break; } } if (addDoubleQuotes) sb.Append('"'); return sb.ToString(); } }