Make Markdown editor optional
This commit is contained in:
@@ -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
|
||||
{
|
||||
<p>Error switching editors.</p>
|
||||
<ul style="display: none;">
|
||||
<li>referrer not null? @(referrer != null)</li>
|
||||
<li>hosts match? @(referrer != null && currentSite.Host == referrer.Host)</li>
|
||||
<li>ports match? @(referrer != null && currentSite.Port == referrer.Port)</li>
|
||||
<li>editorchoice not null? @(HttpContext.Current.Request.QueryString["EditorChoice"] != null)</li>
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
|
||||
<umbraco:Macro Alias="SwitchForumEditor" runat="server" />
|
||||
</asp:Content>
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="InsertImage.ascx.cs"
|
||||
Inherits="our.usercontrols.InsertImage" %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var imageInserted = false;
|
||||
var imageInserting = false;
|
||||
var imageLink;
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
// The Markdown callback expects a single parameter: the path to the image as a string.
|
||||
// PageDown creates an overlay when opening the insert image popup. To remove that overlay, we need to trigger the PageDown callback even when just closing the popup. onbeforeunload seems to be the answer.
|
||||
if (imageInserted) {
|
||||
window.opener.forumInsertImageCallback(imageLink);
|
||||
} else if (!imageInserting) {
|
||||
window.opener.forumInsertImageCallback(null);
|
||||
}
|
||||
};
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown1">
|
||||
var imageInserted = false;
|
||||
var imageInserting = false;
|
||||
var imageLink;
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
// The Markdown callback expects a single parameter: the path to the image as a string.
|
||||
// PageDown creates an overlay when opening the insert image popup. To remove that overlay, we need to trigger the PageDown callback even when just closing the popup. onbeforeunload seems to be the answer.
|
||||
if (imageInserted) {
|
||||
window.opener.forumInsertImageCallback(imageLink);
|
||||
} else if (!imageInserting) {
|
||||
window.opener.forumInsertImageCallback(null);
|
||||
}
|
||||
};
|
||||
</asp:PlaceHolder>
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
jQuery("#insert").click(function () {
|
||||
@@ -27,9 +30,11 @@
|
||||
CloseDialog();
|
||||
});
|
||||
|
||||
jQuery("#<%= btnUpload.ClientID %>").click(function () {
|
||||
imageInserting = true;
|
||||
});
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown2">
|
||||
jQuery("#<%= btnUpload.ClientID %>").click(function () {
|
||||
imageInserting = true;
|
||||
});
|
||||
</asp:PlaceHolder>
|
||||
|
||||
if (jQuery("#<%= tb_url.ClientID %>").val().length > 0) {
|
||||
ShowImage();
|
||||
@@ -79,10 +84,22 @@
|
||||
}
|
||||
|
||||
function InsertImage() {
|
||||
// When we insert a image, we basically just close the dialog and let the unbeforeunload function do the rest of the work.
|
||||
imageLink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
imageInserted = true;
|
||||
CloseDialog();
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageRte">
|
||||
imglink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
origimglink = imglink.replace('rs/', '');
|
||||
|
||||
img = "<a href='" + origimglink + "' target='_blank'><img border='0' src='" + imglink + "' /></a>";
|
||||
|
||||
tinyMCEPopup.editor.execCommand("mceInsertContent", false, img);
|
||||
CloseDialog();
|
||||
</asp:PlaceHolder>
|
||||
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown3">
|
||||
// When we insert a image, we basically just close the dialog and let the unbeforeunload function do the rest of the work.
|
||||
imageLink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
imageInserted = true;
|
||||
CloseDialog();
|
||||
</asp:PlaceHolder>
|
||||
}
|
||||
function CloseDialog() {
|
||||
tinyMCEPopup.close();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xsl:stylesheet [
|
||||
<!ENTITY nbsp " ">
|
||||
<!ENTITY nbsp " ">
|
||||
]>
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
@@ -8,98 +8,155 @@
|
||||
xmlns:msxml="urn:schemas-microsoft-com:xslt"
|
||||
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:uForum="urn:uForum"
|
||||
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets uForum ">
|
||||
<xsl:output method="html" omit-xml-declaration="yes"/>
|
||||
<xsl:param name="currentPage"/>
|
||||
<xsl:variable name="body" select="umbraco.library:Request('commentBody')"/>
|
||||
<xsl:variable name="topicID" select="number(umbraco.library:ContextKey('topicID'))"/>
|
||||
<xsl:variable name="commentID" select="umbraco.library:RequestQueryString('id')"/>
|
||||
<xsl:variable name="tags" select="umbraco.library:Request('tags')"/>
|
||||
<xsl:output method="html" omit-xml-declaration="yes"/>
|
||||
<xsl:param name="currentPage"/>
|
||||
<xsl:variable name="body" select="umbraco.library:Request('commentBody')"/>
|
||||
<xsl:variable name="topicID" select="number(umbraco.library:ContextKey('topicID'))"/>
|
||||
<xsl:variable name="commentID" select="umbraco.library:RequestQueryString('id')"/>
|
||||
<xsl:variable name="tags" select="umbraco.library:Request('tags')"/>
|
||||
|
||||
<xsl:variable name="maxitems">10</xsl:variable>
|
||||
<xsl:variable name="_body">
|
||||
<xsl:if test="$commentID != ''">
|
||||
<xsl:value-of select="uForum:Comment($commentID)//body"/>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:template match="/">
|
||||
<xsl:variable name="maxitems">10</xsl:variable>
|
||||
<xsl:variable name="_body">
|
||||
<xsl:if test="$commentID != ''">
|
||||
<xsl:value-of select="uForum:Comment($commentID)//body"/>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:template match="/">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$body != ''">
|
||||
<div class='success'>
|
||||
<h4>your reply has been created</h4>
|
||||
<p>Refresh the page to view it in the list</p>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$body != ''">
|
||||
<div class='success'>
|
||||
<h4>your reply has been created</h4>
|
||||
<p>Refresh the page to view it in the list</p>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:when test="umbraco.library:IsLoggedOn()">
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('tinyMce', '/scripts/tiny_mce_update/tiny_mce_src.js')"/>
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('uForum', '/scripts/forum/uForum.js?v=6')"/>
|
||||
|
||||
<xsl:if test="uForum:UseMarkdownEditor()">
|
||||
<xsl:value-of select="umbraco.library:RegisterStyleSheetFile('Markdown.Styles', '/css/forum/pagedown.css')"/>
|
||||
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('Markdown.Converter', '/scripts/forum/Markdown.Converter.js')"/>
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('Markdown.Sanitizer', '/scripts/forum/Markdown.Sanitizer.js')"/>
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('Markdown.Editor', '/scripts/forum/Markdown.Editor.js')"/>
|
||||
</xsl:if>
|
||||
|
||||
<script type="text/javascript">
|
||||
uForum.ForumEditor("commentBody");
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
<xsl:choose>
|
||||
<xsl:when test="uForum:UseMarkdownEditor()">
|
||||
jQuery("form").submit( function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var topicId = '<xsl:value-of select="$topicID" />';
|
||||
var body = $("#wmd-input").val(); // Always save the raw markdown input, otherwise, we screw up editing
|
||||
var comment = '<xsl:value-of select="$commentID" />';
|
||||
|
||||
var url = "";
|
||||
|
||||
if(comment != ''){
|
||||
url = uForum.EditComment(comment , <xsl:value-of select="$maxitems" />, body);
|
||||
} else {
|
||||
url = uForum.NewComment(topicId, <xsl:value-of select="$maxitems" />, body);
|
||||
}
|
||||
|
||||
jQuery("#commentSuccess").show();
|
||||
jQuery("#topicForm").hide();
|
||||
});
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
jQuery("form").submit( function(){
|
||||
var topicId = '<xsl:value-of select="$topicID" />';
|
||||
var body = tinyMCE.get('commentBody').getContent();
|
||||
|
||||
var comment = '<xsl:value-of select="$commentID" />';
|
||||
|
||||
var url = "";
|
||||
|
||||
if(comment != ''){
|
||||
url = uForum.EditComment(comment , <xsl:value-of select="$maxitems" />, body);
|
||||
} else {
|
||||
url = uForum.NewComment(topicId, <xsl:value-of select="$maxitems" />, body);
|
||||
}
|
||||
|
||||
jQuery("#commentSuccess").show();
|
||||
jQuery("#topicForm").hide();
|
||||
|
||||
return false;
|
||||
});
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
});
|
||||
</script>
|
||||
<div id="topicForm">
|
||||
<fieldset>
|
||||
<xsl:choose>
|
||||
<xsl:when test="umbraco.library:IsLoggedOn()">
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('tinyMce', '/scripts/tiny_mce_update/tiny_mce_src.js')"/>
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('uForum', '/scripts/forum/uForum.js?v=6')"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
uForum.ForumEditor("commentBody");
|
||||
<xsl:when test="uForum:UseMarkdownEditor()">
|
||||
<div class="success">
|
||||
<h4 style="text-align: center; margin: 2px;">
|
||||
You're using the (experimental) Markdown editor. <br/><a href="/SwitchForumEditor?EditorChoice=Rte">Switch back to the old Rich Text Editor?</a>
|
||||
</h4>
|
||||
</div>
|
||||
<p class="tinymce-container">
|
||||
<textarea style="width: 100%; height: 300px" id="commentBody">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</p>
|
||||
<div class="wmd-container">
|
||||
<div class="wmd-panel">
|
||||
<div id="wmd-button-bar"></div>
|
||||
<textarea class="wmd-input comment" id="wmd-input">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview comment"></div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var editor = Markdown.App.getEditor();
|
||||
editor.run();
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
jQuery("form").submit( function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var topicId = '<xsl:value-of select="$topicID" />';
|
||||
var body = $("#wmd-input").val(); // Always save the raw markdown input, otherwise, we screw up editing
|
||||
var comment = '<xsl:value-of select="$commentID" />';
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<div class="success">
|
||||
<h4 style="text-align: center; margin: 2px;">
|
||||
We have an (experimental) Markdown editor for you to test: <br/><a href="/SwitchForumEditor?EditorChoice=Markdown">Click here to switch to the Markdown Editor.</a>
|
||||
</h4>
|
||||
</div>
|
||||
<p>
|
||||
<textarea style="width: 100%; height: 300px" id="commentBody">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</p>
|
||||
|
||||
var url = "";
|
||||
|
||||
if(comment != ''){
|
||||
url = uForum.EditComment(comment , <xsl:value-of select="$maxitems" />, body);
|
||||
} else {
|
||||
url = uForum.NewComment(topicId, <xsl:value-of select="$maxitems" />, body);
|
||||
}
|
||||
|
||||
jQuery("#commentSuccess").show();
|
||||
jQuery("#topicForm").hide();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div id="topicForm">
|
||||
<fieldset>
|
||||
<p class="tinymce-container">
|
||||
<textarea style="width: 100%; height: 300px" id="commentBody">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</p>
|
||||
<div class="wmd-container">
|
||||
<div class="wmd-panel">
|
||||
<div id="wmd-button-bar"></div>
|
||||
<textarea class="wmd-input comment" id="wmd-input">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview comment"></div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var editor = Markdown.App.getEditor();
|
||||
editor.run();
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="buttons">
|
||||
<input type="submit" value="submit" id="btCreateTopic"/>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div id="commentSuccess" style="display: none" class='success'>
|
||||
<h4 style="text-align: center;">Posting your reply</h4>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<div class="notice">
|
||||
<h4 style="text-align: center;">
|
||||
Please <a href="/member/login?redirectUrl={umbraco.library:UrlEncode(uForum:NiceTopicUrl($topicID))}">login</a> or <a href="/member/signup">Sign up</a> To post replies
|
||||
</h4>
|
||||
</div>
|
||||
</xsl:otherwise>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</fieldset>
|
||||
|
||||
<div class="buttons">
|
||||
<input type="submit" value="submit" id="btCreateTopic"/>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div id="commentSuccess" style="display: none" class='success'>
|
||||
<h4 style="text-align: center;">Posting your reply</h4>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<div class="notice">
|
||||
<h4 style="text-align: center;">
|
||||
Please <a href="/member/login?redirectUrl={umbraco.library:UrlEncode(uForum:NiceTopicUrl($topicID))}">login</a> or <a href="/member/signup">Sign up</a> To post replies
|
||||
</h4>
|
||||
</div>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -48,34 +48,66 @@
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('select2', '/scripts/forum/select2/select2-new.js?v=6')"/>
|
||||
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('tags', '/scripts/forum/tags.js?v=6')"/>
|
||||
<script type="text/javascript">
|
||||
uForum.ForumEditor("topicBody");
|
||||
uForum.ForumEditor("topicBody");
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
window.setInterval(function() {
|
||||
uForum.lookUp();
|
||||
}, 10000);
|
||||
jQuery(document).ready(function(){
|
||||
<xsl:choose>
|
||||
<xsl:when test="uForum:UseMarkdownEditor()">
|
||||
window.setInterval(function() {
|
||||
uForum.lookUp(true);
|
||||
uForum.lookUp(false);
|
||||
}, 10000);
|
||||
|
||||
jQuery("form").submit( function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
jQuery("#btCreateTopic").attr("disabled", "true");
|
||||
jQuery("#topicForm").hide();
|
||||
jQuery(".success").show();
|
||||
jQuery("form").submit( function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var topicId = '<xsl:value-of select="$id"/>';
|
||||
var forumId = <xsl:value-of select="$currentPage/@id"/>;
|
||||
var title = jQuery("#title").val();
|
||||
var body = $("#wmd-input").val(); // Always save the raw markdown input, otherwise, we screw up editing
|
||||
var tags = getTags(); //json string of tags with weight and actual tag
|
||||
if(topicId !== "") {
|
||||
uForum.EditTopic(topicId, title, body,tags);
|
||||
}
|
||||
else {
|
||||
uForum.NewTopic(forumId, title, body,tags);
|
||||
}
|
||||
|
||||
jQuery("#btCreateTopic").attr("disabled", "true");
|
||||
jQuery("#topicForm").hide();
|
||||
jQuery(".success").show();
|
||||
|
||||
var topicId = '<xsl:value-of select="$id"/>';
|
||||
var forumId = <xsl:value-of select="$currentPage/@id"/>;
|
||||
var title = jQuery("#title").val();
|
||||
var body = $("#wmd-input").val(); // Always save the raw markdown input, otherwise, we screw up editing
|
||||
|
||||
var tags = getTags(); //json string of tags with weight and actual tag
|
||||
|
||||
if(topicId !== "") {
|
||||
uForum.EditTopic(topicId, title, body,tags);
|
||||
}
|
||||
else {
|
||||
uForum.NewTopic(forumId, title, body,tags);
|
||||
}
|
||||
});
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
jQuery("#topicForm #title").focusout(function() {
|
||||
uForum.lookUp(false)
|
||||
});
|
||||
|
||||
jQuery("form").submit( function() {
|
||||
jQuery("#btCreateTopic").attr("disabled", "true");
|
||||
jQuery("#topicForm").hide();
|
||||
jQuery(".success").show();
|
||||
|
||||
var topicId = '<xsl:value-of select="$id"/>';
|
||||
var forumId = <xsl:value-of select="$currentPage/@id"/>;
|
||||
var title = jQuery("#title").val();
|
||||
var body = tinyMCE.get('topicBody').getContent();
|
||||
|
||||
var tags = getTags(); //json string of tags with weight and actual tag
|
||||
|
||||
if(topicId !== "") {
|
||||
uForum.EditTopic(topicId, title, body );
|
||||
} else {
|
||||
uForum.NewTopic(forumId, title, body );
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
get the selected tags and return json
|
||||
@@ -108,29 +140,52 @@
|
||||
<p>
|
||||
<input type="text" id="title" class="title" style="width: 670px;" value="{$_title}" />
|
||||
</p>
|
||||
<p class="tinymce-container">
|
||||
<xsl:choose>
|
||||
<xsl:when test="uForum:UseMarkdownEditor()">
|
||||
<div class="success">
|
||||
<h4 style="text-align: center; margin: 2px;">
|
||||
You're using the (experimental) Markdown editor. <br/><a href="/SwitchForumEditor?EditorChoice=Rte">Switch back to the old Rich Text Editor?</a>
|
||||
</h4>
|
||||
</div>
|
||||
<p class="tinymce-container">
|
||||
<textarea style="width: 680px; height: 300px" id="topicBody">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</p>
|
||||
<div class="wmd-container">
|
||||
</p>
|
||||
|
||||
<div class="wmd-container">
|
||||
<div class="wmd-panel">
|
||||
<div id="wmd-button-bar"></div>
|
||||
<textarea class="wmd-input topic" id="wmd-input">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
<div id="wmd-button-bar"></div>
|
||||
<textarea class="wmd-input topic" id="wmd-input">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview topic"></div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
Markdown.App.getEditor().run();
|
||||
})();
|
||||
(function () {
|
||||
Markdown.App.getEditor().run();
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<p>Tags</p>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<div class="success">
|
||||
<h4 style="text-align: center; margin: 2px;">
|
||||
We have an (experimental) Markdown editor for you to test: <br/><a href="/SwitchForumEditor?EditorChoice=Markdown">Click here to switch to the Markdown Editor.</a>
|
||||
</h4>
|
||||
</div>
|
||||
<p>
|
||||
<textarea style="width: 680px; height: 300px" id="topicBody">
|
||||
<xsl:value-of disable-output-escaping="yes" select="$_body"/>
|
||||
</textarea>
|
||||
</p>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<!--<p>Tags</p>
|
||||
<div id="tag-container">
|
||||
<ul name="tags" id="tags" style="width: 300px"></ul>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="buttons">
|
||||
<input type="submit" value="submit" id="btCreateTopic"/>
|
||||
<xsl:if test="$id != ''">
|
||||
|
||||
@@ -270,7 +270,9 @@
|
||||
<Content Include="usercontrols\Forgotpassword.ascx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="usercontrols\HeaderLogin.ascx" />
|
||||
<Content Include="usercontrols\HeaderLogin.ascx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="usercontrols\Login.ascx" />
|
||||
<Content Include="usercontrols\ProjectCollabRequest.ascx" />
|
||||
<Content Include="usercontrols\ProjectEditor.ascx" />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="InsertImage.ascx.cs"
|
||||
Inherits="our.usercontrols.InsertImage" %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var imageInserted = false;
|
||||
var imageInserting = false;
|
||||
var imageLink;
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
// The Markdown callback expects a single parameter: the path to the image as a string.
|
||||
// PageDown creates an overlay when opening the insert image popup. To remove that overlay, we need to trigger the PageDown callback even when just closing the popup. onbeforeunload seems to be the answer.
|
||||
if (imageInserted) {
|
||||
window.opener.forumInsertImageCallback(imageLink);
|
||||
} else if (!imageInserting) {
|
||||
window.opener.forumInsertImageCallback(null);
|
||||
}
|
||||
};
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown1">
|
||||
var imageInserted = false;
|
||||
var imageInserting = false;
|
||||
var imageLink;
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
// The Markdown callback expects a single parameter: the path to the image as a string.
|
||||
// PageDown creates an overlay when opening the insert image popup. To remove that overlay, we need to trigger the PageDown callback even when just closing the popup. onbeforeunload seems to be the answer.
|
||||
if (imageInserted) {
|
||||
window.opener.forumInsertImageCallback(imageLink);
|
||||
} else if (!imageInserting) {
|
||||
window.opener.forumInsertImageCallback(null);
|
||||
}
|
||||
};
|
||||
</asp:PlaceHolder>
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
jQuery("#insert").click(function () {
|
||||
@@ -27,9 +30,11 @@
|
||||
CloseDialog();
|
||||
});
|
||||
|
||||
jQuery("#<%= btnUpload.ClientID %>").click(function () {
|
||||
imageInserting = true;
|
||||
});
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown2">
|
||||
jQuery("#<%= btnUpload.ClientID %>").click(function () {
|
||||
imageInserting = true;
|
||||
});
|
||||
</asp:PlaceHolder>
|
||||
|
||||
if (jQuery("#<%= tb_url.ClientID %>").val().length > 0) {
|
||||
ShowImage();
|
||||
@@ -79,10 +84,22 @@
|
||||
}
|
||||
|
||||
function InsertImage() {
|
||||
// When we insert a image, we basically just close the dialog and let the unbeforeunload function do the rest of the work.
|
||||
imageLink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
imageInserted = true;
|
||||
CloseDialog();
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageRte">
|
||||
imglink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
origimglink = imglink.replace('rs/', '');
|
||||
|
||||
img = "<a href='" + origimglink + "' target='_blank'><img border='0' src='" + imglink + "' /></a>";
|
||||
|
||||
tinyMCEPopup.editor.execCommand("mceInsertContent", false, img);
|
||||
CloseDialog();
|
||||
</asp:PlaceHolder>
|
||||
|
||||
<asp:PlaceHolder runat="server" ID="InsertImageMarkdown3">
|
||||
// When we insert a image, we basically just close the dialog and let the unbeforeunload function do the rest of the work.
|
||||
imageLink = jQuery('#<%= tb_url.ClientID %>').val();
|
||||
imageInserted = true;
|
||||
CloseDialog();
|
||||
</asp:PlaceHolder>
|
||||
}
|
||||
function CloseDialog() {
|
||||
tinyMCEPopup.close();
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.IO;
|
||||
|
||||
namespace our.usercontrols
|
||||
{
|
||||
public partial class InsertImage : System.Web.UI.UserControl
|
||||
public partial class InsertImage : UserControl
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (uForum.Businesslogic.ForumEditor.UseMarkdownEditor())
|
||||
{
|
||||
InsertImageMarkdown1.Visible = true;
|
||||
InsertImageMarkdown2.Visible = true;
|
||||
InsertImageMarkdown3.Visible = true;
|
||||
InsertImageRte.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertImageMarkdown1.Visible = false;
|
||||
InsertImageMarkdown2.Visible = false;
|
||||
InsertImageMarkdown3.Visible = false;
|
||||
InsertImageRte.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnUpload_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -12,6 +12,42 @@ namespace our.usercontrols {
|
||||
|
||||
public partial class InsertImage {
|
||||
|
||||
/// <summary>
|
||||
/// InsertImageMarkdown1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder InsertImageMarkdown1;
|
||||
|
||||
/// <summary>
|
||||
/// InsertImageMarkdown2 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder InsertImageMarkdown2;
|
||||
|
||||
/// <summary>
|
||||
/// InsertImageRte control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder InsertImageRte;
|
||||
|
||||
/// <summary>
|
||||
/// InsertImageMarkdown3 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder InsertImageMarkdown3;
|
||||
|
||||
/// <summary>
|
||||
/// Label1 control.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace our.usercontrols {
|
||||
if (m != null) {
|
||||
umbraco.cms.businesslogic.member.Member.AddMemberToCache(m, false, new TimeSpan(30, 0, 0, 0));
|
||||
|
||||
uForum.Businesslogic.ForumEditor.SetEditorChoiceFromMemberProfile(m.Id);
|
||||
|
||||
if (!string.IsNullOrEmpty(redirectUrl))
|
||||
Response.Redirect(redirectUrl);
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using uForum.Library;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
|
||||
namespace uForum.Businesslogic
|
||||
{
|
||||
public static class ForumEditor
|
||||
{
|
||||
public const string EditorChoiceCookieKey = "EditorChoice";
|
||||
public const string UseMarkdownEditorPropertyAlias = "useMarkdownEditor";
|
||||
public const string EditorChoiceRte = "Rte";
|
||||
public const string EditorChoiceMarkdown = "Markdown";
|
||||
|
||||
public static bool UseMarkdownEditor()
|
||||
{
|
||||
var editorCookie = HttpContext.Current.Request.Cookies[EditorChoiceCookieKey];
|
||||
|
||||
var editorChoice = editorCookie != null
|
||||
? editorCookie[EditorChoiceCookieKey]
|
||||
: SetEditorChoiceFromMemberProfile();
|
||||
|
||||
return editorChoice == EditorChoiceMarkdown;
|
||||
}
|
||||
|
||||
public static string SetEditorChoiceFromMemberProfile(int id = 0)
|
||||
{
|
||||
var currentMember = Utills.GetMember(id == 0 ? Member.CurrentMemberId() : id);
|
||||
|
||||
var editorChoice = EditorChoiceRte;
|
||||
|
||||
if (currentMember != null)
|
||||
{
|
||||
var markdownEditorProperty = currentMember.getProperty(UseMarkdownEditorPropertyAlias);
|
||||
|
||||
if (markdownEditorProperty != null)
|
||||
{
|
||||
|
||||
if (markdownEditorProperty.Value.ToString() == "1")
|
||||
{
|
||||
editorChoice = EditorChoiceMarkdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetEditorChoiceCookie(editorChoice);
|
||||
|
||||
return editorChoice;
|
||||
}
|
||||
|
||||
public static void SaveEditorChoice(string editorChoice)
|
||||
{
|
||||
var currentMember = Utills.GetMember(Member.CurrentMemberId());
|
||||
var markdownEditorProperty = currentMember.getProperty(UseMarkdownEditorPropertyAlias);
|
||||
|
||||
if (markdownEditorProperty != null)
|
||||
{
|
||||
var useMarkdownEditor = editorChoice == EditorChoiceMarkdown;
|
||||
currentMember.getProperty(UseMarkdownEditorPropertyAlias).Value = useMarkdownEditor ? "1" : "0";
|
||||
}
|
||||
|
||||
SetEditorChoiceCookie(editorChoice);
|
||||
}
|
||||
|
||||
public static void ClearEditorChoiceCookie()
|
||||
{
|
||||
HttpContext.Current.Response.Cookies.Remove(EditorChoiceCookieKey);
|
||||
}
|
||||
|
||||
private static void SetEditorChoiceCookie(string value)
|
||||
{
|
||||
var editorChoiceCookie = new HttpCookie(EditorChoiceCookieKey);
|
||||
editorChoiceCookie.Values.Add(EditorChoiceCookieKey, value);
|
||||
editorChoiceCookie.Expires = DateTime.Now.AddYears(5);
|
||||
HttpContext.Current.Response.Cookies.Add(editorChoiceCookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Web;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using HtmlAgilityPack;
|
||||
using uForum.Businesslogic;
|
||||
using umbraco;
|
||||
using MarkdownSharp;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
@@ -460,7 +461,11 @@ namespace uForum.Library {
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
public static bool UseMarkdownEditor()
|
||||
{
|
||||
return ForumEditor.UseMarkdownEditor();
|
||||
}
|
||||
|
||||
private static string ShortenUrl(string url, int max) {
|
||||
if (url.Length <= max)
|
||||
return url;
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
<Compile Include="Businesslogic\Data.cs" />
|
||||
<Compile Include="Businesslogic\Events.cs" />
|
||||
<Compile Include="Businesslogic\Forum.cs" />
|
||||
<Compile Include="Businesslogic\ForumEditor.cs" />
|
||||
<Compile Include="Businesslogic\Mod.cs" />
|
||||
<Compile Include="Businesslogic\Subscribtion.cs" />
|
||||
<Compile Include="Businesslogic\Tag.cs" />
|
||||
|
||||
Reference in New Issue
Block a user