public static HttpResponse ContentShouldBe(this HttpResponse response, MimeType mimeType, string content) { response.ContentType.ShouldEqual(mimeType.Value); response.ReadAsText().ShouldEqual(content); return response; }
public static AssetTagPlan For(MimeType mimeType, params IAssetTagSubject[] subjects) { var plan = new AssetTagPlan(mimeType); plan.AddSubjects(subjects); return plan; }
public AssetPlanKey DequeueAssetsToRender(MimeType mimeType) { var requested = outstandingAssets() .Where(x => MimeType.MimeTypeByFileName(x) == mimeType); var names = returnOrderedDependenciesFor(mimeType, requested); return new AssetPlanKey(mimeType, names); }
public static MimeType New(string mimeTypeValue, params string[] extensions) { var mimeType = new MimeType(mimeTypeValue); extensions.Each(mimeType.AddExtension); _mimeTypes[mimeTypeValue] = mimeType; return mimeType; }
private static void validateMatchingMimetypes(MimeType mimeType, AssetTagPlan plan, IEnumerable<string> names) { if (plan.Subjects.Any(x => x.MimeType != mimeType)) { var message = "Files {0} have mixed mimetype's".ToFormat(names.Join(", ")); throw new MixedMimetypeException(message); } }
protected AssetFileCombination(string folder, MimeType mimeType, IEnumerable<AssetFile> files) { MimeType = mimeType; var basicName = GetCombinedName(files) + mimeType.DefaultExtension(); Name = folder.IsNotEmpty() ? folder + "/" + basicName : basicName; _files = files; }
public Asset(IFubuFile file) { File = file; Filename = Path.GetFileName(file.Path); MimeType = MimeType.MimeTypeByFileName(Filename); Url = file.RelativePath.Replace("\\", "/").TrimStart('/'); }
public AssetFile(string name, AssetFolder folder) : this(name) { Folder = folder; if (_mimeType == null && folder != null) { _mimeType = folder.DefaultMimetype(); } }
public AssetFile(string name, AssetFolder? folder) : this(name) { Folder = folder; if (_mimeType == null && folder.HasValue) { _mimeType = MimeType.ForFolder(folder.Value); } }
public void builds_a_script_combination_when_the_mime_type_is_script() { theCurrentMimeType = MimeType.Javascript; var thePlan = buildPlan("a", "b", "c", "d", "e"); var theCandidate = buildCandidate("c", "d", "b"); var theCombo = theCandidate.DetermineCombinations(thePlan).Single(); theCombo.MimeType.ShouldEqual(MimeType.Javascript); theCombo.ShouldBeOfType<ScriptFileCombination>(); }
public ContentPlan(string name, IEnumerable<AssetFile> files) { _name = name; _sources.AddRange(files.Select(InitialSourceForAssetFile)); var mimeTypes = files.Select(x => x.MimeType).Distinct(); if (mimeTypes.Count() > 1) { throw new ArgumentOutOfRangeException("The list of files is a mix of MimeTypes"); } _mimeType = mimeTypes.Single(); }
public AssetTagPlan BuildPlan(MimeType mimeType, IEnumerable<string> names) { var plan = new AssetTagPlan(mimeType); plan.AddSubjects(FindSubjects(names)); validateMatchingMimetypes(mimeType, plan, names); if (plan.Subjects.Count == 1) { return plan; } _combinations.TryToReplaceWithCombinations(plan); return plan; }
public AssetFile(string name) { if (name.StartsWith(Overrides)) { Override = true; name = name.Substring(Overrides.Length + 1); } _name = name; var mimeType = MimeType.MimeTypeByFileName(Name); if (mimeType != null) { _mimeType = mimeType; } }
public IEnumerable<AssetFileCombination> OrderedListOfCombinations(MimeType mimeType) { return _combinations[mimeType].GetAll().OrderByDescending(x => x.Length); }
public void StoreCombination(MimeType mimeType, AssetFileCombination combination) { _combinations[mimeType][combination.Name] = combination; }
public static HttpResponse ContentTypeShouldBe(this HttpResponse response, MimeType mimeType) { response.ContentType.ShouldEqual(mimeType.Value); return response; }
public static TagList WriteAssetTagsImmediately(this IFubuPage page, MimeType mimeType, params string[] names) { throw new NotSupportedException("Removed in 2.0. Use IFubuPage.Script() or IFubuPage.Css() instead"); }
public AssetPlanKey DequeueAssets(MimeType mimeType, params string[] assets) { var toBeRendered = assets.Except(_rendered).ToList(); _rendered.Fill(toBeRendered); return new AssetPlanKey(mimeType, toBeRendered); }
public static void WriteFile(this IOutputWriter writer, MimeType contentType, string localFilePath, string displayName) { writer.WriteFile(contentType.Value, localFilePath, displayName); }
public ConnegQuerystring(string key, string value, MimeType mimetype) { Key = key; Value = value; Mimetype = mimetype.Value; }
public static void Write(this IOutputWriter writer, MimeType mimeType, string contents) { writer.Write(mimeType.Value, contents); }
public static Task Write(this IOutputWriter writer, MimeType mimeType, string contents) { return(writer.Write(mimeType.Value, contents)); }
// TODO -- this probably needs to be async public static void WriteFile(this IOutputWriter writer, MimeType contentType, string localFilePath, string displayName) { writer.WriteFile(contentType.Value, localFilePath, displayName); }
public bool CanRead(MimeType mimeType) { return Mimetypes.Contains(mimeType.ToString()); }
public static bool Writes(this IMedia media, MimeType mimeType) { return media.Mimetypes.Contains(mimeType.Value); }
/// <summary> /// Write the tags immediately and dequeue them from being rendered again. /// Useful when *always* want jquery at the top /// </summary> /// <param name="page"></param> /// <param name="mimeType"></param> /// <param name="names"></param> /// <returns></returns> public static TagList WriteAssetTagsImmediately(this IFubuPage page, MimeType mimeType, params string[] names) { var correctedNames = page.Get<AssetGraph>().CorrectForAliases(names).ToArray(); return page.Get<IAssetTagWriter>().WriteTags(mimeType, correctedNames); }
public IFormatter FormatterFor(MimeType mimeType) { return FormatterFor(mimeType.Value); }
public static Task Write(this IOutputWriter writer, MimeType mimeType, string contents) { return writer.Write(mimeType.Value, contents); }
// At least the order would be predictable here public IEnumerable<ITransformerPolicy> FindGlobalPoliciesFor(MimeType mimeType) { return _policies.Where(x => x.ActionType == ActionType.Global && x.MimeType == mimeType); }
/// <summary> /// Write the tags immediately and dequeue them from being rendered again. /// Useful when *always* want jquery at the top /// </summary> /// <param name="page"></param> /// <param name="mimeType"></param> /// <param name="names"></param> /// <returns></returns> public static TagList WriteAssetTagsImmediately(this IFubuPage page, MimeType mimeType, params string[] names) { return page.Get<IAssetTagWriter>().WriteTags(mimeType, names); }
private IEnumerable<string> returnOrderedDependenciesFor(MimeType mimeType, IEnumerable<string> requested) { var toRender = _finder.CompileDependenciesAndOrder(requested).ToList(); if (mimeType != null) { toRender.RemoveAll(x => MimeType.MimeTypeByFileName(x) != mimeType); } toRender.RemoveAll(x => _rendered.Contains(x)); _rendered.Fill(toRender); return toRender; }
public static void ContentType(this IOutputWriter writer, MimeType mimeType) { writer.AppendHeader(HttpResponseHeader.ContentType, mimeType.Value); }
public TagList WriteTags(MimeType mimeType) { var plan = _requirements.DequeueAssetsToRender(mimeType); return TagsForPlan(plan).ToTagList(); }
public static void ContentType(this IOutputWriter writer, MimeType mimeType) { writer.AppendHeader(HttpResponseHeader.ContentType, mimeType.Value); }