Update: Plugin Framework
This commit is contained in:
@@ -34,41 +34,36 @@ namespace Disco.Web.Areas.Config.Models.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
public List<Tuple<Type, List<PluginManifest>>> PluginManifestsByType
|
||||
public List<Tuple<Type, List<PluginManifest>>> PluginManifestsByCategory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PluginManifests.Count == 0)
|
||||
return new List<Tuple<Type, List<PluginManifest>>>();
|
||||
return null;
|
||||
|
||||
var categorisedManifests = PluginManifests.SelectMany(pm => pm.Features)
|
||||
.GroupBy(fm => fm.CategoryType)
|
||||
.Select(g => new Tuple<Type, List<PluginManifest>>(g.Key, g.Select(fm => fm.PluginManifest).Distinct().OrderBy(fm => fm.Name).ToList())).ToList();
|
||||
|
||||
// Ensure all plugins are represented
|
||||
var allCategorisedManifests = categorisedManifests.SelectMany(g => g.Item2).ToList();
|
||||
|
||||
var unrepresentedPlugins = PluginManifests.Where(m => !allCategorisedManifests.Contains(m)).ToList();
|
||||
if (unrepresentedPlugins.Count > 0)
|
||||
List<Tuple<Type, PluginManifest>> pluginsByCategory = new List<Tuple<Type, PluginManifest>>();
|
||||
|
||||
foreach (var pluginManifest in PluginManifests)
|
||||
{
|
||||
Tuple<Type, List<PluginManifest>> otherCategory = null;
|
||||
foreach (var category in categorisedManifests)
|
||||
{
|
||||
if (category.Item1 == typeof(OtherFeature))
|
||||
{
|
||||
otherCategory = category;
|
||||
}
|
||||
}
|
||||
if (otherCategory == null)
|
||||
{
|
||||
otherCategory = new Tuple<Type, List<PluginManifest>>(typeof(OtherFeature), new List<PluginManifest>());
|
||||
categorisedManifests.Add(otherCategory);
|
||||
}
|
||||
foreach (var pluginManifest in unrepresentedPlugins)
|
||||
otherCategory.Item2.Add(pluginManifest);
|
||||
var orderedFeatures = pluginManifest.Features.OrderBy(pf => pf.Id);
|
||||
var primaryFeature = orderedFeatures.Where(pf => pf.PrimaryFeature).FirstOrDefault();
|
||||
Type categoryType;
|
||||
|
||||
if (primaryFeature == null)
|
||||
primaryFeature = orderedFeatures.FirstOrDefault();
|
||||
|
||||
if (primaryFeature == null)
|
||||
categoryType = typeof(OtherFeature);
|
||||
else
|
||||
categoryType = primaryFeature.CategoryType;
|
||||
|
||||
pluginsByCategory.Add(new Tuple<Type, PluginManifest>(categoryType, pluginManifest));
|
||||
}
|
||||
|
||||
return categorisedManifests;
|
||||
return pluginsByCategory.GroupBy(p => p.Item1)
|
||||
.OrderBy(g => g.Key.Name)
|
||||
.Select(g => new Tuple<Type, List<PluginManifest>>(g.Key, g.Select(pg => pg.Item2).OrderBy(p => p.Name).ToList())).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
var pluginGroups = Model.PluginManifestsByType;
|
||||
var pluginGroups = Model.PluginManifestsByCategory;
|
||||
|
||||
|
||||
int itemsPerColumn = pluginGroups.Count / 3;
|
||||
@@ -38,7 +38,7 @@
|
||||
<h3>@pluginDefinition.Name</h3>
|
||||
</a>
|
||||
<div class="pageMenuBlurb">
|
||||
<span class="pluginId">@pluginDefinition.Id</span> | <span class="pluginVersion">v@(pluginDefinition.VersionFormatted)</span> | @pluginDefinition.Author | <a href="@pluginDefinition.Url" target="_blank">More Information</a>
|
||||
<span class="pluginVersion">v@(pluginDefinition.VersionFormatted)</span> | @pluginDefinition.Author | <a href="@pluginDefinition.Url" target="_blank">More Information</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Disco.Web.Areas.Config.Views.Plugins
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.4.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Plugins/Index.cshtml")]
|
||||
public class Index : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.Plugins.IndexViewModel>
|
||||
public partial class Index : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.Plugins.IndexViewModel>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
@@ -88,7 +88,7 @@ WriteLiteral(">\r\n <h2>No Plugins are Installed</h2>\r\n </di
|
||||
}
|
||||
else
|
||||
{
|
||||
var pluginGroups = Model.PluginManifestsByType;
|
||||
var pluginGroups = Model.PluginManifestsByCategory;
|
||||
|
||||
|
||||
int itemsPerColumn = pluginGroups.Count / 3;
|
||||
@@ -169,14 +169,14 @@ WriteLiteral("</h2>\r\n");
|
||||
#line hidden
|
||||
WriteLiteral(" <a");
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1435), Tuple.Create("\"", 1504)
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1439), Tuple.Create("\"", 1508)
|
||||
|
||||
#line 37 "..\..\Areas\Config\Views\Plugins\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1442), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.Plugins.Configure(pluginDefinition.Id))
|
||||
, Tuple.Create(Tuple.Create("", 1446), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.Plugins.Configure(pluginDefinition.Id))
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1442), false)
|
||||
, 1446), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <h3>");
|
||||
@@ -196,26 +196,13 @@ WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n <span");
|
||||
|
||||
WriteLiteral(" class=\"pluginId\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 41 "..\..\Areas\Config\Views\Plugins\Index.cshtml"
|
||||
Write(pluginDefinition.Id);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span> | <span");
|
||||
|
||||
WriteLiteral(" class=\"pluginVersion\"");
|
||||
|
||||
WriteLiteral(">v");
|
||||
|
||||
|
||||
#line 41 "..\..\Areas\Config\Views\Plugins\Index.cshtml"
|
||||
Write(pluginDefinition.VersionFormatted);
|
||||
Write(pluginDefinition.VersionFormatted);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -224,21 +211,21 @@ WriteLiteral("</span> | ");
|
||||
|
||||
|
||||
#line 41 "..\..\Areas\Config\Views\Plugins\Index.cshtml"
|
||||
Write(pluginDefinition.Author);
|
||||
Write(pluginDefinition.Author);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" | <a");
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1885), Tuple.Create("\"", 1913)
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1836), Tuple.Create("\"", 1864)
|
||||
|
||||
#line 41 "..\..\Areas\Config\Views\Plugins\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1892), Tuple.Create<System.Object, System.Int32>(pluginDefinition.Url
|
||||
, Tuple.Create(Tuple.Create("", 1843), Tuple.Create<System.Object, System.Int32>(pluginDefinition.Url
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1892), false)
|
||||
, 1843), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" target=\"_blank\"");
|
||||
|
||||
Reference in New Issue
Block a user