Fixes macro script editor and syncing, changes over editPython to use correct webforms file format.

This commit is contained in:
Shannon Deminick
2013-05-08 17:01:48 -10:00
parent 78cd51d333
commit dd1983dc55
9 changed files with 228 additions and 240 deletions

View File

@@ -436,6 +436,13 @@
<Compile Include="Umbraco\Developer\Packages\StarterKits.aspx.designer.cs">
<DependentUpon>StarterKits.aspx</DependentUpon>
</Compile>
<Compile Include="Umbraco\Developer\Python\EditPython.aspx.cs">
<DependentUpon>editPython.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Umbraco\Developer\Python\EditPython.aspx.designer.cs">
<DependentUpon>editPython.aspx</DependentUpon>
</Compile>
<Compile Include="Umbraco\Dialogs\EditMacro.aspx.cs">
<DependentUpon>EditMacro.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -832,6 +839,7 @@
<Content Include="Umbraco_Client\Dialogs\PublishDialog.css" />
<Content Include="Umbraco_Client\Dialogs\PublishDialog.js" />
<Content Include="Umbraco_Client\Dialogs\UmbracoField.js" />
<Content Include="Umbraco_Client\Editors\EditMacroScripts.js" />
<Content Include="Umbraco_Client\Editors\EditXslt.css" />
<Content Include="Umbraco_Client\Editors\EditXslt.js" />
<Content Include="Umbraco_Client\Editors\EditScript.js" />

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Umbraco.Web.UI.Umbraco.Developer.Python
{
public partial class EditPython : global::umbraco.cms.presentation.developer.editPython
{
}
}

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Umbraco.Web.UI.Umbraco.Developer.Python {
public partial class EditPython {
/// <summary>
/// JsInclude2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude2;
}
}

View File

@@ -1,54 +1,35 @@
<%@ Page ValidateRequest="false" Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master"
CodeBehind="editPython.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.developer.editPython" %>
CodeBehind="editPython.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.Developer.Python.EditPython" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<asp:Content ID="DocTypeContent" ContentPlaceHolderID="DocType" runat="server">
<!DOCTYPE html>
</asp:Content>
<asp:Content ID="cp0" runat="server" ContentPlaceHolderID="head">
<umb:JsInclude ID="JsInclude2" runat="server" FilePath="Editors/EditMacroScripts.js" PathNameAlias="UmbracoClient" />
<script type="text/javascript">
function closeErrorDiv() {
jQuery('#errorDiv').hide();
}
(function ($) {
$(document).ready(function () {
var editor = new Umbraco.Editors.EditMacroScripts({
nameTxtBox: $('#<%= pythonFileName.ClientID %>'),
originalFileName: '<%= pythonFileName.Text %>',
saveButton: $("#<%= ((Control)SaveButton).ClientID %>"),
editorSourceElement: $('#<%= pythonFileName.ClientID %>'),
skipTestingCheckBox: $("#<%= SkipTesting.ClientID %>"),
});
editor.init();
function doSubmit() {
closeErrorDiv();
var codeVal = jQuery('#<%= pythonSource.ClientID %>').val();
//if CodeMirror is not defined, then the code editor is disabled.
if (typeof (CodeMirror) != "undefined") {
codeVal = UmbEditor.GetCode();
}
umbraco.presentation.webservices.codeEditorSave.SaveDLRScript(jQuery('#<%= pythonFileName.ClientID %>').val(), '<%= pythonFileName.Text %>', codeVal, document.getElementById('<%= SkipTesting.ClientID %>').checked, submitSucces, submitFailure);
}
function submitSucces(t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', 'Saving scripting file failed', '');
jQuery('#errorDiv').html('<p><a href="#" style="position: absolute; right: 10px; top: 10px;" onclick=\'closeErrorDiv()\'>Hide Errors</a><strong>Error occured</strong></p><p>' + t + '</p>');
jQuery('#errorDiv').slideDown('fast');
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '')
}
}
function submitFailure(t) {
top.UmbSpeechBubble.ShowMessage('warning', 'Scripting file could not be saved', '')
}
function showError() {
var id = "#errorDiv";
if (jQuery(id).is(":visible")) {
jQuery(id).hide();
}
}
//bind save shortcut
UmbClientMgr.appActions().bindSaveShortCut();
});
})(jQuery);
</script>
</asp:Content>
<asp:Content ID="cp1" runat="server" ContentPlaceHolderID="body">
@@ -69,9 +50,4 @@
OffSetY="55" runat="server" />
</cc1:Pane>
</cc1:UmbracoPanel>
<script type="text/javascript">
jQuery(document).ready(function () {
UmbClientMgr.appActions().bindSaveShortCut();
});
</script>
</asp:Content>

View File

