private static IEnumerable <HtmlTag> determineSocialIcons(ProjectRoot project, IAssetUrls urls)
        {
            if (project == null)
            {
                yield break;
            }

            if (project.TwitterHandle.IsNotEmpty())
            {
                yield return(new HtmlTag("a")
                             .AddClass("ico-twitter")
                             .Attr("href", "http://twitter.com/" + project.TwitterHandle)
                             .Append("img", img =>
                {
                    img.Attr("alt", "Twitter")
                    .Attr("src", urls.UrlForAsset(AssetFolder.images, "twitter-icon.png"));
                }));
            }

            if (project.GitHubPage.IsNotEmpty())
            {
                yield return(new HtmlTag("a")
                             .AddClass("ico-github")
                             .Attr("href", project.GitHubPage)
                             .Append("img", img =>
                {
                    img.Attr("alt", "Github")
                    .Attr("src", urls.UrlForAsset(AssetFolder.images, "github-icon.png"));
                }));
            }
        }
Example #2
0
        public IEnumerable <HtmlTag> Build(AssetTagPlan plan)
        {
            // This will happen when a user tries to request an asset set
            // with no assets -- think optional sets
            if (!plan.Subjects.Any())
            {
                return(new HtmlTag[0]);
            }

            IEnumerable <MissingAssetTagSubject>     missingSubjects = plan.RemoveMissingAssets();
            Func <IAssetTagSubject, string, HtmlTag> func            = _builders[plan.MimeType];
            Func <IAssetTagSubject, HtmlTag>         builder         = s => {
                string url = _urls.UrlForAsset(s.Folder, s.Name);
                return(func(s, url));
            };

            IEnumerable <HtmlTag> missingTags = _missingHandler.BuildTagsAndRecord(missingSubjects);
            IEnumerable <HtmlTag> assetTags   = plan.Subjects.Select(builder);

            return(missingTags.Union(assetTags));
        }
        // TODO -- this could really use some more end to end testing
        public MenuItemToken BuildToken(MenuNode node)
        {
            var token = new MenuItemToken {
                Children      = node.Children.Select(BuildToken).ToArray(),
                Key           = node.Key.Key,
                Text          = node.Key.ToString(),
                Category      = node.Category,
                MenuItemState = _stateService.DetermineStateFor(node)
            };

            if (node.Icon().IsNotEmpty())
            {
                token.IconUrl = _urls.UrlForAsset(AssetFolder.images, node.Icon());
            }

            if (node.Type == MenuNodeType.Leaf)
            {
                token.Url = _urlResolver.UrlFor(node.UrlInput, node.BehaviorChain);
            }

            node.ForData(token.Set);

            return(token);
        }