- More extension manifest parsing, module.txt now contains features metadata.

- Dependencies, Category for module's features.
- Renaming homepage field to website.
- Unit tests for manifest.

--HG--
branch : dev
This commit is contained in:
Suha Can
2010-04-06 16:40:57 -07:00
parent 5a5f83910b
commit a6029ec425
12 changed files with 118 additions and 29 deletions

View File

@@ -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;
}
}
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
website: http://www.orchardproject.net

View File

@@ -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
website: http://www.orchardproject.net

View File

@@ -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; }

View File

@@ -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<string, DataItem> fields,
string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? (Mapping)value : null;
}
private static string GetValue(
IDictionary<string, DataItem> fields,
string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? value.ToString() : null;
}
public IEnumerable<ExtensionEntry> ActiveExtensions() {
if (_activeExtensions == null) {
_activeExtensions = BuildActiveExtensions().ToList();
@@ -185,6 +174,28 @@ namespace Orchard.Extensions {
return null;
}
}
private static string[] ParseFeatureDependenciesEntry(string dependenciesEntry) {
List<string> dependencies = new List<string>();
foreach (var s in dependenciesEntry.Split(',')) {
dependencies.Add(s.Trim());
}
return dependencies.ToArray();
}
private static Mapping GetMapping(
IDictionary<string, DataItem> fields,
string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? (Mapping)value : null;
}
private static string GetValue(
IDictionary<string, DataItem> fields,
string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? value.ToString() : null;
}
}
}

View File

@@ -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; }
}
}