public static IHtmlContent WidgetLink(this IHtmlHelper html, NavigationWidget widget, string product) { var href = html.ExampleUrl(widget.Items[0]); var text = widget.Text; StringBuilder link = new StringBuilder(); link.AppendFormat("<a href=\"{0}\">", href); link.Append(text); if (widget.Beta) { link.Append("<span class=\"beta-widget\"></span>"); } if (widget.New) { link.Append("<span class=\"new-widget\"></span>"); } if (widget.Updated) { link.Append("<span class=\"updated-widget\"></span>"); } link.Append("</a>"); return(html.Raw(link.ToString())); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); FindCurrentExample(); NavigationExample currentExample = ViewBag.CurrentExample; NavigationWidget currentWidget = ViewBag.CurrentWidget; if (currentWidget == null) { return; } ViewBag.Description = Description(ViewBag.Product, currentExample, currentWidget); var exampleFiles = new List <ExampleFile>(); exampleFiles.AddRange(SourceCode()); exampleFiles.AddRange(AdditionalSources(currentWidget.Sources)); exampleFiles.AddRange(AdditionalSources(currentExample.Sources)); ViewBag.ExampleFiles = exampleFiles.Where(file => file.Exists(ContentRootPath)); if (currentWidget.Documentation != null && currentWidget.Documentation.ContainsKey(ViewBag.Product)) { ViewBag.Documentation = "http://docs.telerik.com/aspnet-core/" + currentWidget.Documentation[ViewBag.Product]; } if (currentWidget.Forum != null && currentWidget.Forum.ContainsKey(ViewBag.Product)) { ViewBag.Forum = "http://www.telerik.com/forums/" + currentWidget.Forum[ViewBag.Product]; } }
protected void FindCurrentExample() { var found = false; NavigationExample current = null; NavigationWidget currentWidget = null; foreach (NavigationWidget widget in ViewBag.Navigation) { foreach (NavigationExample example in widget.Items) { if (example.ShouldInclude()) { examplesUrl.Add("~/" + example.Url); } if (!found && IsCurrentExample(example.Url)) { current = example; currentWidget = widget; found = true; } } } ViewBag.CurrentWidget = currentWidget; if (currentWidget == null) { return; } ViewBag.CurrentExample = current; if (current.Title != null) { if (current.Title.ContainsKey(MvcFlavor.AspNetCore)) { ViewBag.Title = current.Title[MvcFlavor.AspNetCore]; } } else { ViewBag.Title = current.Text; } if (current.Meta != null) { if (current.Meta.ContainsKey(MvcFlavor.AspNetCore)) { ViewBag.Meta = current.Meta[MvcFlavor.AspNetCore]; } } }
protected string Description(string product, NavigationExample example, NavigationWidget widget) { if (example.Description != null && example.Description.ContainsKey(product)) { return(example.Description[product]); } else if (widget.Description != null && widget.Description.ContainsKey(product)) { return(widget.Description[product]); } return(null); }
public NavigationWidgetViewModel(IEnumerable <NavigationEntity> navigation, NavigationWidget widget) { _navs = navigation; Widget = widget; }
public NavigationWidgetViewModel(IEnumerable<NavigationEntity> navigation, NavigationWidget widget) { Navigations = navigation; Widget = widget; }