WIP page leaf

This commit is contained in:
Paul Schneider 2022-07-10 17:05:05 +01:00
commit 7f9984b059
28 changed files with 164 additions and 75 deletions

View file

@ -25,10 +25,8 @@ namespace isnd.Controllers
public IActionResult Index()
{
return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages
.Include(p => p.Versions)
.Where(p => p.Versions.Count > 0)
.Count(),
UnleashClient = _unleashĈlient

View file

@ -1,6 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
using isnd.Data.Catalog;
using isnd.Helpers;
using isnd.Services;
using isnd.Entities;
@ -20,7 +19,7 @@ namespace isnd.Controllers
{
return Ok(PackageManager.CurrentCatalogIndex);
}
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogPage + "-{id}")]
public IActionResult Index(string id)
{
@ -28,21 +27,20 @@ namespace isnd.Controllers
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
}
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{*lower}")]
public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id, string lower)
{
bool askForindex = lower != null && lower.EndsWith(ApiConfig.Base);
if (askForindex)
{
lower = lower.Substring(0, lower.Length - ApiConfig.Base.Length);
}
string pkgType = ParamHelpers.Optional(ref lower);
var pkgVersion = await dbContext.PackageVersions
.Include(v => v.LatestCommit)
.SingleOrDefaultAsync(
v => v.PackageId == id &&
v.FullString == lower &&
v.Type == pkgType
);
if (pkgVersion == null) return NotFound();
return Ok();
}
var pkgFromname = packageManager.SearchByName(id, 0, 1);
if (pkgFromname == null) return NotFound();
return Ok(pkgFromname);
}
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{*lower}")]
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
@ -50,25 +48,27 @@ namespace isnd.Controllers
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower)
.ToArray();
if (pkgvs.Count()==0) return NotFound();
if (pkgvs.Count() == 0) return NotFound();
List <string> types = pkgvs.Select(
List<string> types = pkgvs.Select(
v => v.Type ?? "Dependency"
).Distinct().ToList();
if (!types.Contains("PackageDelete"))
types.Add("PackageDetails");
var pub = pkgvs.Last().Package.CommitTimeStamp;
types.Add("PackageDetails");
var last = pkgvs.Last();
var pub = last.Package.CommitTimeStamp;
var firstpub = pkgvs.First().Package.CommitTimeStamp;
return Ok(new CatalogLeaf
return Ok(new Data.Packages.Catalog.CatalogLeaf
{
CommitId = id,
CommitId = last.CommitId,
Id = id,
CommitTimeStamp = firstpub,
Version = version,
CommitTimeStamp = pub,
Version = last.FullString,
Published = pub,
RefType = types.ToArray(),
});
}

View file

@ -1,38 +0,0 @@
using System;
using Newtonsoft.Json;
namespace isnd.Controllers
{
public class CatalogRegistration
{
[JsonProperty("@id")]
public string Id { get; set; }
/*
"@id": "https://api.nuget.org/v3/registration3/nuget.versioning/4.3.0.json",
"catalogEntry": "https://api.nuget.org/v3/catalog0/data/2017.08.11.18.24.22/nuget.versioning.4.3.0.json",
"listed": true,
"packageContent": "https://api.nuget.org/v3-flatcontainer/nuget.versioning/4.3.0/nuget.versioning.4.3.0.nupkg",
"published": "2017-08-11T18:24:14.36+00:00",
"registration": "https://api.nuget.org/v3/registration3/nuget.versioning/index.json"
*/
[JsonProperty("catalogEntry")]
public string CatalogEntry { get; set; }
[JsonProperty("listed")]
public bool Listed { get; set; } = true;
[JsonProperty("packageContent")]
public string PackageContent { get; set; }
[JsonProperty("published")]
public DateTime CommitTimeStamp { get; set; }
[JsonProperty("registration")]
public string registration { get; set; }
}
}

View file

@ -32,7 +32,7 @@ namespace isnd.Controllers
}
// Web get spec
[HttpGet(_pkgRootPrefix + ApiConfig.GetNuspec + "/{id}/{lower}/{idf}-{lowerf}."
[HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.SpecFileEstension)]
public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id,

View file

@ -6,7 +6,7 @@ namespace isnd.Controllers
{
public partial class PackagesController
{
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/index.json")]
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.Base)]
public IActionResult GetVersions(
string id,
string lower,

View file

@ -15,8 +15,8 @@ using isnd.Data;
using isnd.Helpers;
using isnd.Entities;
using Microsoft.AspNetCore.Http;
using isnd.Data.Catalog;
using isn.abst;
using isnd.Data.Packages;
namespace isnd.Controllers
{