コード例 #1
1
ファイル: HtmlUtils.cs プロジェクト: vvvsrx/AUserCenter
 public static string GetCharisma_Alert(Charisma_AlertType type, string title, string msg)
 {
     var tag = new HtmlTag("div").AddClass("alert").AddClass(type.ToText());
     tag.Add("button").AddClass("close").Attr("type", "button").Attr("data-dismiss", "alert").Text("×");
     tag.Add("h4").AddClass("alert-heading").Text(title);
     tag.Add("p").Text(msg);
     return tag.ToString();
 }
コード例 #2
0
        public void mustache_text()
        {
            var tag = new HtmlTag("span");
            tag.MustacheText("prop");

            tag.ToString().ShouldEqual("<span>{{prop}}</span>");
        }
コード例 #3
0
        public static string AwesomeDisplay(this IFubuPage page, object model)
        {
            var type = model.GetType();
            var result = new StringBuilder();
            var tags = page.Tags(model);
            var sl = page.Get<IServiceLocator>();

            tags.SetProfile(AwesomeConfiguration.TagProfile);
            var tr = new HtmlTag("tr");
            foreach (var prop in getProperties(type))
            {

                var p = new SingleProperty(prop, type);
                var elementRequest = new ElementRequest(model, p, sl);
                var accessRight = page.Get<IFieldAccessService>().RightsFor(elementRequest);

                HtmlTag display = tags.DisplayFor(elementRequest).Authorized(accessRight.Read);
                var td = new HtmlTag("td").Append(display);
                tr.Append(td);

            }
            var editLink = new LinkTag("Edit", page.EditUrlFor(model));
            tr.Append(new HtmlTag("td").Append(editLink));
            var deleteLink = new LinkTag("Delete", page.DeleteUrlFor(model));
            tr.Append(new HtmlTag("td").Append(deleteLink));
            result.Append(tr.ToString());

            return result.ToString();
        }
コード例 #4
0
        public void mustache_attr()
        {
            var tag = new HtmlTag("a");
            tag.MustacheAttr("href", "url");

            tag.ToString().ShouldEqual("<a href=\"{{url}}\"></a>");
        }
コード例 #5
0
 private void SendConfirmationEmail(User user)
 {
     var email = new HtmlTag("body")
         .Child(new HtmlTag("h3").Text("Thank you for registering"))
         .Child(new HtmlTag("div").Id("wrapper")
                    .Child(new LinkTag("Click here to activate your account",
                                       UrlContext.ToFull(_urlRegistry.UrlFor(new ActivateAccountModel() {Id = user.Id})))));
     _emailService.SendEmail(user.Email, _emailSettings.DefaultFromEmailAddress, "Activate your account", email.ToString());
 }
コード例 #6
0
            public void Should_build_tag_modifier()
            {
                var registry = new TestConventionRegistry();

                registry.TagModifiers.Count().ShouldEqual(3);

                var htmlTag = new HtmlTag("a");
                registry.TagModifiers.ToList()[2].Modify(new UIComponentContext(_boolExpr.ToAccessor(), new TestModel(), null), htmlTag);
                htmlTag.ToString().ShouldEqual(new HtmlTag("a").AddClass("test").ToString());
            }
コード例 #7
0
ファイル: HtmlUtils.cs プロジェクト: vvvsrx/AUserCenter
 public static string GetCharisma_Alert(Charisma_AlertType type, string title, IList<ValidationFailure> content)
 {
     var tag = new HtmlTag("div").AddClass("alert").AddClass(type.ToText());
     tag.Add("button").AddClass("close").Attr("type", "button").Attr("data-dismiss", "alert").Text("×");
     tag.Add("h4").AddClass("alert-heading").Text(title);
     foreach (var item in content)
     {
         tag.Add("p").Text(item.ErrorMessage);
     }
     return tag.ToString();
 }
