Skip to content

Commit 7dd74dd

Browse files
committed
Merge tag 'v1.9.3' into dnn
2 parents 7da5957 + d62321a commit 7dd74dd

File tree

7 files changed

+114
-32
lines changed

7 files changed

+114
-32
lines changed

ClientDependency.Core/HtmlAttributesStringParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ internal static void ParseIntoDictionary(string attributes, IDictionary<string,
7878

7979
}
8080
}
81-
}
81+
}

ClientDependency.Mvc/HtmlHelperExtensions.cs

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static IHtmlString RenderCssHere(this HtmlHelper html, string rendererNam
313313
/// <returns></returns>
314314
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter)
315315
{
316-
return html.RequiresFolder(folderPath, 100, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri));
316+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, 100));
317317
}
318318

319319
/// <summary>
@@ -326,7 +326,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
326326
/// <returns></returns>
327327
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority)
328328
{
329-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri));
329+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, priority));
330330
}
331331

332332
/// <summary>
@@ -340,7 +340,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
340340
/// <returns></returns>
341341
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group)
342342
{
343-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri, group));
343+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, priority, group));
344344
}
345345

346346
/// <summary>
@@ -355,7 +355,28 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
355355
/// <returns></returns>
356356
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group, object htmlAttributes)
357357
{
358-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri, group, htmlAttributes));
358+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, priority, group, htmlAttributes));
359+
}
360+
361+
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group, object htmlAttributes, string forcedProvider)
362+
{
363+
return html.RequiresFolder(folderPath, searchFilter, (absPath) =>
364+
{
365+
var file = new JavascriptFile(absPath)
366+
{
367+
ForceProvider = forcedProvider,
368+
Group = @group,
369+
Priority = priority
370+
};
371+
372+
//now add the attributes to the list
373+
foreach (var d in htmlAttributes.ToDictionary())
374+
{
375+
file.HtmlAttributes.Add(d.Key, d.Value.ToString());
376+
}
377+
378+
html.RequiresJs(file);
379+
});
359380
}
360381

361382
/// <summary>
@@ -369,7 +390,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
369390
/// <returns></returns>
370391
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, object htmlAttributes)
371392
{
372-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri, htmlAttributes));
393+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, priority, htmlAttributes));
373394
}
374395

375396
/// <summary>
@@ -382,7 +403,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
382403
/// <returns></returns>
383404
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, string searchFilter, object htmlAttributes)
384405
{
385-
return html.RequiresFolder(folderPath, 100, searchFilter, (absPath, pri) => html.RequiresJs(absPath, pri, htmlAttributes));
406+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresJs(absPath, 100, htmlAttributes));
386407
}
387408

388409
/// <summary>
@@ -405,7 +426,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
405426
/// <returns></returns>
406427
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, int priority)
407428
{
408-
return html.RequiresFolder(folderPath, priority, "*.js", (absPath, pri) => html.RequiresJs(absPath, pri));
429+
return html.RequiresFolder(folderPath, "*.js", (absPath) => html.RequiresJs(absPath, priority));
409430
}
410431

411432
/// <summary>
@@ -418,7 +439,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
418439
/// <returns></returns>
419440
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, int priority, int group)
420441
{
421-
return html.RequiresFolder(folderPath, priority, "*.js", (absPath, pri) => html.RequiresJs(absPath, pri, group));
442+
return html.RequiresFolder(folderPath, "*.js", (absPath) => html.RequiresJs(absPath, priority, group));
422443
}
423444

424445
/// <summary>
@@ -432,7 +453,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
432453
/// <returns></returns>
433454
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, int priority, int group, object htmlAttributes)
434455
{
435-
return html.RequiresFolder(folderPath, priority, "*.js", (absPath, pri) => html.RequiresJs(absPath, pri, group, htmlAttributes));
456+
return html.RequiresFolder(folderPath, "*.js", (absPath) => html.RequiresJs(absPath, priority, group, htmlAttributes));
436457
}
437458

438459
/// <summary>
@@ -445,7 +466,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
445466
/// <returns></returns>
446467
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, int priority, object htmlAttributes)
447468
{
448-
return html.RequiresFolder(folderPath, priority, "*.js", (absPath, pri) => html.RequiresJs(absPath, pri, htmlAttributes));
469+
return html.RequiresFolder(folderPath, "*.js", (absPath) => html.RequiresJs(absPath, priority, htmlAttributes));
449470
}
450471

451472
/// <summary>
@@ -457,7 +478,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
457478
/// <returns></returns>
458479
public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPath, object htmlAttributes)
459480
{
460-
return html.RequiresFolder(folderPath, 100, "*.js", (absPath, pri) => html.RequiresJs(absPath, pri, htmlAttributes));
481+
return html.RequiresFolder(folderPath, "*.js", (absPath) => html.RequiresJs(absPath, 100, htmlAttributes));
461482
}
462483

