/// <summary>
 /// Build the singular attachment editor
 /// </summary>
 /// <param name="file">The file (attachment) to be displayed</param>
 /// <param name="viewModel">The view model that contains the relevant templates</param>
 /// <returns>The Html Content for the attachment editor</returns>
 private static IHtmlContent EditAttachment(IBlogItem item, BlogFile file, BlogViewModelBase viewModel)
 => ContentFill(BlogViewTemplatePart.Attachment_Item,
                new List <BlogViewTemplateReplacement>()
 {
     new BlogViewTemplateReplacement(BlogViewTemplateField.Common_Controller_Url, viewModel.ControllerUrl, false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.Attachment_Title, file.Title, false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.Attachment_Url, AttachmentUrl(item, file, viewModel), false)
 }, viewModel);
 /// <summary>
 /// None-helper signature of the blog item blog item editor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="preview"></param>
 /// <param name="viewModel"></param>
 /// <returns></returns>
 public static IHtmlContent BlogAttachments(IBlogItem item, BlogViewModelBase viewModel)
 => ContentFill(BlogViewTemplatePart.Attachment_View,
                new List <BlogViewTemplateReplacement>()
 {
     new BlogViewTemplateReplacement(BlogViewTemplateField.Common_Controller_Url, viewModel.ControllerUrl, false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_SEOUrlTitle, SEOUrlTitle(item.Header.Name), false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.Attachments, EditAttachments(item, viewModel).GetString(), false)
 }, viewModel);
Пример #3
0
 /// <summary>
 /// None-helper signature of the blog item blog item editor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="preview"></param>
 /// <param name="viewModel"></param>
 /// <returns></returns>
 public static IHtmlContent BlogSEOHeader(BlogViewModelBase viewModel, IBlogItem item)
 => ContentFill(BlogViewTemplatePart.Blog_SEO_Header,
                new List <BlogViewTemplateReplacement>()
 {
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Author, item.Header.Author, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Name, item.Header.Name, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Description, item.Header.Description, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_SEOTags, SEOKeywords(viewModel.CurrentBlog.Parameters.SEOSettings.Tags, item.Header.Tags), true)
 }, viewModel);
Пример #4
0
        /// <summary>
        /// Standardised content fill function to provide IHtmlContent based on a
        /// template and a set of replacement values
        /// </summary>
        /// <param name="part">The id of the template part</param>
        /// <param name="contentValues">A list of replacement values to process in the template</param>
        /// <param name="viewModel">The viewmodel to provide a link to the templates being used</param>
        /// <returns></returns>
        private static IHtmlContent ContentFill(
            BlogViewTemplatePart part,
            List <BlogViewTemplateReplacement> contentValues,
            BlogViewModelBase viewModel)
        {
            // Create the tag builders to return to the calling MVC page
            HtmlContentBuilder contentBuilder = new HtmlContentBuilder();

            // Append the processed Html to the content builder
            contentBuilder.AppendHtml(viewModel.Templates.Process(part, contentValues));

            // Return the builder
            return(contentBuilder);
        }
 /// <summary>
 /// Build the edit button for the blog item
 /// .. and determine whether it should even be visible for the user
 /// </summary>
 /// <param name="viewModel"></param>
 /// <returns>The html content for the edit button</returns>
 private static IHtmlContent BlogItemEditButton(IBlogItem item, BlogViewModelBase viewModel)
 {
     // Do we have someone logged in and are they an admin user?
     if (viewModel.CurrentUser != null && viewModel.CurrentUser.IsAdmin)
     {
         // Return the content as there is a user logged in and they are an admin user
         return(ContentFill(BlogViewTemplatePart.Blog_EditItem_Button, new List <BlogViewTemplateReplacement>()
         {
             new BlogViewTemplateReplacement(BlogViewTemplateField.Common_Controller_Url, viewModel.ControllerUrl, false),
             new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Id, item.Header.Id, true)
         }, viewModel));
     }
     else
     {
         return(new HtmlContentBuilder()); // No content as not logged in
     }
 }
 /// <summary>
 /// None-helper signature of the blog item rendered (picks up the template for the item from the current view)
 /// </summary>
 /// <param name="item"></param>
 /// <param name="preview"></param>
 /// <param name="viewModel"></param>
 /// <returns></returns>
 public static IHtmlContent BlogItem(IBlogItem item, BlogViewModelBase viewModel)
 => ContentFill(BlogViewTemplatePart.Blog_Item,
                new List <BlogViewTemplateReplacement>()
 {
     new BlogViewTemplateReplacement(BlogViewTemplateField.Common_Controller_Url, viewModel.ControllerUrl, false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Author, item.Header.Author, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Description, item.Header.Description, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Id, item.Header.Id, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Name, item.Header.Name, true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_PublishedDate,
                                     item.Header.PublishedDate.ToCustomDate(viewModel.DisplaySettings.DateFormat), true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_State, item.Header.State.GetDescription(), true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_UpdatedDate,
                                     item.Header.UpdatedDate.ToCustomDate(viewModel.DisplaySettings.DateFormat), true),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_Content, item.Content, false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_EditButton, BlogItemEditButton(item, viewModel).GetString(), false),
     new BlogViewTemplateReplacement(BlogViewTemplateField.BlogItem_SEOUrlTitle, SEOUrlTitle(item.Header.Name), false)
 }, viewModel);
        /// <summary>
        /// Build the attachment editing content
        /// </summary>
        /// <param name="item">The blog entry to get the attachments from</param>
        /// <param name="viewModel">The view model that contains the relevant templates</param>
        /// <returns>The Html Content of the attachment editor</returns>
        private static IHtmlContent EditAttachments(IBlogItem item, BlogViewModelBase viewModel)
        {
            // Create a content builder just to make the looped items content
            HtmlContentBuilder attachmentBuilder = new HtmlContentBuilder();

            // Loop the results and create the row for each result in the itemsBuilder
            item.Files.ForEach(
                file =>
            {
                attachmentBuilder.AppendHtml(EditAttachment(item, file, viewModel));
            }
                );

            // Call the standard content filler function
            return(ContentFill(BlogViewTemplatePart.Attachments,
                               new List <BlogViewTemplateReplacement>()
            {
                new BlogViewTemplateReplacement(BlogViewTemplateField.Attachment_List, attachmentBuilder.GetString(), false)
            },
                               viewModel));
        }
Пример #8
0
 /// <summary>
 /// The translated attachment url (Will not be direct but
 /// through a controller to relay the data)
 /// </summary>
 /// <param name="item">The blog item the file is attached to</param>
 /// <param name="file">The file to provide the url for</param>
 /// <param name="viewModel">The view model that containers the controller base url (incase there are multiple blogs)</param>
 /// <returns>The url for the file attachment</returns>
 public static String AttachmentUrl(IBlogItem item, BlogFile file, BlogViewModelBase viewModel)
 => AttachmentUrl(item, file, viewModel.RelativeControllerUrl);