public static void Load(List<JsonPackage> packages)
{
try
{
foreach (var pkg in GetAllPublishedPackages().ToList())
{
//System.Diagnostics.Debug.WriteLine(string.Format("{0}|{1}|{2}|{3}", pkg.Id, pkg.Version, pkg.IsLatestVersion, pkg.IconUrl));
var jp = new JsonPackage
{
Id = pkg.Id,
PackageType = pkg.PackageType,
Authors = string.IsNullOrEmpty(pkg.Authors) ? "unknown" : pkg.Authors,
Description = pkg.Description.Length > 140 ? string.Format("{0}...", pkg.Description.Substring(0, 140)) : pkg.Description,
DownloadCount = pkg.DownloadCount,
LastUpdated = pkg.LastUpdated.ToString("dd MMM yyyy", Utils.GetDefaultCulture()),
Title = pkg.Title,
OnlineVersion = pkg.Version,
Website = pkg.ProjectUrl,
Tags = pkg.Tags,
IconUrl = pkg.IconUrl,
Location = "G"
};
// for themes or widgets, get screenshot instead of icon
// also get screenshot if icon is missing for package
if(pkg.Screenshots != null && pkg.Screenshots.Count > 0)
{
if ((pkg.PackageType == Constants.Theme || pkg.PackageType == Constants.Widget) || string.IsNullOrEmpty(pkg.IconUrl))
{
jp.IconUrl = pkg.Screenshots[0].ScreenshotUri;
}
}
// if both icon and screenshot missing, get default image for package type
if (string.IsNullOrEmpty(jp.IconUrl))
jp.IconUrl = DefaultThumbnail(pkg.PackageType);
if (!string.IsNullOrEmpty(jp.IconUrl) && !jp.IconUrl.StartsWith("http:"))
jp.IconUrl = Constants.GalleryUrl + jp.IconUrl;
if (!string.IsNullOrWhiteSpace(pkg.GalleryDetailsUrl))
jp.PackageUrl = PackageUrl(pkg.PackageType, pkg.Id);
//System.Diagnostics.Debug.WriteLine(string.Format("{0}|{1}|{2}|{3}", jp.Id, jp.OnlineVersion, jp.PackageType, jp.IconUrl));
packages.Add(jp);
}
}
catch (Exception ex)
{
Utils.Log("BlogEngine.Core.Packaging.Load", ex);
}
}