463484
#endregion
@@ -472,7 +493,7 @@ public static HtmlHelper RequiresJsFolder(this HtmlHelper html, string folderPat
472493
/// <returns></returns>
473494
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter)
474495
{
475-
return html.RequiresFolder(folderPath, 100, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri));
496+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, 100));
476497
}
477498

478499
/// <summary>
@@ -485,7 +506,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
485506
/// <returns></returns>
486507
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority)
487508
{
488-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri));
509+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, priority));
489510
}
490511

491512
/// <summary>
@@ -499,7 +520,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
499520
/// <returns></returns>
500521
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group)
501522
{
502-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri, group));
523+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, priority, group));
503524
}
504525

505526
/// <summary>
@@ -514,7 +535,28 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
514535
/// <returns></returns>
515536
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group, object htmlAttributes)
516537
{
517-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri, group, htmlAttributes));
538+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, priority, group, htmlAttributes));
539+
}
540+
541+
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group, object htmlAttributes, string forcedProvider)
542+
{
543+
return html.RequiresFolder(folderPath, searchFilter, (absPath) =>
544+
{
545+
var file = new CssFile(absPath)
546+
{
547+
ForceProvider = forcedProvider,
548+
Group = @group,
549+
Priority = priority
550+
};
551+
552+
//now add the attributes to the list
553+
foreach (var d in htmlAttributes.ToDictionary())
554+
{
555+
file.HtmlAttributes.Add(d.Key, d.Value.ToString());
556+
}
557+
558+
html.RequiresJs(file);
559+
});
518560
}
519561

520562
/// <summary>
@@ -528,7 +570,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
528570
/// <returns></returns>
529571
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, object htmlAttributes)
530572
{
531-
return html.RequiresFolder(folderPath, priority, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri, htmlAttributes));
573+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, priority, htmlAttributes));
532574
}
533575

534576
/// <summary>
@@ -541,7 +583,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
541583
/// <returns></returns>
542584
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, object htmlAttributes)
543585
{
544-
return html.RequiresFolder(folderPath, 100, searchFilter, (absPath, pri) => html.RequiresCss(absPath, pri, htmlAttributes));
586+
return html.RequiresFolder(folderPath, searchFilter, (absPath) => html.RequiresCss(absPath, 100, htmlAttributes));
545587
}
546588

547589
/// <summary>
@@ -564,7 +606,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
564606
/// <returns></returns>
565607
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, int priority)
566608
{
567-
return html.RequiresFolder(folderPath, priority, "*.css", (absPath, pri) => html.RequiresCss(absPath, pri));
609+
return html.RequiresFolder(folderPath, "*.css", (absPath) => html.RequiresCss(absPath, priority));
568610
}
569611

570612
/// <summary>
@@ -577,7 +619,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
577619
/// <returns></returns>
578620
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, int priority, int group)
579621
{
580-
return html.RequiresFolder(folderPath, priority, "*.css", (absPath, pri) => html.RequiresCss(absPath, pri, group));
622+
return html.RequiresFolder(folderPath, "*.css", (absPath) => html.RequiresCss(absPath, priority, group));
581623
}
582624

583625
/// <summary>
@@ -591,7 +633,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
591633
/// <returns></returns>
592634
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, int priority, int group, object htmlAttributes)
593635
{
594-
return html.RequiresFolder(folderPath, priority, "*.css", (absPath, pri) => html.RequiresCss(absPath, pri, group, htmlAttributes));
636+
return html.RequiresFolder(folderPath, "*.css", (absPath) => html.RequiresCss(absPath, priority, group, htmlAttributes));
595637
}
596638

597639
/// <summary>
@@ -604,7 +646,7 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
604646
/// <returns></returns>
605647
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, int priority, object htmlAttributes)
606648
{
607-
return html.RequiresFolder(folderPath, priority, "*.css", (absPath, pri) => html.RequiresCss(absPath, pri, htmlAttributes));
649+
return html.RequiresFolder(folderPath, "*.css", (absPath) => html.RequiresCss(absPath, priority, htmlAttributes));
608650
}
609651

610652
/// <summary>
@@ -616,11 +658,11 @@ public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPa
616658
/// <returns></returns>
617659
public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, object htmlAttributes)
618660
{
619-
return html.RequiresFolder(folderPath, 100, "*.css", (absPath, pri) => html.RequiresCss(absPath, pri, htmlAttributes));
661+
return html.RequiresFolder(folderPath, "*.css", (absPath) => html.RequiresCss(absPath, 100, htmlAttributes));
620662
}
621663
#endregion
622664