@@ -0,0 +1,70 @@
Umbraco.Sys.registerNamespace("Umbraco.Editors");
(function ($) {
Umbraco.Editors.EditMacroScripts = base2.Base.extend({
//private methods/variables
_opts: null,
// Constructor
constructor: function(opts) {
// Merge options with default
this._opts = $.extend({
// Default options go here
}, opts);
},
init: function () {
//setup UI elements
var self = this;
//bind to the save event
this._opts.saveButton.click(function () {
self.doSubmit();
});
},
doSubmit: function () {
var self = this;
jQuery('#errorDiv').hide();
var fileName = this._opts.nameTxtBox.val();
var codeVal = this._opts.editorSourceElement.val();
//if CodeMirror is not defined, then the code editor is disabled.
if (typeof (CodeMirror) != "undefined") {
codeVal = UmbEditor.GetCode();
}
umbraco.presentation.webservices.codeEditorSave.SaveDLRScript(
fileName, self._opts.originalFileName, codeVal, self._opts.skipTestingCheckBox.is(':checked'),
function (t) { self.submitSucces(t); },
function (t) { self.submitFailure(t); });
},
submitSucces: function(t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', 'Saving scripting file failed', '');
jQuery('#errorDiv').html('<p><a href="#" style="position: absolute; right: 10px; top: 10px;" onclick=\'closeErrorDiv()\'>Hide Errors</a><strong>Error occured</strong></p><p>' + t + '</p>');
jQuery('#errorDiv').slideDown('fast');
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
}
var newFilePath = this._opts.nameTxtBox.val();
UmbClientMgr.mainTree().setActiveTreeType('python');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
},
submitFailure: function(t) {
top.UmbSpeechBubble.ShowMessage('warning', 'Scripting file could not be saved', '');
}
});
})(jQuery);

View File

@@ -363,6 +363,9 @@
<Compile Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\Python\editPython.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\dialogs\AssignDomain2.aspx.cs">
<DependentUpon>AssignDomain2.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1184,13 +1187,6 @@
<Compile Include="umbraco.presentation\umbraco\developer\Packages\SubmitPackage.aspx.designer.cs">
<DependentUpon>SubmitPackage.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\Python\editPython.aspx.cs">
<DependentUpon>editPython.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\Python\editPython.aspx.designer.cs">
<DependentUpon>editPython.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\getXsltStatus.asmx.cs">
<DependentUpon>getXsltStatus.asmx</DependentUpon>
<SubType>Component</SubType>
@@ -1876,9 +1872,6 @@
<Content Include="umbraco.presentation\umbraco\dialogs\sendToTranslation.aspx" />
<Content Include="umbraco.presentation\umbraco\dialogs\uploadImage.aspx" />
<Content Include="umbraco.presentation\umbraco\dialogs\viewAuditTrail.aspx" />
<Content Include="umbraco.presentation\umbraco\developer\Python\editPython.aspx">
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="umbraco.presentation\umbraco\members\ViewMembers.aspx" />
<Content Include="umbraco.presentation\umbraco\plugins\tinymce3\insertImage.aspx">
<SubType>ASPXCodeBehind</SubType>

View File

