mirror of https://github.com/gnosygnu/xowa
Xtns.TemplateStyles: Cache TemplateStyles for HTML databases [#482]
parent
fbe158537e
commit
3d9491e2de
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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";}
|
||||
}
|
Loading…
Reference in new issue