Exemplo n.º 1
0
        public string ParseHtml(string tenant, string html)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var nodes = doc.DocumentNode.SelectNodes("//include[@article-alias and @category-alias]");

            if (nodes == null)
            {
                return(html);
            }

            foreach (var node in nodes)
            {
                string alias         = node.Attributes["article-alias"].Value;
                string categoryAlias = node.Attributes["category-alias"].Value;

                var model = ContentModel.GetContent(tenant, categoryAlias, alias);
                if (model != null)
                {
                    string contents = model.Contents;

                    var newNode = HtmlNode.CreateNode(contents);
                    node.ParentNode.ReplaceChild(newNode, node);
                }
            }

            return(doc.DocumentNode.OuterHtml);
        }
Exemplo n.º 2
0
        public ActionResult Post(string categoryAlias, string alias)
        {
            var model = ContentModel.GetContent(this.Tenant, categoryAlias, alias, true);

            if (model == null)
            {
                return(this.View(GetLayoutPath() + "404.cshtml"));
            }

            string path   = GetLayoutPath();
            string theme  = this.GetTheme();
            string layout = ThemeConfiguration.GetBlogLayout(theme);

            model.LayoutPath = path;
            model.Layout     = layout;
            model.Contents   = ContentExtensions.ParseHtml(this.Tenant, model.Contents);

            return(this.View(this.GetRazorView <AreaRegistration>("Blog/Post.cshtml"), model));
        }
Exemplo n.º 3
0
        private Content GetContents(string categoryAlias, string alias, bool isPost = false, FormCollection form = null)
        {
            string tenant = DbConvention.GetTenant(this.CurrentDomain);
            var    model  = ContentModel.GetContent(tenant, categoryAlias, alias);

            if (model == null)
            {
                return(null);
            }

            bool isHomepage = string.IsNullOrWhiteSpace(categoryAlias) && string.IsNullOrWhiteSpace(alias);

            string path   = GetLayoutPath();
            string layout = isHomepage ? this.GetHomepageLayout() : this.GetLayout();


            model.LayoutPath = path;
            model.Layout     = layout;
            return(model);
        }