Skip to content

Commit 6a5c58d

Browse files
committed
Feed URL moved to configuration from settings
1 parent 3c4c1ac commit 6a5c58d

18 files changed

Lines changed: 58 additions & 292 deletions

File tree

BlogEngine/BlogEngine.Core/BlogConfig.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,5 +280,21 @@ public static string DefaultEditor
280280
}
281281
}
282282
#endregion
283+
284+
#region GalleryFeedUrl
285+
286+
/// <summary>
287+
/// Online gallery feed endpoint
288+
/// </summary>
289+
public static string GalleryFeedUrl
290+
{
291+
get
292+
{
293+
return string.IsNullOrEmpty(WebConfigurationManager.AppSettings["BlogEngine.GalleryFeedUrl"])
294+
? "http://dnbe.net/v01/nuget"
295+
: WebConfigurationManager.AppSettings["BlogEngine.GalleryFeedUrl"];
296+
}
297+
}
298+
#endregion
283299
}
284300
}

BlogEngine/BlogEngine.Core/BlogSettings.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,20 +1258,6 @@ public string Version()
12581258

12591259
#endregion
12601260

1261-
#region GalleryFeedUrl
1262-
1263-
private string _galleryFeedUrl;
1264-
/// <summary>
1265-
/// Gallery server feed URL
1266-
/// </summary>
1267-
public string GalleryFeedUrl
1268-
{
1269-
get { return string.IsNullOrEmpty(_galleryFeedUrl) ? "http://dnbe.net/v01/nuget" : _galleryFeedUrl; }
1270-
set { _galleryFeedUrl = value; }
1271-
}
1272-
1273-
#endregion
1274-
12751261
#region Custom front page
12761262
/// <summary>
12771263
/// When file with name "FrontPage.aspx" or "FrontPage.cshtml"

BlogEngine/BlogEngine.Core/Data/Models/Settings.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ public Settings() { }
104104
/// Require SSL for meta weblog api
105105
/// </summary>
106106
public bool RequireSslForMetaWeblogApi { get; set; }
107-
/// <summary>
108-
/// Gallery feed url
109-
/// </summary>
110-
public string GalleryFeedUrl { get; set; }
111107

112108
public bool EnablePasswordReset { get; set; }
113109
public bool EnableSelfRegistration { get; set; }

BlogEngine/BlogEngine.Core/Data/PackageRepository.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ public IEnumerable<Package> Find(int take = 10, int skip = 0, string filter = ""
5555
{
5656
if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.ManagePackages))
5757
throw new System.UnauthorizedAccessException();
58-
pkgsToLoad = CachedPackages;
58+
59+
if (filter.ToLower() == "themelist")
60+
{
61+
pkgsToLoad = CachedPackages.Where(p => p.PackageType == "Theme").ToList();
62+
}
63+
else
64+
{
65+
pkgsToLoad = CachedPackages;
66+
}
5967
}
6068

6169
if (take == 0) take = pkgsToLoad.Count();

BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public Settings Get()
4646
ns.CompressWebResource = bs.CompressWebResource;
4747
ns.EnableOpenSearch = bs.EnableOpenSearch;
4848
ns.RequireSslForMetaWeblogApi = bs.RequireSslMetaWeblogApi;
49-
ns.GalleryFeedUrl = bs.GalleryFeedUrl;
5049

5150
ns.EnablePasswordReset = bs.EnablePasswordReset;
5251
ns.EnableSelfRegistration = bs.EnableSelfRegistration;
@@ -164,7 +163,6 @@ public bool Update(Settings ns)
164163
bs.CompressWebResource = ns.CompressWebResource;
165164
bs.EnableOpenSearch = ns.EnableOpenSearch;
166165
bs.RequireSslMetaWeblogApi = ns.RequireSslForMetaWeblogApi;
167-
bs.GalleryFeedUrl = ns.GalleryFeedUrl;
168166

169167
bs.EnablePasswordReset = ns.EnablePasswordReset;
170168
bs.EnableSelfRegistration = ns.EnableSelfRegistration;

