mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
New "Releases" tab
This commit is contained in:
parent
5c2599315c
commit
cf579ef5a3
1 changed files with 49 additions and 0 deletions
|
@ -131,6 +131,7 @@ local function get_formspec(data)
|
||||||
fgettext("Description"),
|
fgettext("Description"),
|
||||||
fgettext("Information"),
|
fgettext("Information"),
|
||||||
fgettext("Reviews") .. core.formspec_escape(" [" .. review_count .. "]"),
|
fgettext("Reviews") .. core.formspec_escape(" [" .. review_count .. "]"),
|
||||||
|
fgettext("Releases"),
|
||||||
}
|
}
|
||||||
|
|
||||||
local tab_body_height = bottom_buttons_y - 2.8
|
local tab_body_height = bottom_buttons_y - 2.8
|
||||||
|
@ -232,6 +233,54 @@ local function get_formspec(data)
|
||||||
else
|
else
|
||||||
table.insert_all(formspec, {"label[2,2;", fgettext("Loading..."), "]"} )
|
table.insert_all(formspec, {"label[2,2;", fgettext("Loading..."), "]"} )
|
||||||
end
|
end
|
||||||
|
elseif current_tab == 4 then
|
||||||
|
if not package.releases and not data.releases_error and not data.releases_loading then
|
||||||
|
data.releases_loading = true
|
||||||
|
|
||||||
|
contentdb.get_package_releases(package, function(releases)
|
||||||
|
if not releases then
|
||||||
|
data.releases_error = true
|
||||||
|
end
|
||||||
|
ui.update()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function markup(text)
|
||||||
|
text = text:gsub("(%*%*)([^%s][^*]-[^%s])%*%*", "<b>%2</b>")
|
||||||
|
text = text:gsub("(%*)([^%s][^*]-[^%s])%*", "<i>%2</i>")
|
||||||
|
text = text:gsub("* ", "<b>•</b> ")
|
||||||
|
text = text:gsub("- ", "<b>•</b> ")
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
local hypertext = ""
|
||||||
|
if package.releases then
|
||||||
|
for _, def in pairs(package.releases) do
|
||||||
|
hypertext = hypertext..
|
||||||
|
"<b>"..def.title.."</b> ("..def.release_date:gsub("T.*", "")..")\n"..
|
||||||
|
fgettext("$1 downloads",
|
||||||
|
def.downloads)..".\n"
|
||||||
|
|
||||||
|
if def["release_notes"] then
|
||||||
|
hypertext = hypertext..
|
||||||
|
markup((def["release_notes"]
|
||||||
|
:gsub("<!--.*", ""))
|
||||||
|
:gsub("[\r\n]+$", ""))
|
||||||
|
.."\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
hypertext = hypertext..
|
||||||
|
"\n"
|
||||||
|
end
|
||||||
|
elseif data.releases_error then
|
||||||
|
table.insert_all(formspec, {"label[2,2;", fgettext("Error loading releases"), "]"} )
|
||||||
|
else
|
||||||
|
table.insert_all(formspec, {"label[2,2;", fgettext("Loading..."), "]"} )
|
||||||
|
end
|
||||||
|
table.insert_all(formspec, {
|
||||||
|
"hypertext[0,0;", W, ",", tab_body_height - 0.375,
|
||||||
|
";release;", core.formspec_escape(hypertext), "]",
|
||||||
|
})
|
||||||
else
|
else
|
||||||
error("Unknown tab " .. current_tab)
|
error("Unknown tab " .. current_tab)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue