Example #1
0
        public override void Layout()
        {
            BlogApp blog = ctx.app.obj as BlogApp;

            if (blog == null)
            {
                throw new NullReferenceException("BlogApp");
            }
            blogService.AddHits(blog);

            set("adminUrl", to(new Admin.MyListController().Index));
            bindAdminLink();


            bindAppInfo(blog);

            load("blog.UserMenu", new Users.ProfileController().UserMenu);

            BlogSetting s = blog.GetSettingsObj();

            List <BlogCategory> categories = categoryService.GetByApp(ctx.app.Id);
            List <BlogPost>     newBlogs   = postService.GetNewBlog(ctx.app.Id, s.NewBlogCount);

            List <OpenComment> comments = commentService.GetByApp(typeof(BlogPost), ctx.app.Id, s.NewCommentCount);

            List <Blogroll> blogrolls = rollService.GetByApp(ctx.app.Id, ctx.owner.obj.Id);

            bindBlogroll(blogrolls);
            bindCategories(categories);
            bindPostList(newBlogs);
            bindComments(comments);
        }
Example #2
0
        public static MvcContext GetOne(IMember objOwner, int appId)
        {
            IWebContext webContext = MockWebContext.New(1, "http://localhost/", new System.IO.StringWriter());

            MvcContext ctx = new MvcContext(webContext);

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();

            route.setAppId(appId);   // 为了让生成的link链接中有appId,必须设置此项
            ctx.utils.setRoute(route);

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();

            viewer.obj = new User();
            ctx.utils.setViewerContext(viewer);

            // owner
            OwnerContext owner = new OwnerContext();

            owner.Id  = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext(owner);

            // app
            IAppContext app = new AppContext();

            app.Id  = appId;
            app.obj = BlogApp.findById(appId);
            app.setAppType(typeof(BlogApp));     // 如果要使用alang语言包,必须设置此项
            ctx.utils.setAppContext(app);

            return(ctx);
        }
Example #3
0
        public void Index()
        {
            ctx.Page.Title = lang("blog");

            BlogApp app = ctx.app.obj as BlogApp;

            if (app == null)
            {
                echoError("app不存在");
                return;
            }

            BlogSetting s = app.GetSettingsObj();

            DataPage <BlogPost> results = postService.GetPage(ctx.app.Id, s.PerPageBlogs);

            IBlock block = getBlock("topblog");

            if (ctx.route.page == 1)
            {
                bindTopPosts(s, block);
            }

            bindPosts(results, s);

            set("pager", results.PageBar);
        }
Example #4
0
        public virtual void UpdateCount(BlogApp blog)
        {
            int count = BlogPost.count("AppId=" + blog.Id);

            blog.BlogCount = count;
            blog.update("BlogCount");
        }
Example #5
0
        public virtual void Index()
        {
            target(Save);
            BlogApp app = ctx.app.obj as BlogApp;

            bindSettings(app.GetSettingsObj());
        }
Example #6
0
        public override void Layout()
        {
            BlogApp blog = ctx.app.obj as BlogApp;

            blogService.AddHits(blog);

            set("adminUrl", to(new Admin.MyListController().Index));


            bindAppInfo(blog);

            load("blog.UserMenu", new Users.ProfileController().UserMenu);

            BlogSetting s = blog.GetSettingsObj();

            List <BlogCategory> categories = categoryService.GetByApp(ctx.app.Id);
            List <BlogPost>     newBlogs   = postService.GetNewBlog(ctx.app.Id, s.NewBlogCount);

            //List<BlogPostComment> newComments = commentService.GetNew( ctx.owner.Id, ctx.app.Id, s.NewCommentCount );
            List <BlogPostComment> newComments = BlogPostComment.find("AppId=" + ctx.app.Id).list(s.NewCommentCount);

            List <Blogroll> blogrolls = rollService.GetByApp(ctx.app.Id, ctx.owner.obj.Id);

            bindBlogroll(blogrolls);
            bindCategories(categories);
            bindPostList(newBlogs);
            bindComments(newComments);
        }
Example #7
0
        public virtual void UpdateCommentCount(IApp blogApp)
        {
            BlogApp blog  = blogApp as BlogApp;
            int     count = BlogPostComment.find("AppId=" + blog.Id).count();

            blog.CommentCount = count;
            blog.update("CommentCount");
        }
Example #8
0
        private static void updateAppCount(BlogPost post)
        {
            int     count = db.count <BlogPost>("AppId=" + post.AppId);
            BlogApp app   = BlogApp.findById(post.AppId);

            app.BlogCount = count;
            app.update("BlogCount");
        }
Example #9
0
        private void bindAppInfo( BlogApp blog )
        {
            set( "blog.Count", blog.BlogCount );
            set( "blog.Hits", blog.Hits );
            set( "blog.CommentCount", getBlogComments( blog ) );
            set( "blog.RssUrl", Link.To( new BlogController().Rss ) );

            Page.RssLink = Link.To( new BlogController().Rss );
        }
