split the vendor and the package
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
{
|
{
|
||||||
"Identifier" :"{{.Identifier}}",
|
"Vendor" :"{{.Vendor}}",
|
||||||
|
"Package" :"{{.Package}}",
|
||||||
"Version" :"{{.Version}}",
|
"Version" :"{{.Version}}",
|
||||||
"Type" : "{{.Type}}",
|
"Type" : "{{.Type}}",
|
||||||
"Location": "{{.Location}}",
|
"Location": "{{.Location}}",
|
||||||
|
@@ -14,8 +14,12 @@
|
|||||||
<div class="form-container" oncontextmenu="showContainer('form-container')" onclick="updateForm('/pkg')">
|
<div class="form-container" oncontextmenu="showContainer('form-container')" onclick="updateForm('/pkg')">
|
||||||
<form>
|
<form>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="PackageIdentifier">PackageIdentifier</label>
|
<label for="Vendor">Vendor</label>
|
||||||
<input type="text" id="PackageIdentifier" name="PackageIdentifier" onclick="updateForm('/pkg','PackageIdentifier')">
|
<input type="text" id="Vendor" name="Vendor" onclick="updateForm('/pkg','Vendor')">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="Package">Package</label>
|
||||||
|
<input type="text" id="Package" name="Package" onclick="updateForm('/pkg','Package')">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="PackageVersion">PackageVersion</label>
|
<label for="PackageVersion">PackageVersion</label>
|
||||||
|
4
main.go
4
main.go
@@ -295,7 +295,11 @@ func upload() http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createPackageAndRename() http.Handler{
|
||||||
|
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request){
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
// index creates an HTTP handler that serves the main page with data from the database.
|
// index creates an HTTP handler that serves the main page with data from the database.
|
||||||
// sqldb: The database connection object.
|
// sqldb: The database connection object.
|
||||||
// lang: The language code to localize the content.
|
// lang: The language code to localize the content.
|
||||||
|
12
packages.go
12
packages.go
@@ -19,7 +19,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type jsonStruct struct {
|
type jsonStruct struct {
|
||||||
Identifier string
|
Vendor string
|
||||||
|
Package string
|
||||||
Version string
|
Version string
|
||||||
Type string
|
Type string
|
||||||
Location string
|
Location string
|
||||||
@@ -231,7 +232,8 @@ func moveToNewLocationAndName(data map[string]string) string {
|
|||||||
func createObject(object map[string]string) jsonStruct {
|
func createObject(object map[string]string) jsonStruct {
|
||||||
if detectProblems(object) {
|
if detectProblems(object) {
|
||||||
prop := jsonStruct{
|
prop := jsonStruct{
|
||||||
Identifier: getVendor(object) + "." + getProgram(object),
|
Vendor: getVendor(object) ,
|
||||||
|
Package: getProgram(object),
|
||||||
Version: getVersion(object),
|
Version: getVersion(object),
|
||||||
Type: getInstallerType(object),
|
Type: getInstallerType(object),
|
||||||
}
|
}
|
||||||
@@ -253,15 +255,15 @@ func newJson(object jsonStruct) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(err.Error())
|
slog.Error(err.Error())
|
||||||
}
|
}
|
||||||
sqldb.Exec("INSERT OR IGNORE INTO newapps(identifier, version, type, location, checksum, url) values (?,?,?,?,?,?)", object.Identifier, object.Version, object.Type, object.Location, object.Checksum, object.Url)
|
sqldb.Exec("INSERT OR IGNORE INTO newapps(vendor, package, version, type, location, checksum, url) values (?,?,?,?,?,?,?)", object.Vendor, object.Package, object.Version, object.Type, object.Location, object.Checksum, object.Url)
|
||||||
|
|
||||||
}
|
}
|
||||||
func getJson(sqldb *sql.DB) http.Handler {
|
func getJson(sqldb *sql.DB) http.Handler {
|
||||||
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||||
quer := generateSQL("newapps", []string{"identifier", "version", "type", "location", "checksum", "url"}) + " ORDER BY ROWID DESC LIMIT 1"
|
quer := generateSQL("newapps", []string{"vendor", "package", "version", "type", "location", "checksum", "url"}) + " ORDER BY ROWID DESC LIMIT 1"
|
||||||
data := sqldb.QueryRow(quer)
|
data := sqldb.QueryRow(quer)
|
||||||
jsonelement := jsonStruct{}
|
jsonelement := jsonStruct{}
|
||||||
err := data.Scan(&jsonelement.Identifier, &jsonelement.Version, &jsonelement.Type, &jsonelement.Location, &jsonelement.Checksum, &jsonelement.Url)
|
err := data.Scan(&jsonelement.Vendor, &jsonelement.Package, &jsonelement.Version, &jsonelement.Type, &jsonelement.Location, &jsonelement.Checksum, &jsonelement.Url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(err.Error())
|
slog.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
@@ -132,8 +132,12 @@ function fetchContent(uri) {
|
|||||||
function updateForm(uri, eid){
|
function updateForm(uri, eid){
|
||||||
fetchContent(uri).then(content => {
|
fetchContent(uri).then(content => {
|
||||||
switch(eid){
|
switch(eid){
|
||||||
case "PackageIdentifier":{
|
case "Vendor":{
|
||||||
document.getElementById("PackageIdentifier").value=content.Identifier
|
document.getElementById("Vendor").value=content.Vendor
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Package":{
|
||||||
|
document.getElementById("Package").value=content.Package
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "PackageVersion":{
|
case "PackageVersion":{
|
||||||
|
Reference in New Issue
Block a user