mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.3.1
This commit is contained in:
@@ -30,7 +30,7 @@ public class Xob_import_cfg {
|
||||
if (src_fil_xml == null && src_fil_bz2 == null) return wiki.Fsys_mgr().Root_dir();
|
||||
else if (src_fil_xml != null) return src_fil_xml.OwnerDir();
|
||||
else if (src_fil_bz2 != null) return src_fil_bz2.OwnerDir();
|
||||
else throw Exc_.new_("unknown src dir");
|
||||
else throw Err_.new_wo_type("unknown src dir");
|
||||
}
|
||||
public Io_stream_rdr Src_rdr() {
|
||||
if (src_fil_xml == null && src_fil_bz2 == null) { // will usually be null; non-null when user specifies src through command-line
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xob_import_marker {
|
||||
case Gfui_dlg_msg_.Btn_yes: Xob_cleanup_cmd.Delete_wiki_sql(wiki); End(wiki); return false; // delete wiki
|
||||
case Gfui_dlg_msg_.Btn_no: End(wiki); return true; // delete marker
|
||||
case Gfui_dlg_msg_.Btn_cancel: return true; // noop
|
||||
default: throw Exc_.new_unhandled(rslt);
|
||||
default: throw Err_.new_unhandled(rslt);
|
||||
}
|
||||
}
|
||||
private static Io_url url_(Xowe_wiki wiki) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xob_siteinfo_parser {
|
||||
int end = Bry_finder.Find_fwd(src, Bry_siteinfo_end, bgn); if (end == Bry_.NotFound) return null;
|
||||
return Bry_.Mid(src, bgn, end + Bry_siteinfo_end.length);
|
||||
}
|
||||
catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
catch (Exception e) {Err_.Noop(e); return null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public static void Siteinfo_parse(Xowe_wiki wiki, Gfo_usr_dlg usr_dlg, String siteinfo_str) {
|
||||
@@ -42,7 +42,7 @@ public class Xob_siteinfo_parser {
|
||||
|| String_.Eq(sub_nde.Name(), "case")) siteinfo_misc_bfr.Add_str(sub_nde.Text_inner()).Add_byte_pipe();
|
||||
else if ( String_.Eq(sub_nde.Name(), "base")) {
|
||||
String mainpage_url = sub_nde.Text_inner();
|
||||
byte[] mainpage_name = Siteinfo_parse_mainpage(Bry_.new_u8(mainpage_url)); if (mainpage_name == null) throw Exc_.new_("could not extract mainpage", "mainpage", mainpage_url);
|
||||
byte[] mainpage_name = Siteinfo_parse_mainpage(Bry_.new_u8(mainpage_url)); if (mainpage_name == null) throw Err_.new_wo_type("could not extract mainpage", "mainpage", mainpage_url);
|
||||
wiki.Props().Main_page_(mainpage_name);
|
||||
}
|
||||
else if ( String_.Eq(sub_nde.Name(), "namespaces")) {
|
||||
@@ -59,7 +59,7 @@ public class Xob_siteinfo_parser {
|
||||
int bgn_pos = Bry_finder.Find_fwd(url, wiki_bry, 0);
|
||||
if (bgn_pos == Bry_.NotFound) { // "/wiki/" not found; EX: http://mywiki/My_main_page
|
||||
bgn_pos = Bry_finder.Find_bwd(url, Byte_ascii.Slash); // ASSUME last segment is page
|
||||
if (bgn_pos == Bry_.NotFound) throw Exc_.new_("could not parse main page url", "url", String_.new_u8(url));
|
||||
if (bgn_pos == Bry_.NotFound) throw Err_.new_wo_type("could not parse main page url", "url", String_.new_u8(url));
|
||||
++bgn_pos; // add 1 to position after slash
|
||||
}
|
||||
else // "/wiki/" found
|
||||
@@ -79,7 +79,7 @@ public class Xob_siteinfo_parser {
|
||||
String name = sub_nde.Text_inner();
|
||||
ns_mgr.Add_new(ns_id, Bry_.new_u8(name), case_match, false);
|
||||
}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "xo", "parse failed", "inner", sub_nde.Text_inner());}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "xo", "parse failed", "inner", sub_nde.Text_inner());}
|
||||
}
|
||||
ns_mgr.Init_w_defaults();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class Xob_xml_parser {
|
||||
case Xob_xml_parser_.Id_id_bgn_frag: case Xob_xml_parser_.Id_timestamp_bgn_frag:
|
||||
data_bgn = pos; /*warn*/
|
||||
break;
|
||||
default: throw Exc_.new_unhandled(itm.Tid()); // shouldn't happen
|
||||
default: throw Err_.new_unhandled(itm.Tid()); // shouldn't happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,28 +43,28 @@ public class Xob_xml_parser_tst {
|
||||
@Test public void Xml() {
|
||||
Xowd_page_itm doc = doc_(1, "a", ""a & b <> a | b"", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_u8("\"a & b <> a | b\"")), 0);
|
||||
tst_parse(fil, doc.Text_(Bry_.new_a7("\"a & b <> a | b\"")), 0);
|
||||
}
|
||||
@Test public void Tab() {
|
||||
Xowd_page_itm doc = doc_(1, "a", "a \t b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_u8("a 	 b")), 0);
|
||||
tst_parse(fil, doc.Text_(Bry_.new_a7("a 	 b")), 0);
|
||||
}
|
||||
@Test public void Tab_disable() {
|
||||
Xowd_page_itm doc = doc_(1, "a", "a \t b", Date_1);
|
||||
page_parser.Trie_tab_del_();
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_u8("a \t b")), 0);
|
||||
tst_parse(fil, doc.Text_(Bry_.new_a7("a \t b")), 0);
|
||||
}
|
||||
@Test public void Cr_nl() {
|
||||
Xowd_page_itm doc = doc_(1, "a", "a \r\n b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_u8("a \n b")), 0);
|
||||
tst_parse(fil, doc.Text_(Bry_.new_a7("a \n b")), 0);
|
||||
}
|
||||
@Test public void Cr() {
|
||||
Xowd_page_itm doc = doc_(1, "a", "a \r b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_u8("a \n b")), 0);
|
||||
tst_parse(fil, doc.Text_(Bry_.new_a7("a \n b")), 0);
|
||||
}
|
||||
@Test public void Text_long() {
|
||||
String s = String_.Repeat("a", 1024);
|
||||
|
||||
Reference in New Issue
Block a user