mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add more metadata to importer
This commit is contained in:
parent
2b0f61b453
commit
db3d63d91a
@ -27,12 +27,10 @@ $(function() {
|
|||||||
console.log(result)
|
console.log(result)
|
||||||
$("#name").val(result.name || "")
|
$("#name").val(result.name || "")
|
||||||
$("#title").val(result.title || "")
|
$("#title").val(result.title || "")
|
||||||
const desc = result.description || ""
|
$("#repo").val(result.repo || repoURL)
|
||||||
if (desc.length > 0) {
|
$("#issueTracker").val(result.issueTracker || "")
|
||||||
const idx = desc.indexOf(".")
|
$("#desc").val(result.description || "")
|
||||||
$("#shortDesc").val((idx < 5 || idx > 100) ? desc.substring(0, Math.min(desc.length, 100)) : desc.substring(0, idx))
|
$("#shortDesc").val(result.short_description || "")
|
||||||
$("#desc").val(desc)
|
|
||||||
}
|
|
||||||
finish()
|
finish()
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
alert(e)
|
alert(e)
|
||||||
|
@ -30,6 +30,12 @@ class GithubURLMaker:
|
|||||||
def isValid(self):
|
def isValid(self):
|
||||||
return self.baseUrl is not None
|
return self.baseUrl is not None
|
||||||
|
|
||||||
|
def getRepoURL(self):
|
||||||
|
return "https://github.com/" + self.user + "/" + self.repo + ".git"
|
||||||
|
|
||||||
|
def getIssueTrackerURL(self):
|
||||||
|
return "https://github.com/" + self.user + "/" + self.repo + "/issues/"
|
||||||
|
|
||||||
def getModConfURL(self):
|
def getModConfURL(self):
|
||||||
return self.baseUrl + "/mod.conf"
|
return self.baseUrl + "/mod.conf"
|
||||||
|
|
||||||
@ -70,10 +76,11 @@ def getMeta(urlstr):
|
|||||||
if not urlmaker.isValid():
|
if not urlmaker.isValid():
|
||||||
raise TaskError("Error! Url maker not valid")
|
raise TaskError("Error! Url maker not valid")
|
||||||
|
|
||||||
print(urlmaker.getModConfURL())
|
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
result["repo"] = urlmaker.getRepoURL()
|
||||||
|
result["issueTracker"] = urlmaker.getIssueTrackerURL()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8")
|
contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8")
|
||||||
conf = parseConf(contents)
|
conf = parseConf(contents)
|
||||||
@ -82,11 +89,12 @@ def getMeta(urlstr):
|
|||||||
result[key] = conf[key]
|
result[key] = conf[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print(conf)
|
|
||||||
except OSError:
|
except OSError:
|
||||||
print("mod.conf does not exist")
|
print("mod.conf does not exist")
|
||||||
|
|
||||||
|
if "name" in result:
|
||||||
|
result["title"] = result["name"].replace("_", " ").title()
|
||||||
|
|
||||||
if not "description" in result:
|
if not "description" in result:
|
||||||
try:
|
try:
|
||||||
contents = urllib.request.urlopen(urlmaker.getDescURL()).read().decode("utf-8")
|
contents = urllib.request.urlopen(urlmaker.getDescURL()).read().decode("utf-8")
|
||||||
@ -94,6 +102,12 @@ def getMeta(urlstr):
|
|||||||
except OSError:
|
except OSError:
|
||||||
print("description.txt does not exist!")
|
print("description.txt does not exist!")
|
||||||
|
|
||||||
|
if "description" in result:
|
||||||
|
desc = result["description"]
|
||||||
|
idx = desc.find(".") + 1
|
||||||
|
cutIdx = min(len(desc), 200 if idx < 5 else idx)
|
||||||
|
result["short_description"] = desc[:cutIdx]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@celery.task()
|
@celery.task()
|
||||||
|
Loading…
Reference in New Issue
Block a user