/// <summary> /// 创建文章的静态html页面 /// </summary> /// <param name="article">文章实体</param> /// <returns></returns> public ReturnValue CreateHtml(VwArticle article) { ReturnValue retValue = new ReturnValue(false, "生成失败"); if (article == null || article.ID < 0) { log.Info("CreateHtml article is null !"); retValue.Message = "参数不正确"; return retValue; } Html htm = this.Get(article.ID); if (htm == null)//没有静态页记录 { htm = new Html(); htm.ArtID = article.ID; htm.Url = CodeNote.Common.IDentity.CreateNew().AddStr("/").AddDate("yyyy").AddStr("/").AddDate("MM").AddStr("/").AddDate("ddHHmmssff").AddStr(5).StrID() + ".html"; article.HtmlUrl = htm.Url; htm.Upda = article.ModDate; } else { htm.Upda = article.ModDate; log.Info("Modify: " + article.Subject + " => " + htm.Url); } if (CreateHtml(article, htm)) { retValue = this.AddOrEdit(htm); } return retValue; }
/// <summary> /// 生成静态页面信息 /// </summary> /// <param name="article">文章信息</param> /// <param name="html">html页面信息</param> /// <returns></returns> protected bool CreateHtml(VwArticle article, Html html) { StringTemplate st = CodeNote.Common.TemplateWrap.GetSt("article_detail"); if (st != null) { article.Body = CodeNote.Markdown.Default.Transform(article.Body); //markdown to html st.SetAttribute("update", html.Upda); st.SetAttribute("keywords", article.Tag);//搜索关键字 st.SetAttribute("taglinks", TagInfoManager.TagLinks(article.Tag)); st.SetAttribute("description", CodeNote.Common.StringFilter.ClearHtml(article.Body,200)); st.SetAttribute("entity", article); return CodeNote.Common.IoWrap.WriteFile(CodeNote.Common.ConfigWrap.FiePath(STATIC_HTML_DIR) + html.Url, st.ToString()); } else { log.Warn("Not find 'article_detail.st' template !"); } return false; }
public IList<VwArticle> GetRecList(int topNum, VwArticle article, string filter) { return null; }