mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Section_edit: Add initial groundwork for generating html
This commit is contained in:
@@ -40,7 +40,8 @@ public class Xoh_html_wtr {
|
||||
public Ref_html_wtr Ref_wtr() {return ref_wtr;} private final Ref_html_wtr ref_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.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.Appe().Api_root().Addon().Parser__hdr__section_editable());
|
||||
ref_wtr.Init_by_wiki(wiki);
|
||||
}
|
||||
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {
|
||||
|
||||
@@ -20,5 +20,6 @@ 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 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;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,16 @@ 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.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||
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§ion=~{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
|
||||
@@ -48,7 +52,7 @@ public class Xoh_hdr_html {
|
||||
bfr.Add_byte(Byte_ascii.Angle_end); // '>'
|
||||
if (cfg.Toc__show()) {
|
||||
bfr.Add(Bry__span_lhs_bgn); // "<span class='mw-headline' id='"
|
||||
bfr.Add(toc_itm.Anch()); // '1'
|
||||
bfr.Add(toc_itm.Anch()); // 'Name_and_Etymology'
|
||||
bfr.Add(Bry__span_lhs_end); // "'>"
|
||||
}
|
||||
}
|
||||
@@ -64,6 +68,11 @@ public class Xoh_hdr_html {
|
||||
bfr.Add(Gfh_tag_.Span_rhs); // '</span>'
|
||||
bfr.Add(Bry__hdr_rhs_bgn).Add_int(hdr_num, 1, 1); // '</h', '2'
|
||||
bfr.Add(Bry__hdr_rhs_end); // '>\n'
|
||||
|
||||
// write section editable
|
||||
if (cfg.Section_editable()) {
|
||||
section_editable_fmt.Bld_many(bfr, hdr.Section_editable_page(), hdr.Section_editable_idx(), toc_itm.Anch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.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_imt1(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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user