From 9a716d8b54b422eed0dac833bcc9bf5cc774003d Mon Sep 17 00:00:00 2001 From: benny Date: Sun, 23 Jun 2024 17:38:42 +0300 Subject: [PATCH] split the vendor and the package --- html/lastob.json | 3 ++- html/uploadfile.html | 8 ++++++-- main.go | 4 ++++ packages.go | 12 +++++++----- public/script.js | 8 ++++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/html/lastob.json b/html/lastob.json index ce5b743..951ef02 100644 --- a/html/lastob.json +++ b/html/lastob.json @@ -1,6 +1,7 @@ {{define "main"}} { - "Identifier" :"{{.Identifier}}", + "Vendor" :"{{.Vendor}}", + "Package" :"{{.Package}}", "Version" :"{{.Version}}", "Type" : "{{.Type}}", "Location": "{{.Location}}", diff --git a/html/uploadfile.html b/html/uploadfile.html index 7cbf802..d72c8b7 100644 --- a/html/uploadfile.html +++ b/html/uploadfile.html @@ -14,8 +14,12 @@
- - + + +
+
+ +
diff --git a/main.go b/main.go index 17426e1..216713c 100644 --- a/main.go +++ b/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. // sqldb: The database connection object. // lang: The language code to localize the content. diff --git a/packages.go b/packages.go index 6469c70..0e4ec3e 100644 --- a/packages.go +++ b/packages.go @@ -19,7 +19,8 @@ import ( ) type jsonStruct struct { - Identifier string + Vendor string + Package string Version string Type string Location string @@ -231,7 +232,8 @@ func moveToNewLocationAndName(data map[string]string) string { func createObject(object map[string]string) jsonStruct { if detectProblems(object) { prop := jsonStruct{ - Identifier: getVendor(object) + "." + getProgram(object), + Vendor: getVendor(object) , + Package: getProgram(object), Version: getVersion(object), Type: getInstallerType(object), } @@ -253,15 +255,15 @@ func newJson(object jsonStruct) { if err != nil { 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 { 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) 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 { slog.Error(err.Error()) } diff --git a/public/script.js b/public/script.js index 0fa94f0..a1ddf26 100644 --- a/public/script.js +++ b/public/script.js @@ -132,8 +132,12 @@ function fetchContent(uri) { function updateForm(uri, eid){ fetchContent(uri).then(content => { switch(eid){ - case "PackageIdentifier":{ - document.getElementById("PackageIdentifier").value=content.Identifier + case "Vendor":{ + document.getElementById("Vendor").value=content.Vendor + break; + } + case "Package":{ + document.getElementById("Package").value=content.Package break } case "PackageVersion":{