Пример #1
0
        /// <summary>
        /// 作者
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public ActionResult Author(string username)
        {
            var model = new PostListModel();
            model.SiteName = SiteConfig.GetSetting().SiteName;
            model.MetaTitle = SiteConfig.GetSetting().SiteName;
            model.SiteUrl = ConfigHelper.SiteUrl;
            model.MetaKeywords = SiteConfig.GetSetting().MetaKeywords;
            model.MetaDescription = SiteConfig.GetSetting().MetaDescription;
            model.SiteDescription = SiteConfig.GetSetting().SiteDescription;
            model.FooterHtml = SiteConfig.GetSetting().FooterHtml;
            UserInfo user = _userService.GetUser(username);
            if (user != null)
            {
                int userId = user.UserId;
                model.MetaKeywords = user.NickName;
                model.MetaDescription = user.Description;
                model.MetaTitle = user.NickName;
                model.PostMessage = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", user.NickName);
                model.Url = ConfigHelper.SiteUrl + "author/" + Jqpress.Framework.Utils.StringHelper.SqlEncode(username) + "/page/{0}";
                const int pageSize = 10;
                int count = 0;
                int pageIndex = PressRequest.GetInt("page", 1);
                int cateid = PressRequest.GetQueryInt("cateid", -1);
                if (cateid > 0)
                    pageIndex = pageIndex + 1;
                var postlist = _postService.GetPostPageList(pageSize, pageIndex, out count, cateid.ToString(), 0, userId, -1, -1, -1, -1, "", "", "");
                model.PageList.LoadPagedList(postlist);
                model.PostList = (List<PostInfo>)postlist;

            }
            model.IsDefault = 0;
            return View("List", model);
        }
Пример #2
0
        public ActionResult Category(string slug)
        {
            var model = new PostListModel();
            CategoryInfo cate = _categoryService.GetCategory(slug);
            model.Category = cate;
            if (cate != null)
            {
                int categoryId = cate.CategoryId;
                model.MetaKeywords = cate.CateName;
                model.MetaDescription = cate.Description;
                ViewBag.Title = cate.CateName;
                model.Url = ConfigHelper.SiteUrl + "category/" + StringHelper.SqlEncode(slug) + "/page/{0}";

                const int pageSize = 10;
                int count = 0;
                int pageIndex = PressRequest.GetInt("page", 1);
                int cateid = PressRequest.GetQueryInt("cateid", -1);
                int tagid = PressRequest.GetQueryInt("tagid", -1);
                if (cateid > 0)
                    pageIndex = pageIndex + 1;
                var cateids =categoryId+","+ _categoryService.GetCategoryList().FindAll(c => c.ParentId == categoryId).Aggregate(string.Empty, (current, t) => current + (t.CategoryId + ",")).TrimEnd(',');
                var postlist = _postService.GetPostPageList(pageSize, pageIndex, out count, cateids.TrimEnd(','), tagid, -1, -1, -1, -1, -1, "", "", "");
                model.PageList.LoadPagedList(postlist);
                model.PostList = (List<PostInfo>)postlist;
            }
            model.IsDefault = 0;

            return View(model.Category.ViewName,model);
        }
Пример #3
0
        /// <summary>
        /// 标签
        /// </summary>
        public ActionResult Tag(string slug)
        {
            var model = new PostListModel();
            model.SiteName = SiteConfig.GetSetting().SiteName;
            model.ThemeName = "printV1";
            model.MetaTitle = SiteConfig.GetSetting().SiteName;
            model.SiteUrl = ConfigHelper.SiteUrl;
            model.MetaKeywords = SiteConfig.GetSetting().MetaKeywords;
            model.MetaDescription = SiteConfig.GetSetting().MetaDescription;
            model.SiteDescription = SiteConfig.GetSetting().SiteDescription;
            model.FooterHtml = SiteConfig.GetSetting().FooterHtml;
            TagInfo tag = _tagService.GetTagByPageName(slug);
            if (tag != null)
            {
                int tagId = tag.TagId;
                model.MetaKeywords = tag.CateName;
                model.MetaDescription = tag.Description;
                model.MetaTitle = tag.CateName;
                model.PostMessage = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", tag.CateName);
                model.Url = ConfigHelper.SiteUrl + "tag/" + Jqpress.Framework.Utils.StringHelper.SqlEncode(slug) + "/page/{0}";
                const int pageSize = 10;
                int count = 0;
                int pageIndex = PressRequest.GetInt("page", 1);
                int cateid = PressRequest.GetQueryInt("cateid", -1);
                int tagid = PressRequest.GetQueryInt("tagid", -1);
                if (cateid > 0)
                    pageIndex = pageIndex + 1;
                var postlist = _postService.GetPostPageList(pageSize, pageIndex, out count, cateid.ToString(), tagId, -1, -1, -1, -1, -1, "", "", "");
                model.PageList.LoadPagedList(postlist);
                model.PostList = (List<PostInfo>)postlist;

            }
            model.IsDefault = 0;
            return View("List",model);
        }