From d328ac062dbcfbff9608e654aafe61856366e3f5 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 7 Sep 2010 15:35:21 -0700 Subject: [PATCH 1/4] Applied fix from Rudi Grobler for rss feeds --HG-- branch : dev --- .../Core/Feeds/StandardQueries/ContainerFeedQuery.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs b/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs index 8e531a205..03b804718 100644 --- a/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs +++ b/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs @@ -1,10 +1,12 @@ -using System.Web.Mvc; +using System; +using System.Web.Mvc; using System.Xml.Linq; using JetBrains.Annotations; using Orchard.ContentManagement; using Orchard.Core.Common.Models; using Orchard.Core.Feeds.Models; using Orchard.Core.Feeds.StandardBuilders; +using Orchard.Utility.Extensions; namespace Orchard.Core.Feeds.StandardQueries { [UsedImplicitly] @@ -45,7 +47,8 @@ namespace Orchard.Core.Feeds.StandardQueries { context.Response.Contextualize(requestContext => { var urlHelper = new UrlHelper(requestContext); - link.Add(urlHelper.RouteUrl(inspector.Link)); + var uriBuilder = new UriBuilder(urlHelper.RequestContext.HttpContext.Request.ToRootUrlString()) { Path = urlHelper.RouteUrl(inspector.Link) }; + link.Add(uriBuilder.Uri.OriginalString); }); } else { From afb8578d17794519b1ab1136ce08286d2ab31bdf Mon Sep 17 00:00:00 2001 From: Andrew Ma Date: Thu, 5 Aug 2010 16:27:42 -0700 Subject: [PATCH 2/4] Creating a commandline option to create users --HG-- branch : dev --- .../Orchard.Users/Commands/UserCommands.cs | 64 +++++++++++++++++++ .../Orchard.Users/Orchard.Users.csproj | 1 + 2 files changed, 65 insertions(+) create mode 100644 src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs diff --git a/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs new file mode 100644 index 000000000..7913de574 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs @@ -0,0 +1,64 @@ +using System; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml.Linq; +using Orchard.Commands; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Aspects; +using Orchard.Security; +using Orchard.Users.Services; +using System.Web.Security; + +namespace Orchard.Users.Commands { + public class UserCommands : DefaultOrchardCommandHandler { + private readonly IContentManager _contentManager; + private readonly IMembershipService _membershipService; + private readonly IUserService _userService; + + public UserCommands( + IContentManager contentManager, + IMembershipService membershipService, + IUserService userService) { + _contentManager = contentManager; + _membershipService = membershipService; + _userService = userService; + } + + [OrchardSwitch] + public string UserName { get; set; } + + [OrchardSwitch] + public string Password { get; set; } + + [OrchardSwitch] + public string Email { get; set; } + + [OrchardSwitch] + public string FileName { get; set; } + + [CommandName("user create")] + [CommandHelp("user create /UserName: /Password: /Email:\r\n\t" + "Creates a new User")] + [OrchardSwitches("UserName,Password,Email")] + public string Create() { + string userUnicityMessage = _userService.VerifyUserUnicity(UserName, Email); + if (userUnicityMessage != null) { + return userUnicityMessage; + } + if (Password == null || Password.Length < MinPasswordLength) { + return String.Format("You must specify a password of {0} or more characters.", MinPasswordLength); + } + + var user = _membershipService.CreateUser(new CreateUserParams(UserName, Password, Email, null, null, true)); + if (user != null) + return "User created successfully"; + else + return "The authentication provider returned an error"; + } + + int MinPasswordLength { + get { + return _membershipService.GetSettings().MinRequiredPasswordLength; + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj index 8c037b7ac..9e7e55e13 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj +++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj @@ -66,6 +66,7 @@ + From b7d809e8d0922d6da95132984dd8764b7628b552 Mon Sep 17 00:00:00 2001 From: Andrew Ma Date: Sun, 8 Aug 2010 14:31:39 -0400 Subject: [PATCH 3/4] Adding Localizer to translate strings in UserCommands --HG-- branch : dev --- .../Modules/Orchard.Users/Commands/UserCommands.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs index 7913de574..0d47db6ad 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs @@ -45,14 +45,14 @@ namespace Orchard.Users.Commands { return userUnicityMessage; } if (Password == null || Password.Length < MinPasswordLength) { - return String.Format("You must specify a password of {0} or more characters.", MinPasswordLength); + return T("You must specify a password of {0} or more characters.", MinPasswordLength).ToString(); } var user = _membershipService.CreateUser(new CreateUserParams(UserName, Password, Email, null, null, true)); if (user != null) - return "User created successfully"; + return T("User created successfully").ToString(); else - return "The authentication provider returned an error"; + return T("The authentication provider returned an error").ToString(); } int MinPasswordLength { From 013f11319ab312153a3733ffa37e6a38467df053 Mon Sep 17 00:00:00 2001 From: Bertrand Le Roy Date: Mon, 30 Aug 2010 16:34:19 -0700 Subject: [PATCH 4/4] Fix for http://orchard.codeplex.com/workitem/16600 Web command line doesn't support switches and quoted arguments. --HG-- branch : dev --- .../Controllers/CommandsController.cs | 66 +++++++++++++++++-- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs index e84d75225..910cfaf72 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs @@ -1,4 +1,4 @@ -using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Mvc; @@ -27,12 +27,9 @@ namespace Orchard.DevTools.Controllers { [HttpPost] public ActionResult Execute(CommandsExecuteViewModel model) { - var writer = new StringWriter(); - var parameters = new CommandParameters { - Arguments = model.CommandLine.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries), - Output = writer - }; + var commandLine = model.CommandLine.Trim(); + CommandParameters parameters = GetCommandParameters(commandLine, writer); _commandManager.Execute(parameters); model.History = (model.History ?? Enumerable.Empty()) @@ -43,6 +40,63 @@ namespace Orchard.DevTools.Controllers { return View("Execute", model); } + private static CommandParameters GetCommandParameters(string commandLine, StringWriter writer) { + var arguments = new List(); + var switches = new Dictionary(); + var current = 0; + while (current < commandLine.Length) { + var nextSpace = commandLine.IndexOf(' ', current); + if (nextSpace == -1) nextSpace = commandLine.Length; + var arg = commandLine.Substring(current, nextSpace - current).Trim(); + if (arg.Length == 0) { + current = nextSpace + 1; + continue; + } + if (arg[0] == '/') { + var colonIndex = arg.IndexOf(':'); + if (colonIndex != -1) { + var switchName = arg.Substring(1, colonIndex - 1); + if (arg.Length > colonIndex + 1) { + if (arg[colonIndex + 1] == '"') { + var beginningOfSwitchValue = commandLine.IndexOf('"', current) + 1; + if (beginningOfSwitchValue != 0) { + var endOfSwitchValue = commandLine.IndexOf('"', beginningOfSwitchValue); + if (endOfSwitchValue != -1) { + switches.Add(switchName, + commandLine.Substring(beginningOfSwitchValue, + endOfSwitchValue - beginningOfSwitchValue)); + current = endOfSwitchValue + 1; + continue; + } + } + } + else { + switches.Add(switchName, arg.Substring(colonIndex + 1)); + current = nextSpace + 1; + continue; + } + } + } + } + else if (arg[0] == '"') { + var argumentStart = commandLine.IndexOf('"', current) + 1; + var argumentEnd = commandLine.IndexOf('"', argumentStart); + if (argumentEnd != -1) { + arguments.Add(commandLine.Substring(argumentStart, argumentEnd - argumentStart)); + current = argumentEnd + 1; + continue; + } + } + arguments.Add(arg); + current = nextSpace + 1; + } + + return new CommandParameters { + Arguments = arguments, + Switches = switches, + Output = writer + }; + } } } \ No newline at end of file