Browse Source

Added simple bundle manager.

pull/81/head
Halil İbrahim Kalkan 10 years ago
parent
commit
8f4b17cda5
  1. 4
      src/AbpDesk/AbpDesk.Web.Mvc/Views/Shared/_Layout.cshtml
  2. 1
      src/AbpDesk/AbpDesk.Web.Mvc/Views/_ViewImports.cshtml
  3. 22
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs
  4. 9320
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.css
  5. 1
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.css.map
  6. 6
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.min.css
  7. 1
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.min.css.map
  8. 3535
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/js/bootstrap.js
  9. 7
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/js/bootstrap.min.js
  10. 3
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/project.json
  11. 31
      src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundleCollection.cs
  12. 26
      src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundleManager.cs
  13. 15
      src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundlingOptions.cs
  14. 11
      src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/IBundleManager.cs
  15. 21
      src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpScriptBundle/AbpStyleBundleViewComponent.cs
  16. 5
      src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpScriptBundle/Default.cshtml
  17. 21
      src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpStyleBundle/AbpStyleBundleViewComponent.cs
  18. 5
      src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpStyleBundle/Default.cshtml

4
src/AbpDesk/AbpDesk.Web.Mvc/Views/Shared/_Layout.cshtml

@ -8,6 +8,8 @@
<html>
<head>
<title>title</title>
<vc:abp-style-bundle name="GlobalStyles"></vc:abp-style-bundle>
@RenderSection("styles", false)
</head>
@ -17,6 +19,8 @@
<vc:abp-menu menu-name="@StandardMenus.Main" view-name="Default"></vc:abp-menu>
@RenderBody()
<vc:abp-script-bundle name="GlobalScripts"></vc:abp-script-bundle>
</body>
</html>

1
src/AbpDesk/AbpDesk.Web.Mvc/Views/_ViewImports.cshtml

@ -1,3 +1,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, AbpDesk.Web.Mvc

22
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs

@ -1,5 +1,6 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Bundling;
using Volo.Abp.EmbeddedFiles;
using Volo.Abp.Modularity;
@ -14,6 +15,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
services.Configure<EmbeddedFileOptions>(options =>
{
options.Sources.Add(
new EmbeddedFileSet(
"/libs/",
GetType().GetTypeInfo().Assembly,
"Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.libs"
)
);
options.Sources.Add(
new EmbeddedFileSet(
"/Views/",
@ -22,6 +31,19 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
)
);
});
services.Configure<BundlingOptions>(options =>
{
options.StyleBundles.Add("GlobalStyles", new[]
{
"/libs/bootstrap/css/bootstrap.css"
});
options.ScriptBundles.Add("GlobalScripts", new[]
{
"/libs/bootstrap/js/bootstrap.js"
});
});
}
}
}

9320
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.css

File diff suppressed because it is too large

1
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.css.map

File diff suppressed because one or more lines are too long

6
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.min.css

File diff suppressed because one or more lines are too long

1
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/css/bootstrap.min.css.map

File diff suppressed because one or more lines are too long

3535
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/js/bootstrap.js

File diff suppressed because it is too large

7
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/libs/bootstrap/js/bootstrap.min.js

File diff suppressed because one or more lines are too long

3
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/project.json

@ -15,7 +15,8 @@
"buildOptions": {
"embed": {
"include": [
"Views/**/*.*"
"Views/**/*.*",
"libs/**/*.*"
]
}
}

31
src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundleCollection.cs

@ -0,0 +1,31 @@
using System.Collections.Generic;
using Volo.ExtensionMethods.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.Bundling
{
public class BundleCollection
{
private readonly Dictionary<string, List<string>> _bundles;
public BundleCollection()
{
_bundles = new Dictionary<string, List<string>>();
}
public void Add(string bundleName, string[] files)
{
_bundles.GetOrAdd(bundleName, () => new List<string>()).AddRange(files);
}
public List<string> GetFiles(string bundleName)
{
var files = _bundles.GetOrDefault(bundleName);
if (files == null)
{
throw new AbpException("Undefined bundle: " + bundleName);
}
return files;
}
}
}

26
src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundleManager.cs

@ -0,0 +1,26 @@
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Volo.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.Bundling
{
public class BundleManager : IBundleManager, ITransientDependency
{
private readonly BundlingOptions _options;
public BundleManager(IOptions<BundlingOptions> options)
{
_options = options.Value;
}
public List<string> GetStyleBundleFiles(string bundleName)
{
return _options.StyleBundles.GetFiles(bundleName);
}
public List<string> GetScriptBundleFiles(string bundleName)
{
return _options.ScriptBundles.GetFiles(bundleName);
}
}
}

15
src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/BundlingOptions.cs

@ -0,0 +1,15 @@
namespace Volo.Abp.AspNetCore.Mvc.Bundling
{
public class BundlingOptions
{
public BundleCollection StyleBundles { get; set; }
public BundleCollection ScriptBundles { get; set; }
public BundlingOptions()
{
StyleBundles = new BundleCollection();
ScriptBundles = new BundleCollection();
}
}
}

11
src/Volo.Abp.AspNetCore.Mvc.UI/Bundling/IBundleManager.cs

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.Bundling
{
public interface IBundleManager
{
List<string> GetStyleBundleFiles(string bundleName);
List<string> GetScriptBundleFiles(string bundleName);
}
}

21
src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpScriptBundle/AbpStyleBundleViewComponent.cs

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Bundling;
namespace Volo.Abp.AspNetCore.Mvc.Views.Shared.Components.AbpScriptBundle
{
public class AbpScriptBundleViewComponent : ViewComponent
{
private readonly IBundleManager _bundleManager;
public AbpScriptBundleViewComponent(IBundleManager bundleManager)
{
_bundleManager = bundleManager;
}
public IViewComponentResult Invoke(string name)
{
var files = _bundleManager.GetScriptBundleFiles(name);
return View(files);
}
}
}

5
src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpScriptBundle/Default.cshtml

@ -0,0 +1,5 @@
@model List<string>
@foreach (var scriptFile in Model)
{
<script src="@scriptFile" type="text/javascript"></script>
}

21
src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpStyleBundle/AbpStyleBundleViewComponent.cs

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Bundling;
namespace Volo.Abp.AspNetCore.Mvc.Views.Shared.Components.AbpStyleBundle
{
public class AbpStyleBundleViewComponent : ViewComponent
{
private readonly IBundleManager _bundleManager;
public AbpStyleBundleViewComponent(IBundleManager bundleManager)
{
_bundleManager = bundleManager;
}
public IViewComponentResult Invoke(string name)
{
var files = _bundleManager.GetStyleBundleFiles(name);
return View(files);
}
}
}

5
src/Volo.Abp.AspNetCore.Mvc.UI/Views/Shared/Components/AbpStyleBundle/Default.cshtml

@ -0,0 +1,5 @@
@model List<string>
@foreach (var styleFile in Model)
{
<link rel="stylesheet" type="text/css" href="@styleFile" />
}
Loading…
Cancel
Save