public List <Tuple <CdnFile, string, string, string, string> > GetBadges() { var badges = new List <Tuple <CdnFile, string, string, string, string> >(); badges.AddRange( HoursBadge.AllHoursBadge.Select(x => { var isActive = LearningHours >= x.Item1; return(Tuple.Create( Cdns.ImageBadgeHours(x.Item1 + (isActive ? "" : "-gray") + ".png"), x.Item2, isActive ? Cdns.ImageBadgeHours(x.Item1 + "-b.png").Url : null, "HourBadge", (string)null)); })); if (TopBadge.HasValue) { badges.Add(Tuple.Create(Cdns.ImageBadgeTop(TopBadge + ".jpg"), "Топ {0}% слушателей".FormatWith(TopBadge), Cdns.ImageBadgeTop(TopBadge + "-b.png").Url, "TopBadge", (string)null)); } badges.Add(Tuple.Create(Cdns.ImageBadgeUnlimit("unlimit{0}.png" .FormatWith(HasUnlimit ? "" : "-gray")), "Безлимитное обучение", (string)null, "TopBadge", SimplePages.FullUrls.Unlimited)); if (Best2016Url != null) { badges.Add(Tuple.Create(Cdns.ImageBadgeBest("2016.jpg"), CommonTexts.Best2016, (string)null, "Best2016Badge", Best2016Url)); } return(badges); }
public static CdnFile GetFile(int lectureFileId) { return(Cdns.FileLectureFile(lectureFileId + "." + ext)); }
public HtmlResourcesAggregator AddJsLibrary(Libraries library, string version, ScriptFormats f, Cdns cdn) { if( (library == Libraries.UnobtrusiveMvc) && (cdn != Cdns.Microsoft) ) { throw new ArgumentException("Reuired CDN (" + cdn + ") does not host Microsoft Unobtrusive Ajax!"); } //version = version.StartsWith("-") ? version : string.Concat("-", version); if(version.EndsWith(".")) { version = version.Substring(0, version.Length - 1); } string jsFilename = _librariesNames[(int)library]; string baseUrl = "";// = cdn == Cdns.Google ? "//ajax.googleapis.com/ajax/libs/" : "//ajax.aspnetcdn.com/ajax/"; string urlFmt = ""; switch(cdn) { case Cdns.Google: // //ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js switch(library) { case Libraries.jQuery: urlFmt = "//ajax.googleapis.com/ajax/libs/%LIBRARY_SHORT_NAME%/%LIBRARY_VERSION%/%LIBRARY_SHORT_NAME%%FILE_FORMAT%.js"; break; default: throw new NotImplementedException("Google CDN is not supported yet!!!"); } break; case Cdns.Microsoft: // //ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js switch (library) { case Libraries.jQuery: //baseUrl = "//ajax.aspnetcdn.com/ajax/jquery/"; urlFmt = "//ajax.aspnetcdn.com/ajax/%LIBRARY_SHORT_NAME%/%LIBRARY_SHORT_NAME%-%LIBRARY_VERSION%.js"; break; case Libraries.jQueryUI: baseUrl = "//ajax.aspnetcdn.com/ajax/jquery.ui/"; break; case Libraries.UnobtrusiveMvc: baseUrl = "//ajax.aspnetcdn.com/ajax/mvc/3.0/"; break; } break; } if(string.IsNullOrEmpty(urlFmt)) { jsFilename = f == ScriptFormats.Min ? string.Concat(jsFilename, version, ".min.js") : string.Concat(jsFilename, version, ".js"); } else { jsFilename = urlFmt .Replace("%LIBRARY_SHORT_NAME%", "jquery") .Replace("%LIBRARY_VERSION%", version) .Replace("%FILE_FORMAT%", f == ScriptFormats.Min ? ".min" : ""); } this.JsFiles.Add(string.Format("{0}{1}", baseUrl, jsFilename)); return this; }
public HtmlResourcesAggregator AddJsLibrary(Libraries library, string version, ScriptFormats f, Cdns cdn) { if ((library == Libraries.UnobtrusiveMvc) && (cdn != Cdns.Microsoft)) { throw new ArgumentException("Reuired CDN (" + cdn + ") does not host Microsoft Unobtrusive Ajax!"); } //version = version.StartsWith("-") ? version : string.Concat("-", version); if (version.EndsWith(".")) { version = version.Substring(0, version.Length - 1); } string jsFilename = _librariesNames[(int)library]; string baseUrl = "";// = cdn == Cdns.Google ? "//ajax.googleapis.com/ajax/libs/" : "//ajax.aspnetcdn.com/ajax/"; string urlFmt = ""; switch (cdn) { case Cdns.Google: // //ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js switch (library) { case Libraries.jQuery: urlFmt = "//ajax.googleapis.com/ajax/libs/%LIBRARY_SHORT_NAME%/%LIBRARY_VERSION%/%LIBRARY_SHORT_NAME%%FILE_FORMAT%.js"; break; default: throw new NotImplementedException("Google CDN is not supported yet!!!"); } break; case Cdns.Microsoft: // //ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js switch (library) { case Libraries.jQuery: //baseUrl = "//ajax.aspnetcdn.com/ajax/jquery/"; urlFmt = "//ajax.aspnetcdn.com/ajax/%LIBRARY_SHORT_NAME%/%LIBRARY_SHORT_NAME%-%LIBRARY_VERSION%.js"; break; case Libraries.jQueryUI: baseUrl = "//ajax.aspnetcdn.com/ajax/jquery.ui/"; break; case Libraries.UnobtrusiveMvc: baseUrl = "//ajax.aspnetcdn.com/ajax/mvc/3.0/"; break; } break; } if (string.IsNullOrEmpty(urlFmt)) { jsFilename = f == ScriptFormats.Min ? string.Concat(jsFilename, version, ".min.js") : string.Concat(jsFilename, version, ".js"); } else { jsFilename = urlFmt .Replace("%LIBRARY_SHORT_NAME%", "jquery") .Replace("%LIBRARY_VERSION%", version) .Replace("%FILE_FORMAT%", f == ScriptFormats.Min ? ".min" : ""); } this.JsFiles.Add(string.Format("{0}{1}", baseUrl, jsFilename)); return(this); }
private static void RegisterScript(this BundleCollection bundles, string virtualPath, Cdns cdn, params string[] path) { var bundle = cdn == null ? new ScriptBundle(virtualPath).Include(path) : new ScriptBundle(virtualPath, cdn.Path).Include(path); bundles.Add(bundle); }