mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Graph: Support version 2 graphs
This commit is contained in:
parent
54d74b0acd
commit
93bac15244
@ -43,6 +43,11 @@ public class Json_doc {
|
||||
Json_itm nde = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0);
|
||||
return nde == null || nde.Tid() != Json_itm_.Tid__str ? or : (String)nde.Data();
|
||||
}
|
||||
public int Get_val_as_int_or(byte[] qry_bry, int or) {tmp_qry_bry[0] = qry_bry; return Get_val_as_int_or(tmp_qry_bry, or);}
|
||||
public int Get_val_as_int_or(byte[][] qry_bry, int or) {
|
||||
Json_itm nde = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0);
|
||||
return nde == null || nde.Tid() != Json_itm_.Tid__int ? or : Bry_.To_int(nde.Data_bry());
|
||||
}
|
||||
public Json_grp Get_grp(byte[] qry_bry) {
|
||||
tmp_qry_bry[0] = qry_bry;
|
||||
Json_itm rv = Find_nde(root_nde, tmp_qry_bry, 0, 0); if (rv == null) return null;
|
||||
|
@ -54,6 +54,7 @@ public class Xoae_page implements Xoa_page {
|
||||
}
|
||||
return page_guid;
|
||||
}
|
||||
public void Page_guid_empty_() {page_guid = Guid_adp_.Empty;} // TEST
|
||||
|
||||
public Xowe_wiki Wikie() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xol_lang_itm Lang() {return lang;} public Xoae_page Lang_(Xol_lang_itm v) {lang = v; return this;} private Xol_lang_itm lang;
|
||||
|
@ -74,7 +74,9 @@ public class Xoax_addon_mgr {
|
||||
, new gplx.xowa.addons.wikis.fulltexts .Xosearch_fulltext_addon()
|
||||
|
||||
// jsons
|
||||
, new gplx.xowa.addons.servers.https.utils .Xoa_util_addon()
|
||||
);
|
||||
|
||||
if (app.Mode().Tid_is_http()) {
|
||||
app.Addon_mgr().Itms__add_many(new gplx.xowa.addons.servers.https.Xoax_long_poll_addon());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import gplx.xowa.addons.apps.cfgs.specials.edits.pages.*; import gplx.xowa.addon
|
||||
public class Xocfg_edit_svc {
|
||||
private final Xoa_app app;
|
||||
private Xocfg_edit_loader edit_loader;
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New_by_page(Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xocfg_edit_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import gplx.dbs.*; import gplx.xowa.specials.xowa.diags.*;
|
||||
* run stored procs? EXEC debug_image 'A.png'
|
||||
*/
|
||||
class Xosql_exec_svc {
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New(gplx.xowa.addons.apps.maints.sql_execs.specials.Xosql_exec_special.Prototype.Special__meta().Ttl_bry());
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New_by_page(gplx.xowa.addons.apps.maints.sql_execs.specials.Xosql_exec_special.Prototype.Special__meta().Ttl_bry());
|
||||
private final Xoa_app app;
|
||||
public Xosql_exec_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
|
@ -45,7 +45,7 @@ class Xoa_update_svc implements Gfo_invk {
|
||||
|
||||
// start download
|
||||
Xojs_wkr__download download_wkr = new Xojs_wkr__download
|
||||
( app.Gui__cbk_mgr(), Xog_cbk_trg.New(Xoa_update_special.Prototype.Special__meta().Ttl_bry())
|
||||
( app.Gui__cbk_mgr(), Xog_cbk_trg.New_by_page(Xoa_update_special.Prototype.Special__meta().Ttl_bry())
|
||||
, "xo.app_updater.download__prog", Gfo_invk_cmd.New_by_key(this, Invk__download_done), Gfo_invk_cmd.New_by_key(this, Invk__download_fail), src, trg, src_len);
|
||||
download_wkr.Exec_async("app_updater");
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import gplx.core.brys.evals.*; import gplx.core.gfobjs.*; import gplx.core.progs
|
||||
import gplx.xowa.addons.bldrs.centrals.tasks.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.mgrs.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
public class Xobc_task_mgr implements Xog_json_wkr {
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(Xobc_task_special.Prototype.Special__meta().Ttl_bry());
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New_by_page(Xobc_task_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xobc_task_mgr(Xoa_app app, Io_url data_db_url) {
|
||||
this.app = app;
|
||||
this.cbk_mgr = app.Gui__cbk_mgr();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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() {}
|
||||
}
|
@ -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())
|
||||
);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ import gplx.xowa.langs.cases.*;
|
||||
class Xowdir_item_mgr {
|
||||
private final Xoa_app app;
|
||||
private final Json_wtr json_wtr = new Json_wtr();
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New(Xowdir_item_special.Prototype.Special__meta().Ttl_bry());
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New_by_page(Xowdir_item_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xowdir_item_mgr(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import gplx.langs.jsons.*;
|
||||
import gplx.xowa.addons.wikis.directorys.dbs.*;
|
||||
class Xowdir_list_svc {
|
||||
private final Xoa_app app;
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New(Xowdir_list_special.Prototype.Special__meta().Ttl_bry());
|
||||
private gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New_by_page(Xowdir_list_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xowdir_list_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import gplx.xowa.addons.wikis.fulltexts.indexers.specials.*;
|
||||
import gplx.xowa.addons.wikis.fulltexts.indexers.bldrs.*;
|
||||
class Xofulltext_indexer_svc implements Gfo_invk {
|
||||
private final Xoa_app app;
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(Xofulltext_indexer_special.Prototype.Special__meta().Ttl_bry());
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New_by_page(Xofulltext_indexer_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Xofulltext_indexer_svc(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class Xofulltext_searcher_svc implements Gfo_invk {
|
||||
private void Search(Xofulltext_args_qry args) {
|
||||
// create ui
|
||||
Xofulltext_cache_mgr cache_mgr = args.cache_mgr;
|
||||
Xofulltext_searcher_ui ui = new Xofulltext_searcher_ui(cache_mgr, app.Gui__cbk_mgr(), new Xog_cbk_trg(args.page_guid));
|
||||
Xofulltext_searcher_ui ui = new Xofulltext_searcher_ui(cache_mgr, app.Gui__cbk_mgr(), Xog_cbk_trg.New_by_guid(args.page_guid));
|
||||
|
||||
try {
|
||||
// loop wikis
|
||||
@ -138,7 +138,7 @@ class Xofulltext_searcher_svc implements Gfo_invk {
|
||||
}
|
||||
private void Snips_show_all(int qry_id, byte[] wiki_bry, int page_id, String page_guid) {
|
||||
Xofulltext_cache_mgr cache_mgr = this.Cache_mgr();
|
||||
Xofulltext_searcher_ui searcher_ui = new Xofulltext_searcher_ui(cache_mgr, app.Gui__cbk_mgr(), new Xog_cbk_trg(page_guid));
|
||||
Xofulltext_searcher_ui searcher_ui = new Xofulltext_searcher_ui(cache_mgr, app.Gui__cbk_mgr(), Xog_cbk_trg.New_by_guid(page_guid));
|
||||
|
||||
Xofulltext_cache_line[] lines = cache_mgr.Get_lines_rest(qry_id, wiki_bry, page_id);
|
||||
for (Xofulltext_cache_line line : lines) {
|
||||
|
@ -85,7 +85,7 @@ public class Xog_bnd_win implements Gfo_invk {
|
||||
elem_2.X_(elem_1.X_max());
|
||||
}
|
||||
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(gplx.xowa.addons.apps.cfgs.specials.edits.pages.Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New_by_page(gplx.xowa.addons.apps.cfgs.specials.edits.pages.Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__when_key_down)) When_key_down(m);
|
||||
else if (ctx.Match(k, Invk__when_key_press)) When_key_up(m);
|
||||
|
@ -15,19 +15,18 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
public class Xog_cbk_trg {
|
||||
public Xog_cbk_trg(byte tid, byte[] page_ttl) {
|
||||
this.tid = tid; this.page_ttl = page_ttl;
|
||||
Xog_cbk_trg(byte tid, byte[] page_ttl, String page_guid) {
|
||||
this.tid = tid;
|
||||
this.page_ttl = page_ttl;
|
||||
this.page_guid = page_guid;
|
||||
}
|
||||
public Xog_cbk_trg(String page_guid) {
|
||||
this.tid = Tid__page_guid;
|
||||
this.page_ttl = Bry_.Empty;
|
||||
this.Page_guid = page_guid;
|
||||
}
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public byte[] Page_ttl() {return page_ttl;} private final byte[] page_ttl; // same as ttl.Full_db(); EX: Special:XowaDownloadCentral
|
||||
public String Page_guid;
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public byte[] Page_ttl() {return page_ttl;} private final byte[] page_ttl; // same as ttl.Full_db(); EX: Special:XowaDownloadCentral
|
||||
public String Page_guid() {return page_guid;} private final String page_guid;
|
||||
|
||||
public static final byte Tid__cbk_enabled = 0, Tid__specific_page = 1, Tid__page_guid = 2;
|
||||
public static final Xog_cbk_trg Any = new Xog_cbk_trg(Tid__cbk_enabled, null);
|
||||
public static Xog_cbk_trg New(byte[] page_ttl) {return new Xog_cbk_trg(Tid__specific_page, page_ttl);}
|
||||
|
||||
public static final Xog_cbk_trg Any = new Xog_cbk_trg(Tid__cbk_enabled, null, String_.Empty);
|
||||
public static Xog_cbk_trg New_by_page(byte[] page_ttl) {return new Xog_cbk_trg(Tid__specific_page, page_ttl , String_.Empty);}
|
||||
public static Xog_cbk_trg New_by_guid(String page_guid) {return new Xog_cbk_trg(Tid__page_guid , Bry_.Empty , page_guid);}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class Xog_cbk_wkr__swt implements Xog_cbk_wkr {
|
||||
boolean match = false;
|
||||
switch (trg.Tid()) {
|
||||
case Xog_cbk_trg.Tid__page_guid:
|
||||
match = String_.Eq(trg.Page_guid, page.Page_guid().To_str());
|
||||
match = String_.Eq(trg.Page_guid(), page.Page_guid().To_str());
|
||||
break;
|
||||
case Xog_cbk_trg.Tid__cbk_enabled:
|
||||
match = page.Html_data().Cbk_enabled();
|
||||
|
@ -43,7 +43,8 @@ public class Xoh_head_itm__globals extends Xoh_head_itm__base {
|
||||
wtr.Write_js_alias_var (Page__alias, Page__key);
|
||||
wtr.Write_js_alias_kv (Page__alias, Key__wiki , page.Wiki().Domain_bry());
|
||||
wtr.Write_js_alias_kv (Page__alias, Key__ttl , page.Ttl().Page_db());
|
||||
} private static final byte[] Key__app_mode = Bry_.new_a7("xowa.app.mode"), Page__alias = Bry_.new_a7("x_p"), Page__key = Bry_.new_a7("xowa.page"), Key__wiki = Bry_.new_a7("wiki"), Key__ttl = Bry_.new_a7("ttl");
|
||||
wtr.Write_js_alias_kv (Page__alias, Key__guid , Bry_.new_a7(page.Page_guid().To_str()));
|
||||
} private static final byte[] Key__app_mode = Bry_.new_a7("xowa.app.mode"), Page__alias = Bry_.new_a7("x_p"), Page__key = Bry_.new_a7("xowa.page"), Key__wiki = Bry_.new_a7("wiki"), Key__ttl = Bry_.new_a7("ttl"), Key__guid = Bry_.new_a7("guid");
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_mode_is_gui , app.Mode().Tid_is_gui());
|
||||
wtr.Write_js_global_ini_atr_val(Key_mode_is_http , app.Mode().Tid_is_http());
|
||||
|
@ -15,28 +15,59 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.wikis.pages.tags.*;
|
||||
public class Xoh_head_itm__graph extends Xoh_head_itm__base {
|
||||
private boolean version_is_1, version_is_2;
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__graph;}
|
||||
@Override public int Flags() {return Flag__js_include | Flag__js_window_onload;}
|
||||
public void Version_(Xoa_url url, int v) {
|
||||
if (v == 1)
|
||||
version_is_1 = true;
|
||||
else
|
||||
version_is_2 = true;
|
||||
if (version_is_1 && version_is_2)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "page should not have both version 1 and version 2 graphs; page=~{0}", url.To_bry_full_wo_qargs());
|
||||
}
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url__ary == null) {
|
||||
Io_url lib_dir = app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("Graph", "lib");
|
||||
Url__ary = new byte[][]
|
||||
{ app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("html", "res", "lib", "jquery", "jquery-1.11.3.min.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.layout.cloud.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("topojson.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("vega.js").To_http_file_bry()
|
||||
, app.Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("Graph", "js", "graph.js").To_http_file_bry()
|
||||
};
|
||||
// collect tags
|
||||
Io_url http_root = app.Fsys_mgr().Http_root();
|
||||
Xopg_tag_mgr tags = new Xopg_tag_mgr(true);
|
||||
Xopg_tag_wtr_.Add__jquery(tags, http_root);
|
||||
Xopg_tag_wtr_.Add__xologger(tags, http_root);
|
||||
Xopg_tag_wtr_.Add__xolog(tags, http_root, false);
|
||||
Xopg_tag_wtr_.Add__xoajax(tags, http_root, app);
|
||||
Add__xograph(tags, http_root, page, version_is_1);
|
||||
|
||||
// write tags
|
||||
int len = tags.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xopg_tag_itm tag = tags.Get_at(i);
|
||||
Io_url tag_url = Io_url_.New__http_or_fail(tag.Href());
|
||||
wtr.Write_js_include(tag_url);
|
||||
}
|
||||
for (int i = 0; i < Url__ary_len; ++i)
|
||||
wtr.Write_js_include(Url__ary[i]);
|
||||
}
|
||||
@Override public void Write_js_window_onload(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_line(Js__graph_exec);
|
||||
}
|
||||
private static final int Url__ary_len = 6;
|
||||
private static byte[][] Url__ary;
|
||||
private static final byte[] Js__graph_exec = Bry_.new_a7("xtn__graph__exec();");
|
||||
|
||||
private static final byte[] Js__graph_exec = Bry_.new_a7("xo.xtns.graph.exec();");
|
||||
private static void Add__xograph(Xopg_tag_mgr tags, Io_url http_root, Xoae_page page, boolean version_is_1) {
|
||||
Io_url base_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "core");
|
||||
tags.Add(Xopg_tag_itm.New_js_file(base_dir.GenSubFil_nest("Html_.js")));
|
||||
|
||||
// REF: /graph/extension.json/ext.graph.vega1|ext.graph.vega2
|
||||
Io_url xtn_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "xtns", "Graph");
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "d3.js")));
|
||||
// tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "d3-global.js"))); // XOWA: unused b/c module is not available
|
||||
if (version_is_1) {
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "vega1", "vega.js")));
|
||||
}
|
||||
else {
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "d3.layout.cloud.js")));
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "vega2", "vega.js")));
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("lib", "graph2.compiled.js")));
|
||||
// tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("modules", "graph2.js")));
|
||||
}
|
||||
tags.Add(Xopg_tag_itm.New_js_file(xtn_dir.GenSubFil_nest("Xograph.js")));
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ public class Xoh_head_mgr_tst {
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " x_p.guid = '00000000-0000-0000-0000-000000000000';"
|
||||
, " </script>"
|
||||
));
|
||||
fxt.Init_msg(Xol_msg_itm_.Id_dte_month_name_january, "January" ); // set it back
|
||||
@ -113,6 +114,7 @@ public class Xoh_head_mgr_tst {
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " x_p.guid = '00000000-0000-0000-0000-000000000000';"
|
||||
, " </script>"
|
||||
));
|
||||
}
|
||||
@ -137,6 +139,7 @@ class Xoh_head_mgr_fxt {
|
||||
msg_itm.Atrs_set(Bry_.new_a7(val), false, false);
|
||||
}
|
||||
public void Test_write(String expd) {
|
||||
fxt.Page().Page_guid_empty_();
|
||||
mgr.Write(bfr, fxt.App(), wiki, fxt.Page());
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ public class Xopg_tag_mgr {
|
||||
public void Add(Xopg_tag_itm... ary) {for (Xopg_tag_itm itm : ary) list.Add(itm);}
|
||||
public void Copy(Xopg_tag_mgr src) {
|
||||
int len = src.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
for (int i = 0; i < len; i++)
|
||||
this.Add(src.Get_at(i));
|
||||
}
|
||||
public byte[] To_html(Bry_bfr bfr) {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
tag.To_html(bfr);
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class Xopg_tag_mgr {
|
||||
}
|
||||
public byte[] To_html__style(Bry_bfr bfr) {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
if ( Bry_.Eq(tag.Node(), gplx.langs.htmls.Gfh_tag_.Bry__style)
|
||||
&& tag.Body() != null
|
||||
|
@ -33,9 +33,15 @@ public class Xopg_tag_wtr_ {
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xohelp-0.0.1.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("xohelp-0.0.1.js")));
|
||||
}
|
||||
public static void Add__xolog(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
public static void Add__xologger(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xolog");
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(dir.GenSubFil_nest("xo.log.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.logger.js")));
|
||||
}
|
||||
public static void Add__xolog(Xopg_tag_mgr head_tags, Io_url http_root) {Add__xolog(head_tags, http_root, true);}
|
||||
public static void Add__xolog(Xopg_tag_mgr head_tags, Io_url http_root, boolean write_css) {
|
||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xolog");
|
||||
if (write_css)
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(dir.GenSubFil_nest("xo.log.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.log.js")));
|
||||
}
|
||||
public static void Add__xotmpl(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
@ -52,10 +58,13 @@ public class Xopg_tag_wtr_ {
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.notify.js")));
|
||||
}
|
||||
public static void Add__xoajax(Xopg_tag_mgr head_tags, Io_url http_root, Xoa_app app) {
|
||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoajax");
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.app.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest(Get_app_js_file(app))));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.server.js")));
|
||||
Io_url base_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "core");
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(base_dir.GenSubFil_nest("Uuid_.js")));
|
||||
|
||||
Io_url ajax_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoajax");
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(ajax_dir.GenSubFil_nest("xo.app.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(ajax_dir.GenSubFil_nest(Get_app_js_file(app))));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(ajax_dir.GenSubFil_nest("xo.server.js")));
|
||||
}
|
||||
public static void Add__gui__progbars(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "gui", "progbars");
|
||||
|
@ -16,11 +16,12 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.xtns.graphs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
import gplx.xowa.htmls.heads.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Graph_xnde implements Xox_xnde {
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
ctx.Page().Html_data().Head_mgr().Itm__graph().Enabled_y_();
|
||||
boolean log_wkr_enabled = Log_wkr != Xop_log_basic_wkr.Null; if (log_wkr_enabled) Log_wkr.Log_end_xnde(ctx.Page(), Xop_log_basic_wkr.Tid_graph, src, xnde);
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
@ -30,14 +31,26 @@ public class Graph_xnde implements Xox_xnde {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
json = Json_fmtr.clean(tmp_bfr, json);
|
||||
|
||||
// enable graph
|
||||
Xoh_head_itm__graph itm_graph = ctx.Page().Html_data().Head_mgr().Itm__graph();
|
||||
itm_graph.Enabled_y_();
|
||||
|
||||
// get version; NOTE: default is 2; REF: https://noc.wikimedia.org/conf/InitialiseSettings.php.txt and 'wgGraphDefaultVegaVer' => ['default' => 2]; also, extension.json and "GraphDefaultVegaVer": 2
|
||||
Json_doc jdoc = app.Utl__json_parser().Parse(json);
|
||||
int version = jdoc.Get_val_as_int_or(Bry_.new_a7("version"), 2);
|
||||
itm_graph.Version_(wpg.Url(), version);
|
||||
|
||||
// add to bfr
|
||||
bfr.Add(Html__div_bgn);
|
||||
bfr.Add(Html__div_lhs_bgn);
|
||||
bfr.Add_int_fixed(version, 1);
|
||||
bfr.Add(Html__div_lhs_end);
|
||||
bfr.Add(json);
|
||||
bfr.Add(Html__div_end);
|
||||
bfr.Add(Html__div_rhs);
|
||||
}
|
||||
public static Xop_log_basic_wkr Log_wkr = Xop_log_basic_wkr.Null;
|
||||
private static final byte[]
|
||||
Html__div_bgn = Bry_.new_a7("<div class='mw-wiki-graph'>\n")
|
||||
, Html__div_end = Bry_.new_a7("</div>\n")
|
||||
Html__div_lhs_bgn = Bry_.new_a7("<div class='mw-graph' xo-graph-version=")
|
||||
, Html__div_lhs_end = Bry_.new_a7(">\n")
|
||||
, Html__div_rhs = Bry_.new_a7("</div>\n")
|
||||
;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user