@@ -1,77 +0,0 @@
<%@ Page ValidateRequest="false" Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master"
CodeBehind="editPython.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.developer.editPython" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<asp:Content ID="DocTypeContent" ContentPlaceHolderID="DocType" runat="server">
<!DOCTYPE html>
</asp:Content>
<asp:Content ID="cp0" runat="server" ContentPlaceHolderID="head">
<script type="text/javascript">
function closeErrorDiv() {
jQuery('#errorDiv').hide();
}
function doSubmit() {
closeErrorDiv();
var codeVal = jQuery('#<%= pythonSource.ClientID %>').val();
//if CodeMirror is not defined, then the code editor is disabled.
if (typeof (CodeMirror) != "undefined") {
codeVal = UmbEditor.GetCode();
}
umbraco.presentation.webservices.codeEditorSave.SaveDLRScript(jQuery('#<%= pythonFileName.ClientID %>').val(), '<%= pythonFileName.Text %>', codeVal, document.getElementById('<%= SkipTesting.ClientID %>').checked, submitSucces, submitFailure);
}
function submitSucces(t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', 'Saving scripting file failed', '');
jQuery('#errorDiv').html('<p><a href="#" style="position: absolute; right: 10px; top: 10px;" onclick=\'closeErrorDiv()\'>Hide Errors</a><strong>Error occured</strong></p><p>' + t + '</p>');
jQuery('#errorDiv').slideDown('fast');
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '')
}
}
function submitFailure(t) {
top.UmbSpeechBubble.ShowMessage('warning', 'Scripting file could not be saved', '')
}
function showError() {
var id = "#errorDiv";
if (jQuery(id).is(":visible")) {
jQuery(id).hide();
}
}
</script>
</asp:Content>
<asp:Content ID="cp1" runat="server" ContentPlaceHolderID="body">
<cc1:UmbracoPanel ID="UmbracoPanel1" runat="server" Text="Edit scripting file" Height="300"
Width="600">
<cc1:Pane ID="Pane1" runat="server" Style="margin-bottom: 10px;">
<cc1:PropertyPanel ID="pp_filename" Text="Filename" runat="server">
<asp:TextBox ID="pythonFileName" runat="server" Width="400" CssClass="guiInputText"></asp:TextBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_testing" runat="server" Text="Skip testing (ignore errors)">
<asp:CheckBox ID="SkipTesting" runat="server"></asp:CheckBox>
</cc1:PropertyPanel>
<cc1:PropertyPanel ID="pp_errorMsg" runat="server">
<div id="errorDiv" style="position: relative; display: none;" class="error">
-</div>
</cc1:PropertyPanel>
<cc1:CodeArea ID="pythonSource" ClientSaveMethod="doSubmit" AutoSuggest="true" CodeBase="Razor" AutoResize="true" OffSetX="47"
OffSetY="55" runat="server" />
</cc1:Pane>
</cc1:UmbracoPanel>
<script type="text/javascript">
jQuery(document).ready(function () {
UmbClientMgr.appActions().bindSaveShortCut();
});
</script>
</asp:Content>

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
@@ -17,6 +17,7 @@ using Umbraco.Core.IO;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.presentation.Trees;
using umbraco.cms.helpers;
using umbraco.uicontrols;
namespace umbraco.cms.presentation.developer
{
@@ -28,12 +29,16 @@ namespace umbraco.cms.presentation.developer
}
private List<string> allowedExtensions = new List<string>();
protected PlaceHolder buttons;
protected uicontrols.CodeArea CodeArea1;
protected MenuIconI SaveButton;
private void Page_Load(object sender, System.EventArgs e)
private readonly List<string> _allowedExtensions = new List<string>();
protected PlaceHolder buttons;
protected CodeArea CodeArea1;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
UmbracoPanel1.hasMenu = true;
if (!IsPostBack)
@@ -48,28 +53,26 @@ namespace umbraco.cms.presentation.developer
private List<string> validScriptingExtensions()
{
if (allowedExtensions.Count == 0)
if (_allowedExtensions.Count == 0)
{
foreach (MacroEngineLanguage lang in MacroEngineFactory.GetSupportedUILanguages())
{
if (!allowedExtensions.Contains(lang.Extension))
allowedExtensions.Add(lang.Extension);
if (!_allowedExtensions.Contains(lang.Extension))
_allowedExtensions.Add(lang.Extension);
}
}
return allowedExtensions;
return _allowedExtensions;
}
protected override void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
uicontrols.MenuIconI save = UmbracoPanel1.Menu.NewIcon();
save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif";
save.OnClickCommand = "doSubmit()";
save.AltText = "Save scripting File";
save.ID = "save";
SaveButton = UmbracoPanel1.Menu.NewIcon();
SaveButton.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif";
SaveButton.AltText = "Save scripting File";
SaveButton.ID = "save";
// Add source and filename
String file = IOHelper.MapPath(SystemDirectories.MacroScripts + "/" + Request.QueryString["file"]);
@@ -89,17 +92,84 @@ namespace umbraco.cms.presentation.developer
pythonSource.Text = S;
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/codeEditorSave.asmx"));
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/legacyAjaxCalls.asmx"));
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/legacyAjaxCalls.asmx"));
}
/// <summary>
/// UmbracoPanel1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.UmbracoPanel UmbracoPanel1;
/// <summary>
/// Pane1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane Pane1;
/// <summary>
/// pp_filename control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_filename;
/// <summary>
/// pythonFileName 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.TextBox pythonFileName;
/// <summary>
/// pp_testing control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_testing;
/// <summary>
/// SkipTesting 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.CheckBox SkipTesting;
/// <summary>
/// pp_errorMsg control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_errorMsg;
/// <summary>
/// pythonSource control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.CodeArea pythonSource;
}
}

View File

@@ -1,87 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.cms.presentation.developer {
public partial class editPython {
/// <summary>
/// UmbracoPanel1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.UmbracoPanel UmbracoPanel1;
/// <summary>
/// Pane1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.Pane Pane1;
/// <summary>
/// pp_filename control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_filename;
/// <summary>
/// pythonFileName 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.TextBox pythonFileName;
/// <summary>
/// pp_testing control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_testing;
/// <summary>
/// SkipTesting 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.CheckBox SkipTesting;
/// <summary>
/// pp_errorMsg control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel pp_errorMsg;
/// <summary>
/// pythonSource control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.CodeArea pythonSource;
}
}