v3.3.4
gnosygnu 8 years ago
parent 04af0accdb
commit 8afc115176

@ -34,7 +34,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "3.6.3.3";
public static final String Version = "3.6.3.4";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";

@ -40,21 +40,23 @@ public class Xoax_addon_mgr {
( new gplx.xowa.addons.bldrs.files .Xoax_builds_files_addon()
, new gplx.xowa.addons.bldrs.pagelinks .Xoax_builds_pagelinks_addon()
, new gplx.xowa.addons.bldrs.utils_rankings .Xoax_builds_utils_rankings_addon()
, new gplx.xowa.addons.wikis.searchs .Xoax_builds_search_addon()
, new gplx.xowa.addons.wikis.searchs .Xoax_builds_search_addon()
, new gplx.xowa.addons.bldrs.updates.files .Xoax_updates_files_addon()
, new gplx.xowa.addons.bldrs.htmls .Html__dump_to_fsys__addon()
, new gplx.xowa.addons.bldrs.exports .Export_addon()
, new gplx.xowa.addons.wikis.pages.randoms .Rndm_addon()
// specials
, new gplx.xowa.addons.wikis.registrys .Wiki_registry_addon()
, new gplx.xowa.addons.wikis.imports .Xow_import_addon()
, new gplx.xowa.addons.wikis.registrys .Wiki_registry_addon()
, new gplx.xowa.addons.wikis.imports .Xow_import_addon()
, new gplx.xowa.addons.bldrs.centrals .Xobc_task_addon()
, new gplx.xowa.addons.apps.helps.logs .Xolog_addon()
// jsons
, new gplx.xowa.addons.servers.https .Xoax_long_poll_addon()
);
if (app.Mode().Tid_is_http()) {
app.Addon_mgr().Itms__add_many(new gplx.xowa.addons.servers.https.Xoax_long_poll_addon());
}
return this;
}
public void Run_by_app(Xoa_app app) {
@ -83,6 +85,5 @@ public class Xoax_addon_mgr {
}
}
}
// app.Gui__cbk_mgr().Reg(gplx.xowa.addons.servers.https.Xog_cbk_wkr__http.Instance);
}
}

@ -38,7 +38,7 @@ class Xobc_task_html extends Xow_special_wtr__base {
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.log.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.ajax.listener.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app." + (gplx.core.envs.Op_sys.Cur().Tid_is_drd() ? "drd" : "swt") + ".js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", Get_app_js_file(app))));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.tmpl.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.notify.js")));
@ -46,4 +46,8 @@ class Xobc_task_html extends Xow_special_wtr__base {
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.util.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.js")));
}
private static String Get_app_js_file(Xoa_app app) {
if (app.Mode().Tid_is_http()) return "xo.app.http_server.js";
return gplx.core.envs.Op_sys.Cur().Tid_is_drd() ? "xo.app.drd.js" : "xo.app.swt.js";
}
}

@ -22,7 +22,9 @@ public class Http_long_poll_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_it
public int Sleep_interval = 100;
public int Send_interval = 1000;
public void Init_by_app(Xoa_app app) {}
public void Init_by_app(Xoa_app app) {
app.Gui__cbk_mgr().Reg(Xog_cbk_wkr__http.Instance);
}
public void Send_msg(String msg) {
msgs.Add(msg);
}
@ -42,7 +44,6 @@ public class Http_long_poll_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_it
return String_.Concat_lines_nl(msgs.To_str_ary_and_clear());
}
public byte[] Key() {return BRIDGE_KEY;}
public static final byte[] BRIDGE_KEY = Bry_.new_a7("long_poll");
public byte[] Key() {return BRIDGE_KEY;} private static final byte[] BRIDGE_KEY = Bry_.new_a7("long_poll");
public static final Http_long_poll_cmd Instance = new Http_long_poll_cmd(); Http_long_poll_cmd() {}
}

@ -16,9 +16,14 @@ 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.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
import gplx.xowa.guis.cbks.*; import gplx.core.gfobjs.*;
import gplx.xowa.guis.cbks.*; import gplx.core.gfobjs.*; import gplx.xowa.guis.cbks.swts.*;
public class Xog_cbk_wkr__http implements Xog_cbk_wkr {
public Object Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data) {return null;}
private final Gfobj_wtr__json__browser json_wtr = new Gfobj_wtr__json__browser();
public Object Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data) {
String script = json_wtr.Write_as_func__drd(func, data);
Http_long_poll_cmd.Instance.Send_msg(script);
return null;
}
public void Send_prog(String head) {
Http_long_poll_cmd.Instance.Send_msg(head);
}

@ -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.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import gplx.xowa.files.*;
class Http_file_utl {
public static byte[] To_mime_type_by_path_as_bry(byte[] path_bry) {
int dot_pos = Bry_find_.Find_bwd(path_bry, Byte_ascii.Dot);
return dot_pos == Bry_find_.Not_found ? Mime_octet_stream : To_mime_type_by_ext_as_bry(path_bry, dot_pos, path_bry.length);
}
public static byte[] To_mime_type_by_ext_as_bry(byte[] ext_bry, int bgn, int end) {
Object o = mime_hash.Get_by_mid(ext_bry, bgn, end);
return o == null ? Mime_octet_stream : (byte[])o;
}
private static final byte[]
Mime_octet_stream = Xof_ext_.Mime_type__ary[Xof_ext_.Id_unknown]
, Mime_html = Bry_.new_a7("text/html")
, Mime_css = Bry_.new_a7("text/css")
, Mime_js = Bry_.new_a7("application/javascript")
;
private static final Hash_adp_bry mime_hash = Mime_hash__new();
private static Hash_adp_bry Mime_hash__new() {
Hash_adp_bry rv = Hash_adp_bry.ci_a7();
int len = Xof_ext_.Id__max;
for (int i = 0; i < len; ++i) {
rv.Add_bry_obj
( Bry_.Add(Byte_ascii.Dot, Xof_ext_.Bry__ary[i])
, Xof_ext_.Mime_type__ary[i]);
}
rv.Add_str_obj(".htm" , Mime_html);
rv.Add_str_obj(".html" , Mime_html);
rv.Add_str_obj(".css" , Mime_css);
rv.Add_str_obj(".js" , Mime_js);
return rv;
}
}

