mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12: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)
|
||||
$("#name").val(result.name || "")
|
||||
$("#title").val(result.title || "")
|
||||
const desc = result.description || ""
|
||||
if (desc.length > 0) {
|
||||
const idx = desc.indexOf(".")
|
||||
$("#shortDesc").val((idx < 5 || idx > 100) ? desc.substring(0, Math.min(desc.length, 100)) : desc.substring(0, idx))
|
||||
$("#desc").val(desc)
|
||||
}
|
||||
$("#repo").val(result.repo || repoURL)
|
||||
$("#issueTracker").val(result.issueTracker || "")
|
||||
$("#desc").val(result.description || "")
|
||||
$("#shortDesc").val(result.short_description || "")
|
||||
finish()
|
||||
}).catch(function(e) {
|
||||
alert(e)
|
||||
|
@ -30,6 +30,12 @@ class GithubURLMaker:
|
||||
def isValid(self):
|
||||
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):
|
||||
return self.baseUrl + "/mod.conf"
|
||||
|
||||
@ -70,10 +76,11 @@ def getMeta(urlstr):
|
||||
if not urlmaker.isValid():
|
||||
raise TaskError("Error! Url maker not valid")
|
||||
|
||||
print(urlmaker.getModConfURL())
|
||||
|
||||
result = {}
|
||||
|
||||
result["repo"] = urlmaker.getRepoURL()
|
||||
result["issueTracker"] = urlmaker.getIssueTrackerURL()
|
||||
|
||||
try:
|
||||
contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8")
|
||||
conf = parseConf(contents)
|
||||
@ -82,11 +89,12 @@ def getMeta(urlstr):
|
||||
result[key] = conf[key]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
print(conf)
|
||||
except OSError:
|
||||
print("mod.conf does not exist")
|
||||
|
||||
if "name" in result:
|
||||
result["title"] = result["name"].replace("_", " ").title()
|
||||
|
||||
if not "description" in result:
|
||||
try:
|
||||
contents = urllib.request.urlopen(urlmaker.getDescURL()).read().decode("utf-8")
|
||||
@ -94,6 +102,12 @@ def getMeta(urlstr):
|
||||
except OSError:
|
||||
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
|
||||
|
||||
@celery.task()
|
||||
|
Loading…
Reference in New Issue
Block a user