Beispiel #1
0
        /// <summary>
        /// 渲染.
        /// </summary>
        /// <returns>A string.</returns>
        public virtual string Render()
        {
            using (CoreContext context = new CoreContext())
            {
                string html = context.Configuration.FirstOrDefault(o => o.Key == this.FileName)?.Value.Replace("{{head}}", this.HtmlHead());
                html = html.Replace("{{sidebarMenu}}", SidebarNavigation.SidebarMenu());
                html = html.Replace("{{content-header}}", this.ContentHeader());
                html = html.Replace("{{Footer}}", this.Footer());
                html = html.Replace("{{tobHeader}}", SiteConfiguration.TopHeader);

                var filter = this.SearchFilterConfiguration();
                if (filter != null)
                {
                    html = html.Replace("{{grid-search-filter}}", HtmlContent.ToString(filter.GenerateSearchFilter()));
                    html = html.Replace("{{button-group}}", HtmlContent.ToString(filter.GenerateButton()));
                    html = html.Replace("{{Pager}}", this.Pager());
                }

                var grid = this.GridConfiguration();
                if (grid != null)
                {
                    string table = grid.GenerateGridColumn();
                    html = html.Replace("{{Table}}", table);
                }

                return(html + $"<script>{this.RenderJavaScript()}</script>");
            }
        }
        public async Task <HtmlContent> SavePictures(HtmlContent htmlContent)
        {
            var regex = new Regex("data:image/(?<extension>\\w*);base64.(?<data>\\S*)\"/>",
                                  RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
            var matches = regex.Matches(htmlContent.ToString());
            var html    = htmlContent.ToString();

            foreach (var item in matches)
            {
                var match      = regex.Match(item.ToString());
                var extension  = $".{match.Groups["extension"].Value}";
                var base64Data = match.Groups["data"].Value;
                var rawData    = Convert.FromBase64String(base64Data);

                var ms  = new MemoryStream(rawData);
                var uri = await _fileService.SaveFile(ms, extension);

                html = html.Replace(match.Value, $"{uri}\"/>");
            }

            return(new HtmlContent(html));
        }
Beispiel #3
0
        public string Render()
        {
            TagHelperAttributeList labelAttributes = new TagHelperAttributeList
            {
                { "class", "icon-edit dropdown-item" },
                { "data-url", this._url },
                { "data-method", this._method },
                { "href", "#" },
            };

            var anchor = HtmlContent.TagHelper("class", labelAttributes, $"&nbsp;{this._labelText}");

            return(HtmlContent.ToString(anchor));
        }
Beispiel #4
0
        private string Footer()
        {
            var div = HtmlContent.TagHelper("div", new TagHelperAttributeList {
                { "class", "row-fluid" },
            });
            var div2 = HtmlContent.TagHelper("div", new TagHelperAttributeList {
                { "class", "span12" }, { "id", "footer" },
            });

            div2.Content.Append(" 2019 ©https://github.com/188867052");
            var a = HtmlContent.TagHelper("a", new TagHelperAttributeList {
                { "href", "http://www.taobao.com/" }, { "target", "_blank" },
            });

            a.Content.SetContent(" My Blog");
            div2.Content.AppendHtml(a);
            div.Content.SetHtmlContent(div2);
            return(HtmlContent.ToString(div));
        }