Web search result fixed
This commit is contained in:
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
CONFIGURATION=Debug
|
CONFIGURATION=Debug
|
||||||
TARGETFV=net7.0
|
TARGETFV=net8.0
|
||||||
|
|
||||||
all: build-isn build-isnd
|
all: build-isn build-isnd
|
||||||
|
|
||||||
|
35
src/.vscode/launch.json
vendored
Normal file
35
src/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
|
||||||
|
"name": ".NET Core Launch (web)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/isnd/bin/Debug/net8.0/isnd.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/isnd",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||||
|
"serverReadyAction": {
|
||||||
|
"action": "openExternally",
|
||||||
|
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"sourceFileMap": {
|
||||||
|
"/Views": "${workspaceFolder}/Views"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
41
src/.vscode/tasks.json
vendored
Normal file
41
src/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/isnd/isnd.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/isnd/isnd.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/isnd/isnd.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -12,7 +12,6 @@ namespace isnd.Entities
|
|||||||
public const string AutoComplete = "/autocomplete";
|
public const string AutoComplete = "/autocomplete";
|
||||||
public const string Registration = "/registration";
|
public const string Registration = "/registration";
|
||||||
|
|
||||||
public const string Nuspec = "/nuspec";
|
|
||||||
public const string ContentBase = "/content";
|
public const string ContentBase = "/content";
|
||||||
public const string Nuget = "/nuget";
|
public const string Nuget = "/nuget";
|
||||||
|
|
||||||
|
@ -28,10 +28,18 @@ namespace isnd.Controllers
|
|||||||
Query = model
|
Query = model
|
||||||
};
|
};
|
||||||
List<Catalog> registrations = new List<Catalog>();
|
List<Catalog> registrations = new List<Catalog>();
|
||||||
foreach (var pk in pkgs.data.GroupBy(x => x.PackageId))
|
if (pkgs.data!=null)
|
||||||
|
if (pkgs.data.Length>0)
|
||||||
|
{
|
||||||
|
var grouped = pkgs.data.GroupBy(x => x.PackageId);
|
||||||
|
if (grouped!=null) if (grouped.Count()>0)
|
||||||
|
{
|
||||||
|
foreach (var pk in grouped.ToArray())
|
||||||
{
|
{
|
||||||
registrations.Add(new Catalog(apiBase, pk.Key, pkgs.GetResults().Single(p=>p.Id == pk.Key).Versions));
|
registrations.Add(new Catalog(apiBase, pk.Key, pkgs.GetResults().Single(p=>p.Id == pk.Key).Versions));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return View(new RegistrationPageIndexQueryAndResult
|
return View(new RegistrationPageIndexQueryAndResult
|
||||||
{
|
{
|
||||||
@ -80,7 +88,7 @@ namespace isnd.Controllers
|
|||||||
.FirstOrDefaultAsync(m => m.PackageId == pkgid && m.FullString == version
|
.FirstOrDefaultAsync(m => m.PackageId == pkgid && m.FullString == version
|
||||||
&& (pkgtype!=null && m.Type == pkgtype || m.Type != "Delete" ));
|
&& (pkgtype!=null && m.Type == pkgtype || m.Type != "Delete" ));
|
||||||
if (packageVersion == null) return NotFound();
|
if (packageVersion == null) return NotFound();
|
||||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
if (!User.IsOwner(packageVersion)) return Challenge();
|
||||||
var pkg = await packageManager.GetPackageDetailsAsync(pkgid, version, pkgtype);
|
var pkg = await packageManager.GetPackageDetailsAsync(pkgid, version, pkgtype);
|
||||||
return View(pkg);
|
return View(pkg);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace isnd.Data.Catalog
|
|||||||
|
|
||||||
this.registration = apiBase + ApiConfig.Registration + "/" + pkgId + "/" + fullVersionString + ".json";
|
this.registration = apiBase + ApiConfig.Registration + "/" + pkgId + "/" + fullVersionString + ".json";
|
||||||
Id = registration;
|
Id = registration;
|
||||||
this.PackageContent = apiBase + ApiConfig.Nuget + "/" + pkgId + "/" + fullVersionString
|
this.PackageContent = apiBase + ApiConfig.ContentBase + "/" + pkgId + "/" + fullVersionString
|
||||||
+ "/" + pkgId + "-" + fullVersionString + "." + Constants.PacketFileExtension;
|
+ "/" + pkgId + "-" + fullVersionString + "." + Constants.PacketFileExtension;
|
||||||
Entry = entry;
|
Entry = entry;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace isnd.Data.Packages
|
|||||||
public PackageVersion GetLatestVersion()
|
public PackageVersion GetLatestVersion()
|
||||||
{
|
{
|
||||||
var latest = Versions.Max(v => v.NugetVersion);
|
var latest = Versions.Max(v => v.NugetVersion);
|
||||||
return Versions.First(v=> v.NugetVersion == latest);
|
return Versions.FirstOrDefault(v=> v.NugetVersion == latest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -66,9 +66,9 @@ namespace isnd.Data
|
|||||||
public virtual Commit LatestCommit { get; set; }
|
public virtual Commit LatestCommit { get; set; }
|
||||||
|
|
||||||
public virtual List<PackageDependencyGroup> DependencyGroups { get; set; }
|
public virtual List<PackageDependencyGroup> DependencyGroups { get; set; }
|
||||||
public string NugetLink => $"{ApiConfig.Nuget}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
public string NugetLink => $"{ApiConfig.ContentBase}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||||
+ Constants.PacketFileExtension;
|
+ Constants.PacketFileExtension;
|
||||||
public string NuspecLink => $"{ApiConfig.Nuspec}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
public string NuspecLink => $"{ApiConfig.ContentBase}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||||
+ Constants.SpecFileExtension;
|
+ Constants.SpecFileExtension;
|
||||||
|
|
||||||
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
|
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
|
||||||
|
@ -348,13 +348,20 @@ namespace isnd.Services
|
|||||||
{
|
{
|
||||||
string bid = $"{apiBase}{ApiConfig.Registration}";
|
string bid = $"{apiBase}{ApiConfig.Registration}";
|
||||||
if (string.IsNullOrWhiteSpace(query.Query))
|
if (string.IsNullOrWhiteSpace(query.Query))
|
||||||
|
{
|
||||||
query.Query = "";
|
query.Query = "";
|
||||||
|
return new PackageSearchResult(apiBase);
|
||||||
|
}
|
||||||
|
|
||||||
var packages = await dbContext.Packages
|
var allPackages = dbContext.Packages
|
||||||
.Include(g => g.Versions).OrderBy(v => v.CommitNId)
|
.Include(g => g.Versions).OrderBy(v => v.CommitNId)
|
||||||
.Where(d => d.Id.StartsWith(query.Query)
|
.Where(d => d.Id.StartsWith(query.Query)
|
||||||
&& (query.Prerelease || d.Versions.Any(v => !v.IsPrerelease)))
|
&& (query.Prerelease || d.Versions.Any(v => !v.IsPrerelease)))
|
||||||
.Where(p => p.Versions.Count >= 0)
|
.Where(p => p.Versions.Count >= 0);
|
||||||
|
|
||||||
|
var count = await allPackages.CountAsync();
|
||||||
|
|
||||||
|
var packages = await allPackages
|
||||||
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
||||||
foreach (var package in packages)
|
foreach (var package in packages)
|
||||||
foreach (var version in package.Versions)
|
foreach (var version in package.Versions)
|
||||||
@ -364,7 +371,8 @@ namespace isnd.Services
|
|||||||
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return new PackageSearchResult(packages, apiBase, packages.Count());
|
|
||||||
|
return new PackageSearchResult(packages, apiBase, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId)
|
public async Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Diagnostics;
|
||||||
using isnd.Data.Catalog;
|
using isnd.Data.Catalog;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NuGet.Packaging.Core;
|
using NuGet.Packaging.Core;
|
||||||
@ -8,10 +9,16 @@ namespace isnd.ViewModels
|
|||||||
{
|
{
|
||||||
public class PackageHit : Permalink
|
public class PackageHit : Permalink
|
||||||
{
|
{
|
||||||
public PackageHit(string registrationId, string packageId) : base(registrationId, "Package")
|
public PackageHit(string registrationId, string packageId,
|
||||||
|
|
||||||
|
string version, string description
|
||||||
|
) : base(registrationId, "Package")
|
||||||
{
|
{
|
||||||
PackageId = packageId;
|
PackageId = packageId;
|
||||||
registration = registrationId;
|
registration = registrationId;
|
||||||
|
this.verified = verified;
|
||||||
|
this.description = description;
|
||||||
|
Debug.Assert(version!=null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
using System.Reflection.Metadata.Ecma335;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading;
|
||||||
using isnd.Data;
|
using isnd.Data;
|
||||||
using isnd.Data.Packages;
|
using isnd.Data.Packages;
|
||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
@ -18,16 +20,26 @@ namespace isnd.ViewModels
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Package> result;
|
private IEnumerable<Package> result=null;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string ApiBase{get; private set;}
|
public string ApiBase{get; private set;}
|
||||||
|
|
||||||
|
public PackageSearchResult(string apiBase)
|
||||||
|
{
|
||||||
|
// empty result
|
||||||
|
this.ApiBase = apiBase;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public PackageSearchResult(IEnumerable<Package> result, string apiBase, int totalHit)
|
public PackageSearchResult(IEnumerable<Package> result, string apiBase, int totalHit)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.ApiBase = apiBase;
|
this.ApiBase = apiBase;
|
||||||
data=result.Select(p=> NewPackageHit(apiBase, p)).ToArray();
|
|
||||||
|
data = (totalHit>0) ? result.Select(p=> NewPackageHit(apiBase, p)).ToArray()
|
||||||
|
: new PackageHit[0];
|
||||||
this.totalHits = totalHit;
|
this.totalHits = totalHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +49,10 @@ namespace isnd.ViewModels
|
|||||||
var latest = package.GetLatestVersion();
|
var latest = package.GetLatestVersion();
|
||||||
if (latest==null) return null;
|
if (latest==null) return null;
|
||||||
|
|
||||||
var pkgHit = new PackageHit(regId, package.Id)
|
var pkgHit = new PackageHit(regId, package.Id,
|
||||||
{
|
latest.NugetVersion.ToString(),
|
||||||
version = latest.NugetVersion.ToString(),
|
latest.Description);
|
||||||
description = latest.Description,
|
|
||||||
};
|
|
||||||
if (package.Versions!=null)
|
if (package.Versions!=null)
|
||||||
{
|
{
|
||||||
pkgHit.versions = package.Versions
|
pkgHit.versions = package.Versions
|
||||||
@ -52,8 +63,8 @@ namespace isnd.ViewModels
|
|||||||
return pkgHit;
|
return pkgHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PackageHit[] data { get; protected set; }
|
public PackageHit[] data { get; protected set; } = [];
|
||||||
|
|
||||||
public int totalHits { get; set; }
|
public int totalHits { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
@model isnd.Data.PackageVersion
|
@model PackageDetails
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Delete";
|
ViewData["Title"] = "Delete";
|
||||||
@ -12,40 +12,40 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.Major)
|
@Html.DisplayNameFor(model => model.Title)
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Major)
|
@Html.DisplayFor(model => model.Title)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.Minor)
|
@Html.DisplayNameFor(model => model.Id)
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Minor)
|
@Html.DisplayFor(model => model.Id)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.Patch)
|
@Html.DisplayNameFor(model => model.Version)
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Patch)
|
@Html.DisplayFor(model => model.Version)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.IsPrerelease)
|
@Html.DisplayNameFor(model => model.Description)
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.IsPrerelease)
|
@Html.DisplayFor(model => model.Description)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.Package)
|
@Html.DisplayNameFor(model => model.DownloadCount)
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Package.Id)
|
@Html.DisplayFor(model => model.DownloadCount)
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@if (Model!=null) {
|
@if (Model!=null) {
|
||||||
<form asp-action="DeleteConfirmed">
|
<form asp-action="DeleteConfirmed">
|
||||||
<input type="hidden" name="pkgid" value="@Model.PackageId" />
|
<input type="hidden" name="pkgid" value="@Model.PackageId" />
|
||||||
<input type="hidden" name="version" value="@Model.FullString" />
|
<input type="hidden" name="version" value="@Model.Version" />
|
||||||
<input type="hidden" name="type" value="@Model.Type" />
|
<input type="hidden" name="type" value="@Model.Type" />
|
||||||
<input type="submit" value="Delete" class="btn btn-default" /> |
|
<input type="submit" value="Delete" class="btn btn-default" /> |
|
||||||
<a asp-action="Index">Back to List</a>
|
<a asp-action="Index">Back to List</a>
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="isn.abst" Version="1.0.24" />
|
<PackageReference Include="isn.abst" Version="1.0.24" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Reference in New Issue
Block a user