mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
@@ -379,23 +379,22 @@ Note: A newer version of this plugin <a href="http://www.example.com">is availab
|
||||
|
||||
<h3 id="structs-location">Location Data Structure</h3>
|
||||
<p>This data structure is used to hold information on where a plugin is hosted online. It is not currently used by LOOT, but it was suggested that since the LOOT team receives a considerable number of plugin URLs, they should be recorded in a standard format, as there is no existing store of such information and it could prove useful in the future.
|
||||
<p>The data structure has two forms: the first is a simple string, and the second is a key-value map. The first form should be used for a URL without any associated version data, such as when it is not clear which version is found there, or when it is the only known hosting location for the plugin and as such hosts all available versions. The second form should be used when version data can be associated with the URL, such as when the URL only hosts a subset of the available versions of the plugin.
|
||||
<p>The data structure has two forms: the first is a simple string, and the second is a key-value map. All values in the map are strings.
|
||||
<p>The simple form:
|
||||
<pre><code><var>URL</var></code></pre>
|
||||
<p>where <code><var>URL</var></code> is a URL at which the plugin may be found.
|
||||
<p>The map form:
|
||||
<table>
|
||||
<thead><tr><th>Key Name<th>Data Type<th>Required<th>Notes
|
||||
<thead><tr><th>Key Name<th>Required<th>Notes
|
||||
<tbody>
|
||||
<tr><td><code>link</code><td>string<td>✓<td>A URL at which the plugin may be found.
|
||||
<tr><td><code>ver</code><td>string list<td>✓<td>A list of versions that can be found at the URL. <strong>This key is deprecated, and it will be removed in a future version of the syntax. Do not use it.</strong>
|
||||
<tr><td><code>link</code><td>✓<td>A URL at which the plugin may be found.
|
||||
<tr><td><code>name</code><td>✗<td>A descriptive name for the URL, which may be used as hyperlink text.
|
||||
</table>
|
||||
<p>Examples:
|
||||
<pre><code>'http://skyrim.nexusmods.com/mods/19/'</code></pre>
|
||||
or
|
||||
<pre><code>link: 'http://steamcommunity.com/sharedfiles/filedetails/?id=87144366'
|
||||
ver:
|
||||
- '1.3.2c'
|
||||
<pre><code>link: 'https://steamcommunity.com/sharedfiles/filedetails/?id=419668499'
|
||||
name: 'Unofficial Skyrim Patch on Steam Workshop'
|
||||
</code></pre>
|
||||
|
||||
<h3 id="structs-dirty">Dirty Info Data Structure</h3>
|
||||
@@ -590,11 +589,13 @@ msg:
|
||||
|
||||
<table>
|
||||
<head>
|
||||
<tr><th>Feature Supported?<th>v0.5<th>v0.6<th>v0.7
|
||||
<tr><th>Feature Supported?<th>v0.5<th>v0.6<th>v0.7<th>v0.8
|
||||
<tbody>
|
||||
<tr><td>GitHub Flavored Markdown message formatting<td colspan="2">Only URL hyperlinking is supported, for <code>file:</code>, <code>http:</code> and <code>https:</code> URLs, using the <code>[label](url)</code> and <code><url></code> syntaxes.<td>LOOT uses the <a href="https://github.com/chjj/marked">Marked</a> library (v0.3) to provide support for most of GitHub Flavored Markdown, minus the GitHub-specific features (like @mentions, issue/repo linking and emoji).
|
||||
<tr><td>Message string substitution (ie. <code>sub:</code>)<td colspan="2">No<td>Yes
|
||||
<tr><td>YAML merge keys (ie. <code><<:</code>)<td colspan="2">No<td>Yes
|
||||
<tr><td>Location <code>ver</code> key<td colspan="3">Yes<td>No
|
||||
<tr><td>Location <code>name</code> key<td colspan="3">No<td>Yes
|
||||
</table>
|
||||
|
||||
<h2 id="license">License</h2>
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<template id="locationRow">
|
||||
<tr>
|
||||
<td><loot-validated-input error="A link is required." class="link" required></loot-validated-input></td>
|
||||
<td><paper-input class="ver"></paper-input></td>
|
||||
<td><paper-input class="name"></paper-input></td>
|
||||
<td>
|
||||
<core-tooltip label="Delete Row" noarrow position="left">
|
||||
<paper-icon-button class="delete" icon="delete"></paper-icon-button>
|
||||
|
||||
@@ -238,7 +238,7 @@ loot-editor-close
|
||||
<div id="locations">
|
||||
<table is="editable-table" data-template="locationRow">
|
||||
<thead>
|
||||
<tr><th>URL</th><th>Version</th><th></th></tr>
|
||||
<tr><th>URL</th><th>Name</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Location rows go here. -->
|
||||
@@ -360,16 +360,6 @@ loot-editor-close
|
||||
});
|
||||
plugin.userlist.dirty = rowsData;
|
||||
} else if (tables[j].parentElement.id == 'locations') {
|
||||
rowsData.forEach(function(value, index, arr){
|
||||
/* User metadata can only specify one version, but it should be a list. */
|
||||
if (value.ver.length > 0) {
|
||||
arr[index].ver = [
|
||||
value.ver
|
||||
];
|
||||
} else {
|
||||
delete arr[index].ver;
|
||||
}
|
||||
});
|
||||
plugin.userlist.url = rowsData;
|
||||
}
|
||||
}
|
||||
@@ -539,21 +529,13 @@ loot-editor-close
|
||||
|
||||
if (newData.masterlist && newData.masterlist.url) {
|
||||
newData.masterlist.url.forEach(function(location) {
|
||||
var temp = location;
|
||||
if (temp.ver) {
|
||||
temp.ver = temp.ver[0];
|
||||
}
|
||||
var row = tables[j].addRow(temp);
|
||||
var row = tables[j].addRow(location);
|
||||
tables[j].setReadOnly(row);
|
||||
});
|
||||
}
|
||||
if (tempData.userlist && tempData.userlist.url) {
|
||||
tempData.userlist.url.forEach(function(location) {
|
||||
var temp = location;
|
||||
if (temp.ver) {
|
||||
temp.ver = temp.ver[0];
|
||||
}
|
||||
tables[j].addRow(temp);
|
||||
tables[j].addRow(location);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
pluginEditor.getElementById('dirty').querySelector('th:nth-child(5)').textContent = l10n.translate("Cleaning Utility").fetch();
|
||||
|
||||
pluginEditor.getElementById('locations').querySelector('th:first-child').textContent = l10n.translate("URL").fetch();
|
||||
pluginEditor.getElementById('locations').querySelector('th:nth-child(2)').textContent = l10n.translate("Version").fetch();
|
||||
pluginEditor.getElementById('locations').querySelector('th:nth-child(2)').textContent = l10n.translate("Name").fetch();
|
||||
|
||||
pluginEditor.getElementById('accept').parentElement.setAttribute('label', l10n.translate("Apply").fetch());
|
||||
pluginEditor.getElementById('cancel').parentElement.setAttribute('label', l10n.translate("Cancel").fetch());
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace loot {
|
||||
|
||||
Location::Location(const std::string& url) : _url(url) {}
|
||||
|
||||
Location::Location(const std::string& url, const std::vector<std::string>& versions) : _url(url), _versions(versions) {}
|
||||
Location::Location(const std::string& url, const std::string& name) : _url(url), _name(name) {}
|
||||
|
||||
bool Location::operator < (const Location& rhs) const {
|
||||
return boost::ilexicographical_compare(_url, rhs.URL());
|
||||
@@ -47,19 +47,19 @@ namespace loot {
|
||||
return _url;
|
||||
}
|
||||
|
||||
std::vector<std::string> Location::Versions() const {
|
||||
return _versions;
|
||||
std::string Location::Name() const {
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
namespace YAML {
|
||||
Emitter& operator << (Emitter& out, const loot::Location& rhs) {
|
||||
if (rhs.Versions().empty())
|
||||
if (rhs.Name().empty())
|
||||
out << YAML::SingleQuoted << rhs.URL();
|
||||
else {
|
||||
out << BeginMap
|
||||
<< Key << "link" << Value << YAML::SingleQuoted << rhs.URL()
|
||||
<< Key << "ver" << Value << YAML::SingleQuoted << rhs.Versions()
|
||||
<< Key << "name" << Value << YAML::SingleQuoted << rhs.Name()
|
||||
<< EndMap;
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace loot {
|
||||
public:
|
||||
Location();
|
||||
Location(const std::string& url);
|
||||
Location(const std::string& url, const std::vector<std::string>& versions);
|
||||
Location(const std::string& url, const std::string& name);
|
||||
|
||||
bool operator < (const Location& rhs) const;
|
||||
bool operator == (const Location& rhs) const;
|
||||
|
||||
std::string URL() const;
|
||||
std::vector<std::string> Versions() const;
|
||||
std::string Name() const;
|
||||
private:
|
||||
std::string _url;
|
||||
std::vector<std::string> _versions;
|
||||
std::string _name;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ namespace YAML {
|
||||
Node node;
|
||||
|
||||
node["link"] = rhs.URL();
|
||||
node["ver"] = rhs.Versions();
|
||||
if (!rhs.Name().empty())
|
||||
node["name"] = rhs.Name();
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -64,19 +65,20 @@ namespace YAML {
|
||||
return false;
|
||||
|
||||
std::string url;
|
||||
std::vector<std::string> versions;
|
||||
std::string name;
|
||||
|
||||
if (node.IsMap()) {
|
||||
if (!node["link"] || !node["ver"])
|
||||
if (!node["link"])
|
||||
return false;
|
||||
|
||||
url = node["link"].as<std::string>();
|
||||
versions = node["ver"].as<std::vector<std::string>>();
|
||||
if (node["name"])
|
||||
name = node["name"].as<std::string>();
|
||||
}
|
||||
else
|
||||
url = node.as<std::string>();
|
||||
|
||||
rhs = loot::Location(url, versions);
|
||||
rhs = loot::Location(url, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,15 +37,9 @@ TEST(Location, ConstructorsAndDataAccess) {
|
||||
loc = Location("http://www.example.com");
|
||||
EXPECT_EQ("http://www.example.com", loc.URL());
|
||||
|
||||
loc = Location("http://www.example.com", {
|
||||
"1.0",
|
||||
"1.1"
|
||||
});
|
||||
loc = Location("http://www.example.com", "example");
|
||||
EXPECT_EQ("http://www.example.com", loc.URL());
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
"1.0",
|
||||
"1.1"
|
||||
}), loc.Versions());
|
||||
EXPECT_EQ("example", loc.Name());
|
||||
}
|
||||
|
||||
TEST(Location, EqualityOperator) {
|
||||
@@ -56,8 +50,8 @@ TEST(Location, EqualityOperator) {
|
||||
loc2 = Location("HTTP://WWW.EXAMPLE.COM");
|
||||
EXPECT_TRUE(loc1 == loc2);
|
||||
|
||||
loc1 = Location("http://www.example.com", {"1.0"});
|
||||
loc2 = Location("http://www.example.com", {"1.1"});
|
||||
loc1 = Location("http://www.example.com", "example1");
|
||||
loc2 = Location("http://www.example.com", "example2");
|
||||
EXPECT_TRUE(loc1 == loc2);
|
||||
|
||||
loc1 = Location("http://www.example1.com");
|
||||
@@ -75,8 +69,8 @@ TEST(Location, LessThanOperator) {
|
||||
EXPECT_FALSE(loc1 < loc2);
|
||||
EXPECT_FALSE(loc2 < loc1);
|
||||
|
||||
loc1 = Location("http://www.example.com", {"1.0"});
|
||||
loc2 = Location("http://www.example.com", {"1.1"});
|
||||
loc1 = Location("http://www.example.com", "example1");
|
||||
loc2 = Location("http://www.example.com", "example2");
|
||||
EXPECT_FALSE(loc1 < loc2);
|
||||
EXPECT_FALSE(loc2 < loc1);
|
||||
|
||||
@@ -92,13 +86,10 @@ TEST(Location, YamlEmitter) {
|
||||
e1 << loc;
|
||||
EXPECT_STREQ("'http://www.example.com'", e1.c_str());
|
||||
|
||||
loc = Location("http://www.example.com", {
|
||||
"1.0",
|
||||
"1.1"
|
||||
});
|
||||
loc = Location("http://www.example.com", "example");
|
||||
YAML::Emitter e2;
|
||||
e2 << loc;
|
||||
EXPECT_STREQ("link: 'http://www.example.com'\nver:\n - '1.0'\n - '1.1'", e2.c_str());
|
||||
EXPECT_STREQ("link: 'http://www.example.com'\nname: 'example'", e2.c_str());
|
||||
}
|
||||
|
||||
TEST(Location, YamlEncode) {
|
||||
@@ -107,18 +98,12 @@ TEST(Location, YamlEncode) {
|
||||
Location loc("http://www.example.com");
|
||||
node = loc;
|
||||
EXPECT_EQ("http://www.example.com", node["link"].as<std::string>());
|
||||
EXPECT_EQ(std::vector<std::string>(), node["ver"].as<std::vector<std::string>>());
|
||||
EXPECT_FALSE(node["name"]);
|
||||
|
||||
loc = Location("http://www.example.com", {
|
||||
"1.0",
|
||||
"1.1"
|
||||
});
|
||||
loc = Location("http://www.example.com", "example");
|
||||
node = loc;
|
||||
EXPECT_EQ("http://www.example.com", node["link"].as<std::string>());
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
"1.0",
|
||||
"1.1"
|
||||
}), node["ver"].as<std::vector<std::string>>());
|
||||
EXPECT_EQ("example", node["name"].as<std::string>());
|
||||
}
|
||||
|
||||
TEST(Location, YamlDecode) {
|
||||
@@ -128,15 +113,12 @@ TEST(Location, YamlDecode) {
|
||||
node = YAML::Load("http://www.example.com");
|
||||
loc = node.as<Location>();
|
||||
EXPECT_EQ("http://www.example.com", loc.URL());
|
||||
EXPECT_EQ(std::vector<std::string>(), loc.Versions());
|
||||
EXPECT_EQ("", loc.Name());
|
||||
|
||||
node = YAML::Load("{link: http://www.example.com, ver: [ 1.0, 1.1]}");
|
||||
node = YAML::Load("{link: http://www.example.com, name: example}");
|
||||
loc = node.as<Location>();
|
||||
EXPECT_EQ("http://www.example.com", loc.URL());
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
"1.0",
|
||||
"1.1"
|
||||
}), loc.Versions());
|
||||
EXPECT_EQ("example", loc.Name());
|
||||
|
||||
node = YAML::Load("[0, 1, 2]");
|
||||
EXPECT_ANY_THROW(node.as<Location>());
|
||||
|
||||
Reference in New Issue
Block a user