1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Graph: Support version 2 graphs

This commit is contained in:
gnosygnu
2018-03-03 08:52:14 -05:00
parent 54d74b0acd
commit 93bac15244
23 changed files with 240 additions and 53 deletions

View File

@@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.servers.https.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*; import gplx.xowa.addons.servers.https.*;
import gplx.xowa.htmls.bridges.*;
public class Xoa_util_addon implements Xoax_addon_itm, Xoax_addon_itm__json {
public String Addon__key() {return ADDON__KEY;} private static final String ADDON__KEY = "xowa.app.util";
public Bridge_cmd_itm[] Json_cmds() {
return new Bridge_cmd_itm[]
{ Xoa_util_bridge.Prototype
};
}
public static Xoa_util_addon Get_by_app(Xoa_app app) {
return (Xoa_util_addon)app.Addon_mgr().Itms__get_or_null(ADDON__KEY);
}
}

View File

@@ -0,0 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.servers.https.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*; import gplx.xowa.addons.servers.https.*;
import gplx.langs.jsons.*;
import gplx.xowa.htmls.bridges.*;
public class Xoa_util_bridge implements Bridge_cmd_itm {
private Xoa_util_svc svc;
public void Init_by_app(Xoa_app app) {
svc = new Xoa_util_svc(app);
}
public String Exec(Json_nde data) {
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Bridge_cmd_mgr.Msg__proc, null), Byte_ascii.Max_7_bit);
Json_nde args = data.Get_kv(Bridge_cmd_mgr.Msg__args).Val_as_nde();
switch (proc_id) {
case Proc__page_get: svc.Page_get(args); break;
default: throw Err_.new_unhandled_default(proc_id);
}
return "";
}
private static final byte Proc__page_get = 0;
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
.Add_str_byte("page_get" , Proc__page_get)
;
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("xowa.app.util.misc");
public static final Xoa_util_bridge Prototype = new Xoa_util_bridge(); Xoa_util_bridge() {}
}

View File

@@ -0,0 +1,54 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.servers.https.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*; import gplx.xowa.addons.servers.https.*;
import gplx.langs.jsons.*;
import gplx.xowa.htmls.bridges.*;
import gplx.xowa.wikis.caches.*;
import gplx.xowa.guis.cbks.*;
public class Xoa_util_svc {
private final Xoa_app app;
private final Xog_cbk_mgr cbk_mgr;
public Xoa_util_svc(Xoa_app app) {
this.app = app;
this.cbk_mgr = app.Gui__cbk_mgr();
}
public void Page_get(Json_nde args) {
// get args
String page_get_cbk = args.Get_as_str("page_get_cbk");
byte[] wiki_bry = args.Get_as_bry("wiki");
byte[] page_bry = args.Get_as_bry("page");
String vega_cbk_guid = args.Get_as_str("vega_cbk_guid");
String page_guid = args.Get_as_str("page_guid");
// get wiki
Xow_wiki wiki_base = app.Wiki_mgri().Get_by_or_make_init_y(wiki_bry);
if (!wiki_base.Type_is_edit()) {
throw Err_.new_unimplemented();
}
Xowe_wiki wiki = (Xowe_wiki)wiki_base;
// get page
Xoa_ttl ttl = wiki.Ttl_parse(page_bry);
Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm_2(ttl);
Xog_cbk_trg cbk_trg = Xog_cbk_trg.New_by_guid(page_guid);
cbk_mgr.Send_json(cbk_trg, page_get_cbk, gplx.core.gfobjs.Gfobj_nde.New()
.Add_bry("wiki", wiki_bry)
.Add_bry("page", page_bry)
.Add_str("vega_cbk_guid", vega_cbk_guid)
.Add_bry("page_text", page_itm.Wtxt__direct())
);
}
}