Skip to content

Commit

Permalink
Refactoring Media files
Browse files Browse the repository at this point in the history
- Moving Media Fields to Media Picker
- Enabling Media Library in default recipe
- Integrating TinyMce module only if features are enabled
- Disabling Media Picker in new installs

--HG--
branch : 1.x
  • Loading branch information
Sebastien Ros committed Jun 11, 2013
1 parent eeda28d commit e890127
Show file tree
Hide file tree
Showing 36 changed files with 192 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/Orchard.Profile/profiling-setup-commands.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Reports,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.Media,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Reports,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.MediaLibrary,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute
2 changes: 1 addition & 1 deletion src/Orchard.Specs/Bindings/OrchardSiteFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void GivenIHaveInstalledOrchard(string virtualDirectory) {
webApp.GivenIHaveACleanSiteWith(
virtualDirectory,
TableData(
new { extension = "Module", names = "Orchard.Setup, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.Messaging, Orchard.Media, Orchard.MediaPicker, Orchard.ContentPicker, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Packaging, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields" },
new { extension = "Module", names = "Orchard.Setup, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.Messaging, Orchard.MediaLibrary, Orchard.ContentPicker, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Packaging, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields" },
new { extension = "Core", names = "Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports" },
new { extension = "Theme", names = "SafeMode, TheAdmin, TheThemeMachine" }));

Expand Down
2 changes: 1 addition & 1 deletion src/Orchard.Specs/Setup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Scenario: Some of the initial form values are required
Scenario: Calling setup on a brand new install
Given I have a clean site with
| extension | names |
| Module | Orchard.Setup, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.Messaging, Orchard.Media, Orchard.MediaPicker, Orchard.ContentPicker, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Packaging, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields |
| Module | Orchard.Setup, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.Messaging, Orchard.MediaLibrary, Orchard.ContentPicker, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Packaging, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
| Theme | SafeMode, TheAdmin, TheThemeMachine |
And I am on "/Setup"
Expand Down
4 changes: 2 additions & 2 deletions src/Orchard.Specs/Setup.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Orchard.Web/Modules/Orchard.Fields/Module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ OrchardVersion: 1.4
Description: Some content fields
Features:
Orchard.Fields:
Description: Contains the following fields: Input, Boolean, DateTime, Numeric, Link, Enumeration, Media Picker
Description: Contains the following fields: Input, Boolean, DateTime, Numeric, Link, Enumeration
Category: Fields
Dependencies: Orchard.jQuery, Orchard.Media, Orchard.MediaPicker
Dependencies: Orchard.jQuery
31 changes: 0 additions & 31 deletions src/Orchard.Web/Modules/Orchard.Fields/Orchard.Fields.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
<Content Include="Views\Web.config" />
<Content Include="Scripts\Web.config" />
<Content Include="Styles\Web.config" />
<Compile Include="Drivers\MediaGalleryFieldDriver.cs" />
<Compile Include="Drivers\MediaPickerFieldDriver.cs" />
<Compile Include="Fields\MediaGalleryField.cs" />
<Compile Include="Handlers\MediaGalleryFieldHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
Expand Down Expand Up @@ -125,19 +121,14 @@
<Compile Include="Drivers\LinkFieldDriver.cs" />
<Compile Include="Fields\BooleanField.cs" />
<Compile Include="Fields\InputField.cs" />
<Compile Include="Fields\MediaPickerField.cs" />
<Compile Include="Fields\NumericField.cs" />
<Compile Include="Fields\DateTimeField.cs" />
<Compile Include="Fields\EnumerationField.cs" />
<Compile Include="Fields\LinkField.cs" />
<Compile Include="Settings\BooleanFieldEditorEvents.cs" />
<Compile Include="Settings\BooleanFieldSettings.cs" />
<Compile Include="Settings\MediaGalleryFieldEditorEvents.cs" />
<Compile Include="Settings\MediaGalleryFieldSettings.cs" />
<Compile Include="Settings\InputFieldEditorEvents.cs" />
<Compile Include="Settings\InputFieldSettings.cs" />
<Compile Include="Settings\MediaPickerFieldEditorEvents.cs" />
<Compile Include="Settings\MediaPickerFieldSettings.cs" />
<Compile Include="Settings\NumericFieldEditorEvents.cs" />
<Compile Include="Settings\NumericFieldSettings.cs" />
<Compile Include="Settings\LinkFieldEditorEvents.cs" />
Expand All @@ -147,38 +138,16 @@
<Compile Include="Settings\EnumerationFieldEditorEvents.cs" />
<Compile Include="Settings\EnumerationFieldSettings.cs" />
<Compile Include="Tokens\FieldTokens.cs" />
<Compile Include="ViewModels\MediaGalleryFieldViewModel.cs" />
<Compile Include="ViewModels\NumericFieldViewModel.cs" />
<Compile Include="ViewModels\DateTimeFieldViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\DefinitionTemplates\MediaPickerFieldSettings.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\EditorTemplates\Fields\MediaPicker.Edit.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Fields\MediaPicker.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Fields\Input.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\DefinitionTemplates\MediaGalleryFieldSettings.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\EditorTemplates\Fields\MediaGallery.Edit.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Fields\MediaGallery.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Fields\MediaGallery.SummaryAdmin.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
16 changes: 0 additions & 16 deletions src/Orchard.Web/Modules/Orchard.Fields/Placement.info
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,8 @@
<Place Fields_DateTime_Edit="Content:2.5"/>
<Place Fields_DateTime="Content:after"/>

<!-- MediaPicker -->
<Place Fields_MediaPicker_Edit="Content:2.3"/>
<Place Fields_MediaPicker="Content:after"/>

<!-- MediaGallery -->
<Place Fields_MediaGallery_Edit="Content:2.3"/>
<Place Fields_MediaGallery="Content:after"/>

<Match DisplayType="SummaryAdmin">
<Place Fields_DateTime="Content"/>
<Place Fields_MediaPicker="-"/>
<Place Fields_MediaGallery="-"/>
<Place Fields_MediaGallery_SummaryAdmin="Content:after"/>
</Match>

<Match DisplayType="Summary">
<Place Fields_MediaPicker="-"/>
<Place Fields_MediaGallery="-"/>
</Match>

</Placement>
21 changes: 0 additions & 21 deletions src/Orchard.Web/Modules/Orchard.Fields/Tokens/FieldTokens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ public void Describe(dynamic context) {
.Token("Time", T("Time"), T("The time only."))
.Token("DateTime", T("Date Time"), T("The date and time."))
;

context.For("MediaPickerField", T("Media Picker Field"), T("Tokens for Media Picker Fields"))
.Token("Url", T("Url"), T("The url of the media."))
.Token("AlternateText", T("Alternate Text"), T("The alternate text of the media."))
.Token("Class", T("Class"), T("The class of the media."))
.Token("Style", T("Style"), T("The style of the media."))
.Token("Alignment", T("Alignment"), T("The alignment of the media."))
.Token("Width", T("Width"), T("The width of the media."))
.Token("Height", T("Height"), T("The height of the media."))
;
}

public void Evaluate(dynamic context) {
Expand All @@ -71,17 +61,6 @@ public void Evaluate(dynamic context) {
.Token("DateTime", (Func<DateTimeField, object>)(d => d.DateTime.ToString(_dateTimeLocalization.ShortDateFormat.Text + " " + _dateTimeLocalization.ShortTimeFormat.Text, _cultureInfo.Value)))
.Chain("DateTime", "Date", (Func<DateTimeField, object>)(field => field.DateTime))
;

context.For<MediaPickerField>("MediaPickerField")
.Token("Url", (Func<MediaPickerField, object>)(field => field.Url))
.Chain("Url", "Url", (Func<MediaPickerField, object>)(field => field.Url))
.Token("AlternateText", (Func<MediaPickerField, object>)(field => field.AlternateText))
.Token("Class", (Func<MediaPickerField, object>)(field => field.Class))
.Token("Style", (Func<MediaPickerField, object>)(field => field.Style))
.Token("Alignment", (Func<MediaPickerField, object>)(field => field.Alignment))
.Token("Width", (Func<MediaPickerField, object>)(field => field.Width))
.Token("Height", (Func<MediaPickerField, object>)(field => field.Height))
;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System;
using Orchard.Fields.Settings;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Fields.Fields;
using Orchard.Fields.ViewModels;
using Orchard.Localization;
using Orchard.MediaPicker.Fields;
using Orchard.MediaPicker.Settings;
using Orchard.MediaPicker.ViewModels;
using Orchard.Services;
using Orchard.Utility.Extensions;

namespace Orchard.Fields.Drivers {
namespace Orchard.MediaPicker.Drivers {
public class MediaGalleryFieldDriver : ContentFieldDriver<MediaGalleryField> {
private readonly IJsonConverter _jsonConverter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.Linq;
using Orchard.Fields.Settings;
using Orchard.FileSystems.WebSite;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Localization;
using Orchard.MediaPicker.Fields;
using Orchard.MediaPicker.Settings;
using Orchard.Utility.Extensions;

namespace Orchard.Fields.Drivers {
public class MediaPickerFieldDriver : ContentFieldDriver<Fields.MediaPickerField> {
namespace Orchard.MediaPicker.Drivers {
public class MediaPickerFieldDriver : ContentFieldDriver<MediaPickerField> {
private readonly IWebSiteFolder _webSiteFolder;

public MediaPickerFieldDriver(IWebSiteFolder webSiteFolder) {
Expand All @@ -19,25 +20,25 @@ public MediaPickerFieldDriver(IWebSiteFolder webSiteFolder) {

public Localizer T { get; set; }

private static string GetPrefix(Fields.MediaPickerField field, ContentPart part) {
private static string GetPrefix(MediaPickerField field, ContentPart part) {
return part.PartDefinition.Name + "." + field.Name;
}

private static string GetDifferentiator(Fields.MediaPickerField field, ContentPart part) {
private static string GetDifferentiator(MediaPickerField field, ContentPart part) {
return field.Name;
}

protected override DriverResult Display(ContentPart part, Fields.MediaPickerField field, string displayType, dynamic shapeHelper) {
protected override DriverResult Display(ContentPart part, MediaPickerField field, string displayType, dynamic shapeHelper) {
return ContentShape("Fields_MediaPicker", GetDifferentiator(field, part),
() => shapeHelper.Fields_MediaPicker());
}

protected override DriverResult Editor(ContentPart part, Fields.MediaPickerField field, dynamic shapeHelper) {
protected override DriverResult Editor(ContentPart part, MediaPickerField field, dynamic shapeHelper) {
return ContentShape("Fields_MediaPicker_Edit", GetDifferentiator(field, part),
() => shapeHelper.EditorTemplate(TemplateName: "Fields/MediaPicker.Edit", Model: field, Prefix: GetPrefix(field, part)));
}

protected override DriverResult Editor(ContentPart part, Fields.MediaPickerField field, IUpdateModel updater, dynamic shapeHelper) {
protected override DriverResult Editor(ContentPart part, MediaPickerField field, IUpdateModel updater, dynamic shapeHelper) {
// if the model could not be bound, don't try to validate its properties
if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) {
var settings = field.PartFieldDefinition.Settings.GetModel<MediaPickerFieldSettings>();
Expand All @@ -58,7 +59,7 @@ protected override DriverResult Editor(ContentPart part, Fields.MediaPickerField
return Editor(part, field, shapeHelper);
}

protected override void Importing(ContentPart part, Fields.MediaPickerField field, ImportContentContext context) {
protected override void Importing(ContentPart part, MediaPickerField field, ImportContentContext context) {
context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Url", value => field.Url = value);
context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "AlternateText", value => field.AlternateText = value);
context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Class", value => field.Class = value);
Expand All @@ -68,7 +69,7 @@ protected override void Importing(ContentPart part, Fields.MediaPickerField fiel
context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Height", value => field.Height = Int32.Parse(value));
}

protected override void Exporting(ContentPart part, Fields.MediaPickerField field, ExportContentContext context) {
protected override void Exporting(ContentPart part, MediaPickerField field, ExportContentContext context) {
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Url);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("AlternateText", field.AlternateText);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Class", field.Class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Orchard.ContentManagement.Utilities;
using Orchard.ContentManagement.FieldStorage;

namespace Orchard.Fields.Fields {
namespace Orchard.MediaPicker.Fields {
public class MediaGalleryField : ContentField {
internal LazyField<ICollection<MediaGalleryItem>> _mediaGalleryItems = new LazyField<ICollection<MediaGalleryItem>>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.FieldStorage;

namespace Orchard.Fields.Fields {
namespace Orchard.MediaPicker.Fields {
public class MediaPickerField : ContentField {
public string Url {
get { return Storage.Get<string>(); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Linq;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.Fields.Fields;
using Orchard.MediaPicker.Fields;
using Orchard.Services;

namespace Orchard.Fields.Handlers {
namespace Orchard.MediaPicker.Handlers {
public class MediaGalleryFieldHandler : ContentHandler {
private readonly IJsonConverter _jsonConverter;
private readonly IContentDefinitionManager _contentDefinitionManager;
Expand Down
Loading

0 comments on commit e890127

Please sign in to comment.