Skip to content

Commit

Permalink
improve dirty page behavior
Browse files Browse the repository at this point in the history
tweak category/tag slug generation
  • Loading branch information
ninianne98 committed Apr 27, 2024
1 parent 3c49a8c commit a2b5f58
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 111 deletions.
9 changes: 7 additions & 2 deletions CMSAdmin/Controllers/CmsAdminApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode
try {
Guid currentItemGuid = new Guid(ItemID);
var theSlug = CMSConfigHelper.DecodeBase64(TheSlug);
var originalSlug = theSlug;
theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant();
var matches = 0;
var count = 0;
Expand All @@ -681,8 +682,10 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode
if (matches > 0) {
count = 1;
while (count < 2000 && matches > 0) {
theSlug = string.Format("{0}-{1}", theSlug, count);
theSlug = string.Format("{0}-{1}", originalSlug, count);
theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant();
matches = ContentCategory.GetSimilar(siteid, currentItemGuid, theSlug);
count++;
}
}
}
Expand All @@ -691,8 +694,10 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode
if (matches > 0) {
count = 1;
while (count < 2000 && matches > 0) {
theSlug = string.Format("{0}-{1}", theSlug, count);
theSlug = string.Format("{0}-{1}", originalSlug, count);
theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant();
matches = ContentTag.GetSimilar(siteid, currentItemGuid, theSlug);
count++;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions CMSAdmin/Models/ContentPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public ContentPageModel() {
public Guid? VersionID { get; set; }
public Guid? ParentID { get; set; }
public string Mode { get; set; }
public string? SerialCache { get; set; } = string.Empty;
public bool VisitPage { get; set; }

public Dictionary<string, string> VersionHistory { get; set; }
Expand Down
199 changes: 100 additions & 99 deletions CMSAdmin/Views/CmsAdmin/BlogPostAddEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
bool bLocked = Model.ContentPage.IsPageLocked && Model.ContentPage.Heartbeat_UserId.HasValue;
}

@section scripts{
@section scripts {

<script type="text/javascript">
var webSvc = cmsGetServiceAddress();
Expand Down Expand Up @@ -79,7 +79,7 @@
"Yes": function () { OverwriteFileData(); }
};

if (theTitle.length > 0 ) {
if (theTitle.length > 0) {
if (theFile.length > 0 || theNav.length > 0) {
cmsAlertModalSmallBtns('There is already content title and/or filename, overwrite?', opts);
} else {
Expand Down Expand Up @@ -188,109 +188,109 @@

@if (Model.ContentPage.IsPageLocked) {
<text>
function EditHB() { }
function EditHB() { }

function cancelEditing() { }
function cancelEditing() { }

function deleteContent() { }
function deleteContent() { }

function cmsRecordCancellation() { }
function cmsRecordCancellation() { }

function openPage() {
var theURL = $('#OriginalFileName').val();
function openPage() {
var theURL = $('#OriginalFileName').val();

if (theURL.length > 1) {
window.setTimeout("location.href = '" + theURL + "';", 250);
} else {
cmsAlertModalSmall("No saved page to show.");
if (theURL.length > 1) {
window.setTimeout("location.href = '" + theURL + "';", 250);
} else {
cmsAlertModalSmall("No saved page to show.");
}
}
}
</text>
</text>

} else {

<text>
function openPage() {
var theURL = $('#OriginalFileName').val();
cmsOpenPage(theURL);
}
<text>
function openPage() {
var theURL = $('#OriginalFileName').val();
cmsOpenPage(theURL);
}

function EditHB() {
var dataObj = {};
dataObj["PageID"] = thisPageID;
function EditHB() {
var dataObj = {};
dataObj["PageID"] = thisPageID;

var webMthd = webSvc + "/RecordHeartbeat";
setTimeout("EditHB();", 25 * 1000);
var webMthd = webSvc + "/RecordHeartbeat";
setTimeout("EditHB();", 25 * 1000);

$.ajax({
type: "POST",
url: webMthd,
data: JSON.stringify(dataObj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: updateHeartbeat,
error: cmsAjaxFailedSwallow
});
}
$.ajax({
type: "POST",
url: webMthd,
data: JSON.stringify(dataObj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: updateHeartbeat,
error: cmsAjaxFailedSwallow
});
}

function updateHeartbeat(data, status) {
var hb = $('#cmsHeartBeat');
hb.empty().append('HB: ');
hb.append(data);
}
function updateHeartbeat(data, status) {
var hb = $('#cmsHeartBeat');
hb.empty().append('HB: ');
hb.append(data);
}

$(document).ready(function () {
setTimeout("EditHB();", 1500);
});
$(document).ready(function () {
setTimeout("EditHB();", 1500);
});

function cancelEditing() {
function cancelEditing() {

var opts = {
"No": function () { cmsAlertModalClose(); },
"Yes": function () {
cmsMakeOKToLeave();
cmsRecordCancellation();
window.setTimeout("location.href = '@SiteFilename.BlogPostIndexURL';", 500);
cmsAlertModalClose();
}
};
var opts = {
"No": function () { cmsAlertModalClose(); },
"Yes": function () {
cmsMakeOKToLeave();
cmsRecordCancellation();
window.setTimeout("location.href = '@SiteFilename.BlogPostIndexURL';", 500);
cmsAlertModalClose();
}
};

cmsAlertModalSmallBtns('Are you sure you want to leave the editor? All changes will be lost!', opts);
cmsAlertModalSmallBtns('Are you sure you want to leave the editor? All changes will be lost!', opts);

}
}

function deleteContent() {
function deleteContent() {

var opts = {
"No": function () { cmsAlertModalClose(); },
"Yes": function () {
cmsMakeOKToLeave();
$('#btnDelete').click();
cmsAlertModalClose();
}
};
var opts = {
"No": function () { cmsAlertModalClose(); },
"Yes": function () {
cmsMakeOKToLeave();
$('#btnDelete').click();
cmsAlertModalClose();
}
};

cmsAlertModalSmallBtns('Are you sure you want to delete this content? All version history and widget data will be lost!', opts);
}
cmsAlertModalSmallBtns('Are you sure you want to delete this content? All version history and widget data will be lost!', opts);
}

function cmsRecordCancellation() {
function cmsRecordCancellation() {

if (thePageID != '@Guid.Empty') {
if (thePageID != '@Guid.Empty') {

var webMthd = webSvc + "/CancelEditing";
var webMthd = webSvc + "/CancelEditing";

$.ajax({
type: "POST",
url: webMthd,
data: JSON.stringify({ ThisPage: thePageID }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: cmsAjaxGeneralCallback,
error: cmsAjaxFailed
});
$.ajax({
type: "POST",
url: webMthd,
data: JSON.stringify({ ThisPage: thePageID }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: cmsAjaxGeneralCallback,
error: cmsAjaxFailed
});
}
}
}
</text>
</text>
}

var cmsIsPageLocked = @Model.ContentPage.IsPageLocked.ToString().ToLowerInvariant();
Expand Down Expand Up @@ -385,8 +385,9 @@
<br />
<br />
</div>
@using (Html.BeginForm()) {
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "contentForm" })) {
@Html.AntiForgeryToken()
@Html.HiddenFor(m => m.SerialCache, new { @class = "non-serial-data" })

<div id="PageContents">
<table class="table-lg">
Expand Down Expand Up @@ -547,8 +548,8 @@
<div class="picker-area ui-widget-content ui-corner-bottom">
<div>
@Html.ListBoxFor(m => m.SelectedCategories,
new MultiSelectList(Model.CategoryOptions, "Value", "Text", Model.SelectedCategories),
new { @class = "chosen-select", size = 2, @data_placeholder = "select categories" })
new MultiSelectList(Model.CategoryOptions, "Value", "Text", Model.SelectedCategories),
new { @class = "chosen-select", size = 2, @data_placeholder = "select categories" })
</div>
</div>
</div>
Expand All @@ -565,8 +566,8 @@
<div class="picker-area ui-widget-content ui-corner-bottom">
<div>
@Html.ListBoxFor(m => m.SelectedTags,
new MultiSelectList(Model.TagOptions, "Value", "Text", Model.SelectedTags),
new { @class = "chosen-select", size = 2, @data_placeholder = "select tags" })
new MultiSelectList(Model.TagOptions, "Value", "Text", Model.SelectedTags),
new { @class = "chosen-select", size = 2, @data_placeholder = "select tags" })
</div>
</div>
</div>
Expand Down Expand Up @@ -668,22 +669,22 @@
<input type="button" id="btnCancel" value="Cancel" onclick="cancelEditing();" />
&nbsp;&nbsp;
@if (Model.ContentPage.Root_ContentID != Guid.Empty) {
<input type="button" id="btnDeleteButton" value="Delete" onclick="return deleteContent();" />
<input type="button" id="btnDeleteButton" value="Delete" onclick="return deleteContent();" />
}
</td>
@if (Model.ContentPage.Root_ContentID != Guid.Empty) {
<td>
&nbsp;&nbsp;
</td>
<td align="right">
@Html.DropDownList("ddlVersions", new SelectList(Model.VersionHistory, "Key", "Value"), "[Select Version]")
</td>
<td>
&nbsp;&nbsp;
</td>
<td align="left">
<input type="button" onclick="javascript:cmsPageVersionNav();" name="btnReview" value="Review / Revert" />
</td>
<td>
&nbsp;&nbsp;
</td>
<td align="right">
@Html.DropDownList("ddlVersions", new SelectList(Model.VersionHistory, "Key", "Value"), "[Select Version]")
</td>
<td>
&nbsp;&nbsp;
</td>
<td align="left">
<input type="button" onclick="javascript:cmsPageVersionNav();" name="btnReview" value="Review / Revert" />
</td>
}
</tr>
</table>
Expand All @@ -708,7 +709,7 @@
</div>
</div>

}
}

<div style="display: none">
@using (Html.BeginForm("DeleteContentPage", CmsRouteConstants.CmsController.Admin)) {
Expand Down Expand Up @@ -787,7 +788,7 @@
</script>
<script type="text/javascript">
$(document).ready(function () {
$(".chosen-select").chosen({width: "695px"});
$(".chosen-select").chosen({ width: "695px" });

setTimeout("$('#jqtabs').tabs('option', 'active', 1);", 500);
});
Expand Down
17 changes: 9 additions & 8 deletions CMSAdmin/Views/CmsAdmin/PageAddEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
bool bLocked = Model.ContentPage.IsPageLocked && Model.ContentPage.Heartbeat_UserId.HasValue;
}

@section scripts{
@section scripts {

<script type="text/javascript">
var webSvc = cmsGetServiceAddress();
Expand Down Expand Up @@ -151,7 +151,7 @@

@if (Model.ContentPage.IsPageLocked) {
<text>
function EditHB() { }
function EditHB() { }

function cancelEditing() { }

Expand All @@ -173,10 +173,10 @@
} else {

<text>
function openPage() {
var theURL = $('#OriginalFileName').val();
cmsOpenPage(theURL);
}
function openPage() {
var theURL = $('#OriginalFileName').val();
cmsOpenPage(theURL);
}

function EditHB() {
var dataObj = {};
Expand Down Expand Up @@ -259,7 +259,7 @@
</text>
}

var cmsIsPageLocked = @Model.ContentPage.IsPageLocked.ToString().ToLowerInvariant();
var cmsIsPageLocked = @Model.ContentPage.IsPageLocked.ToString().ToLowerInvariant();

$(window).bind('beforeunload', function () {
//cmsConfirmLeavingPage = false;
Expand Down Expand Up @@ -351,8 +351,9 @@
<br />
<br />
</div>
@using (Html.BeginForm()) {
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "contentForm" })) {
@Html.AntiForgeryToken()
@Html.HiddenFor(m => m.SerialCache, new { @class = "non-serial-data" })

<div id="PageContents">
<table class="table-lg">
Expand Down
6 changes: 4 additions & 2 deletions CMSAdmin/Views/CmsContent/_AdvancedEditHead.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

@*
<!-- jQuery CDN -->
<script> setTimeout(function () { window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"><\/script>'); }, 100); </script>
<script> setTimeout(function () { window.jQuery.ui || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript"><\/script>'); }, 200); </script>
<!-- https://cdnjs.com/libraries/jquery -->
<!-- https://cdnjs.com/libraries/jqueryui -->
<script> setTimeout(function () { window.jQuery || document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js" type="text/javascript"><\/script>'); }, 100); </script>
<script> setTimeout(function () { window.jQuery.ui || document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.3/jquery-ui.min.js" type="text/javascript"><\/script>'); }, 200); </script>
*@
@*
<script> (!window.jQuery || (typeof jQuery == 'undefined')) || document.write('<script src="@jquery.GeneralUri" type="text/javascript"><\/script>'); </script>
Expand Down
Loading

0 comments on commit a2b5f58

Please sign in to comment.