protected virtual SyndicationItem GetFeedItem(IMasterModel model, PostModel post, string rootUrl) { var posturl = post.UrlWithDomain(); //Cannot continue if the url cannot be resolved - probably has publishing issues if (posturl.StartsWith("#")) { return null; } var appPath = _umbracoContext.HttpContext.Request.ApplicationPath; var rootUri = new Uri(rootUrl); var mediaRoot = rootUri.GetLeftPart(UriPartial.Authority) + appPath.EnsureStartsWith('/').TrimEnd('/'); var content = _relativeMediaHref.Replace(GetPostContent(post), match => { if (match.Groups.Count == 2) { return $" href=\"{rootUrl.TrimEnd('/')}{match.Groups[1].Value.EnsureStartsWith('/')}\""; } return null; }); content = _relativeMediaSrc.Replace(content, match => { if (match.Groups.Count == 2) { return $" src=\"{mediaRoot}{match.Groups[1].Value.EnsureStartsWith('/')}\""; } return null; }); var item = new SyndicationItem( post.Name, new TextSyndicationContent(content, TextSyndicationContentKind.Html), new Uri(posturl), post.Id.ToString(CultureInfo.InvariantCulture), post.PublishedDate) { PublishDate = post.PublishedDate, //don't include this as it will override the main content bits //Summary = new TextSyndicationContent(post.Excerpt) }; //TODO: attempting to add media:thumbnail... //item.ElementExtensions.Add(new SyndicationElementExtension("thumbnail", "http://search.yahoo.com/mrss/", "This is a test!")); foreach (var c in post.Categories) { item.Categories.Add(new SyndicationCategory(c)); } return item; }
protected virtual SyndicationItem GetFeedItem(IMasterModel model, PostModel post, string rootUrl) { var content = _relativeMediaHref.Replace(GetPostContent(post), match => { if (match.Groups.Count == 2) { return " href=\"" + rootUrl.TrimEnd('/') + match.Groups[1].Value.EnsureStartsWith('/') + "\""; } return null; }); content = _relativeMediaSrc.Replace(content, match => { if (match.Groups.Count == 2) { return " src=\"" + rootUrl.TrimEnd('/') + match.Groups[1].Value.EnsureStartsWith('/') + "\""; } return null; }); var item = new SyndicationItem( post.Name, new TextSyndicationContent(content, TextSyndicationContentKind.Html), new Uri(post.UrlWithDomain()), post.Id.ToString(CultureInfo.InvariantCulture), post.PublishedDate) { PublishDate = post.PublishedDate, //don't include this as it will override the main content bits //Summary = new TextSyndicationContent(post.Excerpt) }; //TODO: attempting to add media:thumbnail... //item.ElementExtensions.Add(new SyndicationElementExtension("thumbnail", "http://search.yahoo.com/mrss/", "This is a test!")); foreach (var c in post.Categories) { item.Categories.Add(new SyndicationCategory(c)); } return item; }
protected virtual string GetPostContent(PostModel model) { return model.Body.ToHtmlString(); }
/// <summary> /// There are so many variants of Metaweblog API so I've just included as many properties, custom ones, etc... that i can find /// </summary> /// <param name="post"></param> /// <returns></returns> /// <remarks> /// http://msdn.microsoft.com/en-us/library/bb463260.aspx /// http://xmlrpc.scripting.com/metaWeblogApi.html /// http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt /// http://codex.wordpress.org/XML-RPC_MetaWeblog_API /// https://blogengine.codeplex.com/SourceControl/latest#BlogEngine/BlogEngine.Core/API/MetaWeblog/MetaWeblogHandler.cs /// </remarks> private object FromPost(PostModel post) { return new MetaWeblogPost { AllowComments = post.EnableComments ? 1 : 2, Author = post.Author.Name, Categories = post.Categories.ToArray(), Content = post.Body.ToString(), CreateDate = post.PublishedDate != default(DateTime) ? post.PublishedDate : post.UpdateDate, Id = post.Id.ToString(CultureInfo.InvariantCulture), Slug = post.UrlName, Excerpt = post.Excerpt, Tags = string.Join(",", post.Tags.ToArray()), Title = post.Name }; }
public override ActionResult Index(RenderModel model) { var post = new PostModel(model.Content); return View(PathHelper.GetThemeViewPath(post, "Post"), post); }