--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-09-30 12:55:27 -07:00
111 changed files with 1097 additions and 834 deletions

View File

@@ -6,7 +6,7 @@ From the base of the checkout, execute
* the ./orchard.proj creates an orchard web site at ./build/Profiling
* the ./src/Orchard.Profile/profiling-setup-commands.txt holds the additional orchard.exe steps used to initialize
* the ./src/Orchard.DevTools/Commands/ProfilingCommands.cs holds an additional handful of steps to populate items
* the ./src/Orchard.Experimental/Commands/ProfilingCommands.cs holds an additional handful of steps to populate items
The localhost:80 web server should be pointed to the ./build/Profiling folder at this point
The "admin" password is "profiling-secret" without quotes

View File

@@ -1,3 +1,3 @@
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SqlCe /EnabledFeatures:Profiling,Orchard.Framework,Routable,Common,Dashboard,Feeds,PublishLater,HomePage,Contents,ContentsLocation,Navigation,Reports,Scheduling,Indexing,Settings,Localization,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Themes,Orchard.MultiTenancy,Orchard.Blogs,Orchard.Comments,Orchard.Modules,Futures.Widgets,Orchard.Media,Orchard.Tags,Orchard.DevTools
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SqlCe /EnabledFeatures:Profiling,Orchard.Framework,Routable,Common,Dashboard,Feeds,PublishLater,HomePage,Contents,ContentsLocation,Navigation,Reports,Scheduling,Indexing,Settings,Localization,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Themes,Orchard.MultiTenancy,Orchard.Blogs,Orchard.Comments,Orchard.Modules,Orchard.Widgets,Orchard.Media,Orchard.Tags,Orchard.Experimental
add profiling data
feature disable Orchard.DevTools
feature disable Orchard.Experimental

View File

@@ -228,10 +228,6 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.DevTools\Orchard.DevTools.csproj">
<Project>{67C1D3AF-A0EC-46B2-BAE1-DF1DA8E0B890}</Project>
<Name>Orchard.DevTools</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Roles\Orchard.Roles.csproj">
<Project>{D10AD48F-407D-4DB5-A328-173EC7CB010F}</Project>
<Name>Orchard.Roles</Name>

View File

@@ -0,0 +1,15 @@
using NUnit.Framework;
using Orchard.CodeGeneration.Commands;
using Orchard.Environment.Extensions;
namespace Orchard.Tests.Modules.CodeGeneration.Commands {
[TestFixture]
public class CodeGenerationCommandsTests {
[Test]
public void CreateDataMigrationTest() {
//ExtensionManager extensionManager = new ExtensionManager();
//CodeGenerationCommands codeGenerationCommands = new CodeGenerationCommands();
}
}
}

View File

@@ -106,6 +106,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CodeGeneration\Commands\CodeGenerationCommandsTests.cs" />
<Compile Include="DatabaseEnabledTestsBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Roles\Controllers\AdminControllerTests.cs" />
@@ -127,6 +128,10 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.CodeGeneration\Orchard.CodeGeneration.csproj">
<Project>{C0C45321-B51D-4D8D-9B7B-AA4C2E0B2962}</Project>
<Name>Orchard.CodeGeneration</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Roles\Orchard.Roles.csproj">
<Project>{D10AD48F-407D-4DB5-A328-173EC7CB010F}</Project>
<Name>Orchard.Roles</Name>

View File

