diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.Packaging/AdminMenu.cs index 563cda0e5..045bdc775 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/AdminMenu.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/AdminMenu.cs @@ -13,7 +13,7 @@ namespace Orchard.Packaging { builder.Add(T("Gallery"), "5", menu => menu .Add(T("Browse Gallery"), "1.0", item => item .Action("Index", "Gallery", new { area = "Orchard.Packaging" })) - .Add(T("Manage Feeds"), "2.0", item => item + .Add(T("Gallery Feeds"), "2.0", item => item .Action("Sources", "Gallery", new { area = "Orchard.Packaging" }))); } } diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs index d36c4a137..5e4210625 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs @@ -33,7 +33,7 @@ namespace Orchard.Packaging.Controllers { Localizer T { get; set; } public ActionResult Index() { - return Modules(); + return Modules(Guid.Empty); } public ActionResult Sources() { @@ -42,16 +42,59 @@ namespace Orchard.Packaging.Controllers { }); } - public ActionResult AddSource(string url) { - _packagingSourceManager.AddSource(new PackagingSource { Id = Guid.NewGuid(), FeedUrl = url }); + public ActionResult Remove(Guid id) { + _packagingSourceManager.RemoveSource(id); + _notifier.Information(T("The feed has been removed successfully.")); Update(); return RedirectToAction("Sources"); } + public ActionResult AddSource() { + return View(new PackagingAddSourceViewModel()); + } + + public ActionResult AddSourceViewResult(PackagingAddSourceViewModel model) { + return View("AddSource", model); + } + + [HttpPost] + public ActionResult AddSource(string title, string url) { + try { + if ( !String.IsNullOrEmpty(url) ) { + if (!url.StartsWith("http")) { + ModelState.AddModelError("Url", T("The Url is a valid").Text); + } + } + else if ( String.IsNullOrWhiteSpace(url)) { + ModelState.AddModelError("Url", T("Url is required").Text); + } + + if ( String.IsNullOrWhiteSpace(title) ) { + ModelState.AddModelError("Url", T("Title is required").Text); + } + + if ( !ModelState.IsValid ) + return AddSourceViewResult(new PackagingAddSourceViewModel(){Title = title, Url = url}); + + _packagingSourceManager.AddSource(new PackagingSource { Id = Guid.NewGuid(), FeedUrl = url, FeedTitle = title }); + _notifier.Information(T("The feed has been added successfully.")); + Update(); + return RedirectToAction("Sources"); + } + catch ( Exception exception ) { + _notifier.Error(T("Adding feed failed: {0}", exception.Message)); + return AddSourceViewResult(new PackagingAddSourceViewModel() { Title = title, Url = url }); + } + } + + + public ActionResult Modules(Guid? sourceId) { + var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault(); - public ActionResult Modules() { return View("Modules", new PackagingModulesViewModel { - Modules = _packagingSourceManager.GetModuleList() + Modules = _packagingSourceManager.GetModuleList(selectedSource), + Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle), + SelectedSource = selectedSource }); } diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj index 3dc551b0e..e66330312 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj @@ -86,6 +86,7 @@ + @@ -93,6 +94,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/IPackagingSourceManager.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/IPackagingSourceManager.cs index 5f5528630..36ee71b0b 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/IPackagingSourceManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/IPackagingSourceManager.cs @@ -8,6 +8,6 @@ namespace Orchard.Packaging.Services { void RemoveSource(Guid id); void UpdateLists(); - IEnumerable GetModuleList(); + IEnumerable GetModuleList(PackagingSource packagingSource = null); } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSource.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSource.cs index dec7b0aad..2cc6f5e50 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSource.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSource.cs @@ -3,6 +3,7 @@ using System; namespace Orchard.Packaging.Services { public class PackagingSource { public Guid Id { get; set; } + public string FeedTitle { get; set; } public string FeedUrl { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs index fd6714b48..7478e0c6d 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs @@ -46,8 +46,8 @@ namespace Orchard.Packaging.Services { } } - public IEnumerable GetModuleList() { - IEnumerable packageInfos = GetSources() + public IEnumerable GetModuleList(PackagingSource packagingSource = null) { + IEnumerable packageInfos = ( packagingSource == null ? GetSources() : new [] { packagingSource }) .SelectMany( source => Bind(ParseFeed(_appDataFolder.ReadFile(GetFeedCachePath(source))), diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingAddSourceViewModel.cs b/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingAddSourceViewModel.cs new file mode 100644 index 000000000..1b19a6774 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingAddSourceViewModel.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace Orchard.Packaging.ViewModels { + public class PackagingAddSourceViewModel { + + [Required] + public string Url { get; set; } + + [Required] + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingModulesViewModel.cs b/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingModulesViewModel.cs index 72d718de3..1eaeba222 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingModulesViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/ViewModels/PackagingModulesViewModel.cs @@ -4,5 +4,7 @@ using Orchard.Packaging.Services; namespace Orchard.Packaging.ViewModels { public class PackagingModulesViewModel { public IEnumerable Modules { get; set; } + public IEnumerable Sources { get; set; } + public PackagingSource SelectedSource { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddSource.ascx b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddSource.ascx new file mode 100644 index 000000000..1b139ba6e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/AddSource.ascx @@ -0,0 +1,16 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +

+ <%: Html.TitleForPage(T("Add a Feed").ToString())%>

+ +<%using ( Html.BeginFormAntiForgeryPost(Url.Action("AddSource")) ) { %> + <%: Html.ValidationSummary() %> +
+ + + + +
+
+ " /> +
+ <% } %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Modules.ascx b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Modules.ascx index 9f8228b12..d2827f052 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Modules.ascx +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Modules.ascx @@ -2,13 +2,46 @@

<%: Html.TitleForPage(T("Browse Gallery").ToString())%>

-

<%:Html.ActionLink("Update List", "Update") %>

+
+ <%:Html.ActionLink("Update List", "Update", new object{}, new { @class = "button primaryAction" }) %> +
+<% using ( Html.BeginFormAntiForgeryPost(Url.Action("Modules", "Gallery")) ) {%> +
+ + + +
+<% + } %> + -
    +<% if (Model.Modules.Count() > 0) { %> +
      <%foreach (var item in Model.Modules) {%> -
    • - <%:item.SyndicationItem.Title.Text%> - [<%:Html.ActionLink("Install", "Install", new RouteValueDictionary {{"SyndicationId",item.SyndicationItem.Id}})%>] -
    • - <%}%> -
    +
  • +
      +
      +

      <%: item.SyndicationItem.Title.Text %> - <%: T("Version: {0}", "1.0")%>

      +

      <%:item.SyndicationItem.Summary.Text %>

      +
        +
      • <%: T("Last Updated: {0}", item.SyndicationItem.LastUpdatedTime.ToLocalTime()) %>
      • +
      •  | <%: T("Author: {0}", item.SyndicationItem.Authors.Any() ? String.Join(", ", item.SyndicationItem.Authors.Select(a => a.Name)) : T("Unknown").Text)%>
      • +
      +
      + +
    +
  • <% + }%> +
<% + }%> + diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Sources.ascx b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Sources.ascx index 956d48eb8..0e1df6caf 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Sources.ascx +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Views/Gallery/Sources.ascx @@ -1,13 +1,39 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>

- <%: Html.TitleForPage(T("Manage Feeds").ToString())%>

+ <%: Html.TitleForPage(T("Gallery Feeds").ToString())%> -
    - <%foreach (var item in Model.Sources) {%>
  • - <%:Html.Link(item.FeedUrl, item.FeedUrl)%>
  • - <% }%> -
+
+ <%:Html.ActionLink(T("Add a Feed").Text, "AddSource", new { }, new { @class = "button primaryAction" }) %> +
-<%using (Html.BeginFormAntiForgeryPost(Url.Action("AddSource"))) {%> -Url: <%:Html.TextBox("url") %> -<%} %> +
+ "> + + + + + + + + + + + + + <% + foreach ( var item in Model.Sources ) { + %> + + + + + + <% } %> +
<%: T("Title")%><%: T("Url")%>
+ <%: item.FeedTitle %> + + <%:Html.Link(item.FeedUrl, item.FeedUrl)%> + + <%: Html.ActionLink(T("Remove").ToString(), "Remove", new { id = item.Id })%> +
+
diff --git a/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj b/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj index 7b779309e..ab89c67a8 100644 --- a/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj +++ b/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj @@ -90,7 +90,9 @@
- + + Designer + Web.config diff --git a/src/Tools/PackageIndexReferenceImplementation/Web.config b/src/Tools/PackageIndexReferenceImplementation/Web.config index 85e16e0c1..aca1cb27a 100644 --- a/src/Tools/PackageIndexReferenceImplementation/Web.config +++ b/src/Tools/PackageIndexReferenceImplementation/Web.config @@ -13,6 +13,8 @@ + +