From b1d34882a9f9bd996ba843e03472251663ee371e Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 30 Jul 2013 11:50:34 +0200 Subject: [PATCH] Make Markdown editor optional --- .../macroScripts/SwitchForumEditor.cshtml | 21 ++ .../masterpages/SwitchForumEditor.master | 5 + OurUmbraco.Site/scripts/forum/uForum.js | 10 +- .../our.umbraco.org/InsertImage.ascx | 57 +++-- OurUmbraco.Site/xslt/forum-createComment.xslt | 233 +++++++++++------- OurUmbraco.Site/xslt/forum-createTopic.xslt | 131 +++++++--- our.umbraco.org/our.umbraco.org.csproj | 4 +- .../usercontrols/HeaderLogin.ascx.cs | 2 + our.umbraco.org/usercontrols/InsertImage.ascx | 57 +++-- .../usercontrols/InsertImage.ascx.cs | 20 +- .../usercontrols/InsertImage.ascx.designer.cs | 36 +++ our.umbraco.org/usercontrols/Login.ascx.cs | 2 + uForum/Businesslogic/ForumEditor.cs | 78 ++++++ uForum/Library/Xslt.cs | 7 +- uForum/uForum.csproj | 1 + 15 files changed, 488 insertions(+), 176 deletions(-) create mode 100644 OurUmbraco.Site/macroScripts/SwitchForumEditor.cshtml create mode 100644 OurUmbraco.Site/masterpages/SwitchForumEditor.master create mode 100644 uForum/Businesslogic/ForumEditor.cs diff --git a/OurUmbraco.Site/macroScripts/SwitchForumEditor.cshtml b/OurUmbraco.Site/macroScripts/SwitchForumEditor.cshtml new file mode 100644 index 00000000..2eef0c3f --- /dev/null +++ b/OurUmbraco.Site/macroScripts/SwitchForumEditor.cshtml @@ -0,0 +1,21 @@ +@{ + var currentSite = new Uri(HttpContext.Current.Request.Url.AbsoluteUri); + var referrer = HttpContext.Current.Request.UrlReferrer; + + if (referrer != null && currentSite.Host == referrer.Host && currentSite.Port == referrer.Port && HttpContext.Current.Request.QueryString["EditorChoice"] != null) + { + var editorChoice = HttpContext.Current.Request.QueryString["EditorChoice"]; + uForum.Businesslogic.ForumEditor.SaveEditorChoice(editorChoice); + HttpContext.Current.Response.Redirect(referrer.ToString()); + } + else + { +

Error switching editors.

+ + } +} \ No newline at end of file diff --git a/OurUmbraco.Site/masterpages/SwitchForumEditor.master b/OurUmbraco.Site/masterpages/SwitchForumEditor.master new file mode 100644 index 00000000..1295a802 --- /dev/null +++ b/OurUmbraco.Site/masterpages/SwitchForumEditor.master @@ -0,0 +1,5 @@ +<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %> + + + + diff --git a/OurUmbraco.Site/scripts/forum/uForum.js b/OurUmbraco.Site/scripts/forum/uForum.js index 846be4a2..62cae73d 100644 --- a/OurUmbraco.Site/scripts/forum/uForum.js +++ b/OurUmbraco.Site/scripts/forum/uForum.js @@ -51,10 +51,14 @@ var uForum = function () { } }); }, - lookUp: function () { + lookUp: function (useMarkdown) { var query = jQuery("#title").val(); - query += " " + Markdown.App.getPreviewContent(); - + if (useMarkdown) { + query += " " + Markdown.App.getPreviewContent(); + } else { + query += " " + tinyMCE.get('topicBody').getContent(); + } + if (query.length <= 1) { jQuery("#topicsBox").fadeOut("fast"); } diff --git a/OurUmbraco.Site/usercontrols/our.umbraco.org/InsertImage.ascx b/OurUmbraco.Site/usercontrols/our.umbraco.org/InsertImage.ascx index 1a36cd28..361d7ffa 100644 --- a/OurUmbraco.Site/usercontrols/our.umbraco.org/InsertImage.ascx +++ b/OurUmbraco.Site/usercontrols/our.umbraco.org/InsertImage.ascx @@ -1,22 +1,25 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="InsertImage.ascx.cs" Inherits="our.usercontrols.InsertImage" %> + +
+
- - - - - +
- jQuery(document).ready(function(){ - jQuery("form").submit( function(e) { - e.preventDefault(); - - var topicId = ''; - var body = $("#wmd-input").val(); // Always save the raw markdown input, otherwise, we screw up editing - var comment = ''; + + +
+

+ We have an (experimental) Markdown editor for you to test:
Click here to switch to the Markdown Editor. +

+
+

+ +

- var url = ""; - - if(comment != ''){ - url = uForum.EditComment(comment , , body); - } else { - url = uForum.NewComment(topicId, , body); - } - - jQuery("#commentSuccess").show(); - jQuery("#topicForm").hide(); - }); - }); - -
-
-

- -

-
-
-
- -
-
- -
-
-
- -
-
-
- - - -
-

- Please login or Sign up To post replies -

-
-
+
- + + +
+ +
+ +
+ + + +
+

+ Please login or Sign up To post replies +

+
+
- + + + \ No newline at end of file diff --git a/OurUmbraco.Site/xslt/forum-createTopic.xslt b/OurUmbraco.Site/xslt/forum-createTopic.xslt index 292fcbe1..ffa3af2b 100644 --- a/OurUmbraco.Site/xslt/forum-createTopic.xslt +++ b/OurUmbraco.Site/xslt/forum-createTopic.xslt @@ -48,34 +48,66 @@ - -

Tags

+ + + +
+

+ We have an (experimental) Markdown editor for you to test:
Click here to switch to the Markdown Editor. +

+
+

+ +

+
+ + +
diff --git a/our.umbraco.org/our.umbraco.org.csproj b/our.umbraco.org/our.umbraco.org.csproj index c4cdfff5..141fbe96 100644 --- a/our.umbraco.org/our.umbraco.org.csproj +++ b/our.umbraco.org/our.umbraco.org.csproj @@ -270,7 +270,9 @@ ASPXCodeBehind - + + ASPXCodeBehind + diff --git a/our.umbraco.org/usercontrols/HeaderLogin.ascx.cs b/our.umbraco.org/usercontrols/HeaderLogin.ascx.cs index 6e612f30..79a0d7bf 100644 --- a/our.umbraco.org/usercontrols/HeaderLogin.ascx.cs +++ b/our.umbraco.org/usercontrols/HeaderLogin.ascx.cs @@ -137,6 +137,8 @@ namespace our.usercontrols umbraco.cms.businesslogic.member.Member.RemoveMemberFromCache(mem); umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(mem); + uForum.Businesslogic.ForumEditor.ClearEditorChoiceCookie(); + Response.Redirect(umbraco.presentation.nodeFactory.Node.GetCurrent().Url); } } diff --git a/our.umbraco.org/usercontrols/InsertImage.ascx b/our.umbraco.org/usercontrols/InsertImage.ascx index 1a36cd28..361d7ffa 100644 --- a/our.umbraco.org/usercontrols/InsertImage.ascx +++ b/our.umbraco.org/usercontrols/InsertImage.ascx @@ -1,22 +1,25 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="InsertImage.ascx.cs" Inherits="our.usercontrols.InsertImage" %> +