Skip to content

Commit

Permalink
Append version to manager resources. Fixes #1840
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Mar 29, 2022
1 parent a688ae1 commit dadb218
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/Piranha.Manager/Areas/Manager/Pages/AliasEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@section script
{
<script src="~/manager/assets/js/piranha.alias.min.js"></script>
<script src="~/manager/assets/js/piranha.alias.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script>
piranha.permissions.load(function () {
piranha.alias.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@section script
{
<script src="~/manager/assets/js/piranha.comment.min.js"></script>
<script src="~/manager/assets/js/piranha.comment.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script>
piranha.permissions.load(function () {
piranha.comment.load("@RouteData.Values["id"]");
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.Manager/Areas/Manager/Pages/ConfigEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@section script
{
<script src="~/manager/assets/js/piranha.config.min.js"></script>
<script src="~/manager/assets/js/piranha.config.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
}

<div id="config">
Expand Down
4 changes: 2 additions & 2 deletions core/Piranha.Manager/Areas/Manager/Pages/ContentEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
{
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
<script src="~/manager/assets/js/piranha.components.min.js"></script>
<script src="~/manager/assets/js/piranha.contentedit.min.js"></script>
<script src="~/manager/assets/js/piranha.components.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script src="~/manager/assets/js/piranha.contentedit.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

@if (action == "edit")
{
Expand Down
8 changes: 4 additions & 4 deletions core/Piranha.Manager/Areas/Manager/Pages/ContentList.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
<script src="~/manager/assets/js/piranha.contentlist.min.js"></script>
<script src="~/manager/assets/js/piranha.contentlist.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

<script type="text/javascript">
piranha.contentlist.load('@contentGroup');
Expand All @@ -21,8 +21,8 @@

@section partials
{
}

}

<div id="contentlist">
<div class="top">
Expand Down Expand Up @@ -60,7 +60,7 @@
</thead>
<tbody>
<tr v-for="item in items">
<td>
<td>
<a :href="piranha.baseUrl + 'manager/content/edit/' + item.typeId + '/' + item.id">{{ item.title }}</a>
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.Manager/Areas/Manager/Pages/MediaList.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@section script
{
<script src="~/manager/assets/js/piranha.media.min.js"></script>
<script src="~/manager/assets/js/piranha.media.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

<script>
piranha.permissions.load(function () {
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.Manager/Areas/Manager/Pages/ModuleList.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
@section script
{
<script src="~/manager/assets/js/piranha.module.min.js"></script>
<script src="~/manager/assets/js/piranha.module.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
}

<div id="module">
Expand Down
4 changes: 2 additions & 2 deletions core/Piranha.Manager/Areas/Manager/Pages/PageEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
{
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
<script src="~/manager/assets/js/piranha.components.min.js"></script>
<script src="~/manager/assets/js/piranha.pageedit.min.js"></script>
<script src="~/manager/assets/js/piranha.components.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script src="~/manager/assets/js/piranha.pageedit.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

@if (action == "edit")
{
Expand Down
6 changes: 3 additions & 3 deletions core/Piranha.Manager/Areas/Manager/Pages/PageList.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
<script src="~/manager/assets/js/piranha.components.min.js"></script>
<script src="~/manager/assets/js/piranha.pagelist.min.js"></script>
<script src="~/manager/assets/js/piranha.siteedit.min.js"></script>
<script src="~/manager/assets/js/piranha.components.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script src="~/manager/assets/js/piranha.pagelist.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script src="~/manager/assets/js/piranha.siteedit.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

<script type="text/javascript">
piranha.pagelist.load();
Expand Down
4 changes: 2 additions & 2 deletions core/Piranha.Manager/Areas/Manager/Pages/PostEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
{
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
<script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
<script src="~/manager/assets/js/piranha.components.min.js"></script>
<script src="~/manager/assets/js/piranha.postedit.min.js"></script>
<script src="~/manager/assets/js/piranha.components.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>
<script src="~/manager/assets/js/piranha.postedit.min.js[email protected](typeof(Piranha.Manager.Module).Assembly)"></script>

@if (action == "edit")
{
Expand Down
11 changes: 6 additions & 5 deletions core/Piranha.Manager/Areas/Manager/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var module = Piranha.App.Modules.Get<Piranha.Manager.Module>();
var prerelease = Piranha.Utils.IsPreRelease(typeof(Piranha.Manager.Module).Assembly) ? "pre-release" : "";
var isRightToLeft = @System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
var version = Piranha.Utils.GetAssemblyVersionHash(typeof(Piranha.Manager.Module).Assembly);
}
<!doctype html>
<html lang="en">
Expand All @@ -11,11 +12,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@if(isRightToLeft)
{
<link rel="stylesheet" href="~/manager/assets/css/full.rtl.min.css">
<link rel="stylesheet" href="~/manager/assets/css/full.rtl.min.css?v=@version">
}
else
{
<link rel="stylesheet" href="~/manager/assets/css/full.min.css">
<link rel="stylesheet" href="~/manager/assets/css/full.min.css?v=@version">
}
<link rel="icon" href="~/manager/assets/img/logo.png">

Expand Down Expand Up @@ -65,10 +66,10 @@
@RenderSection("partials", required: false)

<environment include="Development">
<script type="text/javascript" src="~/manager/assets/js/piranha-deps-dev.js"></script>
<script type="text/javascript" src="~/manager/assets/js/piranha-deps-dev.js?v=@version"></script>
</environment>
<environment exclude="Development">
<script type="text/javascript" src="~/manager/assets/js/piranha-deps.min.js"></script>
<script type="text/javascript" src="~/manager/assets/js/piranha-deps.min.js?v=@version"></script>
</environment>
@foreach (var script in module.Scripts.Where(s => s.RenderBeforeCoreScripts))
{
Expand All @@ -85,7 +86,7 @@
<script type="@script.Type" src="@Url.Content(script.Src)" integrity="@script.Integrity" crossorigin="@script.GetCrossOriginValueStrValue()"></script>
}
}
<script type="text/javascript" src="~/manager/assets/js/piranha.min.js"></script>
<script type="text/javascript" src="~/manager/assets/js/piranha.min.js?v=@version"></script>
<script type="text/javascript">
Vue.prototype.piranha = window.piranha;
</script>
Expand Down
10 changes: 10 additions & 0 deletions core/Piranha/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ public static string GetAssemblyVersion(Assembly assembly)
return $"{version.Major}.{version.Minor}.{version.Build}";
}

/// <summary>
/// Gets the hashed version string of the given assembly.
/// </summary>
/// <param name="assembly">The assembly</param>
/// <returns>The hashed version string</returns>
public static string GetAssemblyVersionHash(Assembly assembly)
{
return GetAssemblyVersion(assembly).GetHashCode().ToString();
}

/// <summary>
/// Checks if the given assembly is a pre-release.
/// </summary>
Expand Down

0 comments on commit dadb218

Please sign in to comment.