Example #10
0
        private void bindAppInfo(BlogApp blog)
        {
            set("blog.Count", blog.BlogCount);
            set("blog.Hits", blog.Hits);
            set("blog.CommentCount", getBlogComments(blog));
            set("blog.RssUrl", to(new BlogController().Rss));

            Page.RssLink = to(new BlogController().Rss);
        }
Example #11
0
        public IActionResult Publisher(Essay model, BlogApp app)
        {
            int valid = app.Save(model);

            if (valid == 0)
            {
                return(RedirectToAction("Error"));
            }

            return(RedirectToAction("Home"));
        }
        private void bindAppInfo( BlogApp blog )
        {
            int nComments = (int)getBlogComments( blog );

            set( "blog.Count", blog.BlogCount );
            set( "blog.Hits", blog.Hits );
            set( "blog.CommentCount", nComments );
            set("blog.Score", blog.BlogCount * 10 + 5 * nComments + blog.Hits);
            //set( "blog.RssUrl", Link.To( new BlogController().Rss ) );

            Page.RssLink = Link.To( new BlogController().Rss );
        }
        private void bindAppInfo(BlogApp blog)
        {
            int nComments = (int)getBlogComments(blog);

            set("blog.Count", blog.BlogCount);
            set("blog.Hits", blog.Hits);
            set("blog.CommentCount", nComments);
            set("blog.Score", blog.BlogCount * 10 + 5 * nComments + blog.Hits);
            //set( "blog.RssUrl", Link.To( new BlogController().Rss ) );

            Page.RssLink = Link.To(new BlogController().Rss);
        }
Example #14
0
        public virtual void Blog()
        {
            BlogApp app = blogAppService.GetFirstByUser(ctx.owner.Id);

            if (app == null)
            {
                echoError("app不存在");
                return;
            }
            String lnkApp = Link.To(ctx.owner.obj, new Blog.BlogController().Index, app.Id);

            redirectDirect(lnkApp);
        }
Example #15
0
        /// <summary>
        /// 列出相应发表日期的文章
        /// </summary>
        /// <param name="id"></param>
        public void List(int id)
        {
            BlogApp     app = ctx.app.obj as BlogApp;
            BlogSetting s   = app.GetSettingsObj();

            DataPage <BlogPost> list = postService.GetPageByCreatedCate(ctx.app.Id, id, s.PerPageBlogs);

            //bindCategory("list", "post", blogs, bindLink);

            //bindCategory( category );
            bindPostList(list);

            set("pager", list.PageBar);
        }
Example #16
0
        public virtual void Save()
        {
            BlogSetting s = ctx.PostValue <BlogSetting>();

            s.AllowComment          = ctx.PostIsCheck("blogSetting.AllowComment");
            s.AllowAnonymousComment = ctx.PostIsCheck("blogSetting.AllowAnonymousComment");
            s.IsShowStats           = ctx.PostIsCheck("blogSetting.IsShowStats");

            BlogApp app = ctx.app.obj as BlogApp;

            app.Settings = Json.ToString(s);
            app.update();

            echoRedirect(lang("opok"));
        }
Example #17
0
        private void bindComment(BlogPost post)
        {
            ctx.SetItem("createAction", to(new BlogCommentController().Create, post.Id));
            ctx.SetItem("commentTarget", post);

            BlogApp app = ctx.app.obj as BlogApp;

            if (app.GetSettingsObj().AllowComment == 1)
            {
                load("commentSection", new BlogCommentController().ListAndForm);
            }
            else
            {
                set("commentSection", "");
            }
        }
Example #18
0
        private string getCommentUrl(BlogPost post)
        {
            BlogApp app = ctx.app.obj as BlogApp;

            if (app.GetSettingsObj().AllowComment == 0)
            {
                return("#");
            }

            return(t2(new wojilu.Web.Controller.Open.CommentController().List)
                   + "?url=" + alink.ToAppData(post, ctx)
                   + "&dataType=" + typeof(BlogPost).FullName
                   + "&dataTitle=" + post.Title
                   + "&dataUserId=" + post.Creator.Id
                   + "&dataId=" + post.Id
                   + "&appId=" + post.AppId);
        }
Example #19
0
        public void Rss()
        {
            BlogApp     app = ctx.app.obj as BlogApp;
            BlogSetting s   = app.GetSettingsObj();

            RssChannel c = postService.GetRssByAppId(ctx.app.Id, s.RssCount);

            c.Generator = ctx.url.SiteUrl;

            c.Link = strUtil.Join(ctx.url.SiteUrl, c.Link);
            foreach (RssItem i in c.RssItems)
            {
                i.Link = strUtil.Join(ctx.url.SiteUrl, i.Link);
            }

            ctx.RenderXml(c.GetRenderContent());
        }
