Browse Source

Rename `CDN` to `External`.

pull/17894/head
maliming 3 years ago
parent
commit
9db31e75b4
  1. 16
      docs/en/UI/AspNetCore/Bundling-Minification.md
  2. 17
      docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md
  3. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationExtensions.cs
  4. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollectionExtensions.cs
  5. 15
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleFile.cs
  6. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
  7. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelper.cs
  8. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs
  9. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
  10. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs

16
docs/en/UI/AspNetCore/Bundling-Minification.md

@ -382,11 +382,11 @@ Configure<AbpBundlingOptions>(options =>
<script defer src="/libs/timeago/locales/jquery.timeago.en.js?_v=637674729040000000"></script>
````
### CDN Support
### External/CDN file Support
You can configure `AbpBundlingOptions` or use `is-cdn` on `script/style` taghelper to load all or a single js/css file from CDN.
The bundling system automatically recognizes the external/CDN files and adds them to the page without any change.
#### Add CDN files in `AbpBundlingOptions`
#### Using External/CDN files in `AbpBundlingOptions`
````csharp
Configure<AbpBundlingOptions>(options =>
@ -397,7 +397,7 @@ Configure<AbpBundlingOptions>(options =>
configuration
.AddFiles("/styles/my-style1.css")
.AddFiles("/styles/my-style2.css")
.AddCdnFiles("https://cdn.abp.io/bootstrap.css")
.AddFiles("https://cdn.abp.io/bootstrap.css")
.AddFiles("/styles/my-style3.css")
.AddFiles("/styles/my-style4.css");
});
@ -408,7 +408,7 @@ Configure<AbpBundlingOptions>(options =>
configuration
.AddFiles("/scripts/my-script1.js")
.AddFiles("/scripts/my-script2.js")
.AddCdnFiles("https://cdn.abp.io/bootstrap.js")
.AddFiles("https://cdn.abp.io/bootstrap.js")
.AddFiles("/scripts/my-script3.js")
.AddFiles("/scripts/my-script4.js");
});
@ -427,13 +427,13 @@ Configure<AbpBundlingOptions>(options =>
<script src="/__bundles/MyScriptBundle.2E8D0FDC6334D2A6B847393A801525B7.js?_v=638331889644943970"></script>
````
#### Add CDN files in Tag Helpers.
#### Using External/CDN files in Tag Helpers.
````html
<abp-style-bundle name="MyStyleBundle">
<abp-style src="/styles/my-style1.css" />
<abp-style src="/styles/my-style2.css" />
<abp-style src="https://cdn.abp.io/bootstrap.css" is-cdn="true" />
<abp-style src="https://cdn.abp.io/bootstrap.css" />
<abp-style src="/styles/my-style3.css" />
<abp-style src="/styles/my-style4.css" />
</abp-style-bundle>
@ -441,7 +441,7 @@ Configure<AbpBundlingOptions>(options =>
<abp-script-bundle name="MyScriptBundle">
<abp-script src="/scripts/my-script1.js" />
<abp-script src="/scripts/my-script2.js" />
<abp-script src="https://cdn.abp.io/bootstrap.js" is-cdn="true" />
<abp-script src="https://cdn.abp.io/bootstrap.js" />
<abp-script src="/scripts/my-script3.js" />
<abp-script src="/scripts/my-script4.js" />
</abp-script-bundle>

17
docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md

@ -353,11 +353,11 @@ services.Configure<AbpBundlingOptions>(options =>
});
````
### CDN 支持
### 外部/CDN文件支持
你可以配置`AbpBundlingOptions`或在`script/style` taghelper上使用`is-cdn`来从CDN加载js/css.
捆绑系统会自动识别外部/CDN文件,并将其添加到页面中,无需进行任何更改。
#### 在`AbpBundlingOptions`中添加CDN文件
#### 在`AbpBundlingOptions`中添加外部/CDN文件
````csharp
Configure<AbpBundlingOptions>(options =>
@ -368,7 +368,7 @@ Configure<AbpBundlingOptions>(options =>
configuration
.AddFiles("/styles/my-style1.css")
.AddFiles("/styles/my-style2.css")
.AddCdnFiles("https://cdn.abp.io/bootstrap.css")
.AddFiles("https://cdn.abp.io/bootstrap.css")
.AddFiles("/styles/my-style3.css")
.AddFiles("/styles/my-style4.css");
});
@ -379,7 +379,7 @@ Configure<AbpBundlingOptions>(options =>
configuration
.AddFiles("/scripts/my-script1.js")
.AddFiles("/scripts/my-script2.js")
.AddCdnFiles("https://cdn.abp.io/bootstrap.js")
.AddFiles("https://cdn.abp.io/bootstrap.js")
.AddFiles("/scripts/my-script3.js")
.AddFiles("/scripts/my-script4.js");
});
@ -398,13 +398,13 @@ Configure<AbpBundlingOptions>(options =>
<script src="/__bundles/MyScriptBundle.2E8D0FDC6334D2A6B847393A801525B7.js?_v=638331889644943970"></script>
````
#### 在TagHelpers中添加CDN文件
#### 在TagHelpers中添加外部/CDN文件
````html
<abp-style-bundle name="MyStyleBundle">
<abp-style src="/styles/my-style1.css" />
<abp-style src="/styles/my-style2.css" />
<abp-style src="https://cdn.abp.io/bootstrap.css" is-cdn="true" />
<abp-style src="https://cdn.abp.io/bootstrap.css" />
<abp-style src="/styles/my-style3.css" />
<abp-style src="/styles/my-style4.css" />
</abp-style-bundle>
@ -412,7 +412,7 @@ Configure<AbpBundlingOptions>(options =>
<abp-script-bundle name="MyScriptBundle">
<abp-script src="/scripts/my-script1.js" />
<abp-script src="/scripts/my-script2.js" />
<abp-script src="https://cdn.abp.io/bootstrap.js" is-cdn="true" />
<abp-script src="https://cdn.abp.io/bootstrap.js" />
<abp-script src="/scripts/my-script3.js" />
<abp-script src="/scripts/my-script4.js" />
</abp-script-bundle>
@ -430,7 +430,6 @@ Configure<AbpBundlingOptions>(options =>
<script src="/__bundles/MyScriptBundle.191CB68AB4F41C8BF3A7AE422F19A3D2.js?_v=638331889645055490"></script>
````
### 主题
主题使用标准包贡献者将库资源添加到页面布局. 主题还可以定义一些标准/全局包, 因此任何模块都可以为这些标准/全局包做出贡献. 有关更多信息, 请参阅[主题文档](Theming.md).

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationExtensions.cs

@ -17,9 +17,9 @@ public static class BundleConfigurationExtensions
return bundleConfiguration;
}
public static BundleConfiguration AddCdnFiles(this BundleConfiguration bundleConfiguration, params string[] files)
public static BundleConfiguration AddExternalFiles(this BundleConfiguration bundleConfiguration, params string[] files)
{
bundleConfiguration.Contributors.AddCdnFiles(files.Select(x => new BundleFile(x, true)).ToArray());
bundleConfiguration.Contributors.AddExternalFiles(files.Select(x => new BundleFile(x, true)).ToArray());
return bundleConfiguration;
}

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollectionExtensions.cs

@ -12,7 +12,7 @@ public static class BundleContributorCollectionExtensions
contributors.Add(new BundleFileContributor(files));
}
public static void AddCdnFiles(this BundleContributorCollection contributors, params BundleFile[] files)
public static void AddExternalFiles(this BundleContributorCollection contributors, params BundleFile[] files)
{
contributors.Add(new BundleFileContributor(files));
}

15
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleFile.cs

@ -1,15 +1,24 @@
using System;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling;
public class BundleFile
{
public string FileName { get; set; }
public bool IsCdn { get; set; }
public bool IsExternalFile { get; set; }
public BundleFile(string fileName)
{
FileName = fileName;
IsExternalFile = fileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
fileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase);
}
public BundleFile(string fileName, bool isCdn = false)
public BundleFile(string fileName, bool isExternalFile)
{
FileName = fileName;
IsCdn = isCdn;
IsExternalFile = isExternalFile;
}
/// <summary>

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs

@ -81,7 +81,7 @@ public class BundleManager : IBundleManager, ITransientDependency
var localBundleFiles = new List<string>();
foreach (var bundleFile in bundleFiles)
{
if (!bundleFile.IsCdn)
if (!bundleFile.IsExternalFile)
{
localBundleFiles.Add(bundleFile.FileName);
}

5
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelper.cs

@ -18,9 +18,6 @@ public abstract class AbpBundleItemTagHelper<TTagHelper, TTagHelperService> : Ab
/// </summary>
public Type? Type { get; set; }
[HtmlAttributeName("is-cdn")]
public bool IsCdn { get; set; }
protected AbpBundleItemTagHelper(TTagHelperService service)
: base(service)
{
@ -53,7 +50,7 @@ public abstract class AbpBundleItemTagHelper<TTagHelper, TTagHelperService> : Ab
if (Src != null)
{
return new BundleTagHelperFileItem(new BundleFile(Src, IsCdn));
return new BundleTagHelperFileItem(new BundleFile(Src));
}
throw new AbpException("abp-script tag helper requires to set either src or type!");

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs

@ -65,7 +65,7 @@ public abstract class AbpTagHelperResourceService : ITransientDependency
foreach (var bundleFile in bundleFiles)
{
if (bundleFile.IsCdn)
if (bundleFile.IsExternalFile)
{
AddHtmlTag(viewContext, tagHelper, context, output, bundleFile, null);
}

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs

@ -53,7 +53,7 @@ public class AbpTagHelperScriptService : AbpTagHelperResourceService
var nonceText = (viewContext.HttpContext.Items.TryGetValue(AbpAspNetCoreConsts.ScriptNonceKey, out var nonce) && nonce is string nonceString && !string.IsNullOrEmpty(nonceString))
? $"nonce=\"{nonceString}\" "
: string.Empty;
var src = file.IsCdn ? file.FileName : viewContext.GetUrlHelper().Content((file.FileName + "?_v=" + fileInfo!.LastModified.UtcTicks).EnsureStartsWith('~'));
var src = file.IsExternalFile ? file.FileName : viewContext.GetUrlHelper().Content((file.FileName + "?_v=" + fileInfo!.LastModified.UtcTicks).EnsureStartsWith('~'));
output.Content.AppendHtml($"<script {deferText}{nonceText}src=\"{src}\"></script>{Environment.NewLine}");
}
}

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs

@ -51,7 +51,7 @@ public class AbpTagHelperStyleService : AbpTagHelperResourceService
_ => false
};
var href = file.IsCdn ? file.FileName : viewContext.GetUrlHelper().Content((file.FileName + "?_v=" + fileInfo!.LastModified.UtcTicks).EnsureStartsWith('~'));
var href = file.IsExternalFile ? file.FileName : viewContext.GetUrlHelper().Content((file.FileName + "?_v=" + fileInfo!.LastModified.UtcTicks).EnsureStartsWith('~'));
if (preload || Options.PreloadStylesByDefault || Options.PreloadStyles.Any(x => file.FileName.StartsWith(x, StringComparison.OrdinalIgnoreCase)))
{
output.Content.AppendHtml(SecurityHeadersOptions.UseContentSecurityPolicyScriptNonce

Loading…
Cancel
Save