diff --git a/src/Orchard.Tests/Extensions/ExtensionManagerTests.cs b/src/Orchard.Tests/Extensions/ExtensionManagerTests.cs index fe2e6a39a..36de9f64e 100644 --- a/src/Orchard.Tests/Extensions/ExtensionManagerTests.cs +++ b/src/Orchard.Tests/Extensions/ExtensionManagerTests.cs @@ -99,5 +99,81 @@ features: Assert.That(descriptor.Features.First().Description, Is.EqualTo("My super wiki module for Orchard.")); } + [Test] + public void ExtensionDescriptorsShouldBeParsedForCompleteModuleTxt() { + + _folders.Manifests.Add("AnotherWiki", @" +name: AnotherWiki +author: Coder Notaprogrammer +website: http://anotherwiki.codeplex.com +version: 1.2.3 +orchardversion: 1 +features: + AnotherWiki: + Description: My super wiki module for Orchard. + Dependencies: Versioning, Search + Category: Content types + AnotherWiki Editor: + Description: A rich editor for wiki contents. + Dependencies: TinyMCE, AnotherWiki + Category: Input methods + AnotherWiki DistributionList: + Description: Sends e-mail alerts when wiki contents gets published. + Dependencies: AnotherWiki, Email Subscriptions + Category: Email + AnotherWiki Captcha: + Description: Kills spam. Or makes it zombie-like. + Dependencies: AnotherWiki, reCaptcha + Category: Spam +"); + + var descriptor = _manager.AvailableExtensions().Single(); + Assert.That(descriptor.Name, Is.EqualTo("AnotherWiki")); + Assert.That(descriptor.Author, Is.EqualTo("Coder Notaprogrammer")); + Assert.That(descriptor.WebSite, Is.EqualTo("http://anotherwiki.codeplex.com")); + Assert.That(descriptor.Version, Is.EqualTo("1.2.3")); + Assert.That(descriptor.OrchardVersion, Is.EqualTo("1")); + Assert.That(descriptor.Features.Count(), Is.EqualTo(4)); + foreach (var featureDescriptor in descriptor.Features) { + switch (featureDescriptor.Name) { + case "AnotherWiki": + Assert.That(featureDescriptor.ExtensionName, Is.EqualTo("AnotherWiki")); + Assert.That(featureDescriptor.Description, Is.EqualTo("My super wiki module for Orchard.")); + Assert.That(featureDescriptor.Category, Is.EqualTo("Content types")); + Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2)); + Assert.That(featureDescriptor.Dependencies.Contains("Versioning")); + Assert.That(featureDescriptor.Dependencies.Contains("Search")); + break; + case "AnotherWiki Editor": + Assert.That(featureDescriptor.ExtensionName, Is.EqualTo("AnotherWiki")); + Assert.That(featureDescriptor.Description, Is.EqualTo("A rich editor for wiki contents.")); + Assert.That(featureDescriptor.Category, Is.EqualTo("Input methods")); + Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2)); + Assert.That(featureDescriptor.Dependencies.Contains("TinyMCE")); + Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki")); + break; + case "AnotherWiki DistributionList": + Assert.That(featureDescriptor.ExtensionName, Is.EqualTo("AnotherWiki")); + Assert.That(featureDescriptor.Description, Is.EqualTo("Sends e-mail alerts when wiki contents gets published.")); + Assert.That(featureDescriptor.Category, Is.EqualTo("Email")); + Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2)); + Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki")); + Assert.That(featureDescriptor.Dependencies.Contains("Email Subscriptions")); + break; + case "AnotherWiki Captcha": + Assert.That(featureDescriptor.ExtensionName, Is.EqualTo("AnotherWiki")); + Assert.That(featureDescriptor.Description, Is.EqualTo("Kills spam. Or makes it zombie-like.")); + Assert.That(featureDescriptor.Category, Is.EqualTo("Spam")); + Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2)); + Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki")); + Assert.That(featureDescriptor.Dependencies.Contains("reCaptcha")); + break; + default: + Assert.Fail("Features not parsed correctly"); + break; + } + } + } + } } diff --git a/src/Orchard.Web/Core/Themes/Services/ThemeService.cs b/src/Orchard.Web/Core/Themes/Services/ThemeService.cs index ce81b58d0..fe24c84fc 100644 --- a/src/Orchard.Web/Core/Themes/Services/ThemeService.cs +++ b/src/Orchard.Web/Core/Themes/Services/ThemeService.cs @@ -70,7 +70,7 @@ namespace Orchard.Core.Themes.Services { Author = descriptor.Author ?? String.Empty, Description = descriptor.Description ?? String.Empty, DisplayName = descriptor.DisplayName ?? String.Empty, - HomePage = descriptor.HomePage ?? String.Empty, + HomePage = descriptor.WebSite ?? String.Empty, ThemeName = descriptor.Name, Version = descriptor.Version ?? String.Empty, Tags = descriptor.Tags ?? String.Empty @@ -88,7 +88,7 @@ namespace Orchard.Core.Themes.Services { Author = descriptor.Author ?? String.Empty, Description = descriptor.Description ?? String.Empty, DisplayName = descriptor.DisplayName ?? String.Empty, - HomePage = descriptor.HomePage ?? String.Empty, + HomePage = descriptor.WebSite ?? String.Empty, ThemeName = descriptor.Name, Version = descriptor.Version ?? String.Empty, Tags = descriptor.Tags ?? String.Empty diff --git a/src/Orchard.Web/Themes/Classic/Theme.txt b/src/Orchard.Web/Themes/Classic/Theme.txt index 46f52a9ec..f8f804413 100644 --- a/src/Orchard.Web/Themes/Classic/Theme.txt +++ b/src/Orchard.Web/Themes/Classic/Theme.txt @@ -3,4 +3,4 @@ author: Jonathan Wall description: Theme using serif. version: 1.0 tags: Classic, Serif -homepage: http://www.orchardproject.net +website: http://www.orchardproject.net diff --git a/src/Orchard.Web/Themes/ClassicDark/Theme.txt b/src/Orchard.Web/Themes/ClassicDark/Theme.txt index b2bcb4a9c..ae4074b29 100644 --- a/src/Orchard.Web/Themes/ClassicDark/Theme.txt +++ b/src/Orchard.Web/Themes/ClassicDark/Theme.txt @@ -3,4 +3,4 @@ author: Jonathan Wall description: Dark version of the Classic theme. version: 1.0 tags: Classic, Dark, Serif -homepage: http://www.orchardproject.net +website: http://www.orchardproject.net diff --git a/src/Orchard.Web/Themes/Contoso/Theme.txt b/src/Orchard.Web/Themes/Contoso/Theme.txt index eb7a5bdf3..9264d9bc7 100644 --- a/src/Orchard.Web/Themes/Contoso/Theme.txt +++ b/src/Orchard.Web/Themes/Contoso/Theme.txt @@ -3,4 +3,4 @@ author: Michael Dorian Bach description: A simple CMS theme perfect for any modern product or service business website. version: 1.0 tags: business, cms, modern -homepage: http://www.orchardproject.net +website: http://www.orchardproject.net diff --git a/src/Orchard.Web/Themes/Corporate/Theme.txt b/src/Orchard.Web/Themes/Corporate/Theme.txt index 9ae4a3184..9451aed15 100644 --- a/src/Orchard.Web/Themes/Corporate/Theme.txt +++ b/src/Orchard.Web/Themes/Corporate/Theme.txt @@ -3,4 +3,4 @@ author: Michael Dorian Bach description: A simple and neutral business theme for a variety of industries. version: 1.0 tags: business, cms, simple, classic, medical, finance, legal, corporate -homepage: http://www.orchardproject.net +website: http://www.orchardproject.net diff --git a/src/Orchard.Web/Themes/Green/Theme.txt b/src/Orchard.Web/Themes/Green/Theme.txt index 6c56fe58c..44638b8ec 100644 --- a/src/Orchard.Web/Themes/Green/Theme.txt +++ b/src/Orchard.Web/Themes/Green/Theme.txt @@ -3,4 +3,4 @@ author: Jonathan Wall description: This is the Green theme. It uses the YUI grid system for layout. version: 1.0 tags: green, YUI -homepage: http://www.orchardproject.net +website: http://www.orchardproject.net diff --git a/src/Orchard.Web/Themes/SafeMode/Theme.txt b/src/Orchard.Web/Themes/SafeMode/Theme.txt index d25fa82bc..659e52996 100644 --- a/src/Orchard.Web/Themes/SafeMode/Theme.txt +++ b/src/Orchard.Web/Themes/SafeMode/Theme.txt @@ -3,4 +3,4 @@ author: Jonathan Wall description: The Orchard Theme for setup and failure conditions. version: 1.0 tags: hidden -homepage: http://www.orchardproject.net \ No newline at end of file +website: http://www.orchardproject.net \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheAdmin/Theme.txt b/src/Orchard.Web/Themes/TheAdmin/Theme.txt index 6382f8be4..f154c7821 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Theme.txt +++ b/src/Orchard.Web/Themes/TheAdmin/Theme.txt @@ -3,4 +3,4 @@ version: 1.0 author: Jon Wall tags: hidden, admin description: An admin theme not to be used for the site so don't click "Activate" (or "Uninstall"). In the near future admin themes won't be mixed in with site themes. -homepage: http://www.orchardproject.net \ No newline at end of file +website: http://www.orchardproject.net \ No newline at end of file diff --git a/src/Orchard/Extensions/ExtensionDescriptor.cs b/src/Orchard/Extensions/ExtensionDescriptor.cs index 54473e4bc..d5b960d9b 100644 --- a/src/Orchard/Extensions/ExtensionDescriptor.cs +++ b/src/Orchard/Extensions/ExtensionDescriptor.cs @@ -23,7 +23,7 @@ namespace Orchard.Extensions { public string Version { get; set; } public string OrchardVersion { get; set; } public string Author { get; set; } - public string HomePage { get; set; } + public string WebSite { get; set; } public string Tags { get; set; } public string AntiForgery { get; set; } diff --git a/src/Orchard/Extensions/ExtensionManager.cs b/src/Orchard/Extensions/ExtensionManager.cs index 6251b043b..16c9f9d55 100644 --- a/src/Orchard/Extensions/ExtensionManager.cs +++ b/src/Orchard/Extensions/ExtensionManager.cs @@ -7,7 +7,6 @@ using Orchard.Extensions.Helpers; using Orchard.Extensions.Loaders; using Orchard.Localization; using Orchard.Logging; -using Orchard.Utility; using Yaml.Grammar; using System.Web; @@ -57,7 +56,7 @@ namespace Orchard.Extensions { Version = GetValue(fields, "version"), OrchardVersion = GetValue(fields, "orchardversion"), Author = GetValue(fields, "author"), - HomePage = GetValue(fields, "homepage"), + WebSite = GetValue(fields, "website"), Tags = GetValue(fields, "tags"), AntiForgery = GetValue(fields, "antiforgery"), Features = GetFeaturesForExtension(GetMapping(fields, "features"), name), @@ -77,6 +76,12 @@ namespace Orchard.Extensions { if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) { featureDescriptor.Description = featureEntity.Value.ToString(); } + else if (String.Equals(featureEntity.Key.ToString(), "category", StringComparison.OrdinalIgnoreCase)) { + featureDescriptor.Category = featureEntity.Value.ToString(); + } + else if (String.Equals(featureEntity.Key.ToString(), "dependencies", StringComparison.OrdinalIgnoreCase)) { + featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureEntity.Value.ToString()); + } } featureDescriptors.Add(featureDescriptor); @@ -84,22 +89,6 @@ namespace Orchard.Extensions { return featureDescriptors; } - private static Mapping GetMapping( - IDictionary fields, - string key) { - - DataItem value; - return fields.TryGetValue(key, out value) ? (Mapping)value : null; - } - - private static string GetValue( - IDictionary fields, - string key) { - - DataItem value; - return fields.TryGetValue(key, out value) ? value.ToString() : null; - } - public IEnumerable ActiveExtensions() { if (_activeExtensions == null) { _activeExtensions = BuildActiveExtensions().ToList(); @@ -185,6 +174,28 @@ namespace Orchard.Extensions { return null; } - } + private static string[] ParseFeatureDependenciesEntry(string dependenciesEntry) { + List dependencies = new List(); + foreach (var s in dependenciesEntry.Split(',')) { + dependencies.Add(s.Trim()); + } + return dependencies.ToArray(); + } + private static Mapping GetMapping( + IDictionary fields, + string key) { + + DataItem value; + return fields.TryGetValue(key, out value) ? (Mapping)value : null; + } + + private static string GetValue( + IDictionary fields, + string key) { + + DataItem value; + return fields.TryGetValue(key, out value) ? value.ToString() : null; + } + } } diff --git a/src/Orchard/Extensions/FeatureDescriptor.cs b/src/Orchard/Extensions/FeatureDescriptor.cs index 2fe5d87ef..c45bed460 100644 --- a/src/Orchard/Extensions/FeatureDescriptor.cs +++ b/src/Orchard/Extensions/FeatureDescriptor.cs @@ -3,5 +3,7 @@ public string ExtensionName { get; set; } public string Name { get; set; } public string Description { get; set; } + public string Category { get; set; } + public string[] Dependencies { get; set; } } }