Ejemplo n.º 1
0
        public override void AfterAction(MvcContext ctx)
        {
            if (!HtmlHelper.CanHtml(ctx))
            {
                return;
            }

            // 1)文章添加之后,app首页和侧边栏都要更新
            HtmlMaker.GetHome().Process(ctx.app.Id);
            logger.Info("PostAddObserver make app home");


            // 2)新创建的文章,需要通过 ctx 传递
            ContentPost post = HtmlHelper.GetPostFromContext(ctx);

            if (post != null)
            {
                DetailMaker mk = HtmlMaker.GetDetail();
                mk.Process(post);
                ContentPost prev = postService.GetPrevPost(post);
                if (prev != null)
                {
                    mk.Process(prev);
                }
            }

            // 3) 侧边栏
            HtmlMaker.GetSidebar().Process(post.AppId);

            // 4) 其他生成工作放到队列中
            JobManager.PostAdd(post);
        }
Ejemplo n.º 2
0
        public override void AfterAction(MvcContext ctx)
        {
            if (!HtmlHelper.CanHtml(ctx))
            {
                return;
            }

            HtmlMaker.GetHome().Process(ctx.app.Id);
            logger.Info("HomeObserver make app home");
        }
Ejemplo n.º 3
0
        public virtual void AfterPostAdd(int postId)
        {
            ContentPost post = ContentPost.findById(postId);

            // 3)相关列表页也要更新
            HtmlMaker.GetList().Process(post);
            logger.Info("[AfterPostAdd] make html list done. postId=" + postId);

            // 4) 最近列表页处理
            HtmlMaker.GetRecent().ProcessAll(post.AppId);
            logger.Info("[AfterPostAdd] make html recent done. postId=" + postId);
        }
Ejemplo n.º 4
0
        public virtual void AfterPostUpdate(int postId)
        {
            ContentPost post = ContentPost.findById(postId);

            // 3) 列表页处理
            HtmlMaker.GetList().Process(post);
            logger.Info("[AfterPostUpdate] make html list done. postId=" + postId);

            // 4) 最近列表页处理
            HtmlMaker.GetRecent().ProcessAll(post.AppId);
            logger.Info("[AfterPostUpdate] make html recent done. postId=" + postId);

            // 5) 侧边栏
            HtmlMaker.GetSidebar().Process(post.AppId);
            logger.Info("[AfterPostUpdate] make html sidebar done. postId=" + postId);
        }
Ejemplo n.º 5
0
        public override void AfterAction(Context.MvcContext ctx)
        {
            if (!HtmlHelper.CanHtml(ctx))
            {
                return;
            }

            // 1)文章删除之后,app首页更新
            HtmlMaker.GetHome().Process(ctx.app.Id);

            // 2)删除文章详细页
            HtmlMaker.GetDetail().Delete(_contentPost);

            // 3) 其他生成工作放到队列中
            JobManager.PostDelete(_contentPost);
        }
Ejemplo n.º 6
0
        public virtual void Execute()
        {
            logger.Info("begin execute");
            List <ContentApp> apps = ContentApp.find("OwnerType=:otype").set("otype", typeof(Site).FullName).list();

            foreach (ContentApp app in apps)
            {
                ContentSetting setting = app.GetSettingsObj();
                if (setting.IsAutoHtml == 0)
                {
                    logger.Info("skip home, appId=" + app.Id);
                    continue;
                }

                HtmlMaker.GetHome().Process(app.Id);
                logger.Info("make home, appId=" + app.Id);
            }
        }
Ejemplo n.º 7
0
        public override void AfterAction(MvcContext ctx)
        {
            if (!HtmlHelper.CanHtml(ctx))
            {
                return;
            }

            // 1)文章更新之后,比如标题被修改,那么app首页要更新
            HtmlMaker.GetHome().Process(ctx.app.Id);

            // 2)详细页设置
            ContentPost post = postService.GetById(ctx.route.id, ctx.owner.Id);

            HtmlMaker.GetDetail().Process(post);

            // 3) 其他生成工作放到队列中
            JobManager.PostUpdate(post);
        }
Ejemplo n.º 8
0
        public virtual void AfterImport(String ids)
        {
            if (strUtil.IsNullOrEmpty(ids))
            {
                return;
            }
            int[] arrIds = cvt.ToIntArray(ids);
            if (arrIds.Length == 0)
            {
                return;
            }

            List <int>         appIds     = new List <int>();
            List <int>         sectionIds = new List <int>();
            List <ContentPost> posts      = new List <ContentPost>();

            // 1) 逐一生成详细页
            foreach (int id in arrIds)
            {
                ContentPost x = ContentPost.findById(id);
                if (x == null)
                {
                    continue;
                }

                posts.Add(x);

                if (isAutoMakeHtml(x.AppId) == false)
                {
                    continue;
                }

                if (appIds.Contains(x.AppId) == false)
                {
                    appIds.Add(x.AppId);
                }

                if (sectionIds.Contains(x.SectionId) == false)
                {
                    sectionIds.Add(x.SectionId);
                }

                HtmlMaker.GetDetail().Process(x);
                logger.Info("[AfterImport] make html detail done. postId=" + x);
            }

            // 2) 列表页
            foreach (int x in sectionIds)
            {
                HtmlMaker.GetList().ProcessSection(x);
                logger.Info("[AfterImport] make html list done. sectionId=" + x);
            }

            foreach (int appId in appIds)
            {
                // 3) 生成首页
                HtmlMaker.GetHome().Process(appId);
                logger.Info("[AfterImport] make html home done. appId=" + appId);

                // 4) 生成侧边栏
                HtmlMaker.GetSidebar().Process(appId);
                logger.Info("[AfterImport] make html sidebar done. appId=" + appId);

                // 5) 最近列表页处理
                HtmlMaker.GetRecent().ProcessAll(appId);
                logger.Info("[AfterImport] make html recent done. appId=" + appId);
            }
        }