mirror of https://github.com/gnosygnu/xowa
parent
8afc115176
commit
b3c2d3bb5f
@ -0,0 +1,46 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
import gplx.core.brys.evals.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Host_eval_itm {
|
||||
private final Bry_eval_mgr mgr = Bry_eval_mgr.Dflt();
|
||||
private final Host_eval_wkr wkr = new Host_eval_wkr();
|
||||
private final Hash_adp host_hash = Hash_adp_.New();
|
||||
public Host_eval_itm() {
|
||||
mgr.Add_many(wkr);
|
||||
}
|
||||
public byte[] Eval_dir_name(Xow_domain_itm domain_itm) {
|
||||
wkr.Domain_itm_(domain_itm);
|
||||
return mgr.Eval(Bry_.new_u8("Xowa_~{host_regy|wiki_abrv}_latest"));
|
||||
}
|
||||
public String Eval_src_fil(Xobc_data_db data_db, int host_id, Xow_domain_itm domain, String file_name) {
|
||||
return Eval_src_dir(data_db, host_id, domain) + file_name;
|
||||
}
|
||||
public String Eval_src_dir(Xobc_data_db data_db, int host_id, Xow_domain_itm domain) {
|
||||
Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by(host_id);
|
||||
if (host_itm == null) {
|
||||
host_itm = data_db.Tbl__host_regy().Select(host_id);
|
||||
host_hash.Add(host_id, host_itm);
|
||||
}
|
||||
wkr.Domain_itm_(domain);
|
||||
String host_dir = String_.new_u8(mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir())));
|
||||
return String_.Format("http://{0}/{1}/", host_itm.Host_domain(), host_dir);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Host_eval_wkr__tst {
|
||||
private final Host_eval_wkr__fxt fxt = new Host_eval_wkr__fxt();
|
||||
@Test public void En_w() {fxt.Test__resolve_quick("en.wikipedia.org" , "Xowa_enwiki_latest");}
|
||||
@Test public void Fr_d() {fxt.Test__resolve_quick("fr.wiktionary.org" , "Xowa_frwiki_latest");}
|
||||
@Test public void Species() {fxt.Test__resolve_quick("species.wikimedia.org" , "Xowa_enwiki_latest");}
|
||||
}
|
||||
class Host_eval_wkr__fxt {
|
||||
public void Test__resolve_quick(String domain_str, String expd) {
|
||||
Host_eval_itm eval_itm = new Host_eval_itm();
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
Gftest.Eq__bry(Bry_.new_u8(expd), eval_itm.Eval_dir_name(domain_itm));
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
class Xobc_info_doc implements Mustache_doc_itm {
|
||||
private final byte[] wiki_domain, task_size;
|
||||
private final String wiki_dir, torrent_fil;
|
||||
private final Mustache_doc_itm[] urls;
|
||||
public Xobc_info_doc(byte[] wiki_domain, String wiki_dir, byte[] task_size, String torrent_fil, Mustache_doc_itm[] urls) {
|
||||
this.wiki_domain = wiki_domain; this.wiki_dir = wiki_dir; this.task_size = task_size; this.torrent_fil = torrent_fil; this.urls = urls;
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain);
|
||||
else if (String_.Eq(key, "wiki_dir")) bfr.Add_str_u8(wiki_dir);
|
||||
else if (String_.Eq(key, "task_size")) bfr.Add_bry(task_size);
|
||||
else if (String_.Eq(key, "torrent_fil")) bfr.Add_str_u8(torrent_fil);
|
||||
return false;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "urls")) return urls;
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
class Xobc_info_url implements Mustache_doc_itm {
|
||||
private final String url; private final byte[] size;
|
||||
public Xobc_info_url(String url, byte[] size) {
|
||||
this.url = url; this.size = size;
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "url")) bfr.Add_str_u8(url);
|
||||
else if (String_.Eq(key, "size")) bfr.Add_bry(size);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.core.ios.*;
|
||||
class Xobc_info_html extends Xow_special_wtr__base {
|
||||
private final Xobc_task_mgr task_mgr;
|
||||
private final int task_id;
|
||||
public Xobc_info_html(Xobc_task_mgr task_mgr, int task_id) {this.task_mgr = task_mgr; this.task_id = task_id;}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "bldr", "info");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xobc_info.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
// get steps for task
|
||||
Xobc_data_db data_db = task_mgr.Data_db();
|
||||
List_adp list = data_db.Tbl__step_map().Select_all(task_id);
|
||||
|
||||
// get underlying files
|
||||
Host_eval_itm host_eval = new Host_eval_itm();
|
||||
int len = list.Len();
|
||||
Xobc_info_url[] step_urls = new Xobc_info_url[len];
|
||||
Xow_domain_itm wiki_domain = null;
|
||||
int host_id = -1;
|
||||
long total_size = 0;
|
||||
Bry_bfr tmp_size_bfr = Bry_bfr_.New();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int step_id = (int)list.Get_at(i);
|
||||
Xobc_import_step_itm step_itm = data_db.Tbl__import_step().Select_one(step_id);
|
||||
if (i == 0) {
|
||||
wiki_domain = Xow_abrv_xo_.To_itm(step_itm.Wiki_abrv()); // ASSUME: 1st step's wiki is same for all steps
|
||||
host_id = step_itm.Host_id; // ASSUME: 1st step's host_id is same for all steps
|
||||
}
|
||||
String src_fil = host_eval.Eval_src_fil(data_db, host_id, wiki_domain, step_itm.Import_name);
|
||||
Io_size_.To_bfr_new(tmp_size_bfr, step_itm.Import_size_zip, 2);
|
||||
total_size += step_itm.Import_size_raw;
|
||||
Xobc_info_url step_url = new Xobc_info_url(src_fil, tmp_size_bfr.To_bry_and_clear());
|
||||
step_urls[i] = step_url;
|
||||
}
|
||||
|
||||
// get wiki data, total_size
|
||||
host_eval.Eval_dir_name(wiki_domain);
|
||||
Io_url trg_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(wiki_domain.Domain_str());
|
||||
Io_size_.To_bfr_new(tmp_size_bfr, total_size, 2);
|
||||
byte[] total_size_bry = tmp_size_bfr.To_bry_and_clear();
|
||||
|
||||
// get torrent
|
||||
String torrent_fil = null;
|
||||
String key = data_db.Tbl__task_regy().Select_key_by_id_or_null(task_id);
|
||||
if (key == null) torrent_fil = "failed to get torrent for " + Int_.To_str(task_id);
|
||||
else {// convert task_key to name; en.wikipedia.org|2016.06|html
|
||||
String src_dir = host_eval.Eval_src_dir(data_db, host_id, wiki_domain);
|
||||
String[] ary = String_.Split(key, "|");
|
||||
ary[0] = String_.new_u8(wiki_domain.Abrv_wm());
|
||||
torrent_fil = String_.Format("{0}/Xowa_{1}_{2}_{3}.torrent", src_dir, ary[0], ary[1], ary[2]); // EX: http://archive.org/download/Xowa_enwiki_latest/Xowa_enwiktionary_2016-06_core.zip
|
||||
}
|
||||
|
||||
return new Xobc_info_doc
|
||||
( wiki_domain.Domain_bry()
|
||||
, trg_dir.Raw()
|
||||
, total_size_bry
|
||||
, torrent_fil
|
||||
, step_urls
|
||||
);
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xobc_info.css")));
|
||||
}
|
||||
@Override protected void Handle_invalid(Xoa_app app, Xoa_page page, Xow_special_page special) {
|
||||
new Xopage_html_data(special.Special__meta().Display_ttl(), Bry_.new_u8("task has been deleted")).Apply(page);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.*;
|
||||
public class Xobc_info_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary());
|
||||
|
||||
int task_id = url_args.Read_int_or("task_id", -1);
|
||||
if (task_id == -1) return;
|
||||
|
||||
new Xobc_info_html(Xobc_task_special.Task_mgr(wiki.App()), task_id).Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
|
||||
Xobc_info_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xobc_info_special(Xow_special_meta.New_xo("XowaDownloadCentralInfo", "Download Central Task Info"));
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gallery_data implements Xoh_data_itm {// NOTE: some galleries fail hzip; use Hook_bry to catch them; PAGE:en.d:a; DATE:2016-06-24
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__gallery;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Clear() {
|
||||
this.src_bgn = this.src_end = -1;
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag gallery_lhs, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = gallery_lhs.Src_bgn();
|
||||
this.src_end = gallery_lhs.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(int src_bgn, int src_end) {
|
||||
this.src_bgn = src_bgn;
|
||||
this.src_end = src_end;
|
||||
}
|
||||
public static final byte[] Hook_bry = Bry_.new_a7(" class=\"gallery mw-gallery");
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_data rv = new Xoh_gallery_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gallery_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__gallery;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__gallery;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_gallery_data data = (Xoh_gallery_data)data_obj;
|
||||
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Gallery_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
int gallery_bgn = src_bgn;
|
||||
int gallery_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
|
||||
if (gallery_end == -1) {
|
||||
Gfo_log_.Instance.Warn("hzip.gallery.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
|
||||
gallery_end = gallery_bgn;
|
||||
}
|
||||
else
|
||||
++gallery_end;
|
||||
|
||||
Xoh_gallery_data data = (Xoh_gallery_data)data_itm;
|
||||
data.Init_by_decode(gallery_bgn, gallery_end);
|
||||
rdr.Move_to(gallery_end);
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_hzip rv = new Xoh_gallery_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_gallery_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__decode
|
||||
( "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
|
||||
, "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
|
||||
);
|
||||
Gftest.Eq__bool_y(fxt.Page().Xtn__gallery_exists());
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gallery_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
|
||||
private Xoh_page hpg;
|
||||
private byte[] src; private int src_bgn, src_end;
|
||||
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_gallery_data data) {
|
||||
Init_by_decode(hpg, hctx, src, data);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
|
||||
this.hpg = hpg; this.src = src;
|
||||
Xoh_gallery_data data = (Xoh_gallery_data)data_itm;
|
||||
this.src_bgn = data.Src_bgn();
|
||||
this.src_end = data.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
hpg.Xtn__gallery_exists_y_();
|
||||
bfr.Add_mid(src, src_bgn, src_end);
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_wtr rv = new Xoh_gallery_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_timeline_data implements Xoh_data_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__timeline;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Clear() {
|
||||
this.src_bgn = this.src_end = -1;
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag timeline_lhs, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = timeline_lhs.Src_bgn();
|
||||
this.src_end = timeline_lhs.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(int src_bgn, int src_end) {
|
||||
this.src_bgn = src_bgn;
|
||||
this.src_end = src_end;
|
||||
}
|
||||
public static final byte[] Hook_bry = Bry_.new_a7("<pre class='xowa-timeline'>");
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_data rv = new Xoh_timeline_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_timeline_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__timeline;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__timeline;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_timeline_data data = (Xoh_timeline_data)data_obj;
|
||||
|
||||
// just add the entire thing; not worth trying to compress "<pre class='xowa-timeline'>"
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Timeline_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
int timeline_bgn = src_bgn;
|
||||
int timeline_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
|
||||
if (timeline_end == -1) {
|
||||
Gfo_log_.Instance.Warn("hzip.timeline.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
|
||||
timeline_end = timeline_bgn;
|
||||
}
|
||||
else
|
||||
++timeline_end;
|
||||
|
||||
Xoh_timeline_data data = (Xoh_timeline_data)data_itm;
|
||||
data.Init_by_decode(timeline_bgn, timeline_end);
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_hzip rv = new Xoh_timeline_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_timeline_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: <timeline>code</timeline>
|
||||
fxt.Test__decode__raw("<pre class='xowa-timeline'>abc</pre>", "<pre class='xowa-timeline'>abc</pre>");
|
||||
Gftest.Eq__bool_y(fxt.Page().Xtn__timeline_exists());
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_timeline_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
|
||||
private Xoh_page hpg;
|
||||
private byte[] src; private int src_bgn, src_end;
|
||||
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_timeline_data data) {
|
||||
Init_by_decode(hpg, hctx, src, data);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
|
||||
this.hpg = hpg;
|
||||
this.src = src;
|
||||
Xoh_timeline_data data = (Xoh_timeline_data)data_itm;
|
||||
this.src_bgn = data.Src_bgn();
|
||||
this.src_end = data.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
hpg.Xtn__timeline_exists_y_();
|
||||
bfr.Add_mid(src, src_bgn, src_end);
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_wtr rv = new Xoh_timeline_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gly_hzip__style__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Style__no_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
|
||||
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__no_width() { // PURPOSE: if "_width" omitted, do not add back; EX: style="max-width:648px; margin:auto; background:transparent;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'i{,L! color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__max_width_duped() { // PURPOSE: if max-width duped, do not delete 2nd; EX: style="max-width:648px; color:blue; max-width:648px;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'){(Z max-width:648px; color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:652px; _width:652px; max-width:648px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__invalid_unclosed() { // handle broken styles; EX: <gallery style='center'>
|
||||
fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional center' style='center'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__extra_colon() { // handle broken styles; EX: <gallery style='a:b:c:d;' PAGE:en.w:Bronze_Horseman DATE:2016-01-05
|
||||
fxt.Test__bicode("~'9!center~color:red:float:right;~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional center' style='color:red:float:right;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__ws() { // PURPOSE: handle ws in style; EX: <gallery class="gallery mw-gallery-traditional" style="max-width:1115px; _width:1115px; color:blue;'>; PAGE:en.w:Anti-Serb_sentiment; DATE:2016-01-08
|
||||
fxt.Test__bicode("~'){,L color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_img_hzip__dump__link__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Aa.ogg~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__anchor() { // [[File:A.png|link=A#B_C|abc]]; PAGE:en.w:Arabic; DATE:2016-01-06
|
||||
fxt.Test__bicode
|
||||
( "~%#'A#B_C~D.png~#9!I!I"
|
||||
, "<a href='/wiki/A#B_C' class='image' xowa_title='D.png'><img data-xowa-title='D.png' data-xoimg='0|40|40|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n() { // [[File:A.png|link=http://a.org|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Dhttp://a.org~A.png~)#Sabc~"
|
||||
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__y() { // [[File:A.png|link=http://en.wikitionary.org/wiki/Special:Search/A|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"men.wiktionary.org|Search/A~A.png~\")#Sabc~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n_2() { // [[File:A.png|link=creativecommons:by/2.5]]
|
||||
fxt.Test__bicode
|
||||
( "~%#(creativecommons.org|by/2.5/~CC-BY-icon-80x15.png~#)!q"
|
||||
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xowa-title='CC-BY-icon-80x15.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__media() { // [[File:A.png|link=file:///C:/A.ogg]]
|
||||
fxt.Test__bicode
|
||||
( "~%!D~A.ogg~)!,B~"
|
||||
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xowa-title='A.ogg' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%#Xen.wiktionary.org|%F0%AC%96%BE~A.png~#)!,abc~B~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__invalid() { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%\"mcommons.wikimedia.org|~A.png~1!Abc~"
|
||||
, "<a href='/site/commons.wikimedia.org/wiki/Category:' class='image' title='Abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='Abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test__bicode
|
||||
( "~%|iVPA.png~#9#S\":abc~"
|
||||
, "<img data-xowa-title='A.png' data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty__tidy() {// <a><font><img> should not trigger empty link code; PAGE:en.w:Wikipedia:Reference_Desk_archive_unanswered_2005 ; DATE:2016-01-13
|
||||
fxt.Test__bicode
|
||||
( "<a href=\"/wiki/Image:A.png\" class=\"image\" title=\"\" xowa_title=\"A.png\"><font style=\"color:red\">~%|iVPA.png~#!abc~</font></a>"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='' xowa_title='A.png'><font style='color:red'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></font></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__ns_alias() { // [[File:A.png|link=WP:MCB]]; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11
|
||||
fxt.Init__ns_alias__add("WP", Xow_ns_.Tid__project);
|
||||
fxt.Test__bicode
|
||||
( "~%/+MCB~A.png~'WP~)!q"
|
||||
, "<a href='/wiki/WP:MCB' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
fxt.Init__ns_alias__del("WP");
|
||||
}
|
||||
@Test public void Link__xwiki_lc() { // [[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
|
||||
fxt.Test__bicode
|
||||
( "~%#(en.wiktionary.org|en:A~A.png~1)!q"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Category:en:A' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__xwiki_under() {// EX: [[File:A.png|link=User talk:B]]; PAGE:de.b:Wikibooks:Benutzersperrung/_InselFahrer DATE:2016-06-24
|
||||
fxt.Test__bicode
|
||||
( "~%/,meta.wikimedia.org|B~A.png~&User Talk~!", String_.Concat
|
||||
( "<a href='/site/meta.wikimedia.org/wiki/User_Talk:B' class='image' xowa_title='A.png'>"
|
||||
, "<img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''>"
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue