1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Section_edit: Show section when section_key is passed

This commit is contained in:
gnosygnu
2016-12-05 17:43:00 -05:00
parent d64136ab9d
commit 150454fd67
25 changed files with 293 additions and 165 deletions

View File

@@ -225,8 +225,11 @@ 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())
if (mgr.Html_capable()) {
data_raw = wiki.Parser_mgr().Hdr__section_editable__mgr().Extract_section(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)
}
else
bfr.Add(data_raw);
if (data_raw_len > 0) // do not add nl if empty String

View File

@@ -41,8 +41,6 @@ public class Xoh_html_wtr {
public void Init_by_wiki(Xowe_wiki wiki) {
cfg.Toc__show_(Bool_.Y).Lnki__title_(true).Lnki__visited_y_().Lnki__id_(Bool_.Y); // NOTE: set during Init_by_wiki, b/c all tests assume these are false
// cfg.Section_editable_(wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, cfg)); // COMMENT:section_edit DATE:2016-12-04
ref_wtr.Init_by_wiki(wiki);
}
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {

View File

@@ -16,16 +16,9 @@ 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.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
public class Xoh_html_wtr_cfg implements Gfo_invk {
public class Xoh_html_wtr_cfg {
public boolean Toc__show() {return toc__show;} public Xoh_html_wtr_cfg Toc__show_(boolean v) {toc__show = v; return this;} private boolean toc__show;
public boolean Lnki__id() {return lnki__id;} public Xoh_html_wtr_cfg Lnki__id_(boolean v) {lnki__id = v; return this;} private boolean lnki__id;
public boolean Lnki__title() {return lnki__title;} public Xoh_html_wtr_cfg Lnki__title_(boolean v) {lnki__title = v; return this;} private boolean lnki__title;
public boolean Lnki__visited() {return lnki__visited;} public Xoh_html_wtr_cfg Lnki__visited_y_() {lnki__visited = true; return this;} private boolean lnki__visited;
public boolean Section_editable() {return section_editable;} public Xoh_html_wtr_cfg Section_editable_(boolean v) {section_editable = v; return this;} private boolean section_editable;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled)) section_editable = m.ReadBool("v");
else return Gfo_invk_.Rv_unhandled;
return this;
}
}

View File

@@ -23,9 +23,6 @@ import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.addons.htmls.tocs.*;
public class Xoh_hdr_html {
private final Bry_bfr hdr_text_bfr = Bry_bfr_.New();
private final Xoh_toc_itm invalid_toc_itm = new Xoh_toc_itm().Set__txt(Bry_.Empty, Bry_.Empty);
private final Bry_fmt section_editable_fmt = Bry_fmt.Auto_nl_apos
( "<span class='mw-editsection'><span class='mw-editsection-bracket'>[</span><a href='/wiki/~{page_ttl}?action=edit&section=~{section_idx}' title='Edit section: ~{section_name}'>edit</a><span class='mw-editsection-bracket'>]</span></span>"
);
public void Write_html(Bry_bfr bfr, Xoh_html_wtr wtr, Xowe_wiki wiki, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoh_html_wtr_cfg cfg, Xop_tkn_grp grp, int sub_idx, byte[] src, Xop_hdr_tkn hdr) {
// init
@@ -68,8 +65,8 @@ public class Xoh_hdr_html {
bfr.Add(Gfh_tag_.Span_rhs); // '</span>'
// write section editable
if (cfg.Section_editable())
section_editable_fmt.Bld_many(bfr, hdr.Section_editable_page(), hdr.Section_editable_idx(), toc_itm.Anch());
if (wiki.Parser_mgr().Hdr__section_editable__mgr().Enabled())
wiki.Parser_mgr().Hdr__section_editable__mgr().Write_html(bfr, src, page.Ttl().Full_db(), hdr, toc_itm.Anch());
bfr.Add(Bry__hdr_rhs_bgn).Add_int(hdr_num, 1, 1); // '</h', '2'
bfr.Add(Bry__hdr_rhs_end); // '>\n'

View File

@@ -18,9 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 void Write_imt(Bry_bfr bfr, Xop_ctx ctx, Xop_tkn_itm tkn) {
Xop_hdr_tkn hdr_tkn = (Xop_hdr_tkn)tkn;
ctx.Wiki().Parser_mgr().Hdr__section_editable__imt_fmt().Bld_many_to_bry(bfr, hdr_tkn.Section_editable_page(), hdr_tkn.Section_editable_idx());
}
public static final String Cfg__section_editing__enabled = "section_editing.enabled";
}