コード例 #8
0
        public string Transform(Topic current, string data)
        {
            var parts = data.Split(';');
            var url = _urls.ToUrl(current, parts.First());



            var image = new HtmlTag("img").Attr("src", url).Style("max-width", "100%");

            if (parts.Length == 0)
            {
                return image.ToString();
            }

            var header = new HtmlTag("h5", x =>
            {
                x.Add("strong").Text(parts.Last());
            });

            return header.ToString() + image.ToString();

        }
コード例 #9
0
        public string Transform(Topic current, string data)
        {
            var ol = new HtmlTag("ol").AddClass("breadcrumb");

            current.Ancestors().Each(x =>
            {
                ol.Add("li/a").Attr("href", _resolver.ToUrl(current, x)).Text(x.Title);
            });

            ol.Add("li").AddClass("active").Text(current.Title);

            return ol.ToString();
        }
コード例 #10
0
        public void wrap_body()
        {
            var layout = new DefinitionListLabelAndField();
            var display = new TextboxTag().Attr("value", "something");
            layout.BodyTag = display;

            var wrapper = new HtmlTag("strong");
            layout.WrapBody(wrapper);

            layout.BodyTag.ShouldBeTheSameAs(display);
            wrapper.Children.ShouldHaveTheSameElementsAs(display);

            layout.ToString().ShouldContain(wrapper.ToString());
        }
コード例 #11
0
        public void write_to_string()
        {
            var layout = new DefinitionListLabelAndField();
            var label = new HtmlTag("span").Text("some text");
            layout.LabelTag = label;

            var display = new TextboxTag().Attr("value", "something");
            layout.BodyTag = display;

            var html = layout.ToString();

            html.ShouldContain(label.ToString());
            html.ShouldContain(display.ToString());
        }
コード例 #12
0
        public string GenerateHtml(Topic topic)
        {
            var html = _generator.Generate(topic);

            var builder = new StringBuilder(html);
            topic.Substitutions.Each((key, value) => { builder.Replace(key, value); });

            var script = _webSocketScript.Replace("%WEB_SOCKET_ADDRESS%", _settings.WebsocketAddress);
            builder.Replace("</head>", script + "\n</head>");

            var tag = new HtmlTag("script").Attr("language", "javascript").Attr("src", "/topics.js");
            builder.Replace("</head>", tag.ToString() + "\n</head>");

            return builder.ToString();
        }
コード例 #13
0
        // SAMPLE: UsingCollapsibleTag
        public CollapsiblePartialViewModel get_collapsible_partial()
        {
            var inner = new HtmlTag("div");
            for (var i = 0; i < 5; i++ )
            {
                inner.Add("p").Text(Guid.NewGuid().ToString());
            }


            var tag = new CollapsibleTag("acc1", "This is the collapsible tag");
            tag.AppendContent(inner.ToString());

            return new CollapsiblePartialViewModel{
                Tag = tag
            };
        }
コード例 #14
0
        public string Transform(Topic current, string data)
        {
            var props = data.Split(';');
            var key = props.First();

            

            try
            {
                var other = findOther(current, key);
                if (other == null) return string.Empty;

                return transformFromTopic(current, other, props);
            }
            catch (ArgumentOutOfRangeException)
            {
                var tag = new HtmlTag("p").AddClass("bg-warning").Style("padding", "5px");
                tag.Add("b").Text("Unknown topic key '{0}'".ToFormat(key));
                tag.Add("small").Text(" -- CTRL+SHIFT+R to force refresh the topic tree");
                return tag.ToString();
            }
        }
コード例 #15
0
ファイル: HtmlUtils.cs プロジェクト: vvvsrx/AUserCenter
        public static Nancy.ViewEngines.Razor.IHtmlString UserStatusesToSpan(UserAccountStatuses status)
        {
            var tag = new HtmlTag("span").AddClass("label");

            switch (status)
            {
                case UserAccountStatuses.ApprovalPending:
                    tag.Text(UserAccountStatuses.ApprovalPending.ToText());
                    break;
                case UserAccountStatuses.Approved:
                    tag.AddClass("label-success").Text(UserAccountStatuses.Approved.ToText());
                    break;
                case UserAccountStatuses.Banned:
                    tag.AddClass("label-important").Text(UserAccountStatuses.Banned.ToText());
                    break;
                case UserAccountStatuses.Disapproved:
                    tag.AddClass("label-warning").Text(UserAccountStatuses.Disapproved.ToText());
                    break;
                case UserAccountStatuses.NotActive:
                    tag.AddClass("label-inverse").Text(UserAccountStatuses.NotActive.ToText());
                    break;
                default:
                    tag.AddClass("label-info").Text("未知");
                    break;
            }
            return new NonEncodedHtmlString(tag.ToString());
        }
コード例 #16
0
        private static void VisitTableCell(HtmlTag cell, ExportRow exportRow)
        {
            var tag = cell.TagName().ToLower();
            if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th )
            {
                cell.Children.ForEach(c => VisitTableCell(c, exportRow));
                return;
            }
            var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img);
            var text = cell.Children.Any() ? cell.ToString() : cell.Text();
            var exportCell = new ExportCell
                             	{
                                    Text =  ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty),
                                    Markup = isImage ? cell.FirstChild().ToString():string.Empty
                                };

            SetColspan(cell, exportCell);
            exportRow.AddCell(exportCell);
        }
コード例 #17
0
 private static HtmlTag createExample(HtmlTag htmlTag, string methodCall)
 {
     var example = new HtmlTag("fieldset").AddClass("tag");
     example.Add("legend").Text(methodCall);
     example.AddChildren(new HtmlTag("code").AddClass("source").Text(htmlTag.ToString()));
     example.AddChildren(new HtmlTag("div").AddClass("rendered").AddChildren(htmlTag));
     return example;
 }
コード例 #18
0
 private static Example createExample(HtmlTag htmlTag, string expression)
 {
     return new Example
     {
         Expression = expression,
         Source = htmlTag.ToString().HtmlEncode(),
         Rendered = htmlTag
     };
 }
コード例 #19
0
        public HtmlTag TopTag(HtmlTag topChild)
        {
            if (topChild.TagName() != "ul")
            {
                throw new ArgumentOutOfRangeException("Only ul tags are valid here:  \n" + topChild.ToString());
            }

            var topUrl = _urls.UrlFor<JasminePages>(x => x.AllSpecs());
            return new HtmlTag("ul", tag =>
            {
                tag.Id("all-specs-node").AddClass("filetree");

                var link = new LinkTag("All Specs", topUrl, "all-specs");
                var li = tag.Add("li");
                li.Add("span").AddClass("folder").Append(link);

                li.Append(topChild);
            });
        }
コード例 #20
0
 public DisposableHtmlTagWriter(TextWriter writer, HtmlTag htmlTag) : base(writer)
 {
     originalWriter = writer;
     htmlTag.ToString(this);
     originalWriter.Write(forBeginTag.ToString());
 }
コード例 #21
0
ファイル: PasswordService.cs プロジェクト: rauhryan/kokugen
        private void emailUserNewPassword(string newPassword, User user)
        {
            var email = new HtmlTag("div")
                .Child(new HtmlTag("h3", tag => tag.Text("Your password has been reset")))
                .Child(new HtmlTag("span", tag => tag.Text("Your new password is: ")))
                .Child(new HtmlTag("span", tag => tag.Text(newPassword)));

            _emailService.SendEmail(user.Email, _emailSettings.DefaultFromEmailAddress,"Your Password Has Been Reset", email.ToString());
        }
コード例 #22
0
            public ChildTagBuilder(SpecHierarchyBuilder builder, HtmlTag parent)
            {
                if (parent.TagName() != "ul")
                {
                    throw new ArgumentOutOfRangeException("Only ul tags are valid here:  \n" + parent.ToString());
                }

                _builder = builder;
                _parent = parent;
            }