@@ -1,5 +1,5 @@
#if REFACTORING
#error This must move to the Modules tests to accomodateOrchard.DevTools assembly reference
#error This must move to the Modules tests to accomodateOrchard.Experimental assembly reference
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -114,7 +114,7 @@ features:
}
public class StubLoaders : IExtensionLoader {
#region Implementation of IExtensionLoader
#region Implementation of IExtensionLoader
public int Order {
get { return 1; }

View File

@@ -41,6 +41,7 @@ namespace Orchard.Tests.DisplayManagement {
public string Author { get; set; }
public string HomePage { get; set; }
public string Tags { get; set; }
public string Zones { get; set; }
}

View File

@@ -93,16 +93,6 @@ msgstr "Invalid serial number for shell descriptor"
msgid "Manage Settings"
msgstr "Manage Settings"
#: ~/Modules/Futures.Widgets/Controllers/AdminController.cs
#| msgid : "Designer notes not found."
msgid "Designer notes not found."
msgstr "Designer notes not found."
#: ~/Modules/Futures.Widgets/Views/Admin/Edit.ascx
#| msgid : "Edit Widget"
msgid "Edit Widget"
msgstr "Edit Widget"
#: ~/Modules/Orchard.Blogs/Controllers/BlogAdminController.cs
#| msgid : "Not allowed to create blogs"
msgid "Not allowed to create blogs"
@@ -508,77 +498,77 @@ msgstr "Allow new comments"
msgid "Enable to show the comment form. Disabling still allows the existing comments to be shown but does not allow the conversation to continue."
msgstr "Enable to show the comment form. Disabling still allows the existing comments to be shown but does not allow the conversation to continue."
#: ~/Modules/Orchard.DevTools/Controllers/HomeController.cs
#: ~/Modules/Orchard.Experimental/Controllers/HomeController.cs
#| msgid : "Notifier works without BaseViewModel"
msgid "Notifier works without BaseViewModel"
msgstr "Notifier works without BaseViewModel"
#: ~/Modules/Orchard.DevTools/Views/Content/Details.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Details.aspx
#| msgid : "{0} Content Type"
msgid "{0} Content Type"
msgstr "{0} Content Type"
#: ~/Modules/Orchard.DevTools/Views/Content/Details.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Details.aspx
#| msgid : "Content"
msgid "Content"
msgstr "Content"
#: ~/Modules/Orchard.DevTools/Views/Content/Details.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Details.aspx
#| msgid : "view"
msgid "view"
msgstr "view"
#: ~/Modules/Orchard.DevTools/Views/Content/Details.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Details.aspx
#| msgid : "edit"
msgid "edit"
msgstr "edit"
#: ~/Modules/Orchard.DevTools/Views/Content/Details.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Details.aspx
#| msgid : "{0} #{1} v{2}"
msgid "{0} #{1} v{2}"
msgstr "{0} #{1} v{2}"
#: ~/Modules/Orchard.DevTools/Views/Content/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Index.aspx
#| msgid : "Content"
msgid "Content"
msgstr "Content"
#: ~/Modules/Orchard.DevTools/Views/Content/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Index.aspx
#| msgid : "{0}: {1}"
msgid "{0}: {1}"
msgstr "{0}: {1}"
#: ~/Modules/Orchard.DevTools/Views/Content/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Index.aspx
#| msgid : "view"
msgid "view"
msgstr "view"
#: ~/Modules/Orchard.DevTools/Views/Content/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Content/Index.aspx
#| msgid : "edit"
msgid "edit"
msgstr "edit"
#: ~/Modules/Orchard.DevTools/Views/DisplayTemplates/Parts/DevTools.ShowDebugLink.ascx
#: ~/Modules/Orchard.Experimental/Views/DisplayTemplates/Parts/Experimental.ShowDebugLink.ascx
#| msgid : "{0} #{1} v{2}"
msgid "{0} #{1} v{2}"
msgstr "{0} #{1} v{2}"
#: ~/Modules/Orchard.DevTools/Views/EditorTemplates/Parts/DevTools.ShowDebugLink.ascx
#: ~/Modules/Orchard.Experimental/Views/EditorTemplates/Parts/Experimental.ShowDebugLink.ascx
#| msgid : "{0} #{1} v{2}"
msgid "{0} #{1} v{2}"
msgstr "{0} #{1} v{2}"
#: ~/Modules/Orchard.DevTools/Views/Home/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Home/Index.aspx
#| msgid : "Dev Tools"
msgid "Dev Tools"
msgstr "Dev Tools"
#: ~/Modules/Orchard.DevTools/Views/Home/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Home/Index.aspx
#| msgid : "Contents"
msgid "Contents"
msgstr "Contents"
#: ~/Modules/Orchard.DevTools/Views/Home/Index.aspx
#: ~/Modules/Orchard.Experimental/Views/Home/Index.aspx
#| msgid : "Test Unauthorized Request"
msgid "Test Unauthorized Request"
msgstr "Test Unauthorized Request"
@@ -1953,6 +1943,26 @@ msgstr "Edit"
msgid "Remove"
msgstr "Remove"
#: ~/Modules/Orchard.Widgets/Views/Admin/Index.cshtml
#| msgid : "Manage Layers"
msgid "Manage Layers"
msgstr "Manage Layers"
#: ~/Modules/Orchard.Widgets/Views/Admin/Index.cshtml
#| msgid : "Add a new layer"
msgid "Add a new layer"
msgstr "Add a new layer"
#: ~/Modules/Orchard.Widgets/AdminMenu.cs
#| msgid : "Manage Widgets"
msgid "Manage Widgets"
msgstr "Manage Widgets"
#: ~/Modules/Orchard.Widgets/AdminMenu.cs
#| msgid : "Widgets"
msgid "Widgets"
msgstr "Widgets"
#: ~/Themes/Classic/Views/DisplayTemplates/Parts/Pages.Page.Metadata.ascx
#| msgid : "nobody(?)"
msgid "nobody(?)"

View File

@@ -1,7 +1,7 @@
namespace Orchard.Core.Contents.Settings {
public class ContentTypeSettings {
/// <summary>
/// This setting is used to display a Content Type in Content Mamagement menu like
/// This setting is used to display a Content Type in Content Management menu like
/// </summary>
public bool Creatable { get; set; }
}

View File

@@ -1,87 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Futures.Widgets.Models;
using Futures.Widgets.ViewModels;
using Orchard;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Localization;
using Orchard.Services;
using Orchard.Settings;
using Orchard.UI.Notify;
namespace Futures.Widgets.Controllers {
[ValidateInput(false)]
public class AdminController : Controller, IUpdateModel {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
public AdminController(IOrchardServices services, IEnumerable<IHtmlFilter> htmlFilters) {
_htmlFilters = htmlFilters;
Services = services;
T = NullLocalizer.Instance;
}
private IOrchardServices Services { get; set; }
protected virtual ISite CurrentSite { get; set; }
public Localizer T{ get; set;}
public ActionResult AddWidget(string zoneName, string themeName, string returnUrl) {
var hasWidgetsRecord = CurrentSite.As<WidgetsPart>().Record;
var virtualPath = "~/Themes/" + themeName + "/Zones/" + zoneName + ".html";
var physicalPath = Server.MapPath(virtualPath);
if (!System.IO.File.Exists(physicalPath)) {
Services.Notifier.Error(T("Designer notes not found."));
return Redirect(returnUrl);
}
var fileText = _htmlFilters
.Aggregate(System.IO.File.ReadAllText(physicalPath), (text, filter) => filter.ProcessContent(text));
var widget = Services.ContentManager.Create<WidgetPart>("HtmlWidget", init => {
init.Record.Scope = hasWidgetsRecord;
init.Record.Zone = zoneName;
init.Record.Position = "1";
init.As<BodyPart>().Text = fileText;
});
return RedirectToAction("Edit", new { widget.ContentItem.Id, returnUrl });
}
public ActionResult Edit(int id, string returnUrl) {
var widget = Services.ContentManager.Get(id);
var viewModel = new WidgetEditViewModel {
Widget = Services.ContentManager.BuildEditorModel(widget),
ReturnUrl = returnUrl,
};
return View(viewModel);
}
[HttpPost, ActionName("Edit")]
public ActionResult EditPOST(int id, string returnUrl) {
var widget = Services.ContentManager.Get(id);
var viewModel = new WidgetEditViewModel {
Widget = Services.ContentManager.UpdateEditorModel(widget, this),
ReturnUrl = returnUrl,
};
if (ModelState.IsValid == false) {
return View(viewModel);
}
if (string.IsNullOrEmpty(returnUrl)) {
return RedirectToAction("Edit", new { id });
}
return Redirect(returnUrl);
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
}
}

View File

@@ -1,20 +0,0 @@
using System.Web.Routing;
using Futures.Widgets.Models;
using Orchard.ContentManagement.Drivers;
namespace Futures.Widgets.Controllers {
public class WidgetDriver : ContentItemDriver<Widget> {
protected override RouteValueDictionary GetEditorRouteValues(Widget item) {
return new RouteValueDictionary {
{"Area", "Futures.Widgets"},
{"Controller", "Admin"},
{"Action", "Edit"},
{"Id", item.ContentItem.Id}
};
}
protected override bool UseDefaultTemplate {
get { return true; }
}
}
}

View File

@@ -1,34 +0,0 @@
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Futures.Widgets.DataMigrations {
public class WidgetsDataMigration : DataMigrationImpl {
public int Create() {
//CREATE TABLE Futures_Widgets_HasWidgetsRecord (Id INTEGER not null, primary key (Id));
SchemaBuilder.CreateTable("WidgetsPartRecord", table => table
.Column<int>("Id", column => column.PrimaryKey())
);
//CREATE TABLE Futures_Widgets_WidgetRecord (Id INTEGER not null, Zone TEXT, Position TEXT, Scope_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("WidgetPartRecord", table => table
.ContentPartRecord()
.Column<string>("Zone")
.Column<string>("Position")
.Column<int>("Scope_id")
);
return 1;
}
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
cfg => cfg
.WithPart("WidgetPart")
.WithPart("BodyPart")
);
return 2;
}
}
}

View File

@@ -1,27 +0,0 @@
using System.Linq;
using Futures.Widgets.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
namespace Futures.Widgets.Handlers {
public class WidgetsPartHandler : ContentHandler {
public WidgetsPartHandler(
IRepository<WidgetsPartRecord> widgetsRepository,
IRepository<WidgetPartRecord> widgetRepository) {
Filters.Add(new ActivatingFilter<WidgetsPart>("Site"));
// providing standard storage support for widget records
Filters.Add(StorageFilter.For(widgetsRepository));
Filters.Add(StorageFilter.For(widgetRepository));
OnLoaded<WidgetsPart>(
(ctx, part) => part.WidgetField.Loader(
() => ctx.ContentManager
.Query<WidgetPart, WidgetPartRecord>()
.Where(x => x.Scope == part.Record)
.List().ToList()));
}
}
}

View File

@@ -1,6 +0,0 @@
using Orchard.ContentManagement;
namespace Futures.Widgets.Models {
public class WidgetPart : ContentPart<WidgetPartRecord> {
}
}

View File

@@ -1,10 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.Core.Common.Utilities;
namespace Futures.Widgets.Models {
public class WidgetsPart : ContentPart<WidgetsPartRecord> {
public LazyField<IList<WidgetPart>> WidgetField = new LazyField<IList<WidgetPart>>();
public IList<WidgetPart> Widgets { get { return WidgetField.Value; } set { WidgetField.Value = value; } }
}
}

View File

@@ -1,6 +0,0 @@
using Orchard.ContentManagement.Records;
namespace Futures.Widgets.Models {
public class WidgetsPartRecord : ContentPartRecord {
}
}

View File

@@ -1,11 +0,0 @@
name: Widgets
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
version: 0.5.0
orchardversion: 0.5.0
description: A prototype implementation of Orchard widgets that only allows for editable global text regions.
features:
Futures.Widgets:
Description: Widgets container with simple inline content editing widget.
Category: Widget

View File

@@ -1,7 +0,0 @@

namespace Futures.Widgets.ViewModels {
public class WidgetEditViewModel {
public dynamic Widget { get; set; }
public string ReturnUrl { get; set;}
}
}

View File

@@ -1,9 +0,0 @@
@model Futures.Widgets.ViewModels.WidgetEditViewModel
<h1>@Html.TitleForPage(T("Edit Widget").ToString())</h1>
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
@Display(Model.Widget)
@Html.HiddenFor(m => m.ReturnUrl)
}

View File

@@ -0,0 +1,7 @@
name: $$ThemeName$$
author: The Orchard Team
website: http://www.orchardproject.net
description: Description for the theme
version: 1.0
# todo: provide tags
# tags: Classic, Serif

View File

