summaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-06-18 20:47:38 +0100
committerGitHub <noreply@github.com>2018-06-18 20:47:38 +0100
commitca502fc274c640f1e301a77ecb336ab5a23d348d (patch)
tree41c38f278225e21067144330a4c6195eecee963b /src/content
parente8b687d7cafd7ff77572238cf98954527ab1056a (diff)
downloadminetest-ca502fc274c640f1e301a77ecb336ab5a23d348d.tar.gz
minetest-ca502fc274c640f1e301a77ecb336ab5a23d348d.tar.bz2
minetest-ca502fc274c640f1e301a77ecb336ab5a23d348d.zip
Update to new ContentDB API
Diffstat (limited to 'src/content')
-rw-r--r--src/content/packages.cpp15
-rw-r--r--src/content/packages.h16
2 files changed, 15 insertions, 16 deletions
diff --git a/src/content/packages.cpp b/src/content/packages.cpp
index d50e63a6b..dd7574d48 100644
--- a/src/content/packages.cpp
+++ b/src/content/packages.cpp
@@ -43,24 +43,19 @@ std::vector<Package> getPackagesFromURL(const std::string &url)
for (unsigned int i = 0; i < json.size(); ++i) {
Package package;
+ package.author = json[i]["author"].asString();
package.name = json[i]["name"].asString();
package.title = json[i]["title"].asString();
- package.author = json[i]["author"].asString();
package.type = json[i]["type"].asString();
package.shortDesc = json[i]["shortDesc"].asString();
- package.url = json[i]["url"].asString();
package.release = json[i]["release"].asInt();
+ if (json[i].isMember("thumbnail"))
+ package.thumbnail = json[i]["thumbnail"].asString();
- Json::Value jScreenshots = json[i]["screenshots"];
- for (unsigned int j = 0; j < jScreenshots.size(); ++j) {
- package.screenshots.push_back(jScreenshots[j].asString());
- }
-
- if (package.valid()) {
+ if (package.valid())
packages.push_back(package);
- } else {
+ else
errorstream << "Invalid package at " << i << std::endl;
- }
}
return packages;
diff --git a/src/content/packages.h b/src/content/packages.h
index 2290bd607..fc60d5703 100644
--- a/src/content/packages.h
+++ b/src/content/packages.h
@@ -24,20 +24,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct Package
{
+ std::string author;
std::string name; // Technical name
std::string title;
- std::string author;
std::string type; // One of "mod", "game", or "txp"
std::string shortDesc;
- std::string url; // download URL
u32 release;
- std::vector<std::string> screenshots;
+ std::string thumbnail;
+
+ bool valid() const
+ {
+ return !(author.empty() || name.empty() || title.empty() ||
+ type.empty() || release <= 0);
+ }
- bool valid()
+ std::string getDownloadURL(const std::string &baseURL) const
{
- return !(name.empty() || title.empty() || author.empty() ||
- type.empty() || url.empty() || release <= 0);
+ return baseURL + "/packages/" + author + "/" + name + "/download/";
}
};