Skip to content

Commit

Permalink
Merge pull request #19 from UpendoVentures/tasks/rename-commands
Browse files Browse the repository at this point in the history
Renamed commands to better match DNN naming conventions
  • Loading branch information
WillStrohl authored Mar 1, 2022
2 parents 9b929d3 + 4232fd7 commit ccb4d3c
Show file tree
Hide file tree
Showing 15 changed files with 460 additions and 44 deletions.
19 changes: 11 additions & 8 deletions Modules/UpendoPrompt/App_LocalResources/Global.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
<data name="DebugStatusWebConfig.Text" xml:space="preserve">
<value>Debugging in the web.config is {0}.</value>
</data>
<data name="Deprecated.Text" xml:space="preserve">
<value>This command has been deprecated. Please use '{0}' instead. This command will be removed in a future release.</value>
</data>
<data name="Disabled.Text" xml:space="preserve">
<value>disabled</value>
</data>
Expand Down Expand Up @@ -172,22 +175,22 @@
<value>&lt;div&gt;
&lt;p&gt;Helps you see and know where debugging might already be turned on. This is helpful when you're not sure or have multiple people working on a site.&lt;/p&gt;
&lt;h4&gt;Toggle whether the site is in debug mode, or running normally&lt;/h4&gt;
&lt;code class="block"&gt;debug-info&lt;/code&gt;
&lt;code class="block"&gt;list-debug&lt;/code&gt;
&lt;p&gt;This command does not have any options.&lt;/p&gt;
&lt;p&gt;If you find that one or more areas have debug turned on, you should use the command below to disable debug mode. You may need to run it twice.&lt;/p&gt;
&lt;code class="block"&gt;debug-mode&lt;/code&gt;
&lt;code class="block"&gt;set-debug&lt;/code&gt;
&lt;/div&gt;</value>
</data>
<data name="Prompt_DebugMode_ResultHtml.Text" xml:space="preserve">
<value>&lt;div&gt;
&lt;p&gt;When you need more information to help diagnose and resolve an error, this command can help you get more verbose and detailed information.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WARNING!&lt;/strong&gt; When used, this command will RESTART your website. Page loads for the next few moments after running this command will be slower.&lt;/p&gt;
&lt;h4&gt;Using debug-mode&lt;/h4&gt;
&lt;code class="block"&gt;debug-mode&lt;/code&gt;
&lt;h4&gt;Using set-debug&lt;/h4&gt;
&lt;code class="block"&gt;set-debug&lt;/code&gt;
&lt;p&gt;This command does not have any options.&lt;/p&gt;
&lt;p&gt;When you run this command, debug mode is toggled in the superuser settings, web.config, and the DotNetNuke.log4net.config files.&lt;/p&gt;
&lt;p&gt;If you're unsure if you need to run this command, first try running the command below.&lt;/p&gt;
&lt;code class="block"&gt;debug-info&lt;/code&gt;
&lt;code class="block"&gt;list-debug&lt;/code&gt;
&lt;/div&gt;</value>
</data>
<data name="Prompt_ModeInvalid.Text" xml:space="preserve">
Expand All @@ -203,7 +206,7 @@
<value>&lt;div&gt;
&lt;h4&gt;Enable or disable popups on the current or all sites&lt;/h4&gt;

&lt;code class="block"&gt;popups-mode [--mode &amp;lt;enable|disable&amp;gt;] [--scope &amp;lt;current|all&amp;gt;]&lt;/code&gt;
&lt;code class="block"&gt;set-popups [--mode &amp;lt;enable|disable&amp;gt;] [--scope &amp;lt;current|all&amp;gt;]&lt;/code&gt;
&lt;p&gt;Popups have been [enabled/disabled] for [this site/all sites].&lt;/p&gt;
&lt;p&gt;Note: If you don't enter any command arguments, you'll simply disable popups on the current website only.&lt;/p&gt;
&lt;/div&gt;</value>
Expand All @@ -215,8 +218,8 @@
<value>&lt;div&gt;
&lt;p&gt;Ideally, this list should be as short as possible on most websites.&lt;/p&gt;
&lt;p&gt;View all of the theme settings used on the entire DNN instance&lt;/p&gt;
&lt;h4&gt;Using themes-used&lt;/h4&gt;
&lt;code class="block"&gt;themes-used&lt;/code&gt;
&lt;h4&gt;Using list-themes&lt;/h4&gt;
&lt;code class="block"&gt;list-themes&lt;/code&gt;
&lt;p&gt;A listing of all of the themes that have been specified in the superuser settings, site settings, pages, and modules will be listed.&lt;/p&gt;
&lt;/div&gt;</value>
</data>
Expand Down
13 changes: 1 addition & 12 deletions Modules/UpendoPrompt/Commands/DebugInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,13 @@
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Xml;
using System.Xml.Linq;
using Dnn.PersonaBar.Library.Helper;
using Dnn.PersonaBar.Library.Prompt;
using Dnn.PersonaBar.Library.Prompt.Attributes;
using Dnn.PersonaBar.Library.Prompt.Models;
using DotNetNuke.Application;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;
using DotNetNuke.Instrumentation;
using Upendo.Modules.UpendoPrompt.Components;
Expand All @@ -50,7 +39,7 @@