@@ -0,0 +1,332 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Hosting;
using Orchard.Commands;
using Orchard.Data.Migration.Generator;
using Orchard.CodeGeneration.Services;
using Orchard.Data.Migration.Schema;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
namespace Orchard.CodeGeneration.Commands {
[OrchardFeature("Generate")]
public class CodeGenerationCommands : DefaultOrchardCommandHandler {
private readonly IExtensionManager _extensionManager;
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
private const string ModuleName = "CodeGeneration";
private static readonly string CodeGenTemplatePath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
public CodeGenerationCommands(
IExtensionManager extensionManager,
ISchemaCommandGenerator schemaCommandGenerator) {
_extensionManager = extensionManager;
_schemaCommandGenerator = schemaCommandGenerator;
}
[OrchardSwitch]
public bool IncludeInSolution { get; set; }
[OrchardSwitch]
public string BasedOn { get; set; }
[CommandHelp("generate create datamigration <feature-name> \r\n\t" + "Create a new Data Migration class")]
[CommandName("generate create datamigration")]
public void CreateDataMigration(string featureName) {
Context.Output.WriteLine(T("Creating Data Migration for {0}", featureName));
ExtensionDescriptor extensionDescriptor = _extensionManager.AvailableExtensions().FirstOrDefault(extension => extension.ExtensionType == "Module" &&
extension.Features.Any(feature => String.Equals(feature.Name, featureName, StringComparison.OrdinalIgnoreCase)));
if (extensionDescriptor == null) {
Context.Output.WriteLine(T("Creating data migration failed: target Feature {0} could not be found.", featureName));
return;
}
string dataMigrationsPath = HostingEnvironment.MapPath("~/Modules/" + extensionDescriptor.Name + "/DataMigrations/");
string dataMigrationPath = dataMigrationsPath + extensionDescriptor.DisplayName + "DataMigration.cs";
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extensionDescriptor.Name));
if (!Directory.Exists(dataMigrationsPath)) {
Directory.CreateDirectory(dataMigrationsPath);
}
if (File.Exists(dataMigrationPath)) {
Context.Output.WriteLine(T("Data migration already exists in target Module {0}.", extensionDescriptor.Name));
return;
}
List<SchemaCommand> commands = _schemaCommandGenerator.GetCreateFeatureCommands(featureName, false).ToList();
var stringWriter = new StringWriter();
var interpreter = new CodeGenerationCommandInterpreter(stringWriter);
foreach (var command in commands) {
interpreter.Visit(command);
stringWriter.WriteLine();
}
string dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
dataMigrationText = dataMigrationText.Replace("$$ClassName$$", extensionDescriptor.DisplayName);
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
File.WriteAllText(dataMigrationPath, dataMigrationText);
string projectFileText = File.ReadAllText(moduleCsProjPath);
// The string searches in solution/project files can be made aware of comment lines.
if ( projectFileText.Contains("<Compile Include") ) {
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extensionDescriptor.DisplayName + "DataMigration.cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
}
else {
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extensionDescriptor.DisplayName + "DataMigration.cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
}
File.WriteAllText(moduleCsProjPath, projectFileText);
TouchSolution();
Context.Output.WriteLine(T("Data migration created successfully in Module {0}", extensionDescriptor.Name));
}
[CommandHelp("generate create module <module-name> [/IncludeInSolution:true|false]\r\n\t" + "Create a new Orchard module")]
[CommandName("generate create module")]
[OrchardSwitches("IncludeInSolution")]
public void CreateModule(string moduleName) {
Context.Output.WriteLine(T("Creating Module {0}", moduleName));
if ( _extensionManager.AvailableExtensions().Any(extension => String.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase)) ) {
Context.Output.WriteLine(T("Creating Module {0} failed: a module of the same name already exists", moduleName));
return;
}
IntegrateModule(moduleName);
Context.Output.WriteLine(T("Module {0} created successfully", moduleName));
}
[CommandName("generate create theme")]
[CommandHelp("generate create theme <theme-name> [/IncludeInSolution:true|false][/BasedOn:<theme-name>]\r\n\tCreate a new Orchard theme")]
[OrchardSwitches("IncludeInSolution,BasedOn")]
public void CreateTheme(string themeName) {
Context.Output.WriteLine(T("Creating Theme {0}", themeName));
if (_extensionManager.AvailableExtensions().Any(extension => String.Equals(themeName, extension.DisplayName, StringComparison.OrdinalIgnoreCase))) {
Context.Output.WriteLine(base.T("Creating Theme {0} failed: an extention of the same name already exists", themeName));
}
else {
string baseThemePath = null;
if (!string.IsNullOrEmpty(BasedOn)) {
baseThemePath = HostingEnvironment.MapPath("~/Themes/" + BasedOn + "/");
if (string.IsNullOrEmpty(baseThemePath) || Directory.Exists(baseThemePath)) {
Context.Output.WriteLine(T("Creating Theme {0} failed: could not find base theme '{1}'", themeName, baseThemePath));
}
}
IntegrateTheme(themeName, baseThemePath);
Context.Output.WriteLine(base.T("Theme {0} created successfully", new object[] {themeName}));
}
}
[CommandHelp("generate create controller <module-name> <controller-name>\r\n\t" + "Create a new Orchard controller in a module")]
[CommandName("generate create controller")]
public void CreateController(string moduleName, string controllerName) {
Context.Output.WriteLine(T("Creating Controller {0} in Module {1}", controllerName, moduleName));
ExtensionDescriptor extensionDescriptor = _extensionManager.AvailableExtensions().FirstOrDefault(extension => extension.ExtensionType == "Module" &&
string.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase));
if (extensionDescriptor == null) {
Context.Output.WriteLine(T("Creating Controller {0} failed: target Module {1} could not be found.", controllerName, moduleName));
return;
}
string moduleControllersPath = HostingEnvironment.MapPath("~/Modules/" + extensionDescriptor.Name + "/Controllers/");
string controllerPath = moduleControllersPath + controllerName + ".cs";
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extensionDescriptor.Name));
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
if (!Directory.Exists(moduleControllersPath)) {
Directory.CreateDirectory(moduleControllersPath);
}
if (File.Exists(controllerPath)) {
Context.Output.WriteLine(T("Controller {0} already exists in target Module {1}.", controllerName, moduleName));
return;
}
string controllerText = File.ReadAllText(templatesPath + "Controller.txt");
controllerText = controllerText.Replace("$$ModuleName$$", moduleName);
controllerText = controllerText.Replace("$$ControllerName$$", controllerName);
File.WriteAllText(controllerPath, controllerText);
string projectFileText = File.ReadAllText(moduleCsProjPath);
// The string searches in solution/project files can be made aware of comment lines.
if (projectFileText.Contains("<Compile Include")) {
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
}
else {
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
}
File.WriteAllText(moduleCsProjPath, projectFileText);
Context.Output.WriteLine(T("Controller {0} created successfully in Module {1}", controllerName, moduleName));
TouchSolution();
}
private void IntegrateModule(string moduleName) {
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
string projectGuid = Guid.NewGuid().ToString().ToUpper();
CreateFilesFromTemplates(moduleName, projectGuid);
// The string searches in solution/project files can be made aware of comment lines.
if (IncludeInSolution) {
AddToSolution(moduleName, projectGuid, null, null);
}
}
private void IntegrateTheme(string themeName, string baseThemePath) {
HashSet<string> createdFiles;
HashSet<string> createdFolders;
var projectGuid = Guid.NewGuid().ToString().ToUpper();
CreateThemeFromTemplates(themeName, baseThemePath, projectGuid, out createdFiles, out createdFolders);
if (IncludeInSolution) {
AddToSolution(themeName, null, createdFiles, createdFolders);
}
}
private static void CreateFilesFromTemplates(string moduleName, string projectGuid) {
string modulePath = HostingEnvironment.MapPath("~/Modules/" + moduleName + "/");
string propertiesPath = modulePath + "Properties";
Directory.CreateDirectory(modulePath);
Directory.CreateDirectory(propertiesPath);
Directory.CreateDirectory(modulePath + "Controllers");
Directory.CreateDirectory(modulePath + "Views");
File.WriteAllText(modulePath + "\\Views\\Web.config", File.ReadAllText(CodeGenTemplatePath + "ViewsWebConfig.txt"));
Directory.CreateDirectory(modulePath + "Models");
Directory.CreateDirectory(modulePath + "Scripts");
string templateText = File.ReadAllText(CodeGenTemplatePath + "ModuleAssemblyInfo.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleTypeLibGuid$$", Guid.NewGuid().ToString());
File.WriteAllText(propertiesPath + "\\AssemblyInfo.cs", templateText);
File.WriteAllText(modulePath + "\\Web.config", File.ReadAllText(CodeGenTemplatePath + "ModuleWebConfig.txt"));
templateText = File.ReadAllText(CodeGenTemplatePath + "ModuleManifest.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
File.WriteAllText(modulePath + "\\Module.txt", templateText);
templateText = File.ReadAllText(CodeGenTemplatePath + "\\ModuleCsProj.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleProjectGuid$$", projectGuid);
File.WriteAllText(modulePath + "\\" + moduleName + ".csproj", templateText);
}
private static void CreateThemeFromTemplates(string themeName, string baseThemePath, string projectGuid, out HashSet<string> createdFiles, out HashSet<string> createdFolders) {
var themePath = HostingEnvironment.MapPath("~/Themes/" + themeName + "/");
createdFiles = new HashSet<string>();
createdFolders = new HashSet<string>();
// create directories
foreach (var folderName in new string[] { "", "Content", "Styles", "Scripts", "Views", "Zones" }) {
var folder = themePath + folderName;
createdFolders.Add(folder);
Directory.CreateDirectory(folder);
}
if (baseThemePath != null) {
// copy BasedOn theme file by file
foreach (var file in Directory.GetFiles(baseThemePath, "*", SearchOption.AllDirectories)) {
var destPath = file.Replace(baseThemePath, themePath);
Directory.CreateDirectory(Path.GetDirectoryName(destPath));
File.Copy(file, destPath);
createdFiles.Add(destPath);
}
}
else {
// non-BasedOn theme default files
var webConfig = themePath + "Views\\Web.config";
File.WriteAllText(webConfig, File.ReadAllText(CodeGenTemplatePath + "\\ViewsWebConfig.txt"));
createdFiles.Add(webConfig);
}
var templateText = File.ReadAllText(CodeGenTemplatePath + "\\ThemeManifest.txt").Replace("$$ThemeName$$", themeName);
File.WriteAllText(themePath + "Theme.txt", templateText);
createdFiles.Add(themePath + "Theme.txt");
}
private void AddToSolution(string projectName, string projectGuid, HashSet<string> filesToAddToOrchardWeb, HashSet<string> foldersToAddToOrchardWeb) {
var rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
if (!string.IsNullOrEmpty(projectGuid)) {
var solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
if (File.Exists(solutionPath)) {
var projectReference = string.Format("EndProject\r\nProject(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}\", \"Orchard.Web\\Modules\\{0}\\{0}.csproj\", \"{{{1}}}\"\r\n", projectName, projectGuid);
var projectConfiguationPlatforms = string.Format("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n", projectGuid);
var solutionText = File.ReadAllText(solutionPath);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference).Replace("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n", projectConfiguationPlatforms);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndGlobalSection"), "\t{" + projectGuid + "} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}\r\n\t");
File.WriteAllText(solutionPath, solutionText);
TouchSolution();
}
else {
Context.Output.WriteLine(base.T("Warning: Solution file could not be found at {0}", solutionPath));
}
}
AddFilesToOrchardWeb(filesToAddToOrchardWeb, foldersToAddToOrchardWeb);
}
private void AddFilesToOrchardWeb(HashSet<string> content, HashSet<string> folders) {
if (content == null && folders == null) {
return;
}
var orchardWebProj = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
if (!File.Exists(orchardWebProj)) {
Context.Output.WriteLine(T("Warning: Orchard.Web project file could not be found at {0}", orchardWebProj));
}
else {
var filesBaseDir = Path.GetDirectoryName(orchardWebProj) + "\\";
var contentInclude = "";
if (content != null && content.Count > 0) {
contentInclude = string.Join("\r\n",
from file in content
select " <Content Include=\"" + file.Replace(filesBaseDir, "") + "\" />");
}
if (folders != null && folders.Count > 0) {
contentInclude += "\r\n" + string.Join("\r\n", from folder in folders
select " <Folder Include=\"" + folder.Replace(filesBaseDir, "") + "\" />");
}
var itemGroup = string.Format(CultureInfo.InvariantCulture, "<ItemGroup>\r\n{0}\r\n </ItemGroup>\r\n ", contentInclude);
var projectText = File.ReadAllText(orchardWebProj);
// find where the first ItemGroup is after any References
var refIndex = projectText.LastIndexOf("<Reference Include");
if (refIndex != -1) {
var firstItemGroupIndex = projectText.IndexOf("<ItemGroup>", refIndex);
if (firstItemGroupIndex != -1) {
projectText = projectText.Insert(firstItemGroupIndex, itemGroup);
File.WriteAllText(orchardWebProj, projectText);
return;
}
}
Context.Output.WriteLine(T("Warning: Unable to modify Orchard.Web project file at {0}", orchardWebProj));
}
}
private void TouchSolution() {
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
string solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
if (!File.Exists(solutionPath)) {
Context.Output.WriteLine(T("Warning: Solution file could not be found at {0}", solutionPath));
return;
}
try {
File.SetLastWriteTime(solutionPath, DateTime.Now);
}
catch {
Context.Output.WriteLine(T("An unexpected error occured while trying to refresh the Visual Studio solution. Please reload it."));
}
}
}
}

