update WebConsole stuff and implement markers for reviews

This commit is contained in:
2015-04-04 00:10:38 +02:00
parent 5a313c1d61
commit adbcfe3fde
7 changed files with 51 additions and 14 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ namespace OnePeek.Api
/// <param name="storeCulture">Culture of the query (returns location specific metadata + ratings).</param> /// <param name="storeCulture">Culture of the query (returns location specific metadata + ratings).</param>
/// <param name="sorting">Sorting criteria.</param> /// <param name="sorting">Sorting criteria.</param>
/// <returns></returns> /// <returns></returns>
public async Task<AppReviews> GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting) public async Task<AppReviews> GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting, string prevPageMarkerId = null, string nextPageMarkerId = null)
{ {
if (storeCulture == StoreCultureType.Unknown) if (storeCulture == StoreCultureType.Unknown)
{ {
@@ -26,7 +26,7 @@ namespace OnePeek.Api
} }
string xml = await ApiHttpClient.Instance.Get( string xml = await ApiHttpClient.Instance.Get(
EndpointUris.GetWindowsPhoneReviewsUri(appId, storeCulture.ToString(), sorting.ToString()) EndpointUris.GetWindowsPhoneReviewsUri(appId, storeCulture.ToString(), sorting.ToString(), prevPageMarkerId, nextPageMarkerId)
); );
IEnumerable<XElement> xel = XDocument.Parse(xml).Elements().First().Descendants(); IEnumerable<XElement> xel = XDocument.Parse(xml).Elements().First().Descendants();
+14 -3
View File
@@ -28,18 +28,29 @@ namespace OnePeek.Api
internal static Uri GetWindowsPhoneReviewsUri(string appId, string culture, string orderBy) internal static Uri GetWindowsPhoneReviewsUri(string appId, string culture, string orderBy, string prevPageMarkerId = null, string nextPageMarkerId = null)
{ {
culture = culture.Replace('_', '-'); culture = culture.Replace('_', '-');
string country = culture.Split('-')[1]; string country = culture.Split('-')[1];
return Uri(WINDOWSPHONE_REVIEWS_URI, appId, country, culture, orderBy); string affix = String.Empty;
if (!String.IsNullOrWhiteSpace(prevPageMarkerId))
{
affix = "&beforeMarker=" + prevPageMarkerId;
}
else if (!String.IsNullOrWhiteSpace(nextPageMarkerId))
{
affix = "&afterMarker=" + nextPageMarkerId;
}
return Uri(WINDOWSPHONE_REVIEWS_URI + affix, appId, country, culture, orderBy);
} }
private static Uri Uri(string template, params string[] replacements) private static Uri Uri(string template, params string[] replacements)
{ {
string uriString = String.Format(template, replacements).ToLower(); string uriString = String.Format(template, replacements);
return new Uri(uriString, UriKind.Absolute); return new Uri(uriString, UriKind.Absolute);
} }
} }
+2 -2
View File
@@ -19,8 +19,8 @@ namespace OnePeek.Api
return null; return null;
} }
Match match = new Regex(queryKey + @"=([A-Za-z0-9\-=]+)").Match(attr.Value); Match match = new Regex(queryKey + @"=([A-Za-z0-9\-\=]+)").Match(attr.Value);
return match.Success ? match.Groups[1].Value + "=" : null; return match.Success ? match.Groups[1].Value : null;
} }
} }
} }
+1 -1
View File
@@ -27,7 +27,7 @@ namespace OnePeek.WebConsole.Modules
Get["/reviews", true] = async (ctx, token) => Get["/reviews", true] = async (ctx, token) =>
{ {
AppReviews reviews = await ratingEndpoint.GetReviews(Request.Query["id"], StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest); AppReviews reviews = await ratingEndpoint.GetReviews(Request.Query["id"], StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest, Request.Query["prev"], Request.Query["next"]);
return View["Reviews", reviews]; return View["Reviews", reviews];
}; };
} }
+24 -2
View File
@@ -3,6 +3,28 @@
Layout = "_Layout.cshtml"; Layout = "_Layout.cshtml";
} }
<h1>@Model.Name</h1> <div class="large-8 columns">
<h1>@Model.Name</h1>
<h5>by @Model.Publisher.Name</h5>
<div>
Rating: <mark>@Model.Rating.AverageRating</mark> (out of @Model.Rating.RatingCount)
<br /><br />
</div>
<article style="font-size:0.8rem;">
@Html.Raw(Model.Text.Replace("\n", "<br />"))
</article>
</div>
<div class="large-4 columns">
<img src="/api/image/@(Model.Images.Logo.Id).jpg" alt="@Model.Name" style="float: right;" />
</div>
<img src="/api/image/@(Model.Images.Logo.Id).jpg" alt="@Model.Name" /> <hr />
<div class="large-12 columns">
<h3>Screenshots</h3>
@foreach (var image in Model.Images.Screenshots)
{
<a href="/api/image/@(image.Id).jpg"><img src="/api/image/@(image.Id).jpg" alt="" style="width: 115px;" /></a>
}
</div>
+7 -1
View File
@@ -3,8 +3,14 @@
Layout = "_Layout.cshtml"; Layout = "_Layout.cshtml";
} }
@if (!String.IsNullOrWhiteSpace(Model.PrevPageMarkerId))
{
<a class="button" href="/reviews?id=@(Model.Id)&prev=@(Model.PrevPageMarkerId)">prev</a> <a class="button" href="/reviews?id=@(Model.Id)&prev=@(Model.PrevPageMarkerId)">prev</a>
<a class="button" href="/reviews?id=@(Model.Id)&prev=@(Model.NextPageMarkerId)">next</a> }
@if (!String.IsNullOrWhiteSpace(Model.NextPageMarkerId))
{
<a class="button" href="/reviews?id=@(Model.Id)&next=@(Model.NextPageMarkerId)">next</a>
}
@foreach (var review in Model.Reviews) @foreach (var review in Model.Reviews)
{ {
+1 -3
View File
@@ -9,9 +9,7 @@
<body> <body>
<br /><br /> <br /><br />
<div class="row"> <div class="row">
<div class="large-12 columns"> @RenderBody()
@RenderBody()
</div>
</div> </div>
<script src="~/Assets/jquery.js"></script> <script src="~/Assets/jquery.js"></script>
<script src="~/Assets/foundation.min.js"></script> <script src="~/Assets/foundation.min.js"></script>