diff --git a/400_xowa/src/gplx/xowa/Xoa_app_.java b/400_xowa/src/gplx/xowa/Xoa_app_.java
index 7fff0018c..53c431948 100644
--- a/400_xowa/src/gplx/xowa/Xoa_app_.java
+++ b/400_xowa/src/gplx/xowa/Xoa_app_.java
@@ -32,7 +32,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
- public static final String Version = "3.12.1.1";
+ public static final String Version = "3.12.1.2";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";
diff --git a/400_xowa/src/gplx/xowa/addons/apps/cfgs/specials/edits/objs/Xoedit_itm.java b/400_xowa/src/gplx/xowa/addons/apps/cfgs/specials/edits/objs/Xoedit_itm.java
index 07c503c14..9b7923821 100644
--- a/400_xowa/src/gplx/xowa/addons/apps/cfgs/specials/edits/objs/Xoedit_itm.java
+++ b/400_xowa/src/gplx/xowa/addons/apps/cfgs/specials/edits/objs/Xoedit_itm.java
@@ -69,7 +69,7 @@ public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
Gfobj_nde rv = Gfobj_nde.New();
rv.Add_int("id", id);
rv.Add_str("key", key);
- rv.Add_str("dflt", lang);
+ rv.Add_str("dflt", dflt);
rv.Add_str("lang", lang);
rv.Add_str("name", name);
rv.Add_str("help", help);
@@ -88,7 +88,7 @@ public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
if (String_.Eq(k, "id")) bfr.Add_int(id);
else if (String_.Eq(k, "key")) bfr.Add_str_u8(key);
else if (String_.Eq(k, "dflt")) bfr.Add_str_u8(dflt);
- else if (String_.Eq(k, "lang")) bfr.Add_str_u8(name);
+ else if (String_.Eq(k, "lang")) bfr.Add_str_u8(lang);
else if (String_.Eq(k, "name")) bfr.Add_str_u8(name);
else if (String_.Eq(k, "help")) bfr.Add_str_u8(help);
else if (String_.Eq(k, "ctx")) bfr.Add_str_u8(ctx);
diff --git a/400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr.java b/400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr.java
index 9c1647546..4450b4746 100644
--- a/400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr.java
+++ b/400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr.java
@@ -226,7 +226,7 @@ public class Xoh_page_wtr_wkr {
data_raw = Gfs_php_converter.Xto_php(tmp_bfr, Bool_.N, data_raw);
int data_raw_len = data_raw.length;
if (mgr.Html_capable()) {
- data_raw = wiki.Parser_mgr().Hdr__section_editable__mgr().Extract_section(page.Url(), page.Ttl(), data_raw);
+ data_raw = wiki.Parser_mgr().Hdr__section_editable__mgr().Extract_section(app, page.Url(), page.Ttl(), data_raw);
data_raw_len = data_raw.length;
Xoh_html_wtr_escaper.Escape(page.Wikie().Appe().Parser_amp_mgr(), bfr, data_raw, 0, data_raw_len, false, false); // NOTE: must escape; assume that browser will automatically escape (<) (which Mozilla does)
}
diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/hdrs/Xoh_section_editable_.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/hdrs/Xoh_section_editable_.java
index d32519586..bc2e801c2 100644
--- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/hdrs/Xoh_section_editable_.java
+++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/hdrs/Xoh_section_editable_.java
@@ -18,5 +18,5 @@ along with this program. If not, see .
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.hdrs.*;
public class Xoh_section_editable_ {
- public static final String Cfg__section_editing__enabled = "section_editing.enabled";
+ public static final String Cfg__section_editing__enabled = "xowa.edit.section_edit.enabled";
}
diff --git a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list.java b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list.java
index e6ce948f3..4cd2b302d 100644
--- a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list.java
+++ b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list.java
@@ -24,6 +24,7 @@ class Xop_section_list implements Xomw_hdr_cbk {
public Xop_section_list Parse(byte[] src) {
this.src = src;
+ hash.Clear();
Xomw_parser_ctx pctx = new Xomw_parser_ctx();
hdr_wkr.Parse(pctx, src, 0, src.length, this);
return this;
diff --git a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__merge__tst.java b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__merge__tst.java
new file mode 100644
index 000000000..33cd72be6
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__merge__tst.java
@@ -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 .
+*/
+package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
+import org.junit.*; import gplx.core.tests.*;
+public class Xop_section_list__merge__tst {
+ private final Xop_section_list__fxt fxt = new Xop_section_list__fxt();
+ @Test public void Basic() {
+ fxt.Exec__parse
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ , ""
+ , "== Hdr 3 =="
+ , "Para 3"
+ );
+ fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
+ ( "== Hdr 2 =="
+ , "Para 2a"
+ ), String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2a"
+ , ""
+ , "== Hdr 3 =="
+ , "Para 3"
+ )
+ );
+ }
+ @Test public void Nl_many() {
+ fxt.Exec__parse
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , ""
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ , ""
+ , ""
+ , ""
+ , "== Hdr 3 =="
+ , "Para 3"
+ );
+ fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
+ ( "== Hdr 2 =="
+ , "Para 2a"
+ ), String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , ""
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2a"
+ , ""
+ , ""
+ , ""
+ , "== Hdr 3 =="
+ , "Para 3"
+ )
+ );
+ }
+ @Test public void Bos() {
+ fxt.Exec__parse
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ );
+ fxt.Test__merge_bry_or_null("Hdr 1", String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1a"
+ ), String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1a"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ )
+ );
+ }
+ @Test public void Bos__ws() {
+ fxt.Exec__parse
+ ( ""
+ , "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ );
+ fxt.Test__merge_bry_or_null("Hdr 1", String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1a"
+ ), String_.Concat_lines_nl_skip_last
+ ( ""
+ , "== Hdr 1 =="
+ , "Para 1a"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ )
+ );
+ }
+ @Test public void Eos() {
+ fxt.Exec__parse
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2"
+ );
+ fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
+ ( "== Hdr 2 =="
+ , "Para 2a"
+ ), String_.Concat_lines_nl_skip_last
+ ( "== Hdr 1 =="
+ , "Para 1"
+ , ""
+ , "== Hdr 2 =="
+ , "Para 2a"
+ )
+ );
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__tst.java b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__slice__tst.java
similarity index 70%
rename from 400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__tst.java
rename to 400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__slice__tst.java
index ccc499cd9..8df99953e 100644
--- a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__tst.java
+++ b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_list__slice__tst.java
@@ -17,9 +17,9 @@ along with this program. If not, see .
*/
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
import org.junit.*; import gplx.core.tests.*;
-public class Xop_section_list__tst {
+public class Xop_section_list__slice__tst {
private final Xop_section_list__fxt fxt = new Xop_section_list__fxt();
- @Test public void Extract__basic() {
+ @Test public void Basic() {
fxt.Exec__parse
( "== Hdr 1 =="
, "Para 1"
@@ -30,52 +30,26 @@ public class Xop_section_list__tst {
, "== Hdr 3 =="
, "Para 3"
);
- fxt.Test__extract_bry_or_null("Hdr 1"
+ fxt.Test__slice_bry_or_null("Hdr 1"
, "== Hdr 1 =="
, "Para 1"
);
- fxt.Test__extract_bry_or_null("Hdr 2"
+ fxt.Test__slice_bry_or_null("Hdr 2"
, "== Hdr 2 =="
, "Para 2"
);
- fxt.Test__extract_bry_or_null("Hdr 3"
+ fxt.Test__slice_bry_or_null("Hdr 3"
, "== Hdr 3 =="
, "Para 3"
);
}
- @Test public void Merge__basic() {
- fxt.Exec__parse
- ( "== Hdr 1 =="
- , "Para 1"
- , ""
- , "== Hdr 2 =="
- , "Para 2"
- , ""
- , "== Hdr 3 =="
- , "Para 3"
- );
- fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
- ( "== Hdr 2 =="
- , "abcd"
- ), String_.Concat_lines_nl_skip_last
- ( "== Hdr 1 =="
- , "Para 1"
- , ""
- , "== Hdr 2 =="
- , "abcd"
- , ""
- , "== Hdr 3 =="
- , "Para 3"
- )
- );
- }
}
class Xop_section_list__fxt {
private final Xop_section_list list = new Xop_section_list();
public void Exec__parse(String... lines) {
list.Parse(Bry_.new_u8(String_.Concat_lines_nl_skip_last(lines)));
}
- public void Test__extract_bry_or_null(String key, String... lines) {
+ public void Test__slice_bry_or_null(String key, String... lines) {
String expd = String_.Concat_lines_nl_skip_last(lines);
byte[] actl = list.Extract_bry_or_null(Bry_.new_u8(key));
Gftest.Eq__ary__lines(expd, actl, key);
diff --git a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_mgr.java b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_mgr.java
index 641254f46..3c23f8796 100644
--- a/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_mgr.java
+++ b/400_xowa/src/gplx/xowa/parsers/hdrs/sections/Xop_section_mgr.java
@@ -28,7 +28,7 @@ public class Xop_section_mgr implements Gfo_invk {
public void Init_by_wiki(Xowe_wiki wiki) {
enabled = wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, this); // SECTION_EDIT
}
- public byte[] Extract_section(Xoa_url url, Xoa_ttl ttl, byte[] src) {
+ public byte[] Extract_section(Xoae_app app, Xoa_url url, Xoa_ttl ttl, byte[] src) {
// return orig if section_editing not enabled
if (!enabled) return src;
@@ -39,8 +39,10 @@ public class Xop_section_mgr implements Gfo_invk {
// parse wikitext into list of headers
Xop_section_list section_list = new Xop_section_list().Parse(src);
byte[] rv = section_list.Extract_bry_or_null(section_key);
- if (rv == null)
- throw Err_.new_wo_type("section_key not found", "page", ttl.Full_db(), "section_key", section_key);
+ if (rv == null) {
+ app.Gui_mgr().Kit().Ask_ok("", "", String_.Format("Section extraction failed!\nPlease do not edit this page else data will be lost!!\n\nwiki={0}\npage={1}\nsection={2}", url.Wiki_bry(), ttl.Full_db(), section_key));
+ throw Err_.new_wo_type("section_key not found", "wiki", url.Wiki_bry(), "page", ttl.Full_db(), "section_key", section_key);
+ }
return rv;
}
public byte[] Merge_section(Xoa_url url, byte[] edit, byte[] orig) {