public static HtmlTag Menu(this IFubuPage page, string menuName = null) { var navigationService = page.Get<INavigationService>(); var securityContext = page.Get<ISecurityContext>(); var items = navigationService.MenuFor(new NavigationKey(menuName ?? StringConstants.BlogName)); var menu = new HtmlTag("ul"); items.Each(x => { var link = new LinkTag(x.Key, x.Url); var li = new HtmlTag("li"); if (x.Key.Equals("Logout") && x.MenuItemState == MenuItemState.Available) { var spanTag = new HtmlTag("span"); spanTag.Text(string.Format("Welcome, {0}", securityContext.CurrentIdentity.Name)); menu.Append(spanTag); } if (x.MenuItemState == MenuItemState.Active) li.AddClass("current"); if(x.MenuItemState == MenuItemState.Active || x.MenuItemState == MenuItemState.Available) menu.Append(li.Append(link)); }); return menu; }
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(); }
private void writeScripts(HtmlTag foot) { // Do this regardless foot.Append(_assets.For("FubuDiagnostics.js").ToEmbeddedScriptTag()); var routeData = _routeWriter.WriteJavascriptRoutes("FubuDiagnostics.routes", _routes); foot.Append(routeData); var extensionFiles = _assets.JavascriptFiles().Where(x => x.AssemblyName != "FubuMVC.Core"); if (_runtime.Mode.InDiagnostics()) { var names = _scripts.Union(extensionFiles.Select(x => x.Name.Split('.').Reverse().Take(2).Reverse().Join("."))); var links = _tags.BuildScriptTags(names.Select(x => "fubu-diagnostics/" + x)); links.Each(x => foot.Append(x)); } else { _scripts.Each(name => { var file = _assets.For(name); foot.Append(file.ToEmbeddedScriptTag()); }); extensionFiles.Each(file => foot.Append(file.ToEmbeddedScriptTag())); } }
public BootstrapLayout() { _containingDiv = new HtmlTag("div").AddClass("control-group"); _labelPlaceholder = new HtmlTag("div"); _inputContainer = new HtmlTag("div").AddClass("controls"); _containingDiv.Append(_labelPlaceholder); _containingDiv.Append(_inputContainer); }
public override string ToString() { _wrappingDiv = new HtmlTag("div").AddClass("clearfix"); _wrappingDiv.Append(_label); var d = new HtmlTag("div").AddClass("input"); _inputHolder.Children.Each(c => d.Append(c)); _wrappingDiv.Append(d); return string.Format("{0}\n", _wrappingDiv); }
public static HtmlTag HtmlTagLabelCheckbox(string label, string name, bool value) { var d = new HtmlTag("div"); d.Append(new HtmlTag("label").Attr("for", name).Text(label)); if (value) d.Append(new HtmlTag("input").Attr("type", "checkbox").Id(name).Attr("name", name).Attr("checked", "checked")); else d.Append(new HtmlTag("input").Attr("type", "checkbox").Id(name).Attr("name", name).Attr("value", value)); d.Append(new HtmlTag("input").Attr("type", "hidden").Id(name).Attr("name", name).Attr("value", "")); return d; }
public override HtmlTag Build(ElementRequest request) { HtmlTag root = new HtmlTag("div"); var selectListItems = request.RawValue as IEnumerable<string>; if (selectListItems == null) return root; selectListItems.Each(item=> { root.Append(new HtmlTag("span").Text(item)); root.Append(new HtmlTag("br")); }); return root; }
private HtmlTag buildControlGroup() { var group = new HtmlTag("div").AddClass("control-group"); if (LabelTag != null) { group.Append(LabelTag); } group.Append(_body); return group; }
public HtmlTag get_subscriptions() { var div = new HtmlTag("div"); div.Add("h3").Text("Subscription Persistence"); div.Append( new DescriptionBodyTag(Description.For(_persistence))); div.Add("h3").Text("Nodes"); div.Append(new TransportNodeTableTag(_persistence.AllNodes())); div.Add("h3").Text("Subscriptions"); div.Append(new SubscriptionStorageTableTag(_persistence.AllSubscriptions())); return div; }
public ConfigureFubuMVC() { IncludeDiagnostics(true); this.ApplyConvention<ModelValidationConfiguration>(); this.ApplyHandlerConventions<HandlersMarker>(); HtmlConvention(x => x.Editors.Always.Modify((request, tag) => { var fubuRequest = request.Get<IFubuRequest>(); var validationResult = fubuRequest.Get<ValidationResult>(); if (validationResult.IsValid) return; var ul = new HtmlTag("ul"); var liTags = validationResult.Errors.Where(error => error.PropertyName == request.Accessor.InnerProperty.Name).Select(vf => new HtmlTag("li", li => li.Text(vf.ErrorMessage))); ul.Append(liTags); tag.Append(ul); })); this.UseSpark(); Routes .IgnoreNamespaceText("fubu101") .HomeIs<GetHandler>(action => action.Execute(new MovieRequestModel())); Policies.EnrichCallsWith<MovieViewModelJsonBehavior>(request => request.Returns<MovieViewModel>()); Views.TryToAttachWithDefaultConventions(); }
public override HtmlTag Build(ElementRequest request) { HtmlTag root = new HtmlTag("div").Attr("data-bind", "foreach: "+ CCHtmlConventions2.DeriveElementName(request)); var child = new HtmlTag("div").Attr("data-bind", "text: $data" ); root.Append(child); return root; }
public static HtmlString AdminForm(DocumentNode Model, string adminUrl, string divClassName = "") { var div = new HtmlTag("div"); if (divClassName != "") div.AddClass(divClassName); var form = new FormTag().Method("post").Action("#"); form.Append(HtmlBuilder.HtmlTagLabelInput("Name (header)", "name", Model.Name)); form.Append(new HtmlTag("input").Attr("type", "submit").Attr("name", "update").Attr("value", "Update")); form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Hide header", "hideHeader", Model.HideHeader)); form.Append(HtmlBuilder.HtmlTagLabelTextArea("Body text", "body", Model.Body)); form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 1", "extraContent1", Model.ExtraContent1, 5)); //form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 2", "extraContent2", Model.ExtraContent2, 5)); //form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 3", "extraContent3", Model.ExtraContent3, 3)); form.Append(HtmlBuilder.HtmlTagLabelInput("Author", "author", Model.Author)); form.Append(HtmlBuilder.HtmlTagLabelInput("ViewPath", "viewPath", Model.ViewPath)); form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Hidden", "isHidden", Model.IsHidden)); form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Deleted", "isDeleted", Model.IsDeleted)); form.Append(new HtmlTag("input").Attr("type", "submit").Attr("name", "update").Attr("value", "Update")); if (!String.IsNullOrEmpty(Model.Url)) { form.Append(new HtmlTag("p").Append(new HtmlTag("a").Attr("href", Model.Url).Text("View page"))); } div.Append(form); return new HtmlString(div.ToHtmlString()); }
public HtmlTag(string tag, HtmlTag parent) : this(tag) { if (parent != null) { parent.Append(this); } }
public HtmlTag get_tasks() { var peers = _repository.FindPeers(); var cache = new Cache<Uri, TransportNode>(); peers.Each(peer => peer.OwnedTasks.Each(x => cache[x] = peer)); var tag = new HtmlTag("div"); tag.Add("h1").Text("Task Assignements"); var table = new TableTag(); tag.Append(table); table.AddClass("table"); table.AddHeaderRow(row => { row.Header("Task"); row.Header("Assigned to"); row.Header("Control Channel"); }); var tasks = _tasks.PermanentTasks().Union(_tasks.ActiveTasks()).ToArray(); tasks.Each(uri => { table.AddBodyRow(row => addRow(row, uri, cache)); }); return tag; }
public HtmlTag ToHtmlTag() { var root = new HtmlTag("form"); if (!string.IsNullOrEmpty(_id)) { root.Attr("id", _id); } var innerDiv = new HtmlTag("div"); innerDiv.Append(new StyledButtonExpression("all", true).NonLocalizedText("All").ToHtmlTag()); for (int i = 65; i < 91; i++) { string letter = ((char)i).ToString(); innerDiv.Append(new StyledButtonExpression(letter, true).NonLocalizedText(letter).ToHtmlTag()); } root.Append(innerDiv); return root; }
public override HtmlTag Build(ElementRequest request) { HtmlTag root = new HtmlTag("a"); root.Attr("href", "mailto:" + request.StringValue()); root.Attr("name", request.Accessor.FieldName + "Link"); root.Append(new HtmlTag("span").Text(request.StringValue())); return root; }
private static HtmlTag MakeRadioButton(string display, object value, string name) { DivTag divTag = new DivTag(display); HtmlTag radioButton = new RadioButtonTag(false).Attr("value", value).Attr("name",name); HtmlTag label = new HtmlTag("label").Text(display); label.Append(radioButton); divTag.Append(label); return divTag; }
private static HtmlTag CreateFailureTag(IEnumerable<Visit> visits) { var failureTag = new HtmlTag("h2").Text("Failures"); var failures = visits .SelectMany(visit => visit.Responses) .Where( response => !response.Success || response.Assertions.Any(assertion => assertion.Error || assertion.Failure)) .ToList(); if (failures.Any()) failureTag.Append("ol") .Append(failures.Select(failure => new HtmlTag("li").Text(failure.ToString()))); else failureTag.Append(new HtmlTag("p").Text("no failures")); return failureTag; }
public static void AddPageHeader(this HtmlTag tag, string text, string small) { var div = new HtmlTag("div").AddClass("page-header"); var h1 = new HtmlTag("h1").Text(text); h1.Append(new HtmlTag("small").Text(small)); div.Append(h1); tag.Append(div); }
public HtmlTag RequestDataPartial(ValueReport report) { var tag = new HtmlTag("div").Id("request-data"); var dataTags = report.Reports.Where(x => x.Values.Any()).Select(toTag); tag.Append(dataTags); return tag; }
public override HtmlTag Build(ElementRequest request) { HtmlTag root = new HtmlTag("a"); root.Attr("href", request.RawValue); root.Attr("target", "_blank"); root.Id(request.Accessor.FieldName); var img = new HtmlTag("img"); img.Attr("src", request.RawValue); root.Append(img); return root; }
public static HtmlString AdminTree(IDocumentNode Model, string adminUrl, string divClassName = "") { var div = new HtmlTag("div"); if (divClassName != "") div.AddClass(divClassName); var p = new HtmlTag("p").Append(new HtmlTag("a").Text("Root node").Attr("href", adminUrl)); var tree = HtmlBuilder.ChildNodesRecursiveHtmlTag(Model, Model.AncestorAtLevel(0), 99, true, false, adminUrl); var pInfo = new HtmlTag("p").Text("Add new child"); var form = new HtmlTag("form").Attr("method", "post").Attr("action", "#"); form.Append(new HtmlTag("label").Attr("for", "new-name").Text("Header (name)")); form.Append(new HtmlTag("input").Id("new-name").Attr("name", "new-name").Attr("type", "text")); form.Append(new HtmlTag("input").Attr("type", "submit").Attr("name", "insert-new").Attr("value", "Add")); div.Append(p).Append(tree).Append(pInfo).Append(form); return new HtmlString(div.ToHtmlString()); }
public HtmlTag get_scheduled_jobs() { var tag = new HtmlTag("div"); tag.Add("h1").Text("Scheduled Jobs Monitor"); tag.Add("p").Text("at {0} -- reload the page to refresh the data".ToFormat(DateTime.Now)); var schedule = _persistence.FindAll(_graph.Name); tag.Append(new ScheduledJobTable(_urls, schedule)); return tag; }
public HtmlTag get_description_Name(DescriptionRequest request) { var description = DescriptionBag.DescriptionFor(request.Name); var tag = new HtmlTag("div"); tag.Add("h4").Text(description.Title); tag.Append(new DescriptionBodyTag(description)); return tag; }
public HtmlTag WrapWith(string tag) { var wrapper = new HtmlTag(tag); wrapper.Append(this); // Copies visibility and authorization from inner tag wrapper.Render(Render()); wrapper.Authorized(Authorized()); return(wrapper); }
public HtmlTag get_job_details_Job(ScheduledJobRequest request) { var schedule = _persistence.Find(_graph.Name, request.Job); var tag = new HtmlTag("div"); tag.Add("h2").Text("Recent Execution History for " + request.Job); var job = _jobs.Jobs.FirstOrDefault(x => JobStatus.GetKey(x.JobType) == request.Job); if (job != null) { var descriptionTag = new DescriptionBodyTag(Description.For(job)); tag.Append(descriptionTag); tag.Append("hr"); tag.Append("h4").Text("History"); } var history = _persistence.FindHistory(_graph.Name, request.Job); tag.Append(new ScheduledJobHistoryTable(history)); return tag; }
public static HtmlTag SvgImage(this IFubuPage page, string svgImage, string fallbackImage = null) { var staticFileUrl = page.Urls.UrlForAsset(AssetFolder.images, svgImage).Replace("_content", "content"); var objectTag = new HtmlTag("object") .Attr("data", staticFileUrl) .Attr("type", "image/svg+xml"); if (!string.IsNullOrEmpty(fallbackImage)) { objectTag.Append(page.Image(fallbackImage)); } return objectTag; }
public static void AddPageHeader(this HtmlDocument doc, string text, string small = "") { var div = new HtmlTag("div").AddClass("page-header"); var h1 = new HtmlTag("h1").Text(text); if (small.IsNotEmpty()) { h1.Append(new HtmlTag("small").Text(small)); } div.Append(h1); doc.Add(div); }
public DebugReportTagWriter() { _lastTag = _div; _behaviorTags.OnMissing = b => { HtmlTag tag = BuildBehaviorTag(b); _lastTag.Append(tag); _lastTag = tag; return tag; }; }
public override HtmlTag Build(ElementRequest request) { HtmlTag control = new HtmlTag("p").AddClass("phone-number"); control.Append(new HtmlTag("label").Append("span").Text("Phone number")); control.Append(new HtmlTag("span").Text(" ( ")); control.Append(new HtmlTag("input").Attr("type", "text").Attr("maxlength", "3").Attr("name", "PhoneNumber[AreaCode]")); control.Append(new HtmlTag("span").Text(" ) ")); control.Append(new HtmlTag("input").Attr("type", "text").Attr("maxlength", "3").Attr("name", "PhoneNumber[Prefix]")); control.Append(new HtmlTag("span").Text(" - ")); control.Append(new HtmlTag("input").Attr("type", "text").Attr("maxlength", "4").Attr("name", "PhoneNumber[Suffix]")); return control; }
public string Execute(GetFlashes input) { /* <div class="alert"> <a class="close" data-dismiss="alert">×</a> <strong>Warning!</strong> Best check yo self, you're not looking too good. </div> */ var array = _flash.Retrieve<string[]>(); if (array == null) return new NoTag().ToHtmlString(); var div = new HtmlTag("div").AddClass("alert"); var closeLink = new HtmlTag("a").AddClass("close").Data("dismiss", "alert"); div.Append(closeLink); var ul = new HtmlTag("ul"); array.Each(i => ul.Append("li", l => l.Text(i))); div.Append(ul); return div.ToHtmlString(); }
public static HtmlTag GetRatingStars(int rating) { var t = new HtmlTag("span"); for (int i = 0; i < rating; i++) { var img = new HtmlTag("img"); img.Attr("src", "/Public/images/rating.png"); img.AddClass("ratingImage"); t.Append(img); } return t; }
/// <summary> /// Adds a LiteralTag to the Children collection /// </summary> /// <param name="tag"></param> /// <param name="html"></param> /// <returns></returns> public static HtmlTag AppendHtml(this HtmlTag tag, string html) { return(tag.Append(new LiteralTag(html))); }