Skip to content

Commit ad41165

Browse files
authored
Merge pull request #635 from cloudscribe/feature/482_2
#482 version 2
2 parents 9fa4e08 + 8685977 commit ad41165

File tree

54 files changed

+10801
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+10801
-44
lines changed

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/AddJsPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
<input asp-for="Url" name="Url" class="form-control ms-1 me-1" style="min-width:350px;" />
2323
<span asp-validation-for="Url" class="text-danger"></span>
2424
</div>
25-
<button type="submit" class="btn btn-primary">@sr["Add Javascript Url"]</button>
25+
<button type="submit" class="btn btn-primary">@sr["Add JavaScript Url"]</button>
2626
</form>

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/Development.cshtml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
@model cloudscribe.SimpleContent.Web.ViewModels.PageDevelopmentViewModel
22
@inject IPageRoutes pageRoutes
33
@inject IStringLocalizer<SimpleContent> sr
4-
<h1>@ViewBag.Title <small><a href="@Url.RouteUrl(pageRoutes.PageRouteName, new { slug=Model.Slug })">@sr["Cancel"]</a></small></h1>
5-
<p>@sr["With great power comes great responsibility. This page is intended for use by developers, for adding javscript and css into the page. Use this page only if you understand what you are doing."]</p>
6-
<div>
4+
<div class="d-flex justify-content-between align-items-center mb-3">
5+
<h1>@ViewBag.Title</h1>
6+
<a href="@Url.RouteUrl(pageRoutes.PageEditRouteName, new { slug=Model.Slug })" class="btn btn-secondary">@sr["Return to Page Editing"]</a>
7+
</div>
8+
<div class="alert alert-warning col-md-10 col-lg-8 py-2">
9+
@sr["With great power comes great responsibility. This page is intended for use by developers, for adding javscript and css into the page. Use this page only if you understand what you are doing."]
10+
</div>
11+
12+
<h2>@sr["Raw JavaScript"]</h2>
13+
<div class="mb-4">
14+
<form asp-controller="Page" asp-action="AddScriptResource" role="form">
15+
<div class="mb-3">
16+
<label asp-for="Script" class="form-label">@sr["Enter your JavaScript below. Do not include <script> tags."]</label>
17+
<p>
18+
@sr["Scripts are automatically validated for security - only safe DOM manipulation and event handling are permitted."] <br />
19+
</p>
20+
<input type="hidden" asp-for="Slug" />
21+
<textarea asp-for="Script" class="form-control" rows="8" data-bs-toggle="tooltip"
22+
title='@sr["Enter custom Javascript to run on your page. Do not include <script> tags."]'></textarea>
23+
<span asp-validation-for="Script" class="invalid-feedback"></span>
24+
</div>
25+
<button type="submit" class="btn btn-primary">@sr["Save JavaScript"]</button>
26+
</form>
27+
</div>
28+
29+
<h2>@sr["JavaScript URLs"]</h2>
30+
<div class="mb-4">
731
<table class="table table-striped table-hover">
832
<tr>
933
<th>@sr["Environment"]</th>
@@ -32,10 +56,10 @@
3256
</td>
3357
</tr>
3458
</table>
35-
3659
</div>
37-
<div>
3860
61+
<h2>@sr["CSS URLs"]</h2>
62+
<div class="mb-4">
3963
<table class="table table-striped table-hover">
4064
<tr>
4165
<th>@sr["Environment"]</th>
@@ -65,9 +89,8 @@
6589
</tr>
6690
</table>
6791
</div>
92+
6893
@section Scripts {
6994
<script src="~/cr/js/jquery.validate.min.js"></script>
7095
<script src="~/cr/js/jquery.validate.unobtrusive.min.js"></script>
71-
72-
}
73-
96+
}

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/Edit.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
}
174174
@if (showDev)
175175
{
176-
<a class="btn btn-primary" asp-route="@pageRoutes.PageDevelopRouteName" asp-route-slug="@Model.Slug">@sr["Developer Tools"]</a>
176+
<a class="btn btn-primary" asp-route="@pageRoutes.PageDevelopRouteName" asp-route-slug="@Model.Slug" data-unsaved-warning="@sr["You have unsaved changes in the editor. Are you sure you want to navigate to Developer Tools? Your changes will be lost."]">@sr["Developer Tools"]</a>
177177
}
178178
179179
</div>

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/EditScriptsPartial.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ else
2727
}
2828
}
2929
<script src="/csscsr/js/edit-script.js"></script>
30+
<script src="/csscsr/js/unsaved-changes-warning.js"></script>
3031
<partial name="SummernoteScripts" />

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/EditWithTemplate.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
}
157157
@if (showDev)
158158
{
159-
<a class="btn btn-primary" asp-route="@pageRoutes.PageDevelopRouteName" asp-route-slug="@Model.Slug">@sr["Developer Tools"]</a>
159+
<a class="btn btn-primary" asp-route="@pageRoutes.PageDevelopRouteName" asp-route-slug="@Model.Slug" data-unsaved-warning="@sr["You have unsaved changes in the editor. Are you sure you want to navigate to Developer Tools? Your changes will be lost."]">@sr["Developer Tools"]</a>
160160
}
161161
162162
</div>

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Page/EditWithTemplateScriptsPartial.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
}
3434
<script src="~/cr/js/bootstrap-tooltip-toggle.js"></script>
3535
<script src="/csscsr/js/edit-script.js"></script>
36+
<script src="/csscsr/js/unsaved-changes-warning.js"></script>
3637
<partial name="SummernoteScripts" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@model cloudscribe.SimpleContent.Web.ViewModels.PageViewModel
22
<script src="~/cr/js/ckeditor4114/plugins/codesnippet/lib/highlight/highlight.pack.js"></script>
33
<script src="~/cr/js/syntax-highlight-init.js"></script>
4+
5+
@if (Model.CurrentPage?.Script != null && !string.IsNullOrWhiteSpace(Model.CurrentPage.Script))
6+
{
7+
<script src="@Url.Action("InlineScript", "Page", new { pageId = Model.CurrentPage.Id, v = Model.CurrentPage.LastModified.Ticks })"></script>
8+
}

src/cloudscribe.SimpleContent.Models/Blog/Post.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ public static Post FromIPost(IPost post)
9696
post.CopyTo(p);
9797
return p;
9898
}
99-
99+
public string Script { get; set; }
100100
}
101101
}

src/cloudscribe.SimpleContent.Models/IContentItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public interface IContentItem
1111
string Content { get; set; }
1212
DateTime? PubDate { get; set; }
1313
string MetaDescription { get; set; }
14-
14+
string Script { get; set; }
1515
}
1616
}

src/cloudscribe.SimpleContent.Models/ModelExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ public static void CopyTo(this IPage input, IPage target)
310310
target.ShowCreatedDate = input.ShowCreatedDate;
311311
target.ShowLastModifiedBy = input.ShowLastModifiedBy;
312312
target.ShowLastModifiedDate = input.ShowLastModifiedDate;
313+
target.Script = input.Script;
313314
}
314315

315316
/// <summary>

0 commit comments

Comments
 (0)