From 853bdd7b1203ddbd504f1d6809c4e754d8cfa0e7 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 12:17:11 -0700 Subject: [PATCH 01/50] Update "View Page" link to open in a new tab --- OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml index 20d4b8b1..2f924fff 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml @@ -75,7 +75,7 @@
Topic ID
@Model.Topic.Id
Current
-
View Page
+
View Page
From 7777eecee23347c0b67fbce20adb145fe7f6f6bd Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 12:20:15 -0700 Subject: [PATCH 02/50] Removed explicit removal of deleted attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `ITopicRepository` implementations—such as `SqlTopicRepository`—already handle empty or null `AttributeValue` instances. As such, while it's fine to continue to `Remove()` the `AttributeValue`, it's effectively redundant with the next condition, which will use `SetValue()`. --- OnTopic.Editor.AspNetCore/Controllers/EditorController.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs index 06857aaa..8f2f9bc3 100644 --- a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs +++ b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs @@ -346,9 +346,6 @@ public async Task Edit( else if (attribute.Key.Equals("Key")) { topic.Key = attributeValue.Value.Replace(" ", ""); } - else if (String.IsNullOrEmpty(attributeValue.Value)) { - topic.Attributes.Remove(attribute.Key); - } else { topic.Attributes.SetValue(attribute.Key, attributeValue.Value); } From ba2acb4acf5431dd91c413fcf3002bf2c84268c6 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 12:23:57 -0700 Subject: [PATCH 03/50] Explicitly set `Delete()` to be `isRecursive` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `ITopicRepository.Delete()` method accepts an optional overload, `isRecursive`, which was originally set to a default value of `false`. Due to a bug in the implementation, however, this wasn't actually enforced—oops. While this is now fixed, to maintain backward compatibility, it has been updated to a default of `true`. In the next version of the OnTopic library, however, it will be reset back to `false` as a breaking change. To prevent the need to update this at that time, it is now being explicitly set to `true` in the code. --- OnTopic.Editor.AspNetCore/Controllers/EditorController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs index 8f2f9bc3..83ca338a 100644 --- a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs +++ b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs @@ -431,7 +431,7 @@ public IActionResult Delete(bool isModal = false) { | Lock the Topic repository before executing the delete \-------------------------------------------------------------------------------------------------------------------------*/ lock (TopicRepository) { - TopicRepository.Delete(CurrentTopic); + TopicRepository.Delete(CurrentTopic, true); } /*-------------------------------------------------------------------------------------------------------------------------- @@ -723,7 +723,7 @@ public async Task Import(IFormFile jsonFile, [Bind(Prefix = "Impo var unmatchedTopics = topics.Except(target.FindAll(t => !t.IsNew)); foreach (var unmatchedTopic in unmatchedTopics) { - TopicRepository.Delete(unmatchedTopic); + TopicRepository.Delete(unmatchedTopic, true); } /*------------------------------------------------------------------------------------------------------------------------ From 0e6999e83f8e9346db7210c48a7d1fe353592a13 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 12:24:09 -0700 Subject: [PATCH 04/50] Fixed typos in XML Doc --- OnTopic.Editor.AspNetCore/Controllers/EditorController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs index 83ca338a..8578d51a 100644 --- a/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs +++ b/OnTopic.Editor.AspNetCore/Controllers/EditorController.cs @@ -715,9 +715,9 @@ public async Task Import(IFormFile jsonFile, [Bind(Prefix = "Impo /*------------------------------------------------------------------------------------------------------------------------ | DELETE UNMATCHED TOPICS >------------------------------------------------------------------------------------------------------------------------- - | ### HACK JJC20200327: The Data Transfer library doesnt have access to the ITopicRepository, so it can't delete topics. + | ### HACK JJC20200327: The Data Transfer library doesn't have access to the ITopicRepository, so it can't delete topics. | Instead, it removes them from the topic graph. But the ITopicRepository implementations don't have a means of detecting - | removed topics during a recursive save and, therefore, the deletions aren't persited to the database. To mitigate this, + | removed topics during a recursive save and, therefore, the deletions aren't persisted to the database. To mitigate this, | we evaluate the topic graph after the save, and then delete any orphans. \-----------------------------------------------------------------------------------------------------------------------*/ var unmatchedTopics = topics.Except(target.FindAll(t => !t.IsNew)); From 09f3744e88390ab541f1fef3072e90678ba93670 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 15:58:44 -0700 Subject: [PATCH 05/50] Defer inline scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation to defer JavaScript includes, all embedded JavaScript is being deferred by wrapping the calls in a `DOMContentLoaded` event listener. This is necessary since a) most inline scripts will rely on an external script (e.g., jQuery), and b) there isn't a way to `defer` an inline script. While I was at it, I established a new section to the `_Layout.cshtml` called `InlineScript`—though this is of limited use since most inline script is within view components, which cannot override the master layout's sections. Still, if used, it will automatically wrap any script in that section in a `DOMContentLoaded` event listener. For the most part, this was a straight forward exchange. In a couple of cases, concessions needed to be made to ensure that e.g. variables were available to other script blocks (e.g., by placing the variable declaration outside of the event listener block). --- .../Components/ContentTypeList/Default.cshtml | 32 +++++----- .../Editor/Components/DateTime/Default.cshtml | 48 +++++++------- .../Components/NestedTopicList/Default.cshtml | 58 ++++++++++------- .../Components/Relationship/Default.cshtml | 18 +++--- .../TokenizedTopicList/Default.cshtml | 33 +++++----- .../Areas/Editor/Views/Editor/Edit.cshtml | 62 +++++++++---------- .../Areas/Editor/Views/Shared/_Layout.cshtml | 33 +++++++--- 7 files changed, 156 insertions(+), 128 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/ContentTypeList/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/ContentTypeList/Default.cshtml index ef56dc16..4b8eeb59 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/ContentTypeList/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/ContentTypeList/Default.cshtml @@ -14,21 +14,23 @@ else if (Model.TopicList.Count > 2) { } diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/DateTime/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/DateTime/Default.cshtml index 103285a4..23e4943b 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/DateTime/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/DateTime/Default.cshtml @@ -16,30 +16,32 @@ /> \ No newline at end of file diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/NestedTopicList/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/NestedTopicList/Default.cshtml index cde62a49..f033b0e4 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/NestedTopicList/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/NestedTopicList/Default.cshtml @@ -14,31 +14,39 @@
@@ -64,10 +72,12 @@ diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship/Default.cshtml index 7eaf92cb..004c2778 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship/Default.cshtml @@ -14,12 +14,16 @@
\ No newline at end of file diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/TokenizedTopicList/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/TokenizedTopicList/Default.cshtml index 36ca6fc1..45527284 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/TokenizedTopicList/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/TokenizedTopicList/Default.cshtml @@ -18,21 +18,24 @@ } \ No newline at end of file diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml index 5156e461..e87962e6 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml @@ -87,16 +87,29 @@ - @if (!Model.IsModal) { - - } - - @RenderSection("scripts", required: false) + @RenderSection("Scripts", required: false) + + \ No newline at end of file From ecfb1b5609b137228b6e2e9a4b5fe8642a16dcf7 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 16:01:19 -0700 Subject: [PATCH 06/50] Defer referenced scripts With the inline scripts deferred (09f3744) we can now safely defer the referenced scripts. This speeds up the initial page rendering time by not waiting for the JavaScript to load before rendering the DOM. Note that we're _not_ deferring CKEditor as it's such a dominant aspect of forms that use the HTML control that it creates an unwelcome flash of unstyled content (FOUC). --- .../Areas/Editor/Views/Shared/_Layout.cshtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml index e87962e6..a04258a4 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_Layout.cshtml @@ -9,9 +9,9 @@ @Model.Topic.Title (OnTopic) - - + + @@ -85,7 +85,7 @@ - + @RenderSection("Scripts", required: false) From 1052cf83fe89ee5e4c7f3c879e74c7e5c0e94e04 Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 16:02:51 -0700 Subject: [PATCH 07/50] Removed handling of `id` conflicts in CKEditor code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not entirely clear why this code is needed, as current versions of CKEditor, at least, don't mind being bound to a duplicate `id` that's within an iFrame—which is what this script was setup to avoid. Further, when placed within a `DOMContentLoaded` event listener, this throws errors. Those are probably not too hard to fix, but as this doesn't seem to serve a purpose anymore, I'm just going to remove it entirely. As part of this, we can significantly simplify the initialization of CKEditor, as we no longer need a `setEditorInstance()` wrapper for it. Further, while we _could_ `defer` CKEditor, this creates a flash of unstyled content (FOUC) that's irritating given how prominent editor instances might be on a given form. As such, the CKEditor script is not deferred (ecfb1b5), and thus there's no reason to wrap it in a `DOMContentLoaded` event listener. (Had we kept the original script, it still would have needed to be wrapped in a `DOMContentLoaded` event listener since the original script relied upon jQuery, which _is_ deferred.) --- .../Editor/Components/HTML/Default.cshtml | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/HTML/Default.cshtml b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/HTML/Default.cshtml index 67cebb09..f0d572bc 100644 --- a/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/HTML/Default.cshtml +++ b/OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/HTML/Default.cshtml @@ -26,28 +26,9 @@ > \ No newline at end of file From bb727cd4e18d6eb38cc74fbd182b081f79dfd39e Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Thu, 24 Sep 2020 16:03:24 -0700 Subject: [PATCH 08/50] Added `form-control` class to backing field Once CKEditor initializes, the `