From dd1983dc551d2f4135c63e14f0c7f1773b8bd548 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Wed, 8 May 2013 17:01:48 -1000 Subject: [PATCH] Fixes macro script editor and syncing, changes over editPython to use correct webforms file format. --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 8 ++ .../developer/Python/EditPython.aspx.cs | 11 ++ .../Python/EditPython.aspx.designer.cs | 24 ++++ .../umbraco/developer/Python/editPython.aspx | 66 ++++------- .../Editors/EditMacroScripts.js | 70 +++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 13 +- .../umbraco/developer/Python/editPython.aspx | 77 ------------ .../developer/Python/editPython.aspx.cs | 112 ++++++++++++++---- .../Python/editPython.aspx.designer.cs | 87 -------------- 9 files changed, 228 insertions(+), 240 deletions(-) create mode 100644 src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.cs create mode 100644 src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.designer.cs create mode 100644 src/Umbraco.Web.UI/umbraco_client/Editors/EditMacroScripts.js delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.designer.cs diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index d2bd7706e3..43a2e3e60f 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -436,6 +436,13 @@ StarterKits.aspx + + editPython.aspx + ASPXCodeBehind + + + editPython.aspx + EditMacro.aspx ASPXCodeBehind @@ -832,6 +839,7 @@ + diff --git a/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.cs b/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.cs new file mode 100644 index 0000000000..bfa8c2a1d7 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.cs @@ -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 + { + } +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.designer.cs new file mode 100644 index 0000000000..c7637b6b07 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/developer/Python/EditPython.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Umbraco.Web.UI.Umbraco.Developer.Python { + + + public partial class EditPython { + + /// + /// JsInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; + } +} diff --git a/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx b/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx index f1c3b6d617..14780549a2 100644 --- a/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx +++ b/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx @@ -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" %> + + + @@ -69,9 +50,4 @@ OffSetY="55" runat="server" /> - diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditMacroScripts.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditMacroScripts.js new file mode 100644 index 0000000000..8215461336 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditMacroScripts.js @@ -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('

Hide ErrorsError occured

' + t + '

'); + 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); \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index db3d3adc10..3456cf76ee 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -363,6 +363,9 @@ ASPXCodeBehind + + ASPXCodeBehind + AssignDomain2.aspx ASPXCodeBehind @@ -1184,13 +1187,6 @@ SubmitPackage.aspx - - editPython.aspx - ASPXCodeBehind - - - editPython.aspx - getXsltStatus.asmx Component @@ -1876,9 +1872,6 @@ - - ASPXCodeBehind - ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx deleted file mode 100644 index f1c3b6d617..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx +++ /dev/null @@ -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" %> - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.cs index 0d7f73d607..ccbcd6fb6d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.cs @@ -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 allowedExtensions = new List(); - protected PlaceHolder buttons; - protected uicontrols.CodeArea CodeArea1; + protected MenuIconI SaveButton; - private void Page_Load(object sender, System.EventArgs e) + private readonly List _allowedExtensions = new List(); + 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 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")); } + + /// + /// UmbracoPanel1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoPanel UmbracoPanel1; + + /// + /// Pane1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane Pane1; + + /// + /// pp_filename control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_filename; + + /// + /// pythonFileName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox pythonFileName; + + /// + /// pp_testing control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_testing; + + /// + /// SkipTesting control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox SkipTesting; + + /// + /// pp_errorMsg control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_errorMsg; + + /// + /// pythonSource control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.CodeArea pythonSource; } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.designer.cs deleted file mode 100644 index 253bfa28fd..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Python/editPython.aspx.designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.presentation.developer { - - - public partial class editPython { - - /// - /// UmbracoPanel1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.UmbracoPanel UmbracoPanel1; - - /// - /// Pane1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane1; - - /// - /// pp_filename control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_filename; - - /// - /// pythonFileName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox pythonFileName; - - /// - /// pp_testing control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_testing; - - /// - /// SkipTesting control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox SkipTesting; - - /// - /// pp_errorMsg control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_errorMsg; - - /// - /// pythonSource control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.CodeArea pythonSource; - } -}