mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -57,26 +57,25 @@ namespace Orchard.Packaging.Services {
|
|||||||
return galleryFeedContext.Packages
|
return galleryFeedContext.Packages
|
||||||
.Where(p => p.PackageType == filter)
|
.Where(p => p.PackageType == filter)
|
||||||
.ToList()
|
.ToList()
|
||||||
.Select(p => CreatePackageEntry(p, packagingSource, galleryFeedContext.GetReadStreamUri(p)));
|
.Select(p => {
|
||||||
|
PublishedScreenshot firstScreenshot = galleryFeedContext.Screenshots
|
||||||
|
.Where(s => s.PublishedPackageId == p.Id && s.PublishedPackageVersion == p.Version)
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault();
|
||||||
|
return CreatePackageEntry(p, firstScreenshot, packagingSource, galleryFeedContext.GetReadStreamUri(p));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
).ToArray();
|
).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PackagingEntry CreatePackageEntry(PublishedPackage package, PackagingSource source, Uri downloadUri) {
|
private static PackagingEntry CreatePackageEntry(PublishedPackage package, PublishedScreenshot screenshot, PackagingSource source, Uri downloadUri) {
|
||||||
PublishedScreenshot firstScreenshot = package.Screenshots.FirstOrDefault();
|
Uri baseUri = new Uri(string.Format("{0}://{1}:{2}/",
|
||||||
|
downloadUri.Scheme,
|
||||||
|
downloadUri.Host,
|
||||||
|
downloadUri.Port));
|
||||||
|
|
||||||
Uri iconUrl = null;
|
string iconUrl = GetAbsoluteUri(package.IconUrl, baseUri);
|
||||||
if (!string.IsNullOrEmpty(package.IconUrl)) {
|
string firstScreenshot = screenshot != null ? GetAbsoluteUri(screenshot.ScreenshotUri, baseUri) : string.Empty;
|
||||||
if (!Uri.TryCreate(package.IconUrl, UriKind.Absolute, out iconUrl)) {
|
|
||||||
Uri.TryCreate(
|
|
||||||
new Uri(string.Format("{0}://{1}:{2}/",
|
|
||||||
downloadUri.Scheme,
|
|
||||||
downloadUri.Host,
|
|
||||||
downloadUri.Port)),
|
|
||||||
package.IconUrl,
|
|
||||||
out iconUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PackagingEntry {
|
return new PackagingEntry {
|
||||||
Title = string.IsNullOrWhiteSpace(package.Title) ? package.Id : package.Title,
|
Title = string.IsNullOrWhiteSpace(package.Title) ? package.Id : package.Title,
|
||||||
@@ -89,13 +88,28 @@ namespace Orchard.Packaging.Services {
|
|||||||
Description = package.Description,
|
Description = package.Description,
|
||||||
Authors = package.Authors,
|
Authors = package.Authors,
|
||||||
LastUpdated = package.LastUpdated,
|
LastUpdated = package.LastUpdated,
|
||||||
IconUrl = iconUrl != null ? iconUrl.ToString() : string.Empty,
|
IconUrl = iconUrl,
|
||||||
FirstScreenshot = firstScreenshot != null ? firstScreenshot.ScreenshotUri : string.Empty,
|
FirstScreenshot = firstScreenshot,
|
||||||
Rating = package.Rating,
|
Rating = package.Rating,
|
||||||
RatingsCount = package.RatingsCount
|
RatingsCount = package.RatingsCount
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static string GetAbsoluteUri(string url, Uri baseUri) {
|
||||||
|
Uri uri = null;
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
if (!Uri.TryCreate(url, UriKind.Absolute, out uri))
|
||||||
|
{
|
||||||
|
Uri.TryCreate(baseUri,
|
||||||
|
url,
|
||||||
|
out uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uri != null ? uri.ToString() : string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -26,7 +26,7 @@
|
|||||||
string extensionClass = "iconThumbnail";
|
string extensionClass = "iconThumbnail";
|
||||||
string iconUrl = @item.IconUrl;
|
string iconUrl = @item.IconUrl;
|
||||||
if (!string.IsNullOrWhiteSpace(@item.FirstScreenshot)) {
|
if (!string.IsNullOrWhiteSpace(@item.FirstScreenshot)) {
|
||||||
iconUrl = Href(@item.FirstScreenshot);
|
iconUrl = @item.FirstScreenshot;
|
||||||
extensionClass = "screenshotThumbnail";
|
extensionClass = "screenshotThumbnail";
|
||||||
}
|
}
|
||||||
else if (string.IsNullOrWhiteSpace(iconUrl)) {
|
else if (string.IsNullOrWhiteSpace(iconUrl)) {
|
||||||
|
Reference in New Issue
Block a user