Example #20
0
        public virtual RssChannel getRssByApp(int appId, int count)
        {
            List <BlogPost> newListAll = null;

            if (appId > 0)
            {
                newListAll = this.GetNewBlog(appId, count);
            }
            else
            {
                newListAll = this.GetNewListAll(count);
            }

            BlogApp    app  = BlogApp.findById(appId);
            User       user = User.findById(app.OwnerId);
            IMemberApp uapp = new UserAppService().GetByApp(app);

            RssChannel channel = new RssChannel();

            channel.Title = uapp.Name + " -- " + user.Name + "'s blog";
            channel.Link  = Link.ToMember(user);

            foreach (BlogPost post in newListAll)
            {
                RssItem rssItem = new RssItem();
                rssItem.Title       = post.Title;
                rssItem.Description = post.Content;
                rssItem.Category    = post.Category.Name;
                rssItem.PubDate     = post.Created;
                rssItem.Author      = post.Creator.Name;

                rssItem["CreatorLink"] = channel.Link;
                rssItem["CreatorFace"] = post.Creator.PicSmall;
                rssItem.Link           = alink.ToAppData(post);

                channel.RssItems.Add(rssItem);
            }


            return(channel);
        }
Example #21
0
        //  [CacheAction( typeof( BlogIndexCache ) )]
        public void Index()
        {
            WebUtils.pageTitle(this, lang("blog"));

            BlogApp     app = ctx.app.obj as BlogApp;
            BlogSetting s   = app.GetSettingsObj();


            DataPage <BlogPost> results = postService.GetPage(ctx.app.Id, s.PerPageBlogs);

            IBlock block = getBlock("topblog");

            if (ctx.route.page == 1)
            {
                bindTopPosts(s, block);
            }

            bindPosts(results, s);

            set("pager", results.PageBar);
        }
Example #22
0
        public void Show(int id)
        {
            BlogCategory category = categoryService.GetById(id, ctx.owner.Id);

            if (category == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            BlogApp     app = ctx.app.obj as BlogApp;
            BlogSetting s   = app.GetSettingsObj();


            DataPage <BlogPost> list = postService.GetPageByCategory(ctx.app.Id, id, s.PerPageBlogs);

            bindCategory(category);
            bindPostList(list);

            set("pager", list.PageBar);
        }
Example #23
0
        public void Show(int id)
        {
            BlogCategory category = categoryService.GetById(id, ctx.owner.Id);

            if (category == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            //List<BlogCategory> lstblogcategory = categoryService.GetByIdName(id);

            BlogApp     app = ctx.app.obj as BlogApp;
            BlogSetting s   = app.GetSettingsObj();


            DataPage <BlogPost> list = postService.GetPageByCategory(ctx.app.Id, id, s.PerPageBlogs);

            //bindCategory("list", "post", blogs, bindLink);

            //bindCategory( category );



            //IBlock block = getBlock("topblog");
            //if (ctx.route.page == 1)
            //{
            //    bindTopPosts(s, block);
            //}

            bindPostList(list);



            set("pager", list.PageBar);
        }
Example #24
0
 public virtual void AddHits(BlogApp app)
 {
     HitsJob.Add(app);
 }
Example #25
0
        public virtual void UpdateCommentCount(int appId)
        {
            BlogApp blogApp = BlogApp.findById(appId);

            this.UpdateCommentCount(blogApp);
        }
Example #26
0
 public virtual List <BlogApp> GetBlogAppAll()
 {
     return(BlogApp.findAll());
 }
Example #27
0
 public virtual BlogApp GetFirstByUser(int ownerId)
 {
     return(BlogApp.find("OwnerId=" + ownerId + " and OwnerType=:OwnerType")
            .set("OwnerType", typeof(User).FullName)
            .first());
 }
Example #28
0
 private int getBlogComments(BlogApp blog)
 {
     return(blog.CommentCount);
 }
Example #29
0
 public virtual void AddHits( BlogApp app ) {
     HitsJob.Add( app );
 }
Example #30
0
        public IActionResult Home(int?id, int?last, string search, BlogApp app)
        {
            List <Essay> model = app.Get(id, last, search);

            return(View(model));
        }
        private object getBlogComments(BlogApp blog)
        {
            return(BlogPostComment.count("AppId=" + blog.Id));

            //return blog.CommentCount;
        }
 private int getBlogComments( BlogApp blog ) {
     return blog.CommentCount;
 }
Example #33
0
        private object getBlogComments( BlogApp blog )
        {
            return BlogPostComment.count( "AppId=" + blog.Id );

            //return blog.CommentCount;
        }
Example #34
0
        public virtual void UpdateCount( BlogApp blog ) {

            int count = BlogPost.count( "AppId=" + blog.Id );
            blog.BlogCount = count;
            blog.update( "BlogCount" );
        }