mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Xtns.TemplateStyles: Cache TemplateStyles for HTML databases [#482]
This commit is contained in:
parent
fbe158537e
commit
3d9491e2de
@ -28,6 +28,7 @@ public class Err_ {
|
||||
}
|
||||
public static Err new_unhandled(Object val) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch/if", "val", val);}
|
||||
public static Err new_unhandled_default(Object val) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch", "val", val);}
|
||||
public static Err new_unhandled_default_w_msg(Object val, String msg) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch", "val", val, "msg", msg);}
|
||||
public static Err new_unsupported() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not supported");}
|
||||
public static Err new_unimplemented() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not implemented");}
|
||||
public static Err new_unimplemented_w_msg(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
|
||||
|
@ -60,15 +60,40 @@ public class Db_stmt_ {
|
||||
public static void Val_by_obj(Db_stmt stmt, String key, Object val) {
|
||||
int tid = Type_ids_.To_id_by_obj(val);
|
||||
switch (tid) {
|
||||
case Type_ids_.Id__bool: stmt.Val_bool_as_byte (key, Bool_.Cast(val)); break;
|
||||
case Type_ids_.Id__byte: stmt.Val_byte (key, Byte_.Cast(val)); break;
|
||||
case Type_ids_.Id__int: stmt.Val_int (key, Int_.Cast(val)); break;
|
||||
case Type_ids_.Id__long: stmt.Val_long (key, Long_.cast(val)); break;
|
||||
case Type_ids_.Id__float: stmt.Val_float (key, Float_.cast(val)); break;
|
||||
case Type_ids_.Id__double: stmt.Val_double (key, Double_.cast(val)); break;
|
||||
case Type_ids_.Id__str: stmt.Val_str (key, String_.cast(val)); break;
|
||||
case Type_ids_.Id__bry: stmt.Val_bry (key, Bry_.cast(val)); break;
|
||||
default: throw Err_.new_unhandled_default(tid);
|
||||
case Type_ids_.Id__bool: stmt.Val_bool_as_byte (key, Bool_.Cast(val)); break;
|
||||
case Type_ids_.Id__byte: stmt.Val_byte (key, Byte_.Cast(val)); break;
|
||||
case Type_ids_.Id__int: stmt.Val_int (key, Int_.Cast(val)); break;
|
||||
case Type_ids_.Id__long: stmt.Val_long (key, Long_.cast(val)); break;
|
||||
case Type_ids_.Id__float: stmt.Val_float (key, Float_.cast(val)); break;
|
||||
case Type_ids_.Id__double: stmt.Val_double (key, Double_.cast(val)); break;
|
||||
case Type_ids_.Id__str: stmt.Val_str (key, String_.cast(val)); break;
|
||||
case Type_ids_.Id__bry: stmt.Val_bry (key, Bry_.cast(val)); break;
|
||||
default: throw Err_.new_unhandled_default(tid);
|
||||
}
|
||||
}
|
||||
public static void Insert_by_rdr(Dbmeta_fld_list flds, Db_rdr rdr, Db_stmt stmt) {
|
||||
stmt.Clear();
|
||||
Fill_by_rdr(flds, rdr, stmt);
|
||||
stmt.Exec_insert();
|
||||
}
|
||||
private static void Fill_by_rdr(Dbmeta_fld_list flds, Db_rdr rdr, Db_stmt stmt) {
|
||||
int flds_len = flds.Len();
|
||||
for (int i = 0; i < flds_len; i++) {
|
||||
Dbmeta_fld_itm fld = (Dbmeta_fld_itm)flds.Get_at(i);
|
||||
String fld_name = fld.Name();
|
||||
int fld_tid = fld.Type().Tid_ansi();
|
||||
if (fld.Autonum()) continue;
|
||||
switch (fld_tid) {
|
||||
case Dbmeta_fld_tid.Tid__bool: stmt.Val_bool_as_byte (fld_name, rdr.Read_bool_by_byte(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__byte: stmt.Val_byte (fld_name, rdr.Read_byte(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__int: stmt.Val_int (fld_name, rdr.Read_int(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__long: stmt.Val_long (fld_name, rdr.Read_long(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__float: stmt.Val_float (fld_name, rdr.Read_float(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__double: stmt.Val_double (fld_name, rdr.Read_double(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__str: stmt.Val_str (fld_name, rdr.Read_str(fld_name)); break;
|
||||
case Dbmeta_fld_tid.Tid__bry: stmt.Val_bry (fld_name, rdr.Read_bry(fld_name)); break;
|
||||
default: throw Err_.new_unhandled_default_w_msg(fld_tid, fld_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ public class Xoae_page implements Xoa_page {
|
||||
public boolean Xtn__timeline_exists() {return false;} // drd always sets timeline
|
||||
public boolean Xtn__gallery_exists() {return false;} // drd does not need to set gallery.style.css
|
||||
public int Xtn__math_uid__next() {return xtn__math_uid++;} private int xtn__math_uid;
|
||||
public Xoa_kv_hash Kv_data() {return kv_data;} private final Xoa_kv_hash kv_data = new Xoa_kv_hash();
|
||||
public Xoa_kv_hash Kv_data() {return kv_data;} private Xoa_kv_hash kv_data = new Xoa_kv_hash();
|
||||
public void Kv_data_(Xoa_kv_hash v) {kv_data = v;}
|
||||
private Guid_adp page_guid;
|
||||
public Guid_adp Page_guid() {
|
||||
if (page_guid == null) {
|
||||
|
@ -18,7 +18,7 @@ import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.ios.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.addons.*; import gplx.xowa.wikis.fsys.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.meta.*; import gplx.fsdb.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.htmls.hxtns.pages.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public interface Xow_wiki extends Xow_ttl_parser, Gfo_invk {
|
||||
@ -61,5 +61,6 @@ public interface Xow_wiki extends Xow_ttl_parser, Gfo_invk {
|
||||
Xoax_addon_mgr Addon_mgr();
|
||||
boolean Embeddable_enabled(); void Embeddable_enabled_(boolean v);
|
||||
void Init_needed_y_();
|
||||
Hxtn_page_mgr Hxtn_mgr();
|
||||
void Rls();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.wikis.fsys.*;
|
||||
import gplx.xowa.users.*; import gplx.xowa.htmls.*; import gplx.xowa.users.history.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.*; import gplx.xowa.wikis.dbs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.hxtns.pages.*;
|
||||
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.installs.*; import gplx.xowa.bldrs.setups.maints.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.*;
|
||||
@ -125,7 +125,7 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
||||
public Xop_sanitizer Sanitizer() {return sanitizer;} private final Xop_sanitizer sanitizer;
|
||||
public byte[] Wtxt__expand_tmpl(byte[] src) {return parser_mgr.Main().Expand_tmpl(src);}
|
||||
public boolean Embeddable_enabled() {return embeddable_enabled;} public void Embeddable_enabled_(boolean v) {this.embeddable_enabled = v;} private boolean embeddable_enabled;
|
||||
|
||||
public Hxtn_page_mgr Hxtn_mgr() {return hxtn_mgr;} private final Hxtn_page_mgr hxtn_mgr = new Hxtn_page_mgr();
|
||||
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public Xoae_app Appe() {return app;} private Xoae_app app;
|
||||
|
@ -59,6 +59,7 @@ public class Xoax_addon_mgr {
|
||||
|
||||
// xtns
|
||||
, new gplx.xowa.xtns.math .Xomath_addon()
|
||||
, new gplx.xowa.xtns.template_styles .Template_styles_addon()
|
||||
|
||||
// specials
|
||||
, new gplx.xowa.addons.wikis.registrys .Wiki_registry_addon()
|
||||
|
@ -26,6 +26,8 @@ public class Xomp_make_cmd extends Xob_cmd__base {
|
||||
new Xomp_make_lnki().Exec(wiki, cfg, 10000);
|
||||
if (cfg.Mode().Has("stat"))
|
||||
new Xomp_make_stat().Exec(wiki, cfg);
|
||||
if (cfg.Mode().Has("hxtn"))
|
||||
new Xomp_make_hxtn().Exec(wiki, cfg);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cfg)) return cfg;
|
||||
|
@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
public class Xomp_make_cmd_cfg implements Gfo_invk {
|
||||
public Hash_adp Mode() {return mode;} private Hash_adp mode = Hash_adp_.New().Add_and_more("html", "html").Add_and_more("lnki", "lnki").Add_and_more("stat", "stat");
|
||||
public Hash_adp Mode() {return mode;} private Hash_adp mode = Hash_adp_.New().Add_and_more("html", "html").Add_and_more("lnki", "lnki").Add_and_more("stat", "stat").Add_and_more("hxtn", "hxtn");
|
||||
public boolean Delete_html_dbs() {return delete_html_dbs;} private boolean delete_html_dbs = true;
|
||||
public Ordered_hash Merger_wkrs() {return merger_wkrs;} private final Ordered_hash merger_wkrs = Ordered_hash_.New();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
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.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
|
||||
import gplx.xowa.htmls.hxtns.pages.*; import gplx.xowa.htmls.hxtns.blobs.*;
|
||||
class Xomp_make_hxtn {
|
||||
public void Exec(Xowe_wiki wiki, Xomp_make_cmd_cfg cfg) {
|
||||
// create mgr
|
||||
Hxtn_page_mgr page_mgr = new Hxtn_page_mgr();
|
||||
page_mgr.Init_by_wiki(wiki, Bool_.Y);
|
||||
Hxtn_page_tbl page_tbl = page_mgr.Page_tbl();
|
||||
Hxtn_blob_tbl blob_tbl = page_mgr.Blob_tbl();
|
||||
page_mgr.Insert_bgn(true);
|
||||
|
||||
// loop wkrs
|
||||
Xomp_mgr_db mgr_db = Xomp_mgr_db.New__load(wiki);
|
||||
int wkrs_len = mgr_db.Tbl__wkr().Select_count();
|
||||
for (int i = 0; i < wkrs_len; ++i) {
|
||||
// init count / wkr_db
|
||||
int count = 0;
|
||||
Xomp_wkr_db wkr_db = Xomp_wkr_db.New(mgr_db.Dir(), i);
|
||||
|
||||
// insert page_tbl
|
||||
page_tbl.Conn().Txn_bgn("hxtn_page");
|
||||
Db_rdr rdr = wkr_db.Conn().Stmt_sql("SELECT * FROM hxtn_page;").Exec_select__rls_auto(); // ANSI.Y
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
page_tbl.Insert_by_rdr(rdr);
|
||||
if (++count % 10000 == 0) {
|
||||
Gfo_usr_dlg_.Instance.Prog_many("", "", "hxtn.page.insert: db=~{0} count=~{1}", Int_.To_str_pad_bgn_space(i, 3), Int_.To_str_pad_bgn_space(count, 8));
|
||||
page_tbl.Conn().Txn_sav();
|
||||
}
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
page_tbl.Conn().Txn_end();
|
||||
|
||||
// insert blob tbl; note that dupes can exist across wkr_dbs (wkr_db 1 and wkr_db 2 both have Template:Abcd)
|
||||
count = 0;
|
||||
blob_tbl.Conn().Env_db_attach("wkr_db", wkr_db.Url());
|
||||
blob_tbl.Conn().Txn_bgn("hxtn_blob");
|
||||
rdr = blob_tbl.Conn().Stmt_sql("SELECT src.* FROM wkr_db.hxtn_blob src LEFT JOIN hxtn_blob trg ON src.wiki_id = trg.wiki_id AND src.blob_id = trg.blob_id AND src.blob_tid = trg.blob_tid WHERE trg.blob_id IS NULL;").Exec_select__rls_auto(); // ANSI.Y
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
blob_tbl.Insert_by_rdr(rdr);
|
||||
if (++count % 10000 == 0) {
|
||||
Gfo_usr_dlg_.Instance.Prog_many("", "", "hxtn.blob.insert: db=~{0} count=~{1}", Int_.To_str_pad_bgn_space(i, 3), Int_.To_str_pad_bgn_space(count, 8));
|
||||
blob_tbl.Conn().Txn_sav();
|
||||
}
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
blob_tbl.Conn().Txn_end();
|
||||
blob_tbl.Conn().Env_db_detach("wkr_db");
|
||||
}
|
||||
|
||||
// cleanup
|
||||
page_mgr.Insert_end(true);
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ class Xomp_make_stat {
|
||||
Db_conn mgr_conn = mgr_db.Conn();
|
||||
Xomp_stat_tbl mgr_tbl = new Xomp_stat_tbl(mgr_conn);
|
||||
mgr_conn.Txn_bgn("xomp_stats");
|
||||
mgr_conn.Stmt_delete("xomp_stats", Dbmeta_fld_itm.Str_ary_empty).Exec_delete();
|
||||
mgr_tbl.Stmt_new();
|
||||
|
||||
// loop wkrs
|
||||
|
@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.addons.bldrs.mass_parses.parses.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
|
||||
import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.htmls.core.bldrs.*;
|
||||
import gplx.xowa.htmls.core.bldrs.*; import gplx.xowa.htmls.hxtns.pages.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.addons.bldrs.mass_parses.parses.mgrs.*; import gplx.xowa.addons.bldrs.mass_parses.parses.utls.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*; import gplx.xowa.addons.bldrs.mass_parses.parses.pools.*;
|
||||
@ -41,6 +41,7 @@ public class Xomp_parse_wkr implements Gfo_invk {
|
||||
private final int uid;
|
||||
private Xomp_wkr_db wkr_db;
|
||||
private Xomp_stat_tbl stat_tbl;
|
||||
private Hxtn_page_mgr hxtn_mgr;
|
||||
|
||||
// indexer vars
|
||||
private final Xofulltext_indexer_wkr indexer;
|
||||
@ -67,6 +68,8 @@ public class Xomp_parse_wkr implements Gfo_invk {
|
||||
this.wiki = wiki; this.uid = uid;
|
||||
this.wkr_db = Xomp_wkr_db.New(Xomp_mgr_db.New__url(wiki), uid);
|
||||
this.stat_tbl = new Xomp_stat_tbl(wkr_db.Conn());
|
||||
this.hxtn_mgr = wiki.Hxtn_mgr();
|
||||
this.hxtn_mgr.Init_by_xomp_wkr(wkr_db.Conn(), cfg.Zip_tid());
|
||||
}
|
||||
public void Exec() {
|
||||
Xow_parser_mgr parser_mgr = wiki.Parser_mgr();
|
||||
@ -97,6 +100,7 @@ public class Xomp_parse_wkr implements Gfo_invk {
|
||||
hdump_bldr.Init(wiki, wkr_db.Conn(), new Xob_hdump_tbl_retriever__xomp(wkr_db.Html_tbl()));
|
||||
wkr_db.Conn().Txn_bgn("xomp");
|
||||
stat_tbl.Stmt_new();
|
||||
hxtn_mgr.Insert_bgn(false);
|
||||
|
||||
// set status to running
|
||||
mgr_db.Tbl__wkr().Update_status(uid, Xomp_wkr_tbl.Status__running);
|
||||
@ -167,19 +171,26 @@ public class Xomp_parse_wkr implements Gfo_invk {
|
||||
wiki.Parser_mgr().Scrib().Core_term();
|
||||
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear();
|
||||
}
|
||||
if (done_count % commit_interval == 0)
|
||||
if (done_count % commit_interval == 0) {
|
||||
wkr_db.Conn().Txn_sav();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "mass_parse.fail:ns=~{0} ttl=~{1} err=~{2}", ppg.Ns_id(), ppg.Ttl_bry(), Err_.Message_gplx_log(e));
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup
|
||||
if (logger != null) logger.End();
|
||||
wkr_db.Conn().Txn_end();
|
||||
wkr_db.Conn().Rls_conn();
|
||||
stat_tbl.Stmt_rls();
|
||||
mgr.Wkrs_done_add_1(); // NOTE: must release latch last else thread errors
|
||||
try {
|
||||
if (logger != null) logger.End();
|
||||
wkr_db.Conn().Txn_end();
|
||||
wkr_db.Conn().Rls_conn();
|
||||
stat_tbl.Stmt_rls();
|
||||
hxtn_mgr.Insert_end(false);
|
||||
mgr.Wkrs_done_add_1(); // NOTE: must release latch last else thread errors
|
||||
}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "mass_parse.fail_end; err=~{0}", Err_.Message_gplx_log(e));
|
||||
}
|
||||
}
|
||||
public void Bld_stats(Bry_bfr bfr) {
|
||||
int done_time_in_sec = (int)(done_time / 1000); if (done_time_in_sec == 0) done_time_in_sec = 1;
|
||||
|
@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*;
|
||||
public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
@ -34,6 +34,7 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
gplx.xowa.addons.apps.cfgs.Xocfg_mgr cfg_mgr = wiki.App().Cfg();
|
||||
Xow_hdump_mode.Cfg__reg_type(cfg_mgr.Type_mgr());
|
||||
cfg_mgr.Bind_many_wiki(this, wiki, Cfg__read_preferred, Cfg__html_mode);
|
||||
wiki.Hxtn_mgr().Init_by_wiki(wiki, Bool_.N);
|
||||
}
|
||||
public void Load_by_xowe(Xoae_page wpg) {
|
||||
tmp_hpg.Ctor_by_hview(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Db().Page().Id());
|
||||
@ -72,6 +73,7 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
}
|
||||
|
||||
hpg.Db().Html().Html_bry_(src);
|
||||
wiki.Hxtn_mgr().Load_by_page(hpg, ttl);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -102,6 +104,8 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
html_data.Display_ttl_(tmp_hpg.Display_ttl());
|
||||
html_data.Content_sub_(tmp_hpg.Content_sub());
|
||||
html_data.Xtn_skin_mgr().Add(new Xopg_xtn_skin_itm_stub(tmp_hpg.Sidebar_div()));
|
||||
html_data.Custom_head_tags().Add(hpg.Html_data().Custom_head_tags().To_ary());
|
||||
|
||||
Xoh_head_mgr wpg_head = html_data.Head_mgr();
|
||||
Xopg_module_mgr hpg_head = hpg.Head_mgr();
|
||||
wpg_head.Itm__mathjax().Enabled_ (hpg_head.Math_exists());
|
||||
|
96
400_xowa/src/gplx/xowa/htmls/hxtns/blobs/Hxtn_blob_tbl.java
Normal file
96
400_xowa/src/gplx/xowa/htmls/hxtns/blobs/Hxtn_blob_tbl.java
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
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.htmls.hxtns.blobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Hxtn_blob_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_blob"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_blob_tid = flds.Add_int("blob_tid"), fld_wiki_id = flds.Add_int("wiki_id"), fld_blob_id = flds.Add_int("blob_id")
|
||||
, fld_zip_tid = flds.Add_byte("zip_tid"), fld_blob_data = flds.Add_bry("blob_data");
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final byte zip_tid_default;
|
||||
private final Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
public Hxtn_blob_tbl(Db_conn conn, byte zip_tid_default) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
this.zip_tid_default = zip_tid_default;
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_blob_id, fld_wiki_id, fld_blob_tid));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int blob_tid, int wiki_id, int blob_id, byte[] blob_data) {
|
||||
blob_data = zip_mgr.Zip(zip_tid_default, blob_data);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_blob_tid , blob_tid)
|
||||
.Val_int(fld_wiki_id , wiki_id)
|
||||
.Val_int(fld_blob_id , blob_id)
|
||||
.Val_byte(fld_zip_tid , zip_tid_default)
|
||||
.Val_bry(fld_blob_data , blob_data)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Select_to_regy(Bry_bfr temp_bfr, Hash_adp_bry blob_data_hash) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_wiki_id, fld_blob_id, fld_blob_tid))
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
byte[] key = Make_key(temp_bfr, rdr.Read_int(fld_wiki_id), rdr.Read_int(fld_blob_id), rdr.Read_int(fld_blob_tid));
|
||||
blob_data_hash.Add_as_key_and_val(key);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
public byte[] Select_text(int blob_tid, int wiki_id, int blob_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_blob_id, fld_wiki_id, fld_blob_tid)
|
||||
.Crt_int(fld_blob_id, blob_id)
|
||||
.Crt_int(fld_wiki_id, wiki_id)
|
||||
.Crt_int(fld_blob_tid, blob_tid)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
byte[] rv = rdr.Read_bry(fld_blob_data);
|
||||
byte zip_type = rdr.Read_byte(fld_zip_tid);
|
||||
rv = zip_mgr.Unzip(zip_type, rv);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Make_key(Bry_bfr temp_bfr, int blob_id, int wiki_id, int blob_tid) {
|
||||
return temp_bfr.Add_int_variable(blob_id).Add_byte_pipe().Add_int_variable(wiki_id).Add_byte_pipe().Add_int_variable(blob_tid).To_bry_and_clear();
|
||||
}
|
||||
|
||||
public static final int Blob_tid__wtxt = 0, Blob_tid__html = 1;
|
||||
}
|
26
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_itm.java
Normal file
26
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_itm.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.htmls.hxtns.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
class Hxtn_page_itm {
|
||||
public Hxtn_page_itm(int page_id, int wkr_id, int data_id) {
|
||||
this.page_id = page_id;
|
||||
this.wkr_id = wkr_id;
|
||||
this.data_id = data_id;
|
||||
}
|
||||
public int Page_id() {return page_id;} private final int page_id;
|
||||
public int Wkr_id() {return wkr_id;} private final int wkr_id;
|
||||
public int Data_id() {return data_id;} private final int data_id;
|
||||
}
|
102
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_mgr.java
Normal file
102
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_mgr.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.htmls.hxtns.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.lists.*; import gplx.core.lists.hashs.*;
|
||||
import gplx.xowa.htmls.hxtns.pages.*; import gplx.xowa.htmls.hxtns.blobs.*; import gplx.xowa.htmls.hxtns.wkrs.*; import gplx.xowa.htmls.hxtns.wikis.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Hxtn_page_mgr {
|
||||
private Hxtn_page_tbl page_tbl;
|
||||
private Hxtn_blob_tbl blob_tbl;
|
||||
private Hash_adp_bry blob_hash;
|
||||
private final Hash_adp__int wkrs = new Hash_adp__int();
|
||||
private boolean dbs_missing = true;
|
||||
private Bry_bfr temp_bfr;
|
||||
public Hxtn_page_tbl Page_tbl() {return page_tbl;}
|
||||
public Hxtn_blob_tbl Blob_tbl() {return blob_tbl;}
|
||||
|
||||
public void Init_by_xomp_wkr(Db_conn wkr_db_conn, byte zip_tid) {
|
||||
// init tbls and other members
|
||||
this.page_tbl = new Hxtn_page_tbl(wkr_db_conn);
|
||||
this.blob_tbl = new Hxtn_blob_tbl(wkr_db_conn, zip_tid);
|
||||
this.blob_hash = Hash_adp_bry.cs();
|
||||
this.temp_bfr = Bry_bfr_.New();
|
||||
|
||||
// if tbl exists, xomp_resume has run; load known blobs to prevent dupes
|
||||
if (wkr_db_conn.Meta_tbl_exists(page_tbl.Tbl_name())) {
|
||||
blob_tbl.Select_to_regy(temp_bfr, blob_hash);
|
||||
}
|
||||
// else tbl doesn't exist, so create them
|
||||
else {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
}
|
||||
}
|
||||
public void Init_by_wiki(Xow_wiki wiki, boolean is_merge) {
|
||||
Io_url core_db_url = Make_url(wiki, "-html.hxtn-core.xowa");
|
||||
if (!is_merge && !Io_mgr.Instance.ExistsFil(core_db_url)) return;
|
||||
dbs_missing = false;
|
||||
Db_conn page_conn = Db_conn_bldr.Instance.Get_or_new(core_db_url).Conn();
|
||||
this.page_tbl = new Hxtn_page_tbl(page_conn);
|
||||
|
||||
Io_url blob_db_url = Make_url(wiki, "-html.hxtn-blob.xowa");
|
||||
this.blob_tbl = new Hxtn_blob_tbl(Db_conn_bldr.Instance.Get_or_new(blob_db_url).Conn(), gplx.core.ios.streams.Io_stream_tid_.Tid__raw);
|
||||
|
||||
if (is_merge) {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
|
||||
Hxtn_wkr_mgr wkr_mgr = new Hxtn_wkr_mgr();
|
||||
wkr_mgr.Init_by_xomp_merge(page_conn);
|
||||
|
||||
Hxtn_wiki_mgr wiki_mgr = new Hxtn_wiki_mgr();
|
||||
wiki_mgr.Init_by_xomp_merge(page_conn, wiki.Domain_str());
|
||||
}
|
||||
}
|
||||
public void Insert_bgn(boolean is_merge) {
|
||||
page_tbl.Stmt_bgn();
|
||||
blob_tbl.Stmt_bgn();
|
||||
}
|
||||
public void Insert_end(boolean is_merge) {
|
||||
page_tbl.Stmt_end();
|
||||
blob_tbl.Stmt_end();
|
||||
}
|
||||
public void Page_tbl__insert(int page_id, int wkr_id, int data_id) {
|
||||
page_tbl.Insert_exec(page_id, wkr_id, data_id);
|
||||
}
|
||||
public void Blob_tbl__insert(int blob_tid, int wiki_id, int blob_id, byte[] blob_text) {
|
||||
byte[] key = Hxtn_blob_tbl.Make_key(temp_bfr, blob_tid, wiki_id, blob_id);
|
||||
if (!blob_hash.Has(key)) {// multiple pages can refer to same template; only insert if not seen
|
||||
blob_hash.Add_as_key_and_val(key);
|
||||
blob_tbl.Insert_exec(blob_tid, wiki_id, blob_id, blob_text);
|
||||
}
|
||||
}
|
||||
public void Reg_wkr(Hxtn_page_wkr wkr) {
|
||||
wkrs.Add(wkr.Id(), wkr);
|
||||
}
|
||||
public void Load_by_page(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
if (dbs_missing) return; // PERF:do not call SELECT if dbs don't exist
|
||||
List_adp list = page_tbl.Select_by_page(hpg.Page_id());
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Hxtn_page_itm itm = (Hxtn_page_itm)list.Get_at(i);
|
||||
Hxtn_page_wkr wkr = (Hxtn_page_wkr)wkrs.Get_by_or_fail(itm.Wkr_id());
|
||||
wkr.Load_by_page(hpg, ttl, itm.Data_id());
|
||||
}
|
||||
}
|
||||
private static Io_url Make_url(Xow_wiki wiki, String file_name) {return wiki.Fsys_mgr().Root_dir().GenSubFil(wiki.Domain_str() + file_name);}
|
||||
public static final int Id__template_styles = 0;
|
||||
}
|
68
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_tbl.java
Normal file
68
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_tbl.java
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.htmls.hxtns.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
public class Hxtn_page_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_page"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_page_id, fld_wkr_id, fld_data_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Hxtn_page_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
flds.Add_int_pkey_autonum("id");
|
||||
this.fld_page_id = flds.Add_int("page_id");
|
||||
this.fld_wkr_id = flds.Add_int("wkr_id");
|
||||
this.fld_data_id = flds.Add_int("data_id");
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_page_id, fld_wkr_id, fld_data_id));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int page_id, int wkr_id, int data_id) {
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id , page_id)
|
||||
.Val_int(fld_wkr_id , wkr_id)
|
||||
.Val_int(fld_data_id , data_id)
|
||||
.Exec_insert();
|
||||
}
|
||||
public List_adp Select_by_page(int page_id) {
|
||||
List_adp rv = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_page_id)
|
||||
.Crt_int(fld_page_id, page_id)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Hxtn_page_itm itm = new Hxtn_page_itm(rdr.Read_int(fld_page_id), rdr.Read_int(fld_wkr_id), rdr.Read_int(fld_data_id));
|
||||
rv.Add(itm);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
22
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_wkr.java
Normal file
22
400_xowa/src/gplx/xowa/htmls/hxtns/pages/Hxtn_page_wkr.java
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.htmls.hxtns.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
public interface Hxtn_page_wkr {
|
||||
int Id();
|
||||
String Key();
|
||||
void Load_by_page(Xoh_page hpg, Xoa_ttl ttl, int id);
|
||||
}
|
26
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_itm.java
Normal file
26
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_itm.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.htmls.hxtns.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
public class Hxtn_wiki_itm {
|
||||
public Hxtn_wiki_itm(int tid, String domain) {
|
||||
this.tid = tid;
|
||||
this.domain = domain;
|
||||
}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public String Domain() {return domain;} private final String domain;
|
||||
|
||||
public static final int Tid__self = 0, Tid__commons = 1, Tid__wikidata = 2, Tid__next_id = 32;
|
||||
}
|
27
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_mgr.java
Normal file
27
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_mgr.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.htmls.hxtns.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
public class Hxtn_wiki_mgr {
|
||||
private Hxtn_wiki_tbl wiki_tbl;
|
||||
public void Init_by_xomp_merge(Db_conn conn, String wiki_domain) {
|
||||
wiki_tbl = new Hxtn_wiki_tbl(conn);
|
||||
wiki_tbl.Create_tbl();
|
||||
wiki_tbl.Insert(Hxtn_wiki_itm.Tid__self , wiki_domain);
|
||||
wiki_tbl.Insert(Hxtn_wiki_itm.Tid__commons , "commons.wikimedia.org");
|
||||
wiki_tbl.Insert(Hxtn_wiki_itm.Tid__wikidata, "www.wikidata.org");
|
||||
}
|
||||
}
|
51
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_tbl.java
Normal file
51
400_xowa/src/gplx/xowa/htmls/hxtns/wikis/Hxtn_wiki_tbl.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.htmls.hxtns.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
public class Hxtn_wiki_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_wiki"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_wiki_id = flds.Add_int_pkey("wiki_id"), fld_wiki_domain = flds.Add_str("wiki_domain", 255)
|
||||
;
|
||||
private final Db_conn conn;
|
||||
public Hxtn_wiki_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
}
|
||||
public void Rls() {}
|
||||
public void Insert(int wiki_id, String wiki_domain) {
|
||||
conn.Stmt_insert(tbl_name, flds).Clear()
|
||||
.Val_int(fld_wiki_id , wiki_id)
|
||||
.Val_str(fld_wiki_domain , wiki_domain)
|
||||
.Exec_insert();
|
||||
}
|
||||
public Hash_adp Select() {
|
||||
Hash_adp rv = Hash_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select_all(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Hxtn_wiki_itm itm = new Hxtn_wiki_itm(rdr.Read_int(fld_wiki_id), rdr.Read_str(fld_wiki_domain));
|
||||
rv.Add(itm.Domain(), itm);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
29
400_xowa/src/gplx/xowa/htmls/hxtns/wkrs/Hxtn_wkr_mgr.java
Normal file
29
400_xowa/src/gplx/xowa/htmls/hxtns/wkrs/Hxtn_wkr_mgr.java
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.htmls.hxtns.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.htmls.hxtns.pages.*;
|
||||
public class Hxtn_wkr_mgr {
|
||||
private Hxtn_wkr_tbl wkr_tbl;
|
||||
public void Init_by_xomp_merge(Db_conn conn) {
|
||||
wkr_tbl = new Hxtn_wkr_tbl(conn);
|
||||
wkr_tbl.Create_tbl();
|
||||
Reg_wkr(new gplx.xowa.xtns.template_styles.Hxtn_page_wkr__template_styles(null)); // TODO:do formal registration of extensions; WHEN: rework tkn_mkr
|
||||
}
|
||||
private void Reg_wkr(Hxtn_page_wkr wkr) {
|
||||
wkr_tbl.Insert(wkr.Id(), wkr.Key());
|
||||
}
|
||||
}
|
57
400_xowa/src/gplx/xowa/htmls/hxtns/wkrs/Hxtn_wkr_tbl.java
Normal file
57
400_xowa/src/gplx/xowa/htmls/hxtns/wkrs/Hxtn_wkr_tbl.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.htmls.hxtns.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.lists.hashs.*;
|
||||
public class Hxtn_wkr_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_wkr"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_wkr_id = flds.Add_int_pkey("wkr_id"), fld_wkr_key = flds.Add_str("wkr_key", 255)
|
||||
;
|
||||
private final Db_conn conn;
|
||||
public Hxtn_wkr_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
}
|
||||
public void Rls() {}
|
||||
public int Select_max() {
|
||||
return Int_.Cast(conn.Stmt_select_max(tbl_name, fld_wkr_id).Exec_select_val());
|
||||
}
|
||||
public void Insert(int wkr_id, String wkr_key) {
|
||||
conn.Stmt_insert(tbl_name, flds).Clear()
|
||||
.Val_int(fld_wkr_id , wkr_id)
|
||||
.Val_str(fld_wkr_key , wkr_key)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Select(Hash_adp__int wkrs_by_id, Hash_adp wkrs_by_key) {
|
||||
wkrs_by_id.Clear();
|
||||
wkrs_by_key.Clear();
|
||||
Db_rdr rdr = conn.Stmt_select_all(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int wkr_id = rdr.Read_int(fld_wkr_id);
|
||||
String wkr_key = rdr.Read_str(fld_wkr_key);
|
||||
wkrs_by_id.Add(wkr_id, wkr_key);
|
||||
wkrs_by_key.Add(wkr_key, wkr_id);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
}
|
@ -338,5 +338,6 @@ public class Xop_ctx {
|
||||
trg.ref_ignore = src.ref_ignore; // copy ref_ignore; needed for refs inside poem else duplicate refs; it.s:La_Secchia_rapita/Canto_primo; DATE:2015-12-03
|
||||
trg.references_group = src.references_group;
|
||||
trg.cur_page.Ref_mgr_(src.cur_page.Ref_mgr());
|
||||
trg.cur_page.Kv_data_(src.cur_page.Kv_data());
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import gplx.xowa.apps.urls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.specials.mgrs.*;
|
||||
import gplx.xowa.addons.wikis.htmls.css.bldrs.*; import gplx.xowa.addons.wikis.htmls.css.mgrs.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
|
||||
import gplx.xowa.htmls.hxtns.pages.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private boolean init_needed = true;
|
||||
@ -93,6 +94,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
public Xosp_special_mgr Special_mgr() {return special_mgr;} private Xosp_special_mgr special_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
|
||||
public Xoav_app Appv() {return app;} private final Xoav_app app;
|
||||
public Hxtn_page_mgr Hxtn_mgr() {return hxtn_mgr;} private final Hxtn_page_mgr hxtn_mgr = new Hxtn_page_mgr();
|
||||
public boolean Embeddable_enabled() {return embeddable_enabled;} public void Embeddable_enabled_(boolean v) {this.embeddable_enabled = v;} private boolean embeddable_enabled;
|
||||
public void Init_by_wiki() {
|
||||
if (!init_needed) return;
|
||||
|
@ -71,6 +71,7 @@ public class Xopg_html_data {
|
||||
public void Clear() {
|
||||
redlink_list.Clear();
|
||||
toc_mgr.Clear();
|
||||
head_tags.Clear();
|
||||
|
||||
html_restricted = true;
|
||||
display_ttl = content_sub = display_ttl_vnt = null;
|
||||
|
@ -19,7 +19,9 @@ public class Xopg_tag_mgr {
|
||||
public Xopg_tag_mgr(boolean pos_is_head) {this.pos_is_head = pos_is_head;}
|
||||
public boolean Pos_is_head() {return pos_is_head;} private final boolean pos_is_head;
|
||||
public int Len() {return list.Len();}
|
||||
public void Clear() {list.Clear();}
|
||||
public Xopg_tag_itm Get_at(int i) {return (Xopg_tag_itm)list.Get_at(i);}
|
||||
public Xopg_tag_itm[] To_ary() {return (Xopg_tag_itm[])list.To_ary(Xopg_tag_itm.class);}
|
||||
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();
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.xtns.template_styles; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.htmls.hxtns.pages.*; import gplx.xowa.htmls.hxtns.blobs.*; import gplx.xowa.htmls.hxtns.wikis.*;
|
||||
public class Hxtn_page_wkr__template_styles implements Hxtn_page_wkr {
|
||||
private final Hxtn_blob_tbl page_text_tbl;
|
||||
public int Id() {return Hxtn_page_mgr.Id__template_styles;}
|
||||
public String Key() {return "xowa.xtns.template_styles";}
|
||||
public Hxtn_page_wkr__template_styles(Hxtn_blob_tbl page_text_tbl) {
|
||||
this.page_text_tbl = page_text_tbl;
|
||||
}
|
||||
public void Load_by_page(Xoh_page hpg, Xoa_ttl ttl, int page_id) {
|
||||
byte[] template_bry = page_text_tbl.Select_text(Hxtn_blob_tbl.Blob_tid__wtxt, Hxtn_wiki_itm.Tid__self, page_id);
|
||||
hpg.Html_data().Custom_head_tags().Add(gplx.xowa.wikis.pages.tags.Xopg_tag_itm.New_css_code(template_bry));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.xtns.template_styles; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.addons.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Template_styles_addon implements Xoax_addon_itm, Xoax_addon_itm__init {
|
||||
public void Init_addon_by_app(Xoa_app app) {}
|
||||
public void Init_addon_by_wiki(Xow_wiki wiki) {
|
||||
wiki.Hxtn_mgr().Reg_wkr(new Hxtn_page_wkr__template_styles(wiki.Hxtn_mgr().Blob_tbl()));
|
||||
}
|
||||
|
||||
public String Addon__key() {return "xowa.template_styles";}
|
||||
}
|
@ -15,15 +15,17 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.template_styles; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.lists.hashs.*;
|
||||
import gplx.xowa.wikis.caches.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.xowa.htmls.hxtns.*; import gplx.xowa.htmls.hxtns.pages.*; import gplx.xowa.htmls.hxtns.blobs.*; import gplx.xowa.htmls.hxtns.wikis.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Template_styles_nde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
private byte[] css_ttl_bry;
|
||||
private byte[] css_src;
|
||||
private boolean css_ignore;
|
||||
private Int_obj_val css_page_id;
|
||||
private int css_page_id;
|
||||
private Xoa_ttl css_ttl;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
|
||||
switch (xatr_id) {
|
||||
@ -50,22 +52,21 @@ public class Template_styles_nde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm_2(css_ttl);
|
||||
if (page_itm != null) {
|
||||
css_src = page_itm.Wtxt__direct();
|
||||
css_page_id = new Int_obj_val(page_itm.Page_id());
|
||||
css_page_id = page_itm.Page_id();
|
||||
|
||||
// update css_page_ids
|
||||
Hash_adp css_page_ids = (Hash_adp)ctx.Page().Kv_data().Get_or_make(Template_styles_kv_itm.Instance);
|
||||
if (css_page_ids.Has(css_page_id)) {
|
||||
css_ignore = true;
|
||||
Hash_adp__int css_page_ids = (Hash_adp__int)ctx.Page().Kv_data().Get_or_make(Template_styles_kv_itm.Instance);
|
||||
if (css_page_ids.Get_by_or_null(css_page_id) == null) {
|
||||
css_page_ids.Add(css_page_id, "");
|
||||
}
|
||||
else {
|
||||
css_page_ids.Add_as_key_and_val(css_page_id);
|
||||
css_ignore = true;
|
||||
}
|
||||
|
||||
}
|
||||
if (css_src == null) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "Template_styles_nde.page_not_found: wiki=~{0} page=~{1} css_ttl=~{2}", wiki.Domain_bry(), ctx.Page().Url_bry_safe(), css_ttl_bry);
|
||||
}
|
||||
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {
|
||||
if (css_ttl == null) {
|
||||
@ -80,11 +81,18 @@ public class Template_styles_nde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
if (!css_ignore) {
|
||||
Bry_bfr tmp_bfr = ctx.Wiki().Utl__bfr_mkr().Get_b512();
|
||||
try {
|
||||
html_head.Bld_many(tmp_bfr, css_page_id.Val(), css_src);
|
||||
html_head.Bld_many(tmp_bfr, css_page_id, css_src);
|
||||
Xoh_head_itm__css_dynamic css_dynamic = ctx.Page().Html_data().Head_mgr().Itm__css_dynamic();
|
||||
css_dynamic.Enabled_y_();
|
||||
css_dynamic.Add(tmp_bfr.To_bry_and_clear());
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
int page_id = wpg.Db().Page().Id();
|
||||
Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr();
|
||||
html_data_mgr.Page_tbl__insert(page_id, Hxtn_page_mgr.Id__template_styles, css_page_id);
|
||||
html_data_mgr.Blob_tbl__insert(Hxtn_blob_tbl.Blob_tid__wtxt, Hxtn_wiki_itm.Tid__self, css_page_id, css_src);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static String formatTagError(String msg) {
|
||||
@ -102,6 +110,6 @@ public class Template_styles_nde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
}
|
||||
class Template_styles_kv_itm implements gplx.xowa.apps.kvs.Xoa_kv_itm {
|
||||
public String Kv__key() {return "TemplateStyles";}
|
||||
public Object Kv__val_make() {return Hash_adp_.New();}
|
||||
public Object Kv__val_make() {return new Hash_adp__int();}
|
||||
public static final Template_styles_kv_itm Instance = new Template_styles_kv_itm(); Template_styles_kv_itm() {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user