View File

@@ -0,0 +1,11 @@
Name: Code generation module
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
version: 0.1.0
orchardversion: 0.6.0
description:
features:
Generate:
Description: Tools to create Orchard components.
Category: Developer

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C0C45321-B51D-4D8D-9B7B-AA4C2E0B2962}</ProjectGuid>
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.CodeGeneration</RootNamespace>
<AssemblyName>Orchard.CodeGeneration</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HibernatingRhinos.Profiler.Appender">
<HintPath>..\..\..\..\lib\nhprof\HibernatingRhinos.Profiler.Appender.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\CodeGenerationCommands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CodeGenerationCommandInterpreter.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="CodeGenerationTemplates\ThemeManifest.txt" />
<Content Include="Module.txt" />
<Content Include="CodeGenerationTemplates\Controller.txt" />
<Content Include="CodeGenerationTemplates\DataMigration.txt" />
<Content Include="CodeGenerationTemplates\ModuleAssemblyInfo.txt" />
<Content Include="CodeGenerationTemplates\ModuleCsProj.txt" />
<Content Include="CodeGenerationTemplates\ModuleManifest.txt" />
<Content Include="CodeGenerationTemplates\ModuleWebConfig.txt" />
<Content Include="CodeGenerationTemplates\ViewsWebConfig.txt" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
</Target>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>53274</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -1,11 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Orchard.DevTools")]
[assembly: AssemblyTitle("Orchard.CodeGeneration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]
@@ -19,7 +18,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c185e02c-ccf9-4976-bdaa-1fd7e12c1296")]
[assembly: Guid("a5ae5869-1454-4fe8-a998-a3f2e79c91a3")]
// Version information for an assembly consists of the following four values:
//
@@ -31,4 +30,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]

View File

@@ -5,11 +5,11 @@ using System.Linq;
using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Migration.Schema;
namespace Orchard.DevTools.Services {
public class ScaffoldingCommandInterpreter : AbstractDataMigrationInterpreter {
namespace Orchard.CodeGeneration.Services {
public class CodeGenerationCommandInterpreter : AbstractDataMigrationInterpreter {
private readonly TextWriter _output;
public ScaffoldingCommandInterpreter(TextWriter output) {
public CodeGenerationCommandInterpreter(TextWriter output) {
_output = output;
}
@@ -17,7 +17,6 @@ namespace Orchard.DevTools.Services {
_output.WriteLine("\t\t\t// Creating table {0}", command.Name);
_output.WriteLine("\t\t\tSchemaBuilder.CreateTable(\"{0}\", table => table", command.Name);
var matchContentPartRecord = command.TableCommands.OfType<CreateColumnCommand>().Any(
c =>
c.IsPrimaryKey

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<configuration>
<system.web>

View File

@@ -1,211 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Web.Hosting;
using Orchard.Commands;
using Orchard.Data.Migration.Generator;
using Orchard.DevTools.Services;
using Orchard.Environment.Extensions;
namespace Orchard.DevTools.Commands {
[OrchardFeature("Scaffolding")]
public class ScaffoldingCommands : DefaultOrchardCommandHandler {
private readonly IExtensionManager _extensionManager;
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
public ScaffoldingCommands(
IExtensionManager extensionManager,
ISchemaCommandGenerator schemaCommandGenerator) {
_extensionManager = extensionManager;
_schemaCommandGenerator = schemaCommandGenerator;
}
[OrchardSwitch]
public bool IncludeInSolution { get; set; }
[CommandHelp("scaffolding create datamigration <feature-name> \r\n\t" + "Create a new Data Migration class")]
[CommandName("scaffolding create datamigration")]
public void CreateDataMigration(string featureName) {
Context.Output.WriteLine(T("Creating Data Migration for {0}", featureName));
foreach ( var extension in _extensionManager.AvailableExtensions() ) {
if ( extension.ExtensionType == "Module" && extension.Features.Any(f => String.Equals(f.Name, featureName, StringComparison.OrdinalIgnoreCase)) ) {
string dataMigrationsPath = HostingEnvironment.MapPath("~/Modules/" + extension.Name + "/DataMigrations/");
string dataMigrationPath = dataMigrationsPath + extension.DisplayName + "DataMigration.cs";
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/");
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extension.Name));
if ( !Directory.Exists(dataMigrationsPath) ) {
Directory.CreateDirectory(dataMigrationsPath);
}
if ( File.Exists(dataMigrationPath) ) {
Context.Output.WriteLine(T("Data migration already exists in target Module {0}.", extension.Name));
return;
}
var commands = _schemaCommandGenerator.GetCreateFeatureCommands(featureName, false).ToList();
var stringWriter = new StringWriter();
var interpreter = new ScaffoldingCommandInterpreter(stringWriter);
foreach ( var command in commands ) {
interpreter.Visit(command);
stringWriter.WriteLine();
}
string dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
dataMigrationText = dataMigrationText.Replace("$$ClassName$$", extension.DisplayName);
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
File.WriteAllText(dataMigrationPath, dataMigrationText);
string projectFileText = File.ReadAllText(moduleCsProjPath);
// The string searches in solution/project files can be made aware of comment lines.
if ( projectFileText.Contains("<Compile Include") ) {
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extension.DisplayName + "DataMigration.cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
}
else {
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extension.DisplayName + "DataMigration.cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
}
File.WriteAllText(moduleCsProjPath, projectFileText);
TouchSolution();
Context.Output.WriteLine(T("Data migration created successfully in Module {0}", extension.Name));
return;
}
}
Context.Output.WriteLine(T("Creating data migration failed: target Feature {0} could not be found.", featureName));
}
[CommandHelp("scaffolding create module <module-name> [/IncludeInSolution:true|false]\r\n\t" + "Create a new Orchard module")]
[CommandName("scaffolding create module")]
[OrchardSwitches("IncludeInSolution")]
public void CreateModule(string moduleName) {
Context.Output.WriteLine(T("Creating Module {0}", moduleName));
if ( _extensionManager.AvailableExtensions().Any(extension => extension.ExtensionType == "Module" && String.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase)) ) {
Context.Output.WriteLine(T("Creating Module {0} failed: a module of the same name already exists", moduleName));
return;
}
IntegrateModule(moduleName);
Context.Output.WriteLine(T("Module {0} created successfully", moduleName));
}
[CommandHelp("scaffolding create controller <module-name> <controller-name>\r\n\t" + "Create a new Orchard controller in a module")]
[CommandName("scaffolding create controller")]
public void CreateController(string moduleName, string controllerName) {
Context.Output.WriteLine(T("Creating Controller {0} in Module {1}", controllerName, moduleName));
foreach (var extension in _extensionManager.AvailableExtensions()) {
if (extension.ExtensionType == "Module" && String.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase)) {
string moduleControllersPath = HostingEnvironment.MapPath("~/Modules/" + extension.Name + "/Controllers/");
string controllerPath = moduleControllersPath + controllerName + ".cs";
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extension.Name));
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/");
if (!Directory.Exists(moduleControllersPath)) {
Directory.CreateDirectory(moduleControllersPath);
}
if (File.Exists(controllerPath)) {
Context.Output.WriteLine(T("Controller {0} already exists in target Module {1}.", controllerName, moduleName));
return;
}
string controllerText = File.ReadAllText(templatesPath + "Controller.txt");
controllerText = controllerText.Replace("$$ModuleName$$", moduleName);
controllerText = controllerText.Replace("$$ControllerName$$", controllerName);
File.WriteAllText(controllerPath, controllerText);
string projectFileText = File.ReadAllText(moduleCsProjPath);
// The string searches in solution/project files can be made aware of comment lines.
if (projectFileText.Contains("<Compile Include")) {
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
}
else {
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
}
File.WriteAllText(moduleCsProjPath, projectFileText);
Context.Output.WriteLine(T("Controller {0} created successfully in Module {1}", controllerName, moduleName));
TouchSolution();
return;
}
}
Context.Output.WriteLine(T("Creating Controller {0} failed: target Module {1} could not be found.", controllerName, moduleName));
}
private void IntegrateModule(string moduleName) {
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
string projectGuid = Guid.NewGuid().ToString().ToUpper();
CreateFilesFromTemplates(moduleName, projectGuid);
// The string searches in solution/project files can be made aware of comment lines.
if (IncludeInSolution) {
// Add project to Orchard.sln
string solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
if (File.Exists(solutionPath)) {
string projectReference = string.Format(
"EndProject\r\nProject(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}\", \"Orchard.Web\\Modules\\{0}\\{0}.csproj\", \"{{{1}}}\"\r\n",
moduleName, projectGuid);
string projectConfiguationPlatforms = string.Format(
"GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n",
projectGuid);
string solutionText = File.ReadAllText(solutionPath);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference);
solutionText = solutionText.Replace("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n", projectConfiguationPlatforms);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndGlobalSection"), "\t{" + projectGuid + "} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}\r\n\t");
File.WriteAllText(solutionPath, solutionText);
TouchSolution();
}
else {
Context.Output.WriteLine(T("Warning: Solution file could not be found at {0}", solutionPath));
}
}
}
private static void CreateFilesFromTemplates(string moduleName, string projectGuid) {
string modulePath = HostingEnvironment.MapPath("~/Modules/" + moduleName + "/");
string propertiesPath = modulePath + "Properties";
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/");
Directory.CreateDirectory(modulePath);
Directory.CreateDirectory(propertiesPath);
Directory.CreateDirectory(modulePath + "Controllers");
Directory.CreateDirectory(modulePath + "Views");
File.WriteAllText(modulePath + "\\Views\\Web.config", File.ReadAllText(templatesPath + "ViewsWebConfig.txt"));
Directory.CreateDirectory(modulePath + "Models");
Directory.CreateDirectory(modulePath + "Scripts");
string templateText = File.ReadAllText(templatesPath + "ModuleAssemblyInfo.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleTypeLibGuid$$", Guid.NewGuid().ToString());
File.WriteAllText(propertiesPath + "\\AssemblyInfo.cs", templateText);
File.WriteAllText(modulePath + "\\Web.config", File.ReadAllText(templatesPath + "ModuleWebConfig.txt"));
templateText = File.ReadAllText(templatesPath + "ModuleManifest.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
File.WriteAllText(modulePath + "\\Module.txt", templateText);
templateText = File.ReadAllText(templatesPath + "\\ModuleCsProj.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleProjectGuid$$", projectGuid);
File.WriteAllText(modulePath + "\\" + moduleName + ".csproj", templateText);
}
private void TouchSolution() {
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
string solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
if (!File.Exists(solutionPath)) {
Context.Output.WriteLine(T("Warning: Solution file could not be found at {0}", solutionPath));
return;
}
try {
File.SetLastWriteTime(solutionPath, DateTime.Now);
}
catch {
Context.Output.WriteLine(T("An unexpected error occured while trying to refresh the Visual Studio solution. Please reload it."));
}
}
}
}

View File

@@ -1,39 +0,0 @@
using System;
using System.Web.Mvc;
using Orchard.Data.Migration.Generator;
using Orchard.Localization;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
namespace Orchard.DevTools.Controllers {
[ValidateInput(false)]
[Admin]
public class DatabaseUpdateController : Controller {
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
public DatabaseUpdateController(ISchemaCommandGenerator schemaCommandGenerator, IOrchardServices orchardServices) {
_schemaCommandGenerator = schemaCommandGenerator;
Services = orchardServices;
}
public IOrchardServices Services { get; set; }
public Localizer T { get; set; }
public ActionResult Index() {
return View();
}
public ActionResult UpdateDatabase() {
try {
_schemaCommandGenerator.UpdateDatabase();
Services.Notifier.Information(T("Database updated successfuly"));
}
catch (Exception ex) {
Services.Notifier.Error(T("An error occured while updating the database: {0}", ex.Message));
}
return RedirectToAction("Index");
}
}
}

View File

@@ -1,22 +0,0 @@
name: DevTools
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
version: 0.5.0
orchardversion: 0.5.0
description: This module is not activated by default and should only be used in a development environment. It contains various debugging and tracing tools that can display information about your content types.
features:
Orchard.DevTools:
Description: An assortment of debugging tools.
Category: Developer
Scaffolding:
Description: Tools to create Orchard components.
Category: Developer
Dependencies: Orchard.DevTools
Profiling:
Description: Tools to help profile Orchard.
Category: Developer
Dependencies: Orchard.DevTools
Orchard.DevTools.WebCommandLine:
Description: Enables site administrators to execute Orchard.exe commands via web interface
Category: Developer

View File

@@ -1,6 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.DevTools.Models" %>
<div class="debug message"><%=T(
"DevTools: displaying {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.DevTools", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>

View File

@@ -1,8 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.DevTools.Models" %>
<% if (Model.ContentItem.Id > 0) { %>
<div class="debug message"><%=T(
"DevTools: editing {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.DevTools", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>
<% } %>

View File

@@ -1,42 +0,0 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,7 +1,8 @@
using Orchard.Localization;
using Orchard.UI.Navigation;
namespace Orchard.DevTools {
namespace Orchard.Experimental {
public class AdminMenu : INavigationProvider {
public string MenuName { get { return "admin"; } }
public Localizer T { get; set; }
@@ -9,7 +10,7 @@ namespace Orchard.DevTools {
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Site Configuration"), "11",
menu => menu
.Add(T("Developer Tools"), "10.0", item => item.Action("Index", "Home", new { area = "Orchard.DevTools" })
.Add(T("Experimental"), "10.0", item => item.Action("Index", "Home", new { area = "Orchard.Experimental" })
));
}
}

View File

@@ -7,7 +7,8 @@ using Orchard.Core.Routable.Models;
using Orchard.Environment.Extensions;
using Orchard.Security;
namespace Orchard.DevTools.Commands {
namespace Orchard.Experimental.Commands {
[OrchardFeature("Profiling")]
public class ProfilingCommands : DefaultOrchardCommandHandler {
private readonly IContentManager _contentManager;

View File

@@ -3,13 +3,13 @@ using System.IO;
using System.Linq;
using System.Web.Mvc;
using Orchard.Commands;
using Orchard.DevTools.ViewModels;
using Orchard.Experimental.ViewModels;
using Orchard.Environment.Extensions;
using Orchard.Themes;
using Orchard.UI.Admin;
namespace Orchard.DevTools.Controllers {
[Themed, Admin, OrchardFeature("Orchard.DevTools.WebCommandLine")]
namespace Orchard.Experimental.Controllers {
[Themed, Admin, OrchardFeature("Orchard.Experimental.WebCommandLine")]
public class CommandsController : Controller {
private readonly ICommandManager _commandManager;

View File

@@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Orchard.Data;
using Orchard.DevTools.ViewModels;
using Orchard.Experimental.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.DisplayManagement;
namespace Orchard.DevTools.Controllers {
namespace Orchard.Experimental.Controllers {
public class ContentController : Controller {
private readonly IRepository<ContentTypeRecord> _contentTypeRepository;
private readonly IContentManager _contentManager;
@@ -34,6 +34,7 @@ namespace Orchard.DevTools.Controllers {
var model = new ContentDetailsViewModel {
Item = version == null ? _contentManager.Get(id) : _contentManager.Get(id, VersionOptions.Number((int)version))
};
model.PartTypes = model.Item.ContentItem.Parts
.Select(x => x.GetType())
.SelectMany(x => AllTypes(x))
@@ -50,6 +51,7 @@ namespace Orchard.DevTools.Controllers {
yield return scan;
scan = scan.BaseType;
}
foreach (var itf in type.GetInterfaces()) {
yield return itf;
}

View File

@@ -1,14 +1,14 @@
using System;
using System.Web;
using System.Web.Mvc;
using Orchard.DevTools.Models;
using Orchard.Experimental.Models;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Themes;
using Orchard.UI.Notify;
using Orchard.UI.Admin;
namespace Orchard.DevTools.Controllers {
namespace Orchard.Experimental.Controllers {
[Themed]
[Admin]
public class HomeController : Controller {

View File

@@ -3,9 +3,9 @@ using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq;
using Orchard.ContentManagement.MetaData;
using Orchard.DevTools.ViewModels;
using Orchard.Experimental.ViewModels;
namespace Orchard.DevTools.Controllers {
namespace Orchard.Experimental.Controllers {
[ValidateInput(false)]
public class MetadataController : Controller {
private readonly IContentDefinitionManager _contentDefinitionManager;

View File

@@ -1,18 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Themes;
using Orchard.UI.Admin;
namespace Orchard.DevTools.Controllers {
namespace Orchard.Experimental.Controllers {
[Themed, Admin]
public class InventoryController : Controller {
public class ShapeTableController : Controller {
private readonly IShapeTableManager _shapeTableManager;
public InventoryController(IShapeTableManager shapeTableManager) {
public ShapeTableController(IShapeTableManager shapeTableManager) {
_shapeTableManager = shapeTableManager;
}

View File

@@ -7,7 +7,7 @@ using System.Xml;
using Orchard.DisplayManagement.Shapes;
using Orchard.Mvc.Filters;
namespace Orchard.DevTools {
namespace Orchard.Experimental {
public class DebugFilter : FilterProvider, IActionFilter {
public void OnActionExecuting(ActionExecutingContext filterContext) {
}
@@ -39,8 +39,7 @@ namespace Orchard.DevTools {
Writer = writer;
var model = _viewResultBase.ViewData.Model;
Accept(model);
}
finally {
} finally {
Writer = null;
}
}
@@ -63,4 +62,4 @@ namespace Orchard.DevTools {
}
}
}
}
}

View File

@@ -1,18 +1,18 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.DevTools.Models;
using Orchard.Experimental.Models;
namespace Orchard.DevTools.Handlers {
namespace Orchard.Experimental.Handlers {
[UsedImplicitly]
public class DebugLinkHandler : ContentHandler {
protected override void BuildDisplayShape(BuildDisplayModelContext context) {
var devToolsSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.DevToolsSettings>();
if (devToolsSettings.ShowDebugLinks)
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
if (experimentalSettings.ShowDebugLinks)
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
}
protected override void BuildEditorShape(BuildEditorModelContext context) {
var devToolsSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.DevToolsSettings>();
if (devToolsSettings.ShowDebugLinks)
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
if (experimentalSettings.ShowDebugLinks)
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
}
}

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement;
namespace Orchard.DevTools.Models {
namespace Orchard.Experimental.Models {
public class ShowDebugLink {
public ContentItem ContentItem { get; set; }
}

View File

@@ -1,4 +1,5 @@
namespace Orchard.DevTools.Models {
namespace Orchard.Experimental.Models {
public class Simple {
public string Title { get; set; }
public int Quantity { get; set; }

View File

@@ -0,0 +1,18 @@
Name: Experimental module
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
version: 0.1.0
orchardversion: 0.6.0
description:
features:
Profiling:
Description: Tools to help profile Orchard.
Category: Developer
Dependencies: Orchard.Experimental
Orchard.Experimental.WebCommandLine:
Description: Enables site administrators to execute Orchard.exe commands via web interface
Category: Developer
Orchard.Experimental:
Description: An assortment of debugging tools.
Category: Developer

View File

@@ -3,21 +3,17 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{67C1D3AF-A0EC-46B2-BAE1-DF1DA8E0B890}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<ProjectGuid>{AB3C207C-0126-4143-8D62-1119DF80D366}</ProjectGuid>
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.DevTools</RootNamespace>
<AssemblyName>Orchard.DevTools</AssemblyName>
<RootNamespace>Orchard.Experimental</RootNamespace>
<AssemblyName>Orchard.Experimental</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -27,7 +23,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -36,48 +31,52 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="HibernatingRhinos.Profiler.Appender, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0774796e73ebf640, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="HibernatingRhinos.Profiler.Appender">
<HintPath>..\..\..\..\lib\nhprof\HibernatingRhinos.Profiler.Appender.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Mobile" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Commands\ProfilingCommands.cs" />
<Compile Include="Commands\ScaffoldingCommands.cs" />
<Compile Include="Controllers\CommandsController.cs" />
<Compile Include="Controllers\ContentController.cs" />
<Compile Include="Controllers\DatabaseUpdateController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\InventoryController.cs" />
<Compile Include="Controllers\ShapeTableController.cs" />
<Compile Include="Controllers\MetadataController.cs" />
<Compile Include="DebugFilter.cs" />
<Compile Include="Handlers\DebugLinkHandler.cs" />
@@ -85,37 +84,34 @@
<Compile Include="Models\Simple.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="ScaffoldingTemplates\DataMigration.txt" />
<Compile Include="Services\ScaffoldingCommandInterpreter.cs" />
<Compile Include="Settings\DevToolsSettings.cs" />
<Compile Include="Settings\ExperimentalSettings.cs" />
<Compile Include="Shapes.cs" />
<Compile Include="ViewModels\CommandsExecuteViewModel.cs" />
<Compile Include="ViewModels\ContentIndexViewModel.cs" />
<Compile Include="ViewModels\ContentDetailsViewModel.cs" />
<Compile Include="ViewModels\ContentIndexViewModel.cs" />
<Compile Include="ViewModels\MetadataIndexViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="ScaffoldingTemplates\Controller.txt" />
<Content Include="ScaffoldingTemplates\ModuleAssemblyInfo.txt" />
<Content Include="ScaffoldingTemplates\ModuleCsProj.txt" />
<Content Include="ScaffoldingTemplates\ModuleManifest.txt" />
<Content Include="ScaffoldingTemplates\ModuleWebConfig.txt" />
<Content Include="ScaffoldingTemplates\ViewsWebConfig.txt" />
<Content Include="Views\Commands\Execute.ascx" />
<Content Include="Views\DatabaseUpdate\Index.aspx" />
<Content Include="Views\DefinitionTemplates\DevToolsSettings.ascx" />
<Content Include="Views\Home\_RenderableAction.ascx" />
<Content Include="Views\Home\Simple.aspx" />
<Content Include="Views\Content\Details.aspx" />
<Content Include="Views\Content\Index.aspx" />
<Content Include="Views\DefinitionTemplates\ExperimentalSettings.aspx" />
<Content Include="Views\EditorTemplates\Parts\Experimental.ShowDebugLink.ascx" />
<Content Include="Views\Home\Index.aspx" />
<Content Include="Views\DisplayTemplates\Parts\DevTools.ShowDebugLink.ascx" />
<Content Include="Views\EditorTemplates\Parts\DevTools.ShowDebugLink.ascx" />
<Content Include="Views\Home\Simple.aspx" />
<Content Include="Views\Home\_RenderableAction.ascx" />
<Content Include="Views\DatabaseUpdate\Index.aspx" />
<Content Include="Views\Metadata\Index.aspx" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\DisplayTemplates\Parts\Experimental.ShowDebugLink.ascx" />
<None Include="Views\HackScript.cshtml" />
<None Include="Views\HackStyle.cshtml" />
<None Include="Views\ThinBorder.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
@@ -127,14 +123,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Views\HackScript.cshtml" />
<Content Include="Views\HackStyle.cshtml" />
<Content Include="Views\ThinBorder.cshtml" />
<Content Include="Views\Home\FormShapes.cshtml">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\UsingShapes.cshtml" />
<Content Include="Views\Inventory\ShapeTable.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\ShapeTable\ShapeTable.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
@@ -142,20 +139,8 @@
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
</Target>
<ProjectExtensions>
<VisualStudio>
@@ -163,13 +148,14 @@
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>1231</DevelopmentServerPort>
<DevelopmentServerPort>55620</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Environment.Extensions.Models;
using Orchard.Security.Permissions;
namespace Orchard.DevTools {
namespace Orchard.Experimental {
public class Permissions : IPermissionProvider {
public static readonly Permission DebugShowAllMenuItems = new Permission { Description = "DevTools: Show all menu items", Name = "DebugShowAllMenuItems" };
public static readonly Permission DebugShowAllMenuItems = new Permission { Description = "Experimental: Show all menu items", Name = "DebugShowAllMenuItems" };
public virtual Feature Feature { get; set; }
@@ -22,4 +20,4 @@ namespace Orchard.DevTools {
}
}
}
}

View File

@@ -4,11 +4,10 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Futures.Widgets")]
[assembly: AssemblyTitle("Orchard.Experimental")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Futures.Widgets")]
[assembly: AssemblyProduct("Orchard")]
[assembly: AssemblyCopyright("Copyright © CodePlex Foundation 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -19,7 +18,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8c179868-e814-4277-a0af-b71707c3bff4")]
[assembly: Guid("dedeaad6-f97c-4db1-b544-8e72496aa5ed")]
// Version information for an assembly consists of the following four values:
//
@@ -31,4 +30,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]

View File

@@ -5,26 +5,25 @@ using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.DevTools.Settings {
public class DevToolsSettings {
namespace Orchard.Experimental.Settings {
public class ExperimentalSettings {
public bool ShowDebugLinks { get; set; }
}
public class DevToolsSettingsHooks : ContentDefinitionEditorEventsBase {
public class ExperimentalSettingsHooks : ContentDefinitionEditorEventsBase {
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
var model = definition.Settings.GetModel<DevToolsSettings>();
var model = definition.Settings.GetModel<ExperimentalSettings>();
yield return DefinitionTemplate(model);
}
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new DevToolsSettings();
updateModel.TryUpdateModel(model, "DevToolsSettings", null, null);
var model = new ExperimentalSettings();
updateModel.TryUpdateModel(model, "ExperimentalSettings", null, null);
builder
.WithSetting("DevToolsSettings.ShowDebugLinks", model.ShowDebugLinks ? true.ToString() : null);
.WithSetting("ExperimentalSettings.ShowDebugLinks", model.ShowDebugLinks ? true.ToString() : null);
yield return DefinitionTemplate(model);
}
}
}
}

View File

@@ -1,9 +1,9 @@
using Orchard.DisplayManagement.Implementation;
namespace Orchard.DevTools {
namespace Orchard.Experimental {
public class Shapes : IShapeFactoryEvents {
public void Creating(ShapeCreatingContext context) {
}
public void Created(ShapeCreatedContext context) {
@@ -15,4 +15,4 @@ namespace Orchard.DevTools {
}
}
}
}
}

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Orchard.Experimental.ViewModels {
namespace Orchard.DevTools.ViewModels {
public class CommandsExecuteViewModel {
public string[] History { get; set; }
public string CommandLine { get; set; }

View File

@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.ContentManagement.ViewModels;
using Orchard.UI.Zones;
namespace Orchard.DevTools.ViewModels {
namespace Orchard.Experimental.ViewModels {
public class ContentDetailsViewModel {
public IContent Item { get; set; }

View File

@@ -2,7 +2,8 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
namespace Orchard.DevTools.ViewModels {
namespace Orchard.Experimental.ViewModels {
public class ContentIndexViewModel {
public IEnumerable<ContentTypeRecord> Types { get; set; }
public IEnumerable<ContentItem> Items { get; set; }

View File

@@ -1,7 +1,8 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.DevTools.ViewModels {
namespace Orchard.Experimental.ViewModels {
public class MetadataIndexViewModel {
public IEnumerable<ContentTypeDefinition> TypeDefinitions { get; set; }
public IEnumerable<ContentPartDefinition> PartDefinitions { get; set; }

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.DevTools.ViewModels.CommandsExecuteViewModel>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Experimental.ViewModels.CommandsExecuteViewModel>" %>
<h1>
<%: Html.TitleForPage(T("Command line").ToString()) %></h1>
<div>

View File

@@ -1,5 +1,5 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ContentDetailsViewModel>" %>
<%@ Import Namespace="Orchard.DevTools.ViewModels"%>
<%@ Import Namespace="Orchard.Experimental.ViewModels"%>
<%@ Import Namespace="Orchard.ContentManagement"%>
<%@ Import Namespace="System.Reflection" %>
<h1><%: Html.TitleForPage(T("{0} Content Type", Model.Item.ContentItem.ContentType).ToString(), T("Content").ToString())%></h1>

View File

@@ -1,5 +1,5 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ContentIndexViewModel>" %>
<%@ Import Namespace="Orchard.DevTools.ViewModels"%>
<%@ Import Namespace="Orchard.Experimental.ViewModels"%>
<h1><%: Html.TitleForPage(T("Content").ToString()) %></h1>
<h2><%: T("Content Types")%></h2>
<ul>

View File

@@ -1,4 +1,4 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<BaseViewModel>"%>
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<BaseViewModel>"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%: Html.TitleForPage(T("Data Migration").ToString()) %></h1>
<p><%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DatabaseUpdate") %></p>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.DevTools.Settings.DevToolsSettings>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Experimental.Settings.ExperimentalSettings>" %>
<fieldset>
<%:Html.EditorFor(m=>m.ShowDebugLinks) %>
<label for="<%:Html.FieldIdFor(m => m.ShowDebugLinks) %>" class="forcheckbox"><%:T("Show debug links") %></label>

View File

@@ -0,0 +1,6 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<div class="debug message"><%=T(
"Experimental: displaying {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>

View File

@@ -0,0 +1,8 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShowDebugLink>" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<% if (Model.ContentItem.Id > 0) { %>
<div class="debug message"><%=T(
"Experimental: editing {0}",
Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.Experimental", Model.ContentItem.Id, Model.ContentItem.Version }, new { })
) %></div>
<% } %>

View File

@@ -1,6 +1,6 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Simple>" %>
<%@ Import Namespace="Orchard.DevTools.Models" %>
<%@ Import Namespace="Orchard.Experimental.Models" %>
<h1>
<%= H(Model.Title) %></h1>
<p>

View File

@@ -1,6 +1,6 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<MetadataIndexViewModel>" %>
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Experimental.ViewModels.MetadataIndexViewModel>" %>
<%@ Import Namespace="Orchard.DevTools.ViewModels" %>
<%@ Import Namespace="Orchard.Experimental.ViewModels" %>
<style title="text/css">
ul
{

View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
<add namespace="Orchard.Mvc.Html"/>
</namespaces>
</pages>
</system.web>
<system.web.extensions/>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -91,9 +91,7 @@ namespace Orchard.Setup.Services {
"Orchard.Comments",
"Orchard.Tags",
"Orchard.Media",
"Futures.Widgets",
"Orchard.DevTools",
"Orchard.Widgets",
"Orchard.jQuery"
};

View File

@@ -115,6 +115,7 @@ namespace Orchard.Setup {
public string Author { get; set; }
public string HomePage { get; set; }
public string Tags { get; set; }
public string Zones { get; set; }
}
private readonly SafeModeTheme _theme = new SafeModeTheme {

View File

@@ -45,18 +45,18 @@ namespace Orchard.Themes.DesignerNotes {
var accessAdminPanel = _authorizationService.TryCheckAccess(
StandardPermissions.AccessAdminPanel, CurrentUser, null);
if (accessAdminPanel) {
//Temporary: Don't show "edit" button if "Futures.Widgets" is not enabled.
//Temporary: Don't show "edit" button if "Orchard.Widgets" is not enabled.
accessAdminPanel = _shellDescriptorManager
.GetShellDescriptor()
.Features
.Any(f => f.Name == "Futures.Widgets");
.Any(f => f.Name == "Orchard.Widgets");
}
var writer = context.Html.ViewContext.Writer;
if (accessAdminPanel) {
writer.Write("<div class=\"managewrapper\"><div class=\"manage\">");
writer.Write(context.Html.ActionLink(T("Edit").ToString(), "AddWidget", new {
Area = "Futures.Widgets",
Area = "Orchard.Widgets",
Controller = "Admin",
context.ZoneName,
theme.ThemeName,

View File

@@ -7,5 +7,6 @@
public string Author { get; set; }
public string HomePage { get; set; }
public string Tags { get; set; }
public string Zones { get; set; }
}
}

View File

@@ -83,6 +83,7 @@ namespace Orchard.Themes.Services {
foreach (var descriptor in _extensionManager.AvailableExtensions()) {
if (String.Equals(descriptor.Name, name, StringComparison.OrdinalIgnoreCase)) {
return CreateTheme(descriptor);
Zones = descriptor.Zones ?? String.Empty,
}
}
return null;
@@ -102,6 +103,7 @@ namespace Orchard.Themes.Services {
ITheme theme = CreateTheme(descriptor);
Zones = descriptor.Zones ?? String.Empty,
if (!theme.Tags.Contains("hidden")) {
themes.Add(theme);
}

View File

@@ -0,0 +1,15 @@
using Orchard.Localization;
using Orchard.UI.Navigation;
namespace Orchard.Widgets {
public class AdminMenu : INavigationProvider {
public Localizer T { get; set; }
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Widgets"), "10",
menu => menu
.Add(T("Manage Widgets"), "1.0", item => item.Action("Index", "Admin", new { area = "Orchard.Widgets" }).Permission(Permissions.ManageWidgets)));
}
}
}

View File

@@ -0,0 +1,21 @@
using System.Web.Mvc;
using Orchard.Localization;
using Orchard.Settings;
namespace Orchard.Widgets.Controllers {
[ValidateInput(false)]
public class AdminController : Controller {
public AdminController(IOrchardServices services) {
Services = services;
T = NullLocalizer.Instance;
}
private IOrchardServices Services { get; set; }
protected virtual ISite CurrentSite { get; set; }
public Localizer T { get; set; }
public ActionResult Index() {
return View();
}
}
}

View File

@@ -1,13 +1,11 @@
using System.Web.Mvc;
using Futures.Widgets.Models;
using Orchard;
using System;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.Mvc.Filters;
using Orchard.Settings;
using Orchard.UI.Admin;
namespace Futures.Widgets {
public class WidgetFilter : FilterProvider, IActionFilter {
namespace Orchard.Widgets.Filters {
public class WidgetFilter : FilterProvider, IResultFilter {
private readonly IContentManager _contentManager;
private readonly IWorkContextAccessor _workContextAccessor;
@@ -16,10 +14,10 @@ namespace Futures.Widgets {
_workContextAccessor = workContextAccessor;
}
public void OnActionExecuting(ActionExecutingContext filterContext) {
public void OnResultExecuting(ResultExecutingContext filterContext) {
}
public void OnActionExecuted(ActionExecutedContext filterContext) {
public void OnResultExecuted(ResultExecutedContext filterContext) {
var workContext = _workContextAccessor.GetContext(filterContext);
if (workContext == null ||
@@ -29,17 +27,11 @@ namespace Futures.Widgets {
return;
}
var siteWidgets = workContext.CurrentSite.As<WidgetsPart>();
if (siteWidgets == null) {
return;
}
var zones = workContext.Page.Zones;
foreach (var widget in siteWidgets.Widgets) {
var widgetShape = _contentManager.BuildDisplayModel(widget);
zones[widget.Record.Zone].Add(widgetShape, widget.Record.Position);
}
// Get Layers
// Get LayerZones
// Get WidgetParts
// BuildDisplayModel
// Add to Zone.
}
}
}

View File

@@ -0,0 +1,13 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Widgets.Models;
namespace Orchard.Widgets.Handlers {
[UsedImplicitly]
public class LayerPartHandler : ContentHandler {
public LayerPartHandler(IRepository<LayerPartRecord> layersRepository) {
Filters.Add(StorageFilter.For(layersRepository));
}
}
}

View File

@@ -0,0 +1,13 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Widgets.Models;
namespace Orchard.Widgets.Handlers {
[UsedImplicitly]
public class WidgetPartHandler : ContentHandler {
public WidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
Filters.Add(StorageFilter.For(widgetsRepository));
}
}
}

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
namespace Orchard.Widgets.Models {
public class Layer : ContentItem {
public IList<LayerZone> LayerZones = new List<LayerZone>();
public LayerPart LayerPart = new LayerPart();
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Widgets.Models {
public class LayerPart : ContentPart<LayerPartRecord> {
}
}

View File

@@ -0,0 +1,9 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Widgets.Models {
public class LayerPartRecord : ContentPartRecord {
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual string Rule { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
using System.Collections.Generic;
namespace Orchard.Widgets.Models {
public class LayerZone {
public IList<WidgetPart> WidgetParts = new List<WidgetPart>();
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Widgets.Models {
public class WidgetPart : ContentPart<WidgetPartRecord> {
}
}

View File

@@ -1,9 +1,8 @@
using Orchard.ContentManagement.Records;
namespace Futures.Widgets.Models {
namespace Orchard.Widgets.Models {
public class WidgetPartRecord : ContentPartRecord {
public virtual WidgetsPartRecord Scope { get; set; }
public virtual string Zone { get; set; }
public virtual string Title { get; set; }
public virtual string Position { get; set; }
}
}
}

View File

@@ -0,0 +1,11 @@
name: Widgets
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
version: 0.5.0
orchardversion: 0.5.0
description: An implementation of widgets for Orchard.
features:
Orchard.Widgets:
Description: An implementation of widgets.
Category: Widget

View File

@@ -3,21 +3,17 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E65E5633-C0FF-453C-A906-481C14F969D6}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<ProjectGuid>{194D3CCC-1153-474D-8176-FDE8D7D0D0BD}</ProjectGuid>
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Futures.Widgets</RootNamespace>
<AssemblyName>Futures.Widgets</AssemblyName>
<RootNamespace>Orchard.Widgets</RootNamespace>
<AssemblyName>Orchard.Widgets</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -27,7 +23,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -36,57 +31,68 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Mobile" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Handlers\WidgetsPartHandler.cs" />
<Compile Include="DataMigrations\WidgetsDataMigration.cs" />
<Compile Include="Models\WidgetsPartRecord.cs" />
<Compile Include="Models\WidgetsPart.cs" />
<Compile Include="Handlers\LayerPartHandler.cs" />
<Compile Include="Handlers\WidgetPartHandler.cs" />
<Compile Include="Models\Layer.cs" />
<Compile Include="Models\LayerPart.cs" />
<Compile Include="Models\LayerPartRecord.cs" />
<Compile Include="Models\LayerZone.cs" />
<Compile Include="Models\WidgetPart.cs" />
<Compile Include="Models\WidgetPartRecord.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\WidgetEditViewModel.cs" />
<Compile Include="WidgetFilter.cs" />
<Compile Include="Filters\WidgetFilter.cs" />
<Compile Include="Services\IWidgetService.cs" />
<Compile Include="Services\WidgetService.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Views\Admin\Edit.cshtml" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<Folder Include="App_Data\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<None Include="Views\Admin\Index.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
@@ -103,13 +109,14 @@
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>17593</DevelopmentServerPort>
<DevelopmentServerPort>48009</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
using Orchard.Environment.Extensions.Models;
using Orchard.Security.Permissions;
namespace Orchard.Widgets {
public class Permissions : IPermissionProvider {
public static readonly Permission ManageWidgets = new Permission { Description = "Managing Widgets", Name = "ManageWidgets" };
public virtual Feature Feature { get; set; }
public IEnumerable<Permission> GetPermissions() {
return new Permission[] {
ManageWidgets,
};
}
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
return new[] {
new PermissionStereotype {
Name = "Administrator",
Permissions = new[] {ManageWidgets}
},
};
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Orchard.Widgets")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MSIT")]
[assembly: AssemblyProduct("Orchard.Widgets")]
[assembly: AssemblyCopyright("Copyright © MSIT 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c326e210-8edd-45ba-a686-02c1370c3ad1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,8 @@
using System.Collections.Generic;
using Orchard.Widgets.Models;
namespace Orchard.Widgets.Services {
public interface IWidgetService : IDependency {
IEnumerable<Layer> GetLayers();
}
}

Some files were not shown because too many files have changed in this diff Show More