Esempio n. 1
0
        /// <summary>
        /// 首页
        /// </summary>
        public Task Index(ICompatibleHttpContext context)
        {
            // 如果启用了静态文件缓存
            if (Settings.PERM_INDEX_CACHE_SECOND > 0)
            {
                var task = this.CheckStaticIndex(context, Settings.PERM_INDEX_CACHE_SECOND);
                if (task != null)
                {
                    return(task);
                }
            }
            var     ctx  = Cms.Context;
            SiteDto site = ctx.CurrentSite;

            // 站点站点路径
            if (!this.CheckSiteUrl(context, site))
            {
                return(SafetyTask.CompletedTask);
            }

            //检测网站状态及其缓存
            if (ctx.CheckSiteState() && ctx.CheckAndSetClientCache())
            {
                DefaultWebOutput.RenderIndex(ctx);
            }
            return(SafetyTask.CompletedTask);
        }
Esempio n. 2
0
        /// <summary>
        /// 栏目页
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Task Category(ICompatibleHttpContext context)
        {
            context.Response.ContentType("text/html;charset=utf-8");
            CmsContext ctx = Cms.Context;

            //检测网站状态及其缓存
            if (ctx.CheckSiteState() && ctx.CheckAndSetClientCache())
            {
                var path     = context.Request.GetPath();
                var sitePath = ctx.SiteAppPath;
                // 如果为"/news/",跳转到"/news"
                var pLen = path.Length;
                if (path[pLen - 1] == '/')
                {
                    context.Response.StatusCode(301);
                    context.Response.AddHeader("Location", path.Substring(0, pLen - 1));
                    return(SafetyTask.CompletedTask);
                }

                // 验证是否为当前站点的首页
                if (path == sitePath)
                {
                    return(this.Index(context));
                }

                String catPath = this.SubPath(path, sitePath);
                int    page    = 1;
                //获取页码和tag
                if (catPath.EndsWith(".html"))
                {
                    var ls    = catPath.LastIndexOf("/", StringComparison.Ordinal);
                    var len   = catPath.Length;
                    var begin = ls + 1 + "list_".Length;
                    var ps    = catPath.Substring(begin, len - begin - 5);
                    int.TryParse(ps, out page);
                    catPath = catPath.Substring(0, ls);
                }


                DefaultWebOutput.RenderCategory(ctx, catPath, page);
                // //执行
                // bool eventResult = false;
                // if (OnCategoryRequest != null)
                // {
                //     OnCategoryRequest(ctx, catPath, page, ref eventResult);
                // }
                //
                // //如果返回false,则执行默认输出
                // if (!eventResult)
                // {
                //     DefaultWebOutput.RenderCategory(ctx, catPath, page);
                // }
            }

            return(SafetyTask.CompletedTask);
        }
Esempio n. 3
0
        /// <summary>
        /// 首页
        /// </summary>
        public Task Index(ICompatibleHttpContext context)
        {
            // 如果启用了静态文件缓存
            if (Settings.PERM_INDEX_CACHE_SECOND > 0)
            {
                var task = this.CheckStaticIndex(context, Settings.PERM_INDEX_CACHE_SECOND);
                if (task != null)
                {
                    return(task);
                }
            }

            // bool eventResult = false;
            // if (OnIndexRequest != null)
            // {
            //     OnIndexRequest(base.OutputContext, ref eventResult);
            // }
            var     ctx  = Cms.Context;
            SiteDto site = ctx.CurrentSite;

            // 站点站点路径
            if (!this.CheckSiteUrl(context, site))
            {
                return(SafetyTask.CompletedTask);
            }

            //检测网站状态及其缓存
            if (ctx.CheckSiteState() && ctx.CheckAndSetClientCache())
            {
                DefaultWebOutput.RenderIndex(ctx);
            }

            return(SafetyTask.CompletedTask);


            //如果返回false,则执行默认输出
            // if (!eventResult)
            // {
            //     DefaultWebOutput.RenderIndex(base.OutputContext);
            // }
        }
Esempio n. 4
0
        /// <summary>
        ///     首页
        /// </summary>
        public Task Index(ICompatibleHttpContext context)
        {
            // 如果启用了静态文件缓存
            if (Settings.PERM_INDEX_CACHE_SECOND > 0)
            {
                var task = CheckStaticIndex(context, Settings.PERM_INDEX_CACHE_SECOND);
                if (task != null)
                {
                    return(task);
                }
            }

            var ctx  = Cms.Context;
            var site = ctx.CurrentSite;

            // 站点站点路径
            if (!CheckSiteUrl(context, site))
            {
                return(SafetyTask.CompletedTask);
            }
            //检测网站状态及其缓存
            if (ctx.CheckSiteState())
            {
                if (Settings.PERM_INDEX_CACHE_SECOND > 0)
                {
#if DEBUG
                    Console.WriteLine("[ cms][ Info]: update index page cache..");
#endif
                    var    unix = TimeUtils.Unix(DateTime.Now);
                    String html = GenerateIndexPageCache(context, IndexCacheKey, IndexCacheUnixKey, unix);
                    context.Response.ContentType("text/html;charset=utf-8");
                    return(context.Response.WriteAsync(html));
                }
                DefaultWebOutput.RenderIndex(ctx);
            }

            return(SafetyTask.CompletedTask);
        }
Esempio n. 5
0
        /// <summary>
        /// 文档页
        /// </summary>
        /// <returns></returns>
        public Task Archive(ICompatibleHttpContext context)
        {
            context.Response.ContentType("text/html;charset=utf-8");
            var path = context.Request.GetPath();
            var task = this.CheckStaticFile(context, path);

            if (task != null)
            {
                return(task);
            }
            CmsContext ctx = Cms.Context;

            //检测网站状态及其缓存
            if (ctx.CheckSiteState() && ctx.CheckAndSetClientCache())
            {
                context.Response.ContentType("text/html;charset=utf-8");
                String archivePath = this.SubPath(path, ctx.SiteAppPath);
                archivePath = archivePath.Substring(0, archivePath.LastIndexOf(".", StringComparison.Ordinal));
                DefaultWebOutput.RenderArchive(ctx, archivePath);
            }

            return(SafetyTask.CompletedTask);

            /*
             * bool eventResult = false;
             * if (OnArchiveRequest != null)
             * {
             *  OnArchiveRequest(ctx, archivePath, ref eventResult);
             * }
             *
             * //如果返回false,则执行默认输出
             * if (!eventResult)
             * {
             *  DefaultWebOutput.RenderArchive(ctx, archivePath);
             * }
             */
        }