Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pd-buildserver committed Dec 13, 2023
2 parents c0e8ea7 + 3d7add5 commit 273570a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/Tetrifact.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public IActionResult UploadPackage()
/// </summary>
/// <returns></returns>
[ServiceFilter(typeof(ReadLevel))]
[Route("package/{packageId}/{pageIndex?}")]
public IActionResult Package(string packageId, int pageIndex)
[Route("package/{packageId}")]
public IActionResult Package(string packageId, [FromQuery(Name = "pageIndex")] int pageIndex)
{
ViewData["serverName"] = _settings.ServerName;
ViewData["packageId"] = packageId;
Expand All @@ -111,7 +111,7 @@ public IActionResult Package(string packageId, int pageIndex)
/// <returns></returns>
[ServiceFilter(typeof(ReadLevel))]
[Route("packages/{page?}")]
public IActionResult Packages(int page)
public IActionResult Packages([FromQuery(Name = "page")] int page)
{
// user-facing page values start at 1 instead of 0. reset
if (page != 0)
Expand All @@ -131,18 +131,21 @@ public IActionResult Packages(int page)
/// <returns></returns>
[ServiceFilter(typeof(ReadLevel))]
[Route("search/{search?}/{page?}")]
public IActionResult Search(string search, int page)
public IActionResult Search(string search, [FromQuery(Name = "page")] int page)
{
// user-facing page values start at 1 instead of 0. reset
if (page != 0)
page--;

if (search == null)
search = string.Empty;

PageableData<Package> results = _packageList.Find(search, page, _settings.ListPageSize);
Pager pager = new Pager();
ViewData["serverName"] = _settings.ServerName;
ViewData["search"] = search;
ViewData["packages"] = results;
ViewData["pager"] = pager.Render(results, _settings.PagesPerPageGroup, "/search", "page");
ViewData["pager"] = pager.Render(results, _settings.PagesPerPageGroup, $"/search/{search}", "page");
return View();
}

Expand Down
8 changes: 5 additions & 3 deletions src/Tetrifact.Web/Core/Pager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ private string RenderPageLinks(int currentPage, int pagesPerGroup, string baseur

s.Append($"<ul class='{this.CssClass}'>");

if (!baseurl.Contains("?"))
baseurl = $"{baseurl}?";

// previous
if (this.Currentgroup > 0)
{
int back = ((this.Currentgroup * pagesPerGroup) - 1);
s.Append($"<li class='pager-item'><a class='pager-link' href='{baseurl}/{pageIndexName}={back + 1}{hash}'>");
s.Append($"<li class='pager-item'><a class='pager-link' href='{baseurl}&{pageIndexName}={back + 1}{hash}'>");
s.Append("<span class='pager-linkContent'>");
s.Append("..");
s.Append("</span>");
Expand All @@ -146,7 +148,7 @@ private string RenderPageLinks(int currentPage, int pagesPerGroup, string baseur
if (isActive)
s.Append($"<a class='pager-link pager-link--active'>");
else
s.Append($"<a class='pager-link' href='{baseurl}/{c + 1}{hash}'>");
s.Append($"<a class='pager-link' href='{baseurl}&{pageIndexName}={c + 1}{hash}'>");

s.Append("<span class='pager-linkContent'>");
s.Append(c + 1);
Expand All @@ -159,7 +161,7 @@ private string RenderPageLinks(int currentPage, int pagesPerGroup, string baseur
if (this.Currentgroup < this.TotalGroups - 1)
{
int forward = (this.Currentgroup + 1) * pagesPerGroup;
s.Append($"<li class='pager-item'><a class='pager-link' href='{baseurl}/{forward + 1}{hash}'>");
s.Append($"<li class='pager-item'><a class='pager-link' href='{baseurl}&{pageIndexName}={forward + 1}{hash}'>");
s.Append("<span class='pager-linkContent'>");
s.Append("..");
s.Append("</span>");
Expand Down
2 changes: 1 addition & 1 deletion src/Tetrifact.Web/Views/Home/Package.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
@if (manifest.Tags.Any())
{
<ul>
@foreach (string tag in manifest.Tags)
@foreach (string tag in manifest.Tags.OrderBy(t => t))
{
<li class="listItem">
<a class="package-removeTag" data-tag="@tag" href="javascript:void(null)">
Expand Down
2 changes: 1 addition & 1 deletion src/Tetrifact.Web/Views/Shared/TagsList.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@model IEnumerable<string>

<ul class="tags">
@foreach (string tag in Model)
@foreach (string tag in Model.OrderBy(t => t))
{
<li class="tags-tag">
<a class="tags-link" href="/packagesWithTag/@Uri.EscapeDataString(tag)">@tag</a>
Expand Down

0 comments on commit 273570a

Please sign in to comment.