BlogEngine/BlogEngine.Core/Packaging/Gallery.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static void Load(List<Package> packages)
5757
jp.Extra = extra;
5858
jp.DownloadCount = extra.DownloadCount;
5959
jp.Rating = extra.Rating;
60+
jp.PackageType = extra.PkgType.ToString();
6061
}
6162
}
6263
packages.Add(jp);
@@ -79,7 +80,7 @@ public static PackageExtra GetPackageExtra(string id)
7980
{
8081
try
8182
{
82-
var url = BlogSettings.Instance.GalleryFeedUrl.Replace("/nuget", "/api/extras/" + id);
83+
var url = BlogConfig.GalleryFeedUrl.Replace("/nuget", "/api/extras/" + id);
8384
WebClient wc = new WebClient();
8485
string json = wc.DownloadString(url);
8586
return JsonConvert.DeserializeObject<PackageExtra>(json);
@@ -99,7 +100,7 @@ public static IEnumerable<PackageExtra> GetPackageExtras()
99100
{
100101
try
101102
{
102-
var url = BlogSettings.Instance.GalleryFeedUrl.Replace("/nuget", "/api/extras");
103+
var url = BlogConfig.GalleryFeedUrl.Replace("/nuget", "/api/extras");
103104
WebClient wc = new WebClient();
104105
string json = wc.DownloadString(url);
105106
return JsonConvert.DeserializeObject<List<PackageExtra>>(json);
@@ -120,7 +121,7 @@ public static string RatePackage(string id, Review review)
120121
{
121122
try
122123
{
123-
var url = BlogSettings.Instance.GalleryFeedUrl.Replace("/nuget", "/api/review?pkgId=" + id);
124+
var url = BlogConfig.GalleryFeedUrl.Replace("/nuget", "/api/review?pkgId=" + id);
124125
WebClient wc = new WebClient();
125126
var data = JsonConvert.SerializeObject(review);
126127
wc.Headers.Add("content-type", "application/json");
@@ -145,7 +146,7 @@ public static string RatePackage(string id, Review review)
145146

146147
static IEnumerable<IPackage> GetNugetPackages()
147148
{
148-
var rep = PackageRepositoryFactory.Default.CreateRepository(BlogSettings.Instance.GalleryFeedUrl);
149+
var rep = PackageRepositoryFactory.Default.CreateRepository(BlogConfig.GalleryFeedUrl);
149150
return rep.GetPackages();
150151
}
151152

BlogEngine/BlogEngine.Core/Packaging/GalleryData.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System;
24
using System.Collections.Generic;
35

46
public class PackageExtra
@@ -7,8 +9,13 @@ public enum PackageType
79
{
810
Extension, Theme, Widget
911
}
12+
13+
[JsonConverter(typeof(StringEnumConverter))]
14+
public PackageType PkgType { get; set; }
15+
1016
public string Id { get; set; }
1117
public int DownloadCount { get; set; }
18+
1219
public float Rating
1320
{
1421
get

BlogEngine/BlogEngine.Core/Packaging/Installer.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ private static IPackageRepository _repository
1818
{
1919
get
2020
{
21-
return PackageRepositoryFactory.Default.CreateRepository(
22-
BlogSettings.Instance.GalleryFeedUrl);
21+
return PackageRepositoryFactory.Default.CreateRepository(BlogConfig.GalleryFeedUrl);
2322
}
2423
}
2524

@@ -37,7 +36,7 @@ public static bool InstallPackage(string pkgId)
3736

3837
var packageManager = new PackageManager(
3938
_repository,
40-
new DefaultPackagePathResolver(BlogSettings.Instance.GalleryFeedUrl),
39+
new DefaultPackagePathResolver(BlogConfig.GalleryFeedUrl),
4140
new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
4241
);
4342

@@ -106,7 +105,7 @@ private static void UninstallGalleryPackage(string pkgId)
106105
// if installed from gallery, also remove NuGet package files
107106
var packageManager = new PackageManager(
108107
_repository,
109-
new DefaultPackagePathResolver(BlogSettings.Instance.GalleryFeedUrl),
108+
new DefaultPackagePathResolver(BlogConfig.GalleryFeedUrl),
110109
new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
111110
);
112111
var package = _repository.FindPackage(pkgId);

BlogEngine/BlogEngine.Core/Web/HttpHandlers/ResourceHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void ProcessRequest(HttpContext context)
9494
sbSiteVars.Append("BlogInstanceId: '" + Blog.CurrentInstance.Id + "',");
9595
sbSiteVars.Append("AbsoluteWebRoot: '" + Utils.AbsoluteWebRoot + "',");
9696
sbSiteVars.Append("GenericPageSize: '" + BlogConfig.GenericPageSize.ToString() + "',");
97-
sbSiteVars.Append("GalleryFeedUrl: '" + BlogSettings.Instance.GalleryFeedUrl + "',");
97+
sbSiteVars.Append("GalleryFeedUrl: '" + BlogConfig.GalleryFeedUrl + "',");
9898
sbSiteVars.Append("IsPrimary: '" + Blog.CurrentInstance.IsPrimary + "',");
9999
sbSiteVars.Append("Version: 'BlogEngine.NET " + BlogSettings.Instance.Version() + "'");
100100

BlogEngine/BlogEngine.NET/AppCode/Api/GalleryFeedsController.cs

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)