namespace Upendo.Modules.UpendoPrompt.Commands
{
[ConsoleCommand("debug-info", Constants.PromptCategory, "PromptDebugInfo")]
[ConsoleCommand("list-debug", Constants.PromptCategory, "PromptDebugInfo")]
public class DebugInfo : PromptBase, IConsoleCommand
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(DebugInfo));
Expand Down
7 changes: 1 addition & 6 deletions Modules/UpendoPrompt/Commands/DebugMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,22 @@
#endregion

using System;
using System.IO;
using System.Xml;
using Dnn.PersonaBar.Library.Helper;
using Dnn.PersonaBar.Library.Prompt;
using Dnn.PersonaBar.Library.Prompt.Attributes;
using Dnn.PersonaBar.Library.Prompt.Models;
using DotNetNuke.Application;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;
using DotNetNuke.Instrumentation;
using Upendo.Modules.UpendoPrompt.Components;
using Constants = Upendo.Modules.UpendoPrompt.Components.Constants;

namespace Upendo.Modules.UpendoPrompt.Commands
{
[ConsoleCommand("debug-mode", Constants.PromptCategory, "PromptDebugMode")]
[ConsoleCommand("set-debug", Constants.PromptCategory, "PromptDebugMode")]
public class DebugMode : PromptBase, IConsoleCommand
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(DebugMode));
Expand Down
102 changes: 102 additions & 0 deletions Modules/UpendoPrompt/Commands/Deprecated/DebugInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#region License

// Distributed under the MIT License
// ============================================================
// Copyright (c) Upendo Ventures, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Xml;
using System.Xml.Linq;
using Dnn.PersonaBar.Library.Helper;
using Dnn.PersonaBar.Library.Prompt;
using Dnn.PersonaBar.Library.Prompt.Attributes;
using Dnn.PersonaBar.Library.Prompt.Models;
using DotNetNuke.Application;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;
using DotNetNuke.Instrumentation;
using Upendo.Modules.UpendoPrompt.Components;
using Upendo.Modules.UpendoPrompt.Entities;
using Constants = Upendo.Modules.UpendoPrompt.Components.Constants;

namespace Upendo.Modules.UpendoPrompt.Commands.Deprecated
{
[Obsolete("Please use 'list-debug' instead. Will be removed in version 1.5.0 or higher.")]
[ConsoleCommand("debug-info", Constants.PromptCategory, "PromptDebugInfo")]
public class DebugInfo : PromptBase, IConsoleCommand
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(DebugInfo));

#region Implementation

public override void Init(string[] args, PortalSettings portalSettings, UserInfo userInfo, int activeTabId)
{
// do nothing
}

public override ConsoleResultModel Run()
{
try
{
var output = string.Format(LocalizeString(Constants.LocalizationKeys.DEPRECATED), "list-debug");

return new ConsoleResultModel
{
Output = output,
IsError = false
};
}
catch (Exception e)
{
LogError(e);
return new ConsoleErrorResultModel(string.Concat(Constants.OutputPrefix, this.LocalizeString(Constants.LocalizationKeys.ErrorOccurred)));
}
}

#endregion

#region Helpers

protected override void LogError(Exception ex)
{
if (ex != null)
{
Logger.Error(ex.Message, ex);
if (ex.InnerException != null)
{
Logger.Error(ex.InnerException.Message, ex.InnerException);
}
}
}
#endregion
}
}
95 changes: 95 additions & 0 deletions Modules/UpendoPrompt/Commands/Deprecated/DebugMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#region License

// Distributed under the MIT License
// ============================================================
// Copyright (c) Upendo Ventures, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#endregion

using System;
using System.IO;
using System.Xml;
using Dnn.PersonaBar.Library.Helper;
using Dnn.PersonaBar.Library.Prompt;
using Dnn.PersonaBar.Library.Prompt.Attributes;
using Dnn.PersonaBar.Library.Prompt.Models;
using DotNetNuke.Application;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;
using DotNetNuke.Instrumentation;
using Upendo.Modules.UpendoPrompt.Components;
using Constants = Upendo.Modules.UpendoPrompt.Components.Constants;

namespace Upendo.Modules.UpendoPrompt.Commands.Deprecated
{
[Obsolete("Please use 'debug-mode' instead. Will be removed in version 1.5.0 or higher.")]
[ConsoleCommand("debug-mode", Constants.PromptCategory, "PromptDebugMode")]
public class DebugMode : PromptBase, IConsoleCommand
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(DebugMode));

#region Implementation

public override void Init(string[] args, PortalSettings portalSettings, UserInfo userInfo, int activeTabId)
{
// do nothing
}

public override ConsoleResultModel Run()
{
try
{
var output = string.Format(LocalizeString(Constants.LocalizationKeys.DEPRECATED), "set-debug");

return new ConsoleResultModel
{
Output = output,
IsError = false
};
}
catch (Exception e)
{
LogError(e);
return new ConsoleErrorResultModel(string.Concat(Constants.OutputPrefix, this.LocalizeString(Constants.LocalizationKeys.ErrorOccurred)));
}
}

#endregion

#region Helpers
protected override void LogError(Exception ex)
{
if (ex != null)
{
Logger.Error(ex.Message, ex);
if (ex.InnerException != null)
{
Logger.Error(ex.InnerException.Message, ex.InnerException);
}
}
}
#endregion
}
}
Loading

0 comments on commit ccb4d3c

Please sign in to comment.