623-
private static HtmlHelper RequiresFolder(this HtmlHelper html, string folderPath, int priority, string fileSearch, Action<string, int> requiresAction)
665+
private static HtmlHelper RequiresFolder(this HtmlHelper html, string folderPath, string fileSearch, Action<string> requiresAction)
624666
{
625667
var httpContext = html.ViewContext.HttpContext;
626668
var systemRootPath = httpContext.Server.MapPath("~/");
@@ -632,8 +674,7 @@ private static HtmlHelper RequiresFolder(this HtmlHelper html, string folderPath
632674
foreach (var file in files)
633675
{
634676
var absoluteFilePath = "~/" + file.Substring(systemRootPath.Length).Replace("\\", "/");
635-
requiresAction(absoluteFilePath, priority);
636-
html.RequiresJs(absoluteFilePath, priority);
677+
requiresAction(absoluteFilePath);
637678
}
638679
}
639680

ClientDependency.UnitTests/HtmlAttributesStringParserTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ namespace ClientDependency.UnitTests
1111
[TestFixture]
1212
public class HtmlAttributesStringParserTest
1313
{
14+
[Test]
15+
public void Ensure_No_Duplicates()
16+
{
17+
const string attributes = "defer:true,async:true";
18+
var destination = new Dictionary<string, string>();
19+
20+
HtmlAttributesStringParser.ParseIntoDictionary(attributes, destination);
21+
22+
Assert.AreEqual(2, destination.Count);
23+
Assert.AreEqual("defer", destination.First().Key);
24+
Assert.AreEqual("true", destination.First().Value);
25+
Assert.AreEqual("async", destination.Last().Key);
26+
Assert.AreEqual("true", destination.Last().Value);
27+
28+
}
29+
1430
[Test]
1531
public void Parse_Media_Query()
1632
{

ClientDependency.Web.Test/ClientDependency.Web.Test.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<IISExpressUseClassicPipelineMode />
3737
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
3838
<UseGlobalApplicationHostFile />
39+
<Use64BitIISExpress />
3940
</PropertyGroup>
4041
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
4142
<DebugSymbols>true</DebugSymbols>
@@ -374,6 +375,7 @@
374375
<Content Include="Views\Test\Sass.cshtml" />
375376
<Content Include="Views\Test\Coffee.cshtml" />
376377
<Content Include="Views\Test\TypeScript.cshtml" />
378+
<Content Include="Views\Test\Folder.cshtml" />
377379
<None Include="Views\Test\Default.cshtml" />
378380
</ItemGroup>
379381
<ItemGroup>
@@ -450,7 +452,7 @@
450452
<AutoAssignPort>True</AutoAssignPort>
451453
<DevelopmentServerPort>54153</DevelopmentServerPort>
452454
<DevelopmentServerVPath>/VirtualFolderTest</DevelopmentServerVPath>
453-
<IISUrl>http://localhost:54321/VirtualFolderTest/</IISUrl>
455+
<IISUrl>http://localhost:54322/VirtualFolderTest/</IISUrl>
454456
<NTLMAuthentication>False</NTLMAuthentication>
455457
<UseCustomServer>False</UseCustomServer>
456458
<CustomServerUrl>

ClientDependency.Web.Test/Views/Test/Default.cshtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
Home Page
1111
}
1212

13-
@{ Html.RequiresCss("Content.css", "Styles"); }
13+
@{
14+
15+
Html.RequiresCss("Content.css", "Styles");
16+
17+
}
1418

1519
<div class="mainContent">
1620
<h2>Using the default provider specified in the web.config</h2>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@model ClientDependency.Web.Test.Models.TestModel
2+
@using ClientDependency.Core.Mvc
3+
4+
@{
5+
Layout = "~/Views/Shared/Master.cshtml";
6+
}
7+
8+
@section TitleContent
9+
{
10+
Home Page
11+
}
12+
13+
@{ Html.RequiresJsFolder("~/Js/TestPath"); }
14+
15+
<div class="mainContent">
16+
<h2>
17+
This tests including an entire folder</h2>
18+
19+
</div>

SolutionInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using System.Security;
33

44
[assembly: AssemblyCompany("Shannon Deminick")]
5-
[assembly: AssemblyCopyright("Copyright © Shannon Deminick 2016")]
5+
[assembly: AssemblyCopyright("Copyright © Shannon Deminick 2017")]
66
[assembly: AssemblyTrademark("")]
77
[assembly: AssemblyCulture("")]
88

99

10-
[assembly: AssemblyVersion("1.9.2")]
11-
[assembly: AssemblyFileVersion("1.9.2")]
12-
[assembly: AssemblyInformationalVersion("1.9.2")]
10+
[assembly: AssemblyVersion("1.9.3")]
11+
[assembly: AssemblyFileVersion("1.9.3")]
12+
[assembly: AssemblyInformationalVersion("1.9.3")]

0 commit comments

Comments
 (0)