mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-22 22:04:01 -06:00
ide: UppHub improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@15710 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
fe94ba6d3a
commit
be4d1ccac5
1 changed files with 33 additions and 27 deletions
|
|
@ -1,7 +1,5 @@
|
|||
#include "ide.h"
|
||||
|
||||
// Todo: other folders in UppHub
|
||||
|
||||
struct UppHubNest : Moveable<UppHubNest> {
|
||||
int tier = -1;
|
||||
String name;
|
||||
|
|
@ -22,14 +20,15 @@ struct UppHubDlg : WithUppHubLayout<TopWindow> {
|
|||
bool loading_stopped;
|
||||
String last_package;
|
||||
|
||||
void Readme();
|
||||
void Load(int tier, const String& url, bool deep);
|
||||
void Load();
|
||||
void Install(bool noprompt = false);
|
||||
void Uninstall(bool noprompt = false);
|
||||
void Reinstall();
|
||||
void Install(const Index<String>& ii);
|
||||
void SyncList();
|
||||
void Readme();
|
||||
Value LoadJson(const String& url);
|
||||
void Load(int tier, const String& url);
|
||||
void Load();
|
||||
void Install(bool noprompt = false);
|
||||
void Uninstall(bool noprompt = false);
|
||||
void Reinstall();
|
||||
void Install(const Index<String>& ii);
|
||||
void SyncList();
|
||||
|
||||
UppHubNest *Get(const String& name) { return upv.FindPtr(name); }
|
||||
UppHubNest *Current() { return Get(list.GetKey()); }
|
||||
|
|
@ -104,13 +103,8 @@ void UppHubDlg::Readme()
|
|||
}
|
||||
}
|
||||
|
||||
void UppHubDlg::Load(int tier, const String& url, bool deep)
|
||||
Value UppHubDlg::LoadJson(const String& url)
|
||||
{
|
||||
if(loaded.Find(url) >= 0)
|
||||
return;
|
||||
loaded.Add(url);
|
||||
|
||||
|
||||
String s = LoadFile(url);
|
||||
|
||||
if(IsNull(s)) {
|
||||
|
|
@ -128,7 +122,7 @@ void UppHubDlg::Load(int tier, const String& url, bool deep)
|
|||
r.Execute();
|
||||
|
||||
if(loading_stopped)
|
||||
return;
|
||||
return ErrorValue();
|
||||
|
||||
s = r.GetContent();
|
||||
}
|
||||
|
|
@ -138,17 +132,36 @@ void UppHubDlg::Load(int tier, const String& url, bool deep)
|
|||
|
||||
if(begin >= 0 && end >= 0)
|
||||
s = s.Mid(begin, end - begin);
|
||||
|
||||
DDUMP(s);
|
||||
|
||||
Value v = ParseJSON(s);
|
||||
if(v.IsError()) {
|
||||
s.Replace(""", "\"");
|
||||
s.Replace("&", "&");
|
||||
DDUMP(s);
|
||||
v = ParseJSON(s);
|
||||
DDUMP(v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
void UppHubDlg::Load(int tier, const String& url)
|
||||
{
|
||||
if(loaded.Find(url) >= 0)
|
||||
return;
|
||||
loaded.Add(url);
|
||||
|
||||
Value v = LoadJson(url);
|
||||
|
||||
DDUMP(v);
|
||||
|
||||
try {
|
||||
String list_name = v["name"];
|
||||
for(Value ns : v["nests"]) {
|
||||
String url = ns["url"];
|
||||
if(url.GetCount())
|
||||
ns = LoadJson(url);
|
||||
String name = ns["name"];
|
||||
UppHubNest& n = upv.GetAdd(name);
|
||||
n.name = name;
|
||||
|
|
@ -170,16 +183,10 @@ void UppHubDlg::Load(int tier, const String& url, bool deep)
|
|||
Attr(n.readme, "readme");
|
||||
n.list_name = list_name;
|
||||
}
|
||||
if(deep)
|
||||
for(Value l : v["links"]) {
|
||||
if(loading_stopped)
|
||||
break;
|
||||
Load(tier + 1, l, true);
|
||||
}
|
||||
for(Value l : v["refs"]) {
|
||||
for(Value l : v["links"]) {
|
||||
if(loading_stopped)
|
||||
break;
|
||||
Load(tier + 1, l, false);
|
||||
Load(tier + 1, l);
|
||||
}
|
||||
}
|
||||
catch(ValueTypeError) {}
|
||||
|
|
@ -206,8 +213,7 @@ void UppHubDlg::Load()
|
|||
upv.Clear();
|
||||
|
||||
Load(0, Nvl(LoadFile(ConfigFile("upphub_root")),
|
||||
"https://raw.githubusercontent.com/ultimatepp/ultimatepp/master/upphub.root"),
|
||||
true);
|
||||
"https://raw.githubusercontent.com/ultimatepp/ultimatepp/master/upphub.root"));
|
||||
|
||||
SyncList();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue