/** * 网站配置项 * * @param key * @param defalutValue 默认值 * @return */ public string site_option(string key, string defalutValue) { if (StringKit.IsBlank(key)) { return(""); } return(_optionService.Get(key, defalutValue)); }
/** * 返回主题设置选项 * * @param key * @return */ public string theme_option(string key, string defaultValue) { string option = theme_option(key); if (StringKit.IsBlank(option)) { return(defaultValue); } return(option); }
public ApiResponse <int> NewArticle([FromBody] ContentInput contents) { var user = _userService.CurrentUsers; contents.Type = Types.ARTICLE; contents.AuthorId = user.Uid; //将点击数设初始化为0 contents.Hits = 0; //将评论数设初始化为0 contents.CommentsNum = 0; if (StringKit.IsBlank(contents.Categories)) { contents.Categories = "默认分类"; } var cid = _contentsService.publish(contents); return(ApiResponse <int> .Ok(cid, cid)); }
/** * 截取文章摘要(返回HTML) * * @param value 文章内容 * @return 转换 markdown 为 html */ public string intro(string value) { if (StringKit.IsBlank(value)) { return(null); } int pos = value.IndexOf("<!--more-->", StringComparison.Ordinal); if (pos != -1) { string html = value.Substring(0, pos); return(Markdown.ToHtml(html)); } else { return(Markdown.ToHtml(value)); } }
public List <Metas> getMetas(string searchType, string type, int limit) { if (StringKit.IsBlank(searchType) || StringKit.IsBlank(type)) { return(new List <Metas>()); } if (limit < 1 || limit > iBlogsConst.MAX_POSTS) { limit = 10; } //// 获取最新的项目 //if (Types.RECENT_META.Equals(searchType)) //{ // var sql = // "select a.*, count(b.cid) as count from t_metas a left join `t_relationships` b on a.mid = b.mid " // + // "where a.type = @type group by a.mid order by count desc, a.mid desc limit @limit"; // return _.Query<Metas>(sql, new { type = type, limit = limit }).ToList(); //} //// 随机获取项目 //if (Types.RANDOM_META.Equals(searchType)) //{ // List<int> mids = _sqLite.Query<int>( // "select mid from t_metas where type = @type order by random() * mid limit @limit", // new { type = type, limit = limit }).ToList(); // if (mids != null) // { // string sql = // "select a.*, count(b.cid) as count from t_metas a left join `t_relationships` b on a.mid = b.mid " // + // "where a.mid in @mids group by a.mid order by count desc, a.mid desc"; // return _sqLite.Query<Metas>(sql, mids).ToList(); // } //} return(new List <Metas>()); }