@ -51,9 +51,9 @@ class Http_server_socket implements Gfo_invk {
wkr_pool.Add(wkr_uid);
// server_wtr.Write_str_w_nl("added new worker; uid=" + wkr_uid);
}
Http_server_wkr_v2 wkr = new Http_server_wkr_v2(server_mgr, wkr_uid);
Http_server_wkr wkr = new Http_server_wkr(server_mgr, wkr_uid);
wkr.Init_by_thread(client_socket);
Thread_adp_.Start_by_key("thread:xowa.http_server.client", wkr, Http_server_wkr_v2.Invk_run);
Thread_adp_.Start_by_key("thread:xowa.http_server.client", wkr, Http_server_wkr.Invk_run);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

@ -20,7 +20,7 @@ import gplx.core.ios.*; import gplx.core.ios.streams.*;
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.apps.*;
import gplx.xowa.htmls.js.*;
class Http_server_wkr_v2 implements Gfo_invk {
class Http_server_wkr implements Gfo_invk {
private final int uid;
private final Http_server_mgr server_mgr;
private final Http_server_wtr server_wtr;
@ -34,7 +34,7 @@ class Http_server_wkr_v2 implements Gfo_invk {
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(64);
private Socket_adp socket;
private Http_data__client data__client;
public Http_server_wkr_v2(Http_server_mgr server_mgr, int uid){
public Http_server_wkr(Http_server_mgr server_mgr, int uid){
this.server_mgr = server_mgr; this.uid = uid;
this.app = server_mgr.App(); this.server_wtr = server_mgr.Server_wtr(); this.url_encoder = server_mgr.Encoder();
this.root_dir_http = app.Fsys_mgr().Root_dir().To_http_file_str();
@ -84,6 +84,7 @@ class Http_server_wkr_v2 implements Gfo_invk {
int url_end = question_pos == Bry_find_.Not_found ? url.length : question_pos; // ignore files with query params; EX: /file/A.png?key=val
url_encoder.Decode(tmp_bfr, Bool_.N, url, url_bgn, url_end); // decode url to actual chars; note that XOWA stores on fsys in UTF-8 chars; "<22>" not "%C3"
byte[] path = tmp_bfr.To_bry_and_clear();
if (gplx.core.envs.Op_sys.Cur().Tid_is_wnt()) path = Bry_.Replace(path, Byte_ascii.Backslash, Byte_ascii.Slash);
client_wtr.Write_bry(Xosrv_http_wkr_.Rsp__http_ok);
// client_wtr.Write_str("Expires: Sun, 17-Jan-2038 19:14:07 GMT\n");
String mime_type = String_.new_u8(Http_file_utl.To_mime_type_by_path_as_bry(path));
@ -179,33 +180,3 @@ class Xosrv_http_wkr_ {
, Rsp__content_type_html = Bry_.new_a7("Content-Type: text/html; charset=utf-8\n")
;
}
class Http_file_utl {
public static byte[] To_mime_type_by_path_as_bry(byte[] path_bry) {
int dot_pos = Bry_find_.Find_bwd(path_bry, Byte_ascii.Dot);
return dot_pos == Bry_find_.Not_found ? Mime_octet_stream : To_mime_type_by_ext_as_bry(path_bry, dot_pos, path_bry.length);
}
public static byte[] To_mime_type_by_ext_as_bry(byte[] ext_bry, int bgn, int end) {
Object o = mime_hash.Get_by_mid(ext_bry, bgn, end);
return o == null ? Mime_octet_stream : (byte[])o;
}
private static final byte[]
Mime_html = Bry_.new_a7("text/html")
, Mime_jpg = Bry_.new_a7("image/jpeg")
, Mime_png = Bry_.new_a7("image/png")
, Mime_gif = Bry_.new_a7("image/gif")
, Mime_svg = Bry_.new_a7("image/svg+xml")
, Mime_css = Bry_.new_a7("text/css")
, Mime_js = Bry_.new_a7("application/javascript")
, Mime_octet_stream = Bry_.new_a7("application/octet-stream")
;
private static final Hash_adp_bry mime_hash = Hash_adp_bry.ci_a7()
.Add_str_obj(".htm" , Mime_html)
.Add_str_obj(".html" , Mime_html)
.Add_str_obj(".jpg" , Mime_jpg)
.Add_str_obj(".png" , Mime_png)
.Add_str_obj(".gif" , Mime_gif)
.Add_str_obj(".svg" , Mime_svg)
.Add_str_obj(".css" , Mime_css)
.Add_str_obj(".js" , Mime_js)
;
}

@ -1,174 +0,0 @@
/*
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.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import gplx.core.envs.Op_sys;
import gplx.core.net.*; import gplx.core.threads.*; import gplx.langs.htmls.encoders.*;
import java.io.*;
import java.net.*;
import java.nio.charset.Charset;
class Http_server_wkr_v1 implements Runnable{
private static final String CRLF = "\r\n";
private Socket socket;
private Xoae_app app;
private String app_root_dir;
public Http_server_wkr_v1(Socket socket, Xoae_app app){
this.socket = socket;
this.app = app;
this.app_root_dir = app.Fsys_mgr().Root_dir().To_http_file_str();
}
public void run(){
String err_line = "00";
try {
InputStream is = socket.getInputStream(); err_line = "01";
DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); err_line = "02";
BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); err_line = "03";
String request = br.readLine(); err_line = "04";
//System.out.println(request); err_line = "03";
String req = request.substring(4, request.length() - 9).trim(); err_line = "05";
String wiki_domain = "home"; err_line = "06";
String page_name = "Main_Page"; err_line = "07";
if(!req.contains("%file%")){
if(req.equals("/")) { // no page; EX:"localhost:8080" vs "localhost:8080/en.wikipedia.org/wiki/Earth"
String home_url = String_.new_u8(app.Http_server().Home()); err_line = "08";
if (String_.Has_at_bgn(home_url, "file://")) {
Io_url file_url = Io_url_.http_any_(home_url, Op_sys.Cur().Tid_is_wnt()); err_line = "09";
String page_html = Io_mgr.Instance.LoadFilStr(file_url); err_line = "10";
Write_page(dos, page_html, app_root_dir, wiki_domain); err_line = "11";
}
else {
req += app.Http_server().Home(); err_line = "12";
}
}
req = Http_server_wkr_.Assert_main_page(app, req); err_line = "13";
}
if(req.contains("%xowa-cmd%") || req.contains("/xowa-cmd:")){
System.out.println("Command output:"); err_line = "14";
String cmd = ""; err_line = "15";
if (req.contains("%xowa-cmd%"))
cmd = req.substring(req.indexOf("%xowa-cmd%")+20);
else
cmd = req.substring(req.indexOf("/xowa-cmd:")+10);
System.out.println(cmd); err_line = "15";
app.Http_server().Run_xowa_cmd(app, cmd); err_line = "16";
dos.writeBytes("Command sent, see console log for more details."); err_line = "17";
dos.close(); err_line = "18";
}
else if(req.contains("%file%")){
String path = req.replace("/%file%/", app_root_dir); err_line = "19";
path = path.substring(path.indexOf(app_root_dir)+5); err_line = "20";
Gfo_url_encoder url_converter = Gfo_url_encoder_.Http_url; err_line = "21";
path = url_converter.Decode_str(path); err_line = "22";
if(path.contains("?")){
path = path.substring(0, path.indexOf("?")); err_line = "23";
}
FileInputStream fis = new FileInputStream(path); err_line = "24";
dos.writeBytes("HTTP/1.1 200 OK: "); err_line = "25";
dos.writeBytes("Content-Type: " + contentType(path) + CRLF); err_line = "26";
dos.writeBytes(CRLF); err_line = "27";
sendBytes(fis, dos); err_line = "28";
fis.close(); err_line = "28";
dos.close(); err_line = "29";
br.close(); err_line = "30";
socket.close(); err_line = "31";
}else{
String[] req_split = req.split("/"); err_line = "32";
System.out.println("Request: " +request); err_line = "33";
if(req_split.length >= 1){
wiki_domain = req_split[1]; err_line = "34";
}
if(req_split.length >= 4){
page_name = req_split[3]; err_line = "35";
for(int i = 4; i <= req_split.length-1; i++){
page_name += "/"+req_split[i]; err_line = "36";
}
Gfo_url_encoder url_converter = Gfo_url_encoder_.Http_url; err_line = "37";
page_name = url_converter.Decode_str(page_name); err_line = "38";
//page_name = app.Url_converter_url().Decode_str(page_name);
}
try{
// String page_html = app.Http_server().Parse_page_to_html(app, wiki_domain, page_name); err_line = "39";
// Write_page(dos, page_html, app_root_dir, wiki_domain); err_line = "40";
}catch(Exception err) {
dos.writeBytes("Site not found. Check address please, or see console log.\n"+err.getMessage()); err_line = "41";
dos.close(); err_line = "42";
}
}
} catch (IOException e) {
e.printStackTrace();
}
catch (Exception e) {
String err_msg = String_.Format("error retrieving page. Please make sure your url is of the form: http://localhost:8080/home/wiki/Main_Page; err_msg={0} err_line={1}", e.toString(), err_line);
System.out.println(err_msg);
e.printStackTrace();
}
}
private static void Write_page(DataOutputStream strm, String page_html, String app_file_dir, String wiki_domain) {
page_html = Convert_page(page_html, app_file_dir, wiki_domain);
Write_to_stream(strm, page_html);
}
private static String Convert_page(String page_html, String app_file_dir, String wiki_domain) {
page_html = page_html.replaceAll(app_file_dir , "%file%/");
page_html = page_html.replaceAll("xowa-cmd" , "%xowa-cmd%/xowa-cmd");
page_html = page_html.replaceAll("<a href=\"/wiki/" , "<a href=\"/"+wiki_domain+"/wiki/");
page_html = page_html.replaceAll("<a href='/wiki/" , "<a href='/"+wiki_domain+"/wiki/");
page_html = page_html.replaceAll("action=\"/wiki/" , "action=\"/"+wiki_domain+"/wiki/");
page_html = page_html.replaceAll("/site" , "");
return page_html;
}
private static void Write_to_stream(DataOutputStream strm, String page_html) {
try{
strm.writeBytes("HTTP/1.1 200 OK: ");
strm.writeBytes("Content-Type: text/html; charset=utf-8" + CRLF);
// strm.writeBytes("Access-Control-Allow-Origin: *" + CRLF); // No 'Access-Control-Allow-Origin' header is present on the requested resource.
strm.writeBytes(CRLF);
strm.write(page_html.getBytes(Charset.forName("UTF-8")));
strm.close();
} catch (Exception err) {
try {
strm.writeBytes("Site not found. Check address please, or see console log.\n"+err.getMessage());
strm.close();
}
catch (Exception io_err) {}
}
}
private void sendBytes(FileInputStream fis, DataOutputStream dos) {
byte[] buffer = new byte[1024];
int bytes = 0;
try {
while((bytes= fis.read(buffer)) != -1){
dos.write(buffer, 0, bytes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private String contentType(String fileName) {
if(fileName.endsWith(".htm") || fileName.endsWith(".html"))
return "text/html";
if(fileName.endsWith(".jpg"))
return "text/jpg";
if(fileName.endsWith(".gif"))
return "text/gif";
return "application/octet-stream";
}
}

@ -135,3 +135,14 @@ public class Xob_xml_parser_tst {
return rv;
}
}
class Xob_xml_parser_fxt {
// private final Xob_xml_parser page_parser = new Xob_xml_parser();
// public void Test__parse(Io_buffer_rdr fil, Xowd_page_itm expd, int cur_pos) {
// Xowd_page_itm actl = new Xowd_page_itm();
// int rv = page_parser.Parse_page(actl, usr_dlg, fil, fil.Bfr(), cur_pos, ns_mgr);
// Tfds.Eq(expd.Id(), actl.Id(), "id");
// Tfds.Eq(String_.new_u8(expd.Ttl_full_db()), String_.new_u8(actl.Ttl_full_db()), "title");
// Tfds.Eq(String_.new_u8(expd.Text()), String_.new_u8(actl.Text()), "text");
// Tfds.Eq_date(expd.Modified_on(), actl.Modified_on(), "timestamp");
// }
}

@ -32,24 +32,26 @@ public class Load_page_wkr implements Gfo_thread_wkr {
Running_(true);
// wait_for_popups; free mem check;
Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
Wait_for_popups();
Xowe_wiki_.Rls_mem_if_needed(wiki);
// load page meta; wait_for_popups
this.page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
page.Html_data().Hdump_exists_(hdump_exists);
Wait_for_popups();
// load page text
boolean parse = true;
if (hdump_exists) {
wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
parse = Bry_.Len_eq_0(page.Hdump_data().Body()); // NOTE: need to check if actually empty
}
if (parse)
wiki.Parser_mgr().Parse(page, false);
this.page = wiki.Page_mgr().Load_page(url, ttl, tab);
// DELETE:v3.6.4
// Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
// Wait_for_popups();
// Xowe_wiki_.Rls_mem_if_needed(wiki);
//
// // load page meta; wait_for_popups
// this.page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
// boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
// page.Html_data().Hdump_exists_(hdump_exists);
// Wait_for_popups();
//
// // load page text
// boolean parse = true;
// if (hdump_exists) {
// wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
// parse = Bry_.Len_eq_0(page.Hdump_data().Body()); // NOTE: need to check if actually empty
// }
// if (parse)
// wiki.Parser_mgr().Parse(page, false);
// launch thread to show page
Gfo_invk_.Invk_by_val(tab.Cmd_sync(), Xog_tab_itm.Invk_show_url_loaded_swt, this);
@ -62,11 +64,12 @@ public class Load_page_wkr implements Gfo_thread_wkr {
Running_(false);
}
}
private static void Wait_for_popups() {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items
int wait_count = 0;
while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
Thread_adp_.Sleep(10);
}
// DELETE:v3.6.4
// private static void Wait_for_popups() {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items
// int wait_count = 0;
// while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
// Thread_adp_.Sleep(10);
// }
private static final Object thread_lock = new Object(); private static boolean running = false;
public static boolean Running() {
boolean rv = false;

@ -113,7 +113,7 @@ public class Xog_html_itm implements Xog_js_wkr, Gfo_invk, Gfo_evt_itm {
Gfo_invk_.Invk_by_msg(cmd_sync, Invk_html_elem_atr_set, m);
}
}
public void Html_redlink(String html_uid) {Html_doc_atr_append_or_set(html_uid, "class", gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_redlink_utl.New_str);}
public void Html_redlink(String html_uid) {Html_doc_atr_append_or_set(html_uid, "class", gplx.xowa.wikis.pages.lnkis.Xoh_redlink_utl.New_str);}
private void Html_doc_atr_append_or_set(String elem_id, String atr_key, String atr_val) {
GfoMsg m = GfoMsg_.new_cast_(Invk_html_doc_atr_append_or_set).Add("elem_id", elem_id).Add("atr_key", atr_key).Add("atr_val", atr_val);
Gfo_invk_.Invk_by_msg(cmd_sync, Invk_html_doc_atr_append_or_set, m);

@ -220,6 +220,7 @@ public class Xog_tab_itm implements Gfo_invk {
wkr.Wiki().Appe().Thread_mgr_old().Page_load_mgr().Resume();
}
}
// DELETE:v3.6.4
// public void Async() {
// if (page == null) return; // TEST: occurs during Xog_win_mgr_tst
// Xowe_wiki wiki = page.Wikie(); Xoae_app app = wiki.Appe(); Xog_win_itm win_itm = tab_mgr.Win(); Gfo_usr_dlg usr_dlg = win_itm.Usr_dlg();
@ -290,7 +291,7 @@ class Load_files_wkr implements Gfo_thread_wkr {
public boolean Thread__resume() {return true;}
public void Thread__exec() {
try {Xog_async_wkr.Async(tab);}
// try {tab.Async();}
// try {tab.Async();} // DELETE:v3.6.4
catch (Exception e) {
tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().To_str(), Err_.Message_gplx_full(e));
}

@ -68,7 +68,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size();
else if (ctx.Match(k, Invk_page_refresh)) Page__refresh();
else if (ctx.Match(k, Invk_page_async_exec)) Xog_async_wkr.Async(((Xog_tab_itm)m.ReadObj("v")));
// else if (ctx.Match(k, Invk_page_async_exec)) ((Xog_tab_itm)m.ReadObj("v")).Async();
// else if (ctx.Match(k, Invk_page_async_exec)) ((Xog_tab_itm)m.ReadObj("v")).Async(); // DELETE:v3.6.4
else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xopg_page_.Tid_read);
else if (ctx.Match(k, Invk_page_view_edit)) Page__mode_(Xopg_page_.Tid_edit);
else if (ctx.Match(k, Invk_page_view_html)) Page__mode_(Xopg_page_.Tid_html);

@ -83,6 +83,7 @@ public class Xow_hdump_mgr__load {
wpg_head.Itm__popups().Bind_hover_area_ (hpg_head.Imap_exists());
wpg_head.Itm__gallery().Enabled_ (hpg_head.Gallery_packed_exists());
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
wpg_head.Itm__timeline().Enabled_ (true);
// transfer images from Xoh_page to Xoae_page
Xoh_img_mgr src_imgs = hpg.Img_mgr();

@ -40,7 +40,6 @@ public class Xoh_hdoc_ctx {
public Xoh_stat_itm Hzip__stat() {return hzip__stat;} private final Xoh_stat_itm hzip__stat = new Xoh_stat_itm();
public Xohz_tag_regy Hzip__xnde__regy() {return hzip__xnde__regy;} private final Xohz_tag_regy hzip__xnde__regy = Xohz_tag_regy_.New_dflt();
public Xoh_xnde_dict_reg Hzip__xnde__dict() {return hzip__xnde__dict;} private final Xoh_xnde_dict_reg hzip__xnde__dict = new Xoh_xnde_dict_reg();
public int Uid__lnki_nxt() {return ++uid__lnki;} private int uid__lnki;
public int Uid__gly__nxt() {return ++uid__gly;} private int uid__gly;
public boolean Mode_is_diff() {return mode_is_diff;} private boolean mode_is_diff; public void Mode_is_diff_(boolean v) {mode_is_diff = v;}
public void Init_by_app(Xoa_app app) {
@ -65,7 +64,6 @@ public class Xoh_hdoc_ctx {
}
private void Clear() {
hzip__stat.Clear();
this.uid__lnki = 1; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
this.uid__gly = -1;
}

@ -175,8 +175,8 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
case Xoh_anch_cls_.Tid__voyage__email: cls_bry = Xoh_anch_cls_.Bry__voyage_email; break;
}
if (cls_bry != null) bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(cls_bry);
if (!hctx.Mode_is_diff()) {
if (html_uid == -1) html_uid = hctx.Uid__lnki_nxt(); // html_uid == -1 for non-lnkis
if ( !hctx.Mode_is_diff() // do not add id during hzip_diff
&& href_type != Xoh_anch_href_data.Tid__inet) { // lnke should not get id
bfr.Add(Gfh_bldr_.Bry__id__nth).Add_str_a7(gplx.xowa.wikis.pages.lnkis.Xopg_lnki_list.Lnki_id_prefix).Add_int_variable(html_uid);
}
if ( href_type != Xoh_anch_href_data.Tid__anch) { // anchs never have title;

@ -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.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
class Xoh_toc_wtr {
private final Bry_bfr bfr = Bry_bfr_.New();
public void Clear() {
bfr.Clear();
}
public void Add(byte[] hdr_text) { // text within hdr; EX: <h2>Abc</h2> -> Abc
}
}

@ -0,0 +1,69 @@
/*
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.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import org.junit.*;
public class Xoh_toc_wtr_tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
@Test public void Ws() {
fxt.Test__add(" a b ", "a b");
}
@Test public void Apos__italic() {
fxt.Test__add("<i>a</i>", "<i>a</i>");
}
@Test public void Xnde__small() {
fxt.Test__add("<small>a</small>", "a");
}
@Test public void Xnde__nest__xnde() { // <sup> removed but not <small>
fxt.Test__add("a <sup>b<small>c</small>d</sup> e", "a b<small>c</small>d e");
}
@Test public void Xnde__nest__lnki() { // <small> and <a> removed
fxt.Test__add("<small><a href=\"/wiki/A\">b</a></small>", "b");
}
@Test public void Xnde__nest__inline() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
fxt.Test__add("a<span id='b'>b<br/></span>", "ab");
}
@Test public void Lnki__caption() {
fxt.Test__add("<a href=\"/wiki/A\">b</a>", "b");
}
@Test public void Lnki__caption__nest() {
fxt.Test__add("<a href=\"/wiki/A\">b<i>c</i>d</a>", "b<i>c</i>d");
}
@Test public void Amp__ncr() {
fxt.Test__add("&#91;a&#93;", "&#91;a&#93;");
}
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
fxt.Test__add("a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>", "a");
}
@Test public void Category__literal() { // PURPOSE: literal Category should show in in TOC; EX: de.w:1234; DATE:2014-01-21
fxt.Test__add("A<a href=\"/wiki/Category:B\">Category:B</a>", "ACategory:B");
}
@Test public void File() { // PURPOSE: file should show in in TOC; EX: tr.w:D<>nya_Miraslari; DATE:2014-06-06
fxt.Test__add
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a> b"
, " b");
}
@Test public void Translate_w_comment() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
fxt.Test__add("<translate><!--b-->ac</translate>", "ac");
}
}
class Xoh_toc_wtr_fxt {
private final Xoh_toc_wtr wtr = new Xoh_toc_wtr();
public void Clear() {wtr.Clear();}
public void Test__add(String html, String expd_text) {
}
}

@ -223,248 +223,249 @@ public class Xol_lang_stub_ { // lists all known stub_ary supported by MW
, Id_ko = 197
, Id_ko_kp = 198
, Id_koi = 199
, Id_kr = 200
, Id_krc = 201
, Id_kri = 202
, Id_krj = 203
, Id_krl = 204
, Id_ks = 205
, Id_ks_arab = 206
, Id_ks_deva = 207
, Id_ksh = 208
, Id_ku = 209
, Id_ku_arab = 210
, Id_ku_latn = 211
, Id_kv = 212
, Id_kw = 213
, Id_ky = 214
, Id_la = 215
, Id_lad = 216
, Id_lb = 217
, Id_lbe = 218
, Id_lez = 219
, Id_lfn = 220
, Id_lg = 221
, Id_li = 222
, Id_lij = 223
, Id_liv = 224
, Id_lmo = 225
, Id_ln = 226
, Id_lo = 227
, Id_loz = 228
, Id_lrc = 229
, Id_lt = 230
, Id_ltg = 231
, Id_lus = 232
, Id_luz = 233
, Id_lv = 234
, Id_lzh = 235
, Id_lzz = 236
, Id_mai = 237
, Id_map_bms = 238
, Id_mdf = 239
, Id_mg = 240
, Id_mh = 241
, Id_mhr = 242
, Id_mi = 243
, Id_mic = 244
, Id_min = 245
, Id_mk = 246
, Id_ml = 247
, Id_mn = 248
, Id_mnc = 249
, Id_mo = 250
, Id_mr = 251
, Id_mrj = 252
, Id_ms = 253
, Id_mt = 254
, Id_mui = 255
, Id_mus = 256
, Id_mwl = 257
, Id_mwv = 258
, Id_my = 259
, Id_myv = 260
, Id_mzn = 261
, Id_na = 262
, Id_nah = 263
, Id_nan = 264
, Id_nap = 265
, Id_nb = 266
, Id_nds = 267
, Id_nds_nl = 268
, Id_ne = 269
, Id_new = 270
, Id_ng = 271
, Id_niu = 272
, Id_nl = 273
, Id_nl_informal = 274
, Id_nn = 275
, Id_no = 276
, Id_nov = 277
, Id_nrm = 278
, Id_nso = 279
, Id_nv = 280
, Id_ny = 281
, Id_oc = 282
, Id_om = 283
, Id_or = 284
, Id_os = 285
, Id_pa = 286
, Id_pag = 287
, Id_pam = 288
, Id_pap = 289
, Id_pbb = 290
, Id_pcd = 291
, Id_pdc = 292
, Id_pdt = 293
, Id_pfl = 294
, Id_pi = 295
, Id_pih = 296
, Id_pl = 297
, Id_pms = 298
, Id_pnb = 299
, Id_pnt = 300
, Id_ppl = 301
, Id_prg = 302
, Id_ps = 303
, Id_pt = 304
, Id_pt_br = 305
, Id_qqq = 306
, Id_qu = 307
, Id_qug = 308
, Id_rap = 309
, Id_rgn = 310
, Id_rif = 311
, Id_rm = 312
, Id_rmf = 313
, Id_rmy = 314
, Id_rn = 315
, Id_ro = 316
, Id_roa_rup = 317
, Id_roa_tara = 318
, Id_ru = 319
, Id_rue = 320
, Id_rup = 321
, Id_ruq = 322
, Id_ruq_cyrl = 323
, Id_ruq_latn = 324
, Id_rw = 325
, Id_ryu = 326
, Id_sa = 327
, Id_sah = 328
, Id_sat = 329
, Id_saz = 330
, Id_sc = 331
, Id_scn = 332
, Id_sco = 333
, Id_sd = 334
, Id_sdc = 335
, Id_sdh = 336
, Id_se = 337
, Id_sei = 338
, Id_ses = 339
, Id_sg = 340
, Id_sgs = 341
, Id_sh = 342
, Id_shi = 343
, Id_shn = 344
, Id_si = 345
, Id_simple = 346
, Id_sk = 347
, Id_sl = 348
, Id_sli = 349
, Id_sly = 350
, Id_sm = 351
, Id_sma = 352
, Id_sn = 353
, Id_so = 354
, Id_sq = 355
, Id_sr = 356
, Id_sr_ec = 357
, Id_sr_el = 358
, Id_srn = 359
, Id_ss = 360
, Id_st = 361
, Id_stq = 362
, Id_su = 363
, Id_sv = 364
, Id_sw = 365
, Id_sxu = 366
, Id_szl = 367
, Id_ta = 368
, Id_tcy = 369
, Id_te = 370
, Id_test = 371
, Id_tet = 372
, Id_tg = 373
, Id_tg_cyrl = 374
, Id_tg_latn = 375
, Id_th = 376
, Id_ti = 377
, Id_tk = 378
, Id_tl = 379
, Id_tly = 380
, Id_tn = 381
, Id_to = 382
, Id_tokipona = 383
, Id_tp = 384
, Id_tpi = 385
, Id_tr = 386
, Id_tru = 387
, Id_ts = 388
, Id_tt = 389
, Id_tt_cyrl = 390
, Id_tt_latn = 391
, Id_ttt = 392
, Id_tum = 393
, Id_tw = 394
, Id_ty = 395
, Id_tyv = 396
, Id_tzm = 397
, Id_ua = 398
, Id_udm = 399
, Id_ug = 400
, Id_ug_arab = 401
, Id_ug_latn = 402
, Id_uk = 403
, Id_ur = 404
, Id_uz = 405
, Id_ve = 406
, Id_vec = 407
, Id_vep = 408
, Id_vi = 409
, Id_vls = 410
, Id_vmf = 411
, Id_vo = 412
, Id_vot = 413
, Id_vro = 414
, Id_wa = 415
, Id_war = 416
, Id_wo = 417
, Id_wuu = 418
, Id_xal = 419
, Id_xh = 420
, Id_xmf = 421
, Id_yi = 422
, Id_yo = 423
, Id_yue = 424
, Id_za = 425
, Id_zea = 426
, Id_zh = 427
, Id_zh_classical = 428
, Id_zh_cn = 429
, Id_zh_hans = 430
, Id_zh_hant = 431
, Id_zh_hk = 432
, Id_zh_min_nan = 433
, Id_zh_mo = 434
, Id_zh_my = 435
, Id_zh_sg = 436
, Id_zh_tw = 437
, Id_zh_yue = 438
, Id_zu = 439
, Id_kok = 200
, Id_kr = 201
, Id_krc = 202
, Id_kri = 203
, Id_krj = 204
, Id_krl = 205
, Id_ks = 206
, Id_ks_arab = 207
, Id_ks_deva = 208
, Id_ksh = 209
, Id_ku = 210
, Id_ku_arab = 211
, Id_ku_latn = 212
, Id_kv = 213
, Id_kw = 214
, Id_ky = 215
, Id_la = 216
, Id_lad = 217
, Id_lb = 218
, Id_lbe = 219
, Id_lez = 220
, Id_lfn = 221
, Id_lg = 222
, Id_li = 223
, Id_lij = 224
, Id_liv = 225
, Id_lmo = 226
, Id_ln = 227
, Id_lo = 228
, Id_loz = 229
, Id_lrc = 230
, Id_lt = 231
, Id_ltg = 232
, Id_lus = 233
, Id_luz = 234
, Id_lv = 235
, Id_lzh = 236
, Id_lzz = 237
, Id_mai = 238
, Id_map_bms = 239
, Id_mdf = 240
, Id_mg = 241
, Id_mh = 242
, Id_mhr = 243
, Id_mi = 244
, Id_mic = 245
, Id_min = 246
, Id_mk = 247
, Id_ml = 248
, Id_mn = 249
, Id_mnc = 250
, Id_mo = 251
, Id_mr = 252
, Id_mrj = 253
, Id_ms = 254
, Id_mt = 255
, Id_mui = 256
, Id_mus = 257
, Id_mwl = 258
, Id_mwv = 259
, Id_my = 260
, Id_myv = 261
, Id_mzn = 262
, Id_na = 263
, Id_nah = 264
, Id_nan = 265
, Id_nap = 266
, Id_nb = 267
, Id_nds = 268
, Id_nds_nl = 269
, Id_ne = 270
, Id_new = 271
, Id_ng = 272
, Id_niu = 273
, Id_nl = 274
, Id_nl_informal = 275
, Id_nn = 276
, Id_no = 277
, Id_nov = 278
, Id_nrm = 279
, Id_nso = 280
, Id_nv = 281
, Id_ny = 282
, Id_oc = 283
, Id_om = 284
, Id_or = 285
, Id_os = 286
, Id_pa = 287
, Id_pag = 288
, Id_pam = 289
, Id_pap = 290
, Id_pbb = 291
, Id_pcd = 292
, Id_pdc = 293
, Id_pdt = 294
, Id_pfl = 295
, Id_pi = 296
, Id_pih = 297
, Id_pl = 298
, Id_pms = 299
, Id_pnb = 300
, Id_pnt = 301
, Id_ppl = 302
, Id_prg = 303
, Id_ps = 304
, Id_pt = 305
, Id_pt_br = 306
, Id_qqq = 307
, Id_qu = 308
, Id_qug = 309
, Id_rap = 310
, Id_rgn = 311
, Id_rif = 312
, Id_rm = 313
, Id_rmf = 314
, Id_rmy = 315
, Id_rn = 316
, Id_ro = 317
, Id_roa_rup = 318
, Id_roa_tara = 319
, Id_ru = 320
, Id_rue = 321
, Id_rup = 322
, Id_ruq = 323
, Id_ruq_cyrl = 324
, Id_ruq_latn = 325
, Id_rw = 326
, Id_ryu = 327
, Id_sa = 328
, Id_sah = 329
, Id_sat = 330
, Id_saz = 331
, Id_sc = 332
, Id_scn = 333
, Id_sco = 334
, Id_sd = 335
, Id_sdc = 336
, Id_sdh = 337
, Id_se = 338
, Id_sei = 339
, Id_ses = 340
, Id_sg = 341
, Id_sgs = 342
, Id_sh = 343
, Id_shi = 344
, Id_shn = 345
, Id_si = 346
, Id_simple = 347
, Id_sk = 348
, Id_sl = 349
, Id_sli = 350
, Id_sly = 351
, Id_sm = 352
, Id_sma = 353
, Id_sn = 354
, Id_so = 355
, Id_sq = 356
, Id_sr = 357
, Id_sr_ec = 358
, Id_sr_el = 359
, Id_srn = 360
, Id_ss = 361
, Id_st = 362
, Id_stq = 363
, Id_su = 364
, Id_sv = 365
, Id_sw = 366
, Id_sxu = 367
, Id_szl = 368
, Id_ta = 369
, Id_tcy = 370
, Id_te = 371
, Id_test = 372
, Id_tet = 373
, Id_tg = 374
, Id_tg_cyrl = 375
, Id_tg_latn = 376
, Id_th = 377
, Id_ti = 378
, Id_tk = 379
, Id_tl = 380
, Id_tly = 381
, Id_tn = 382
, Id_to = 383
, Id_tokipona = 384
, Id_tp = 385
, Id_tpi = 386
, Id_tr = 387
, Id_tru = 388
, Id_ts = 389
, Id_tt = 390
, Id_tt_cyrl = 391
, Id_tt_latn = 392
, Id_ttt = 393
, Id_tum = 394
, Id_tw = 395
, Id_ty = 396
, Id_tyv = 397
, Id_tzm = 398
, Id_ua = 399
, Id_udm = 400
, Id_ug = 401
, Id_ug_arab = 402
, Id_ug_latn = 403
, Id_uk = 404
, Id_ur = 405
, Id_uz = 406
, Id_ve = 407
, Id_vec = 408
, Id_vep = 409
, Id_vi = 410
, Id_vls = 411
, Id_vmf = 412
, Id_vo = 413
, Id_vot = 414
, Id_vro = 415
, Id_wa = 416
, Id_war = 417
, Id_wo = 418
, Id_wuu = 419
, Id_xal = 420
, Id_xh = 421
, Id_xmf = 422
, Id_yi = 423
, Id_yo = 424
, Id_yue = 425
, Id_za = 426
, Id_zea = 427
, Id_zh = 428
, Id_zh_classical = 429
, Id_zh_cn = 430
, Id_zh_hans = 431
, Id_zh_hant = 432
, Id_zh_hk = 433
, Id_zh_min_nan = 434
, Id_zh_mo = 435
, Id_zh_my = 436
, Id_zh_sg = 437
, Id_zh_tw = 438
, Id_zh_yue = 439
, Id_zu = 440
;
public static final int Id__max = 440;
public static final int Id__max = 441;
public static Hash_adp_bry Regy() {
if (stub_hash == null) { // NOTE: any parenthetical String below will have an "unseen" character of "\xE2\x80\xAA" at the begining and "\xE2\x80\xAC" at the end. They are responsible for parentheses-orientation in RTL stub_ary.
stub_hash = Hash_adp_bry.ci_a7(); // ASCII:lang_code; NOTE: must be ci; EX: {{#languages:FR}}
@ -668,6 +669,7 @@ Regy_add(stub_hash, Id_kn, "kn", "ಕನ್ನಡ");
Regy_add(stub_hash, Id_ko, "ko", "한국어");
Regy_add(stub_hash, Id_ko_kp, "ko-kp", "한국어 (조선)");
Regy_add(stub_hash, Id_koi, "koi", "Перем Коми");
Regy_add(stub_hash, Id_kok, "kok", "");
Regy_add(stub_hash, Id_kr, "kr", "Kanuri");
Regy_add(stub_hash, Id_krc, "krc", "Къарачай-Малкъар");
Regy_add(stub_hash, Id_kri, "kri", "Krio");
@ -814,7 +816,7 @@ Regy_add(stub_hash, Id_sh, "sh", "Srpskohrvatski / Српскохрватски"
Regy_add(stub_hash, Id_shi, "shi", "Tašlḥiyt");
Regy_add(stub_hash, Id_shn, "shn", "Shan");
Regy_add(stub_hash, Id_si, "si", "Sinhalese");
Regy_add(stub_hash, Id_simple, "simple", "Simple"); // NOTE: changed from "Simple English"; DATE:2016-06-11
Regy_add(stub_hash, Id_simple, "simple", "Simple English");
Regy_add(stub_hash, Id_sk, "sk", "Slovenčina");
Regy_add(stub_hash, Id_sl, "sl", "Slovenščina");
Regy_add(stub_hash, Id_sli, "sli", "Schläsch");

@ -176,13 +176,29 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
if (name_ary_len != 0 ) { // name_ary_len != 0 for direct template inclusions; PAGE:en.w:Human evolution and {{:Human evolution/Species chart}}; && ctx.Tmpl_whitelist().Has(name_ary)
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.Add(wiki.Ns_mgr().Ns_template().Name_db_w_colon(), name_ary));
if (ttl == null) { // ttl is not valid; just output orig; REF.MW:Parser.php|braceSubstitution|if ( !$found ) $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args );
byte[] missing_ttl
= subst_found || template_prefix_found // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
? name_ary_orig
: name_ary
;
bfr.Add(Xop_curly_bgn_lxr.Hook).Add(missing_ttl).Add(Xop_curly_end_lxr.Hook);
return false;
if (subst_found || template_prefix_found) { // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
bfr.Add(Xop_curly_bgn_lxr.Hook).Add(name_ary_orig).Add(Xop_curly_end_lxr.Hook);
return false;
}
else { // output entire tmpl_src WITH args; used to output name only which broke pages; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
bfr.Add(Xop_curly_bgn_lxr.Hook);
bfr.Add(name_ary);
for (int i = 0; i < args_len; ++i) {
Arg_nde_tkn nde = this.Args_get_by_idx(i);
bfr.Add_byte(Byte_ascii.Pipe);
bfr.Add_mid(src, nde.Src_bgn(), nde.Src_end());
}
bfr.Add(Xop_curly_end_lxr.Hook);
return false;
}
// DELETE:v3.6.4
// byte[] missing_ttl
// = subst_found || template_prefix_found // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
// ? name_ary_orig
// : name_ary
// ;
// bfr.Add(Xop_curly_bgn_lxr.Hook).Add(missing_ttl).Add(Xop_curly_end_lxr.Hook);
// return false;
}
else { // some templates produce null ttls; EX: "Citation needed{{subst"
defn = wiki.Cache_mgr().Defn_cache().Get_by_key(ttl.Page_db());

@ -0,0 +1,41 @@
/*
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.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.nss.*;
public class Xot_invk_wkr__missing__tst {
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
@Test public void Missing() {
fxt.Init_defn_clear();
fxt.Init_defn_add("test_template", "{{[[Template:{{{1}}}|{{{1}}}]]}}");
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template|a}}", "{{[[Template:a|a]]}}");
fxt.Init_defn_clear();
}
@Test public void Missing__name_and_args() { // PURPOSE: missing title should return name + args; used to only return name; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
fxt.Init_defn_clear();
fxt.Init_defn_add("test_template", "{{ {{{1}}} | a | b }}");
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template}}", "{{{{{1}}}| a | b }}"); // NOTE: this should include spaces (" {{{1}}} "), but for now, ignore
fxt.Init_defn_clear();
}
@Test public void Missing_foreign() {
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
byte[] old_ns = ns.Name_db();
ns.Name_bry_(Bry_.new_a7("Template_foreign"));
fxt.Test_parse_tmpl_str("{{Missing}}", "[[:Template_foreign:Missing]]");
ns.Name_bry_(old_ns);
}
}

@ -201,19 +201,6 @@ public class Xot_invk_wkr_basic_tst {
fxt.Init_defn_add("temp_2", "{{{key1}}}");
fxt.Test_parse_tmpl_str("{{temp_1}}", "val1");
}
@Test public void Missing() {
fxt.Init_defn_clear();
fxt.Init_defn_add("test_template", "{{[[Template:{{{1}}}|{{{1}}}]]}}");
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template|a}}", "{{[[Template:a|a]]}}");
fxt.Init_defn_clear();
}
@Test public void Missing_foreign() {
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
byte[] old_ns = ns.Name_db();
ns.Name_bry_(Bry_.new_a7("Template_foreign"));
fxt.Test_parse_tmpl_str("{{Missing}}", "[[:Template_foreign:Missing]]");
ns.Name_bry_(old_ns);
}
@Test public void Xnde_xtn_preserved() { // PURPOSE: tmpl was dropping .Xtn ndes;
fxt.Init_defn_clear();
fxt.Init_defn_add("test_template", "{{{1}}}");

@ -32,9 +32,12 @@ public class Xowe_page_mgr {
Wait_for_popups();
// load page text
if (hdump_exists)
boolean parse = true;
if (hdump_exists) {
wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
else
parse = Bry_.Len_eq_0(page.Hdump_data().Body()); // NOTE: need to check if actually empty for archive.org wikis which included html_db_id without html_dbs; DATE:2016-06-22
}
if (parse)
wiki.Parser_mgr().Parse(page, false);
return page;
}

@ -15,8 +15,8 @@ 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.lnkis.htmls; 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.lnkis.*;
package gplx.xowa.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xoh_redlink_utl {
public static final byte[] Cls_bry = Bry_.new_a7("class='new'");
public static final String New_str = "new";
public static final byte[] Cls_bry = Bry_.new_a7("class='new'");
public static final String New_str = "new";
}

@ -43,7 +43,7 @@ public class Xopg_lnki_list {
list.Add(lnki);
}
public void Clear() {
lnki_idx = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_lnki_wtr.Lnki_id_min; // NOTE: must start at 0, so that ++lnki_idx is > 0; html_wtr checks for > 0; DATE:2014-10-09
lnki_idx = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_lnki_wtr.Lnki_id_min; // NOTE: must start at 0, so that ++lnki_idx is > 0; html_wtr checks for > 0; DATE:2014-10-09; OLD_COMMENT: NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
list.Clear();
}

@ -131,7 +131,7 @@ public class Scrib_lib_language implements Scrib_lib {
}
public boolean FetchLanguageName(Scrib_proc_args args, Scrib_proc_rslt rslt) {
byte[] lang_code = args.Pull_bry(0);
// byte[] trans_code = args.Get_bry_or_null(1); // TODO_OLD: FetchLanguageName("en", "fr") -> Anglais; WHEN: needs global database of languages;
// byte[] trans_code = args.Get_bry_or_null(1); // TODO_OLD: FetchLanguageName("en", "fr") -> Anglais; WHEN: needs global database of languages; cldr
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(lang_code);
return rslt.Init_obj(lang_itm == null ? String_.Empty : String_.new_u8(lang_itm.Canonical_name()));
}

Loading…
Cancel
Save