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

Wiki: Support renamed folders (fix)

This commit is contained in:
gnosygnu
2017-02-06 22:12:56 -05:00
parent 6f9e92afff
commit 938beac9f9
4379 changed files with 0 additions and 327818 deletions

View File

@@ -1,27 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public class Xoa_page__commons_mgr {
public boolean Xowa_mockup() {return xowa_mockup;} public void Xowa_mockup_(boolean v) {xowa_mockup = v;} private boolean xowa_mockup;
public Xow_wiki Source_wiki() {return source_wiki;} public void Source_wiki_(Xow_wiki v) {source_wiki = v;} private Xow_wiki source_wiki;
public Xow_wiki Source_wiki_or(Xow_wiki or) {return source_wiki == null ? or : source_wiki;}
public void Clear() {
this.xowa_mockup = false;
this.source_wiki = null;
}
}

View File

@@ -1,43 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.htmls.*;
public class Xopage_html_data {
public Xopage_html_data(byte[] display_ttl, byte[] body) {
this.display_ttl = display_ttl;
this.body = body;
}
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
public byte[] Body() {return body;} private final byte[] body;
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_y_() {this.cbk_enabled = true;}
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
public void Apply(Xoa_page page) {
Xopg_html_data html_data = page.Html_data();
html_data.Html_restricted_n_();
html_data.Skip_parse_(Bool_.Y);
html_data.Display_ttl_(display_ttl);
html_data.Custom_body_(this.Body());
html_data.Custom_head_tags().Copy(head_tags);
html_data.Custom_tail_tags().Copy(tail_tags);
html_data.Cbk_enabled_(cbk_enabled);
}
public static Xopage_html_data err_(String msg) {return new Xopage_html_data(Bry_.Empty, Bry_.new_u8(msg));}
}

View File

@@ -1,56 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.bits.*;
public class Xopg_module_mgr {
public boolean Math_exists() {return math_exists;} public void Math_exists_(boolean v) {math_exists = v;} private boolean math_exists;
public boolean Imap_exists() {return imap_exists;} public void Imap_exists_(boolean v) {imap_exists = v;} private boolean imap_exists;
public boolean Gallery_packed_exists() {return gallery_packed_exists;} public void Gallery_packed_exists_(boolean v) {gallery_packed_exists = v;} private boolean gallery_packed_exists;
public boolean Hiero_exists() {return hiero_exists;} public void Hiero_exists_(boolean v) {hiero_exists = v;} private boolean hiero_exists;
public void Init(boolean math, boolean imap, boolean packed, boolean hiero) {
this.math_exists = math;
this.imap_exists = imap;
this.gallery_packed_exists = packed;
this.hiero_exists = hiero;
}
public int Flag() {return Calc_flag(math_exists, imap_exists, gallery_packed_exists, hiero_exists);}
public void Flag_(int v) {
this.math_exists = Bitmask_.Has_int(v, Tid_math);
this.imap_exists = Bitmask_.Has_int(v, Tid_imap);
this.gallery_packed_exists = Bitmask_.Has_int(v, Tid_packed);
this.hiero_exists = Bitmask_.Has_int(v, Tid_hiero);
}
public void Clear() {
math_exists = imap_exists = gallery_packed_exists = hiero_exists = false;
}
private static int Calc_flag(boolean math, boolean imap, boolean packed, boolean hiero) {
int rv = 0;
if (math) rv = Bitmask_.Add_int(rv, Tid_math);
if (imap) rv = Bitmask_.Add_int(rv, Tid_imap);
if (packed) rv = Bitmask_.Add_int(rv, Tid_packed);
if (hiero) rv = Bitmask_.Add_int(rv, Tid_hiero);
return rv;
}
private static final int // SERIALIZED; only supports 8 different types
Tid_math = 1
, Tid_imap = 2
, Tid_packed = 4
, Tid_hiero = 8
;
public static final int Tid_null = 0;
}

View File

@@ -1,21 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public class Xopg_page_ {
public static final byte Tid_read = 0, Tid_edit = 1, Tid_html = 2;
}

View File

@@ -1,49 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.xowa.wikis.pages.htmls.*;
public class Xopg_page_heading implements Bfr_arg {
private Xowe_wiki wiki;
private Xopg_html_data html_data;
private byte[] ttl_full_db;
private byte[] display_title;
private boolean mode_is_read;
public Xopg_page_heading Init(Xowe_wiki wiki, boolean mode_is_read, Xopg_html_data html_data, byte[] ttl_full_db, byte[] display_title) {
this.wiki = wiki;
this.mode_is_read = mode_is_read;
this.ttl_full_db = ttl_full_db;
this.html_data = html_data;
this.display_title = display_title;
return this;
}
public void Bfr_arg__add(Bry_bfr bfr) {
if (html_data.Xtn_pgbnr() != null) return; // pgbnr exists; don't add title
byte[] edit_lead_section = Bry_.Empty;
if ( wiki.Parser_mgr().Hdr__section_editable__mgr().Enabled()
&& mode_is_read) {
Bry_bfr tmp_bfr = Bry_bfr_.New();
wiki.Parser_mgr().Hdr__section_editable__mgr().Write_html(tmp_bfr, ttl_full_db, Bry_.Empty, Bry__lead_section_hint);
edit_lead_section = tmp_bfr.To_bry_and_clear();
}
fmtr.Bld_many(bfr, display_title, edit_lead_section);
}
private static final byte[] Bry__lead_section_hint = Bry_.new_u8("(Lead)");
private final Bry_fmt fmtr = Bry_fmt.Auto_nl_apos("<h1 id='firstHeading' class='firstHeading'>~{page_title}~{edit_lead_section}</h1>"); // <span>~{page_title}</span>
}

View File

@@ -1,29 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.guis.views.*;
public class Xopg_tab_data {
public Xog_tab_itm Tab() {return tab;} public void Tab_(Xog_tab_itm v) {this.tab = v;} private Xog_tab_itm tab;
public boolean Cancel_show() {return cancel_show;} public void Cancel_show_y_() {this.cancel_show = true;} private boolean cancel_show; // used for Special:Search
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
public void Clear() {
this.cancel_show = false;
this.tab = null;
close_mgr.Clear();
}
}

View File

@@ -1,62 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.btries.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
public class Xopg_tmpl_prepend_mgr {
private Bry_bfr[] stack = Bry_bfr_.Ary_empty; private int stack_len, stack_max;
public void Clear() {
stack = Bry_bfr_.Ary_empty; stack_len = stack_max = 0;
}
public boolean Tmpl_args_parsing() {return tmpl_args_parsing;} public void Tmpl_args_parsing_(boolean v) {tmpl_args_parsing = v;} private boolean tmpl_args_parsing;
public Xopg_tmpl_prepend_mgr Bgn(Bry_bfr bfr) {
int new_len = stack_len + 1;
if (new_len > stack_max) {
stack_max += 8;
Bry_bfr[] new_stack = new Bry_bfr[stack_max];
Array_.Copy_to(stack, new_stack, 0);
stack = new_stack;
}
stack[stack_len] = bfr;
stack_len = new_len;
return this;
}
public void End(Xop_ctx ctx, Bry_bfr bfr, byte[] val, int val_len, boolean called_from_tmpl) {
if ( val_len > 0 // val is not empty
&& tmpl_prepend_nl_trie.Match_bgn(val, 0, val_len) != null // val starts with {| : ; # *; REF.MW:Parser.php|braceSubstitution
) {
boolean add = true;
if (called_from_tmpl) { // called from tmpl
for (int i = stack_len - 1; i > -1; --i) { // iterate backwards over tmpl_stack;
Bry_bfr stack_bfr = stack[i];
switch (stack_bfr.Get_at_last_or_nil_if_empty()) {
case Byte_ascii.Null: continue; // bfr is empty; ignore it
case Byte_ascii.Nl: add = false; i = -1; break; // bfr ends in \n; don't add and stop; PAGE:bn.w:লিওনেল_মেসি |ko.w:도쿄_지하철_히비야_선|DATE:2014-05-27
default: i = -1; break; // bfr has char; stop
}
}
}
else // called from func arg; always add \n; EX:vi.w:Friedrich_II_của_Phổ; DATE:2014-04-26
add = true;
if (add)
bfr.Add_byte(Byte_ascii.Nl);
}
if (called_from_tmpl) --stack_len;
}
private static final Btrie_fast_mgr tmpl_prepend_nl_trie = Xop_curly_bgn_lxr.tmpl_bgn_trie_();
}

View File

@@ -1,200 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.vnts.*;
import gplx.xowa.guis.views.*; import gplx.xowa.parsers.utils.*;
import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.redirects.*;
public class Xow_page_mgr implements Gfo_invk {
private final Xowe_wiki wiki;
public Xow_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xoae_page Load_page_by_ttl (Xoa_ttl ttl) {return Load_page(ttl, Bool_.N);}
public Xoae_page Load_page_by_ttl_for_msg (Xoa_ttl ttl) {return Load_page(ttl, Bool_.Y);}
private Xoae_page Load_page(Xoa_ttl ttl, boolean called_from_msg) {
Xoae_page rv = Xoae_page.New(wiki, ttl);
Load_by_ns(rv, wiki.Utl__url_parser().Parse(ttl.Raw()), ttl, called_from_msg);
return rv;
}
private void Load_by_ns(Xoae_page rv, Xoa_url url, Xoa_ttl ttl, boolean called_from_msg) {
rv.Url_(url); // NOTE: must update page.Url(); should combine with Xoae_page.New()
// WORKAROUND: loop twice in order to allow redirects from regular page to special
for (int i = 0; i < 2; i++) {
Xow_ns ns = ttl.Ns();
switch (ns.Id()) {
case Xow_ns_.Tid__special: // Special pages are built (not loaded from db)
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
Xopg_redirect_itm redirect_itm = rv.Redirect_trail().Itms__get_at_nth_or_null();
if (redirect_itm != null) {
rv.Redirect_trail().Clear(); // clear needed; EX: Special:Random -> [[Redirected_page]] -> {must clear here} -> [[Page]]
Load_by_ns(rv, redirect_itm.Url(), redirect_itm.Ttl(), called_from_msg);
}
return;
case Xow_ns_.Tid__mediawiki: // MediaWiki msgs can either be loaded from memory, or from database
if ( !called_from_msg // if called_from_msg, fall through to actual data retrieval below, else infinite loop; DATE:2014-05-09
&& Xow_page_tid.Identify_by_ttl(ttl.Page_db()) == Xow_page_tid.Tid_wikitext // skip ".js" and ".css" pages in MediaWiki; DATE:2014-06-13
) {
Xol_lang_itm lang = wiki.Lang();
byte[] msg_key = ttl.Page_db();
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
msg_key = lang.Case_mgr().Case_build_1st_lower(tmp_bfr, msg_key, 0, msg_key.length);
byte[] msg_val = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), msg_key).Val(); // NOTE: do not change to Get_msg_val; Get_msg_val, also replaces $1 with values, and $1 needs to be preserved for callers;
rv.Db().Text().Text_bry_(msg_val);
tmp_bfr.Mkr_rls();
return;
}
break;
}
Xoa_ttl redirect_ttl = Load_from_db(rv, ns, ttl, url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
// GOTO_BY_LOOP: handle redirect to special
if (redirect_ttl != null && redirect_ttl.Ns().Id_is_special()) {
ttl = redirect_ttl;
url = wiki.Utl__url_parser().Parse(ttl.Raw()); // update url w/ redirected ttl; need to update qargs else will redirect to correct ttl (Special:XowaCfg) but not qargs (grp=xowa.addon.math); EX:src=Options/Math; trg=Special:XowaCfg?grp=xowa.addon.math; DATE:2017-01-02
rv.Redirect_trail().Clear();
rv.Db().Page().Exists_y_();
}
// not a redirect to special; just exit
else
return;
}
}
public Xoa_ttl Load_from_db(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean redirect_force) {
int redirects = 0;
Xowd_page_itm page_row = Xowd_page_itm.new_tmp();
while (true) { // loop until (a) no more redirects or (b) page not found
// load from page table
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(page_row, ns, ttl.Page_db());
if (!exists) {rv.Db().Page().Exists_n_(); return ttl;}
if (wiki.App().Mode().Tid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
wiki.Appe().Usr_dlg().Prog_many("", "", "loading page for ~{0}", ttl.Raw());
// load page_info
rv.Db().Page().Id_(page_row.Id()).Modified_on_(page_row.Modified_on()).Html_db_id_(page_row.Html_db_id());
// load from text table
wiki.Db_mgr().Load_mgr().Load_page(page_row, ns);
byte[] wtxt = page_row.Text();
rv.Db().Text().Text_bry_(wtxt);
if (redirect_force) return ttl; // redirect_force passed; return page now, even if page is a redirect elsewhere; NOTE: only applies to WTXT, not HTML
// handle redirects for html_dbs
if ( page_row.Redirect_id() > 0 // redirect exists
&& Bry_.Len_eq_0(wtxt)) { // wikitext is not found
Redirect_to_html_page(rv, wiki, page_row);
return ttl;
}
// handle redirects
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect(wtxt);
if ( redirect_ttl == null // not a redirect
|| redirects++ > 4) // too many redirects; something went wrong
return redirect_ttl;
// redirect; do some bookkeeping and reset ns / ttl
// NOTE: this adds the target ttl to redirect_mgr (#REDIRECT [[A]]); note that special redirects will add source ttl; DATE:2016-07-31
rv.Redirect_trail().Itms__add__article(Xoa_url.New(wiki, rv.Ttl()), rv.Ttl(), wtxt);// NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
rv.Ttl_(redirect_ttl);
ns = redirect_ttl.Ns();
ttl = redirect_ttl;
}
}
private void Redirect_to_html_page(Xoae_page rv, Xowe_wiki wiki, Xowd_page_itm page_row) { // handle redirects for HtmlDbs; PAGE:fr.b:Wikibooks DATE:2016-07-14
// load redirect
Xowd_page_itm redirect_row = new Xowd_page_itm();
wiki.Db_mgr().Load_mgr().Load_by_id(redirect_row, page_row.Redirect_id());
if (rv.Db().Page().Exists_n()) {
return;
}
// set redirect data
rv.Db().Page().Id_(redirect_row.Id()).Modified_on_(redirect_row.Modified_on()).Html_db_id_(redirect_row.Html_db_id());
Xoa_ttl redirect_ttl = wiki.Ttl_parse(redirect_row.Ns_id(), redirect_row.Ttl_page_db());
rv.Ttl_(redirect_ttl);
rv.Redirect_trail().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, Bry_.Empty); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
}
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl) {return Load_page_and_parse(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
wiki.Init_assert();
Xoae_page page = Xoae_page.New(wiki, ttl); page.Tab_data().Tab_(tab);
// COMMENT: breaks position-restore when moving back from history; if (tab != null) tab.Page_ref_(page); // HACK: (1) null check for http server; (2) Page_ref_(page) needed for log in xobc
this.Load_by_ns(page, url, ttl, false);
if (page.Db().Page().Exists_n()) { // page doesn't exist; try variants
boolean vnt_missing = true;
Xol_vnt_mgr vnt_mgr = lang.Vnt_mgr();
if (vnt_mgr.Enabled()) { // if vnt enabled, then try to load by vnt form; DATE:2015-09-15
gplx.xowa.wikis.data.tbls.Xowd_page_itm page_itm = vnt_mgr.Convert_mgr().Convert_ttl(wiki, ttl);
if (page_itm != null && page_itm.Exists()) {
Xoa_ttl vnt_ttl = Xoa_ttl.Parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
page = this.Load_page(vnt_ttl, false);
vnt_missing = page.Db().Page().Exists_n();
}
}
if (vnt_missing) {
if (ttl.Ns().Id_is_file()) {
Xowe_wiki commons_wiki = (Xowe_wiki)wiki.Appe().Wiki_mgr().Get_by_or_null(wiki.Commons_wiki_key());
if (commons_wiki != null) { // commons exists
if (!Bry_.Eq(wiki.Domain_bry(), commons_wiki.Domain_bry())) { // !Bry_.Eq is recursion guard
Xoae_page rv = commons_wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, true);
if (rv.Db().Page().Exists()) {
rv.Commons_mgr().Source_wiki_(wiki);
return rv;
}
else {
rv.Db().Page().Exists_y_();
page.Commons_mgr().Xowa_mockup_(true);
return page;
}
}
}
}
else {
page.Db().Page().Exists_n_();
return page;
}
}
}
if (page.Db().Page().Exists_n()) return page; // NOTE: commons can return null page
page.Tab_data().Tab_(tab);
page.Lang_(lang);
if (parse_page)
wiki.Parser_mgr().Parse(page, false); // NOTE: do not clear page b/c reused for search
return page;
}
public void Redirect(Xoae_page page, byte[] page_bry) {
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki, page_bry);
Xoa_url trg_url = Xoa_url.New(wiki.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url);
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}
public void Redirect2(Xowe_wiki wiki2, Xoae_page page, byte[] page_bry) {
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki2, page_bry);
Xoa_url trg_url = Xoa_url.New(wiki2.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url);
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
wiki2.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_create_enabled_)) wiki.Db_mgr().Save_mgr().Create_enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_update_modified_on_enabled_)) wiki.Db_mgr().Save_mgr().Update_modified_on_enabled_(m.ReadYn("v"));
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_create_enabled_ = "create_enabled_", Invk_update_modified_on_enabled_ = "update_modified_on_enabled_";
}

View File

@@ -1,87 +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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.guis.views.*;
import gplx.xowa.addons.wikis.pages.syncs.core.*;
public class Xowe_page_mgr {
private final Xowe_wiki wiki;
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final Xosync_read_mgr read_mgr = new Xosync_read_mgr();
public Xowe_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xosync_read_mgr Sync_mgr() {return read_mgr;}
public void Init_by_wiki(Xowe_wiki wiki) {
read_mgr.Init_by_wiki(wiki);
}
public Xoae_page Load_page(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) {
Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
Wait_for_popups(wiki.App());
Xowe_wiki_.Rls_mem_if_needed(wiki);
// load page meta; wait_for_popups
Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
ttl = page.Ttl(); // note that Load_page_and_parse can redirect ttl; EX: Special:Random -> A; DATE:2017-01-05
Wait_for_popups(wiki.App());
// auto-update
read_mgr.Auto_update(wiki, page, ttl);
// load from html_db
boolean from_html_db = page.Db().Page().Html_db_id() != -1;
boolean read_from_html_db_preferred = wiki.Html__hdump_mgr().Load_mgr().Read_preferred();
if (from_html_db) {
if (read_from_html_db_preferred) {
wiki.Html__hdump_mgr().Load_mgr().Load_by_xowe(page);
from_html_db = Bry_.Len_gt_0(page.Db().Html().Html_bry()); // NOTE: archive.org has some wtxt_dbs which included page|html_db_id without actual html_dbs; DATE:2016-06-22
}
else
from_html_db = false;
}
// load from wtxt_db; occurs if (a) no html_db_id; (b) option says to use wtxt db; (c) html_db_id exists, but no html_db;
if (!from_html_db) {
wiki.Parser_mgr().Parse(page, false);
// load from html_db if no wtxt found and option just marked as not read_preferred
if ( Bry_.Len_eq_0(page.Db().Text().Text_bry()) // no wtxt found
&& !ttl.Ns().Id_is_special() // skip special
&& !read_from_html_db_preferred // read preferred not marked
) {
wiki.Html__hdump_mgr().Load_mgr().Load_by_xowe(page);
from_html_db = Bry_.Len_gt_0(page.Db().Html().Html_bry());
}
}
page.Html_data().Hdump_exists_(from_html_db);
// if [[Category]], generate catlinks (subc; page; file)
if (ttl.Ns().Id_is_ctg()) {
wiki.Ctg__catpage_mgr().Write_catpage(tmp_bfr, page);
if (from_html_db)
page.Db().Html().Html_bry_(Bry_.Add(page.Db().Html().Html_bry(), tmp_bfr.To_bry_and_clear()));
else
page.Html_data().Catpage_data_(tmp_bfr.To_bry_and_clear());
}
return page;
}
private static void Wait_for_popups(Xoa_app app) {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items
if (app.Mode().Tid_is_http()) return;
int wait_count = 0;
while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
gplx.core.threads.Thread_adp_.Sleep(10);
}
}

View File

@@ -1,30 +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.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_db_data {
public Xopg_db_page Page() {return page;} private final Xopg_db_page page = new Xopg_db_page();
public Xopg_db_text Text() {return text;} private final Xopg_db_text text = new Xopg_db_text();
public Xopg_db_html Html() {return html;} private final Xopg_db_html html = new Xopg_db_html();
public Xopg_db_protection Protection() {return protection;} private final Xopg_db_protection protection = new Xopg_db_protection();
public void Clear() {
page.Clear();
html.Clear();
text.Clear();
protection.Clear();
}
}

View File

@@ -1,31 +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.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_db_html {
public Xopg_db_html() {this.Clear();}
public byte[] Html_bry() {return html_bry;} private byte[] html_bry;
public void Html_bry_(byte[] v) {this.html_bry = v;}
public int Zip_tid() {return zip_tid;} private int zip_tid;
public int Hzip_tid() {return hzip_tid;} private int hzip_tid;
public void Zip_tids_(int zip_tid, int hzip_tid) {this.zip_tid = zip_tid; this.hzip_tid = hzip_tid;}
public void Clear() {
html_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
zip_tid = 0;
hzip_tid = 0;
}
}

View File

@@ -1,63 +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.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.wikis.nss.*;
public class Xopg_db_page {
public Xopg_db_page() {this.Clear();}
// from page table
public boolean Exists() {return exists;} private boolean exists;
public boolean Exists_n() {return !exists;}
public int Id() {return id;} private int id;
public int Ns_id() {return ns_id;} private int ns_id;
public byte[] Ttl_bry() {return ttl_bry;} private byte[] ttl_bry;
public DateAdp Modified_on() {return modified_on;} private DateAdp modified_on;
public int Text_len() {return text_len;} private int text_len;
public int Text_db_id() {return text_db_id;} private int text_db_id;
public int Html_db_id() {return html_db_id;} private int html_db_id;
public int Redirect_to_id() {return redirect_to_id;} private int redirect_to_id;
public int Score() {return score;} private int score;
public void Exists_y_() {this.Exists_(Bool_.Y);}
public void Exists_n_() {this.Exists_(Bool_.N);}
public void Exists_(boolean v) {this.exists = v;}
public Xopg_db_page Id_(int v) {this.id = v; return this;}
public Xopg_db_page Modified_on_(DateAdp v) {this.modified_on = v; return this;}
public Xopg_db_page Html_db_id_(int v) {this.html_db_id = v; return this;}
// wiki-related
public Xow_ns Ns() {return ns;} private Xow_ns ns;
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
// init methods
public Xopg_db_page Init_by_db(int id, int ns_id, byte[] ttl_bry, DateAdp modified_on, int text_len, int text_db_id, int html_db_id, int redirect_to_id, int score) {
this.id = id; this.ns_id = ns_id; this.ttl_bry = ttl_bry; this.modified_on = modified_on;
this.text_len = text_len; this.text_db_id = text_db_id; this.html_db_id = html_db_id; this.redirect_to_id = redirect_to_id; this.score = score;
this.ns = null; this.ttl = null;
return this;
}
public Xopg_db_page Init_by_wiki(Xow_wiki wiki) {
this.ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
this.ttl = wiki.Ttl_parse(ns_id, ttl_bry);
return this;
}
public void Clear() {
this.exists = true;
this.modified_on = DateAdp_.MinValue; // NOTE: must set to MinValue else some tests will fail
this.html_db_id = -1; // NOTE: must set to -1 b/c code checks for -1 to indicate no html; DATE:2016-07-14
}
}

View File

@@ -1,32 +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.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_db_protection {
public Xopg_db_protection() {this.Clear();}
public byte[] User() {return user;} public Xopg_db_protection User_(byte[] v) {user = v; return this;} private byte[] user;
public byte[] Protection_level() {return protection_level;} public Xopg_db_protection Protection_level_(byte[] v) {protection_level = v; return this;} private byte[] protection_level;
public byte[] Protection_expiry() {return protection_expiry;} private byte[] protection_expiry;
public void Clear() {
this.user = Bry_.Empty;
this.protection_level = Bry_.Empty;
this.protection_expiry = Bry__protection_expiry__infinite;
}
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinity");// NOTE: means page never expires; must be "infinity" as per en.w:Module:Effective_protection_expiry DATE:2016-08-05
}

View File

@@ -1,25 +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.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_db_text {
public byte[] Text_bry() {return text_bry;} private byte[] text_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
public void Text_bry_(byte[] v) {this.text_bry = v;}
public void Clear() {
// text_bry = Bry_.Empty; // TOMBSTONE: do not set to Bry_.Empty else causes mass parse to noop; also causes Options/Files.Clear to noop; DATE:2016-07-15
}
}

View File

@@ -1,25 +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.wikis.pages.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.addons.htmls.tocs.*;
public class Xopg_hdump_data {
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
public void Clear() {
imgs.Clear();
}
}

View File

@@ -1,96 +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.wikis.pages.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.lnkis.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.addons.htmls.tocs.*;
import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.xtns.indicators.*;
public class Xopg_html_data {
public Xopg_lnki_list Redlink_list() {return redlink_list;} private final Xopg_lnki_list redlink_list = new Xopg_lnki_list();
public boolean Html_restricted() {return html_restricted;} private boolean html_restricted = true;
public void Html_restricted_(boolean v) {html_restricted = v;} public void Html_restricted_n_() {Html_restricted_(Bool_.N);} public void Html_restricted_y_() {Html_restricted_(Bool_.Y);}
public byte[] Display_ttl() {
return ( display_ttl_vnt != null // -{T}- was in document
&& display_ttl == null // {{DISPLAYTITLE}} does not exist
&& lang_convert_content // __NOCONVERTCONTENT__ exists
&& lang_convert_title // __NOCONVERTTITLE__ exists
)
? display_ttl_vnt // return variant title; DATE:2014-08-29
: display_ttl // return normal title
;
}
public Xopg_html_data Display_ttl_(byte[] v) {display_ttl = v; return this;} private byte[] display_ttl;
public boolean Mode_wtxt_shown() {synchronized (this) {return mode_wtxt_shown;}} public void Mode_wtxt_shown_y_() {synchronized (this) {this.mode_wtxt_shown = true;}} private boolean mode_wtxt_shown;
public byte[] Display_ttl_vnt() {return display_ttl_vnt;} public void Display_ttl_vnt_(byte[] v) {display_ttl_vnt = v;} private byte[] display_ttl_vnt;
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {content_sub = v;} private byte[] content_sub;
public Xopg_page_heading Page_heading() {return page_heading;} private final Xopg_page_heading page_heading = new Xopg_page_heading();
public String Bmk_pos() {return html_bmk_pos;} public void Bmk_pos_(String v) {html_bmk_pos = v;} private String html_bmk_pos;
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr_.Reset(255);
public byte[] Edit_preview_w_dbg() {return Bry_.Add(xtn_scribunto_dbg, edit_preview);} public void Edit_preview_(byte[] v) {edit_preview = v;} private byte[] edit_preview = Bry_.Empty;
public int Lnke_autonumber_next() {return lnke_autonumber++;} private int lnke_autonumber = 1;
public int Sect_uid() {return sect_uid;} private int sect_uid = -1; public int Sect_uid_next() {return ++sect_uid;}
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_(boolean v) {this.cbk_enabled = v;}
public boolean Hdump_exists() {return hdump_exists;} private boolean hdump_exists; public void Hdump_exists_(boolean v) {this.hdump_exists = v;}
public byte[] Catpage_data() {return catpage_data;} private byte[] catpage_data; public void Catpage_data_(byte[] v) {this.catpage_data = v;}
public boolean Writing_hdr_for_toc() {return writing_hdr_for_toc;} private boolean writing_hdr_for_toc; public void Writing_hdr_for_toc_y_() {writing_hdr_for_toc = Bool_.Y;} public void Writing_hdr_for_toc_n_() {writing_hdr_for_toc = Bool_.N;}
public Xoh_toc_mgr Toc_mgr() {return toc_mgr;} private final Xoh_toc_mgr toc_mgr = new Xoh_toc_mgr();
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
public Indicator_html_bldr Indicators() {return indicators;} private final Indicator_html_bldr indicators = new Indicator_html_bldr();
public int Xtn_gallery_next_id() {return ++xtn_gallery_next_id;} private int xtn_gallery_next_id = -1;
public boolean Xtn_gallery_packed_exists() {return xtn_gallery_packed_exists;} public void Xtn_gallery_packed_exists_y_() {xtn_gallery_packed_exists = true;} private boolean xtn_gallery_packed_exists;
public boolean Xtn_imap_exists() {return xtn_imap_exists;} public void Xtn_imap_exists_y_() {xtn_imap_exists = true;} private boolean xtn_imap_exists;
public int Xtn_imap_next_id() {return ++xtn_imap_next_id;} private int xtn_imap_next_id; // NOTE: must keep separate imap_id b/c html_elem_id is not always set;
public byte[] Xtn_search_text() {return xtn_search_txt;} public void Xtn_search_text_(byte[] v) {xtn_search_txt = v;} private byte[] xtn_search_txt = Bry_.Empty;
public byte[] Xtn_scribunto_dbg() {return xtn_scribunto_dbg;} public void Xtn_scribunto_dbg_(byte[] v) {xtn_scribunto_dbg = Bry_.Add(xtn_scribunto_dbg, v);} private byte[] xtn_scribunto_dbg = Bry_.Empty;
public Pgbnr_itm Xtn_pgbnr() {return xtn_pgbnr;} public void Xtn_pgbnr_(Pgbnr_itm v) {xtn_pgbnr = v;} private Pgbnr_itm xtn_pgbnr;
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
public boolean Skip_parse() {return skip_parse;} public void Skip_parse_(boolean v) {skip_parse = v;} private boolean skip_parse;
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
public byte[] Custom_body() {return custom_body;} public Xopg_html_data Custom_body_(byte[] v) {custom_body = v; return this;} private byte[] custom_body;
public byte[] Custom_tab_name() {return custom_tab_name;} public Xopg_html_data Custom_tab_name_(byte[] v) {custom_tab_name = v; return this;} private byte[] custom_tab_name;
public void Clear() {
redlink_list.Clear();
toc_mgr.Clear();
html_restricted = true;
display_ttl = content_sub = display_ttl_vnt = null;
lang_convert_content = lang_convert_title = true;
lnke_autonumber = 1;
sect_uid = -1;
xtn_skin_mgr.Clear();
xtn_gallery_packed_exists = false;
xtn_imap_next_id = 0; xtn_gallery_next_id = -1;
xtn_imap_exists = false;
xtn_search_txt = Bry_.Empty;
xtn_scribunto_dbg = Bry_.Empty;
xtn_pgbnr = null;
module_mgr.Clear();
custom_html = custom_tab_name = null;
indicators.Clear();
this.mode_wtxt_shown = false;
}
public void Init_by_page(Xoa_ttl ttl) {
redlink_list.Disabled_(ttl.Ns().Id_is_module());
}
}

View File

@@ -1,22 +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.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";
}

View File

@@ -1,22 +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.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public interface Xopg_lnki_itm {
Xoa_ttl Ttl();
int Html_uid(); void Html_uid_(int v);
}

View File

@@ -1,51 +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.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.parsers.lnkis.*;
public class Xopg_lnki_list {
private final List_adp list = List_adp_.New();
private int lnki_idx;
public Xopg_lnki_list() {
this.Clear();
}
public boolean Disabled() {return disabled;} private boolean disabled; public Xopg_lnki_list Disabled_(boolean v) {this.disabled = v; return this;}
public int Len() {return list.Len();}
public Xopg_lnki_itm Get_at(int i) {return (Xopg_lnki_itm)list.Get_at(i);}
public void Add_direct(Xopg_lnki_itm lnki) {list.Add(lnki);} // add lnki directly to list without changing html_uid; needed for hdumps which call "Fill_page" to transfer from Xoh_page to Xoae_page
public void Add(Xopg_lnki_itm lnki) {
if (disabled) return;
Xoa_ttl ttl = lnki.Ttl(); if (ttl == null) return; // ttl is null for invalid links
Xow_ns ns = ttl.Ns();
lnki.Html_uid_(++lnki_idx); // NOTE: set html_id in order html to print out "id='xowa_lnki_1'; want to print out id for consistency's sake, even if these links won't be check for redlinks; DATE:2015-05-07
if ( ns.Id_is_file_or_media() // ignore files which will usually not be in local wiki (most are in commons), and whose html is built up separately
|| (ns.Id_is_ctg() && !ttl.ForceLiteralLink()) // ignore ctgs which have their own html builder, unless it is literal; EX: [[:Category:A]]; DATE:2014-02-24
|| ns.Id_is_special() // ignore special, especially Search; EX: Special:Search/Earth
|| ttl.Anch_bgn() == Anch_bgn_anchor_only // anchor only link; EX: [[#anchor]]
|| ttl.Wik_itm() != null // xwiki lnki; EX: simplewiki links in homewiki; [[simplewiki:Earth]]
)
return;
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; OLD_COMMENT: NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
list.Clear();
}
public static final String Lnki_id_prefix = "xolnki_";
private static final int Anch_bgn_anchor_only = 1; // signifies lnki which is only anchor; EX: [[#anchor]]
}

View File

@@ -1,95 +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.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.guis.cbks.js.*;
import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.langs.vnts.*;
public class Xopg_redlink_mgr implements Gfo_invk {
private final Xoa_page page; private final Xog_js_wkr js_wkr;
public Xopg_redlink_mgr(Xoa_page page, Xog_js_wkr js_wkr) {this.page = page; this.js_wkr = js_wkr; }
private void Redlink() {
// init; exit if redlink disabled (on Module pages)
Xopg_lnki_list lnki_list = page.Html_data().Redlink_list(); if (lnki_list.Disabled()) return;
Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
Xow_wiki wiki = page.Wiki();
Ordered_hash lnki_hash = Ordered_hash_.New_bry();
// create unique list of page_rows
int len = lnki_list.Len();
usr_dlg.Log_many("", "", "redlink.redlink_bgn: page=~{0} total_links=~{1}", page.Ttl().Raw(), len);
for (int i = 0; i < len; ++i) {
if (usr_dlg.Canceled()) return;
Xoa_ttl ttl = lnki_list.Get_at(i).Ttl();
Xowd_page_itm page_row = new Xowd_page_itm().Ttl_(ttl);
byte[] full_db = ttl.Full_db();
if (!lnki_hash.Has(full_db)) // only search page_table once for multiple identical redlinks; EX: "[[Missing]] [[Missing]]"
lnki_hash.Add(full_db, page_row);
}
// load page_rows from page_tbl
int page_len = lnki_hash.Len();
for (int i = 0; i < page_len; i += Batch_size) {
if (usr_dlg.Canceled()) return;
int end = i + Batch_size; if (end > page_len) end = page_len;
wiki.Data__core_mgr().Tbl__page().Select_in__ns_ttl(usr_dlg, lnki_hash, wiki.Ns_mgr(), Bool_.Y, i, end);
// wiki.Db_mgr().Load_mgr().Load_by_ttls(usr_dlg, lnki_hash, Bool_.Y, i, end);
}
// cross-check page_rows against lnki_list; redlink if missing;
boolean vnt_enabled = wiki.Lang().Vnt_mgr().Enabled();
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
int redlink_count = 0;
for (int i = 0; i < len; ++i) {
Xopg_lnki_itm lnki = lnki_list.Get_at(i);
byte[] full_db = lnki.Ttl().Full_db();
Xowd_page_itm page_row = (Xowd_page_itm)lnki_hash.Get_by(full_db);
if (page_row.Exists()) continue; // page exists; nothing to do;
// for vnt languages, convert missing ttl to vnt and check again; EX: [[zh_cn]] will check for page_ttl for [[zh_tw]]
String html_uid = Xopg_lnki_list.Lnki_id_prefix + Int_.To_str(lnki.Html_uid());
if (vnt_enabled) {
Xowd_page_itm vnt_page = vnt_mgr.Convert_mgr().Convert_ttl(wiki, lnki.Ttl()); // check db
if (vnt_page != null) { // vnt found; update href to point to vnt
Xoa_ttl vnt_ttl = wiki.Ttl_parse(lnki.Ttl().Ns().Id(), vnt_page.Ttl_page_db());
js_wkr.Html_atr_set(html_uid, "href", "/wiki/" + String_.new_u8(vnt_ttl.Full_url()));
if (!String_.Eq(vnt_mgr.Html__lnki_style(), "")) js_wkr.Html_atr_set(html_uid, "style", vnt_mgr.Html__lnki_style()); // colorize for debugging
continue;
}
}
// lnki is missing; redlink it
if (usr_dlg.Canceled()) return;
Js_img_mgr.Update_link_missing(js_wkr, html_uid);
++redlink_count;
}
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0}", redlink_count);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_run)) {synchronized (this) {Redlink();}} // NOTE: attempt to eliminate random IndexBounds errors; DATE:2014-09-02
else return Gfo_invk_.Rv_unhandled;
return this;
} public static final String Invk_run = "run";
private static final int Batch_size = 32;
public static void Run_async(Xoa_page pg, Xog_js_wkr js_wkr) {
try {
Xopg_redlink_mgr mgr = new Xopg_redlink_mgr(pg, js_wkr);
gplx.core.threads.Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, mgr, gplx.xowa.wikis.pages.lnkis.Xopg_redlink_mgr.Invk_run);
} catch (Exception e) {Gfo_usr_dlg_.Instance.Warn_many("", "", "page.thread.redlinks: page=~{0} err=~{1}", pg.Ttl().Raw(), Err_.Message_gplx_full(e));}
}
}

View File

@@ -1,29 +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.wikis.pages.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_redirect_itm {
public Xopg_redirect_itm(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {
this.url = url;
this.ttl = ttl;
this.wikitext = wikitext;
}
public Xoa_url Url() {return url;} private final Xoa_url url; // EX: "en.wikipedia.org/wiki/A"
public Xoa_ttl Ttl() {return ttl;} private final Xoa_ttl ttl; // EX: "A"
public byte[] Wikitext() {return wikitext;} private final byte[] wikitext; // EX: "#REDIRECT [[A]]"
public boolean By_wikitext() {return wikitext != null;} // true if by "#REDIRECT [[A]]"; false if by Special:Random, Special:Search, etc.;
}

View File

@@ -1,57 +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.wikis.pages.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.specials.*;
public class Xopg_redirect_mgr {
private final List_adp itms = List_adp_.New();
public int Itms__len() {return itms.Len();}
public byte[] Itms__get_wtxt_at_0th_or_null() {return itms.Len() == 0 ? null : this.Itms__get_at(0).Wikitext();}
public Xopg_redirect_itm Itms__get_at_0th_or_null() {return itms.Len() == 0 ? null : (Xopg_redirect_itm)itms.Get_at(0);}
public Xopg_redirect_itm Itms__get_at_nth_or_null() {return itms.Len() == 0 ? null : (Xopg_redirect_itm)itms.Get_at(itms.Len() - 1);}
public Xopg_redirect_itm Itms__get_at(int i) {return (Xopg_redirect_itm)itms.Get_at(i);}
public void Itms__add__article(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {Itms__add(url, ttl, wikitext);}
public void Itms__add__special(Xow_wiki wiki, Xow_special_meta meta, Keyval... url_args) {
// build url and include args if available
byte[] url_bry = meta.Ttl_bry();
int url_args_len = url_args.length;
if (url_args_len > 0) {
Bry_bfr bfr = Bry_bfr_.New();
bfr.Add(url_bry);
for (int i = 0; i < url_args_len; ++i) {
Keyval url_arg = url_args[i];
bfr.Add_byte(i == 0 ? Byte_ascii.Question : Byte_ascii.Amp);
bfr.Add_str_u8(url_arg.Key());
bfr.Add_byte(Byte_ascii.Eq);
bfr.Add_obj(url_arg.Val());
}
url_bry = bfr.To_bry_and_clear();
}
// create objects and add to list
Xoa_url url = wiki.Utl__url_parser().Parse(url_bry);
Xoa_ttl ttl = wiki.Ttl_parse(meta.Ttl_bry());
this.Itms__add(url, ttl, null);
}
private void Itms__add(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {
Xopg_redirect_itm itm = new Xopg_redirect_itm(url, ttl, wikitext);
itms.Add(itm);
}
public void Clear() {
itms.Clear();
}
}

View File

@@ -1,53 +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.wikis.pages.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.specials.*;
public class Xopg_redirect_mgr__tst {
@Before public void init() {fxt.Clear();} private final Xopg_redirect_mgr__fxt fxt = new Xopg_redirect_mgr__fxt();
@Test public void Basic() {
fxt.Test__Itms__add__special(fxt.Make_meta("XowaTest"), Keyval_.Ary_empty, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest", "Special:XowaTest", null));
}
@Test public void Args() {
fxt.Test__Itms__add__special
( fxt.Make_meta("XowaTest"), Keyval_.Ary(Keyval_.new_("k1", "v1"), Keyval_.new_("k2", "v2"), Keyval_.new_("k3", "v3"))
, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest?k1=v1&k2=v2&k3=v3", "Special:XowaTest", null)
);
}
}
class Xopg_redirect_mgr__fxt {
private Xow_wiki wiki;
private final Xopg_redirect_mgr mgr = new Xopg_redirect_mgr();
public void Clear() {
mgr.Clear();
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
public Xow_special_meta Make_meta(String key) {return Xow_special_meta.New_xo(key, "test display name");}
public Xopg_redirect_itm Make__itm(String url_str, String ttl_str, String wikitext) {
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(url_str));
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(ttl_str));
return new Xopg_redirect_itm(url, ttl, Bry_.new_u8_safe(wikitext));
}
public void Test__Itms__add__special(Xow_special_meta meta, Keyval[] url_args, Xopg_redirect_itm expd) {
mgr.Itms__add__special(wiki, meta, url_args);
Xopg_redirect_itm actl = mgr.Itms__get_at(0);
Gftest.Eq__bry(expd.Ttl().Raw(), actl.Ttl().Raw(), "ttl");
Gftest.Eq__str(expd.Url().To_str(), actl.Url().To_str(), "url");
Gftest.Eq__bry(expd.Wikitext(), actl.Wikitext(), "wikitext");
}
}

View File

@@ -1,33 +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.wikis.pages.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_xtn_skin_fmtr_arg implements gplx.core.brys.Bfr_arg {
private Xoae_page page; private byte xtn_skin_tid;
public Xopg_xtn_skin_fmtr_arg(Xoae_page page, byte xtn_skin_tid) {
this.page = page; this.xtn_skin_tid = xtn_skin_tid;
}
public void Bfr_arg__add(Bry_bfr bfr) {
Xopg_xtn_skin_mgr mgr = page.Html_data().Xtn_skin_mgr();
int len = mgr.Count();
for (int i = 0; i < len; ++i) {
Xopg_xtn_skin_itm itm = mgr.Get_at(i);
if (itm.Tid() == xtn_skin_tid)
itm.Write(bfr, page);
}
}
}

View File

@@ -1,23 +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.wikis.pages.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public interface Xopg_xtn_skin_itm {
byte Tid();
byte[] Key();
void Write(Bry_bfr bfr, Xoae_page page);
}

View File

@@ -1,25 +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.wikis.pages.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_xtn_skin_itm_stub implements Xopg_xtn_skin_itm {
private final byte[] val;
public Xopg_xtn_skin_itm_stub(byte[] val) {this.val = val;}
public byte Tid() {return Xopg_xtn_skin_itm_tid.Tid_sidebar;}
public byte[] Key() {return Bry_.Empty;}
public void Write(Bry_bfr bfr, Xoae_page page) {bfr.Add(val);}
}

View File

@@ -1,21 +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.wikis.pages.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_xtn_skin_itm_tid {
public static final byte Tid_sidebar = 0;
}

View File

@@ -1,26 +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.wikis.pages.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_xtn_skin_mgr {
private Ordered_hash hash = Ordered_hash_.New_bry();
public int Count() {return hash.Count();}
public void Add(Xopg_xtn_skin_itm itm) {hash.Add_if_dupe_use_1st(itm.Key(), itm);}
public Xopg_xtn_skin_itm Get_at(int i) {return (Xopg_xtn_skin_itm)hash.Get_at(i);}
public Xopg_xtn_skin_itm Get_or_null(byte[] key) {return (Xopg_xtn_skin_itm)hash.Get_by(key);}
public void Clear() {hash.Clear();}
}

View File

@@ -1,31 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.guis.cbks.*; import gplx.core.gfobjs.*;
public class Xopg_alertify_ {
public static void Add_tags(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url alertify_root = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "lib", "alertify");
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.core.css")));
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.bootstrap.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "alertify-0.3.11.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "xo-alertify-0.0.1.js")));
}
public static void Exec_log(Xog_json_wkr wkr, String msg) {
wkr.Send_json("xo.alertify.log_by_str", Gfobj_nde.New().Add_str("msg", msg));
}
}

View File

@@ -1,88 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.langs.htmls.*;
public class Xopg_tag_itm {
Xopg_tag_itm(byte tid, byte[] node, byte[] href, byte[] body, Keyval... atrs) {
this.tid = tid;
this.node = node;
this.href = href;
this.body = body;
this.atrs = atrs;
}
public final String Source = "xowa";
public byte Tid() {return tid;} private final byte tid;
public byte[] Node() {return node;} private final byte[] node;
public byte[] Href() {return href;} private final byte[] href;
public byte[] Body() {return body;} private final byte[] body;
public Keyval[] Atrs() {return atrs;} private final Keyval[] atrs;
public void To_html(Bry_bfr bfr) {
bfr.Add_byte(Byte_ascii.Angle_bgn);
bfr.Add(node);
To_html_atr(bfr, "data-source", "xowa");
int len = atrs.length;
for (int i = 0; i < len; ++i) {
Keyval atr = atrs[i];
To_html_atr(bfr, atr.Key(), atr.Val_to_str_or_empty());
}
bfr.Add_byte(Byte_ascii.Angle_end);
if (!Bry_.Eq(node, Gfh_tag_.Bry__link)) {
if (body != null) {
bfr.Add_byte_nl();
bfr.Add(body);
bfr.Add_byte_nl();
}
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
bfr.Add(node);
bfr.Add_byte(Byte_ascii.Angle_end);
}
bfr.Add_byte_nl();
}
private static void To_html_atr(Bry_bfr bfr, String key, String val) {
bfr.Add_byte_space();
bfr.Add_str_a7(key);
bfr.Add_byte(Byte_ascii.Eq);
bfr.Add_byte(Byte_ascii.Quote);
bfr.Add_str_a7(val);
bfr.Add_byte(Byte_ascii.Quote);
}
public static final byte Tid__css_file = 0, Tid__css_code = 1, Tid__js_file = 2, Tid__js_code = 3, Tid__htm_frag = 4;
private static final Keyval
Tag__type_css = Keyval_.new_("type", "text/css"), Tag__type_js = Keyval_.new_("type", "text/javascript"), Tag__type_html = Keyval_.new_("type", "text/html")
, Tag__rel_stylesheet = Keyval_.new_("rel", "stylesheet");
public static Xopg_tag_itm New_css_file(Io_url href_url) {
byte[] href = href_url.To_http_file_bry();
return new Xopg_tag_itm(Tid__css_file, Gfh_tag_.Bry__link , href, null, Tag__type_css, Tag__rel_stylesheet, Keyval_.new_("href", String_.new_u8(href)));
}
public static Xopg_tag_itm New_css_code(byte[] code) {
return new Xopg_tag_itm(Tid__css_code, Gfh_tag_.Bry__style , null, code, Tag__type_css);
}
public static Xopg_tag_itm New_js_file(Io_url src_url) {
byte[] src = src_url.To_http_file_bry();
return new Xopg_tag_itm(Tid__js_file , Gfh_tag_.Bry__script, src , null, Tag__type_js, Keyval_.new_("src", String_.new_u8(src)));
}
public static Xopg_tag_itm New_js_code(String code) {return New_js_code(Bry_.new_u8(code));}
public static Xopg_tag_itm New_js_code(byte[] code) {
return new Xopg_tag_itm(Tid__js_code , Gfh_tag_.Bry__script, null, code, Tag__type_js);
}
public static Xopg_tag_itm New_htm_frag(Io_url url, String id) {
byte[] html = Io_mgr.Instance.LoadFilBry(url);
return new Xopg_tag_itm(Tid__htm_frag, Gfh_tag_.Bry__script, null, html, Tag__type_html, Keyval_.new_("id", id));
}
}

View File

@@ -1,51 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_mgr {
private final List_adp list = List_adp_.New();
public Xopg_tag_mgr(boolean pos_is_head) {this.pos_is_head = pos_is_head;}
public boolean Pos_is_head() {return pos_is_head;} private final boolean pos_is_head;
public int Len() {return list.Len();}
public Xopg_tag_itm Get_at(int i) {return (Xopg_tag_itm)list.Get_at(i);}
public void Add(Xopg_tag_itm... ary) {for (Xopg_tag_itm itm : ary) list.Add(itm);}
public void Copy(Xopg_tag_mgr src) {
int len = src.Len();
for (int i = 0; i < len; ++i)
this.Add(src.Get_at(i));
}
public byte[] To_html(Bry_bfr bfr) {
int len = this.Len();
for (int i = 0; i < len; ++i) {
Xopg_tag_itm tag = this.Get_at(i);
tag.To_html(bfr);
}
return bfr.To_bry_and_clear();
}
public byte[] To_html__style(Bry_bfr bfr) {
int len = this.Len();
for (int i = 0; i < len; ++i) {
Xopg_tag_itm tag = this.Get_at(i);
if ( Bry_.Eq(tag.Node(), gplx.langs.htmls.Gfh_tag_.Bry__style)
&& tag.Body() != null
) {
tag.To_html(bfr);
}
}
return bfr.To_bry_and_clear();
}
}

View File

@@ -1,112 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.langs.htmls.*;
public class Xopg_tag_wtr {
public static boolean Loader_as_script_static = true; // TEST
public static byte[] Write(Bry_bfr bfr, boolean write_loader_tag, Xopg_tag_wtr_cbk cbk, Xopg_tag_mgr tag_mgr) {
boolean loader_as_script = Loader_as_script_static; // allow disabling for dekstop later
boolean embed_loader = !gplx.core.envs.Op_sys.Cur().Tid_is_drd(); // PERF: drd will embed in bundle.js
// get files_count
int len = tag_mgr.Len();
int files_total = 0;
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
if (loader_as_script) {
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file:
++files_total;
break;
}
}
}
// bgn loader_as_script
if (loader_as_script) {
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_lhs_w_type).Add_byte_nl();
if (embed_loader && tag_mgr.Pos_is_head())
Wtr.Add_loader_func(bfr);
if (files_total > 0) Wtr.Add_files_bgn(bfr);
}
// write tags
len = tag_mgr.Len();
int files_idx = 0;
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
if (loader_as_script) {
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file:
Wtr.Add_files_itm(bfr, itm, files_idx++);
break;
}
continue;
}
else
cbk.Write_tag(bfr, itm);
}
// end loader_as_script
if (loader_as_script) {
if (files_total > 0) Wtr.Add_files_end(bfr, files_total);
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_rhs).Add_byte_nl();
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file: continue;
}
cbk.Write_tag(bfr, itm);
}
}
return bfr.To_bry_and_clear();
}
static class Wtr { //#*nested
public static void Add_loader_func(Bry_bfr bfr) {
bfr.Add_str_a7_w_nl(" function load_files_sequentially(files, idx, done_cbk) {");
bfr.Add_str_a7_w_nl(" if (files[idx]) { // idx is valid");
bfr.Add_str_a7_w_nl(" var script = document.createElement('script');");
bfr.Add_str_a7_w_nl(" script.setAttribute('type','text/javascript');");
bfr.Add_str_a7_w_nl(" script.setAttribute('src', files[idx]);");
bfr.Add_str_a7_w_nl(" script.onload = function(){");
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, ++idx, done_cbk); // load next file");
bfr.Add_str_a7_w_nl(" };");
bfr.Add_str_a7_w_nl(" document.getElementsByTagName('head')[0].appendChild(script)");
bfr.Add_str_a7_w_nl(" }");
bfr.Add_str_a7_w_nl(" else { // idx is not valid; finished;");
bfr.Add_str_a7_w_nl(" done_cbk();");
bfr.Add_str_a7_w_nl(" }");
bfr.Add_str_a7_w_nl(" }");
}
public static void Add_files_bgn(Bry_bfr bfr) {
bfr.Add_str_a7_w_nl(" var files =");
}
public static void Add_files_itm(Bry_bfr bfr, Xopg_tag_itm itm, int idx) {
bfr.Add_str_a7(idx == 0 ? " [ '" : " , '");
bfr.Add(itm.Href());
bfr.Add_byte_apos().Add_byte_nl();
}
public static void Add_files_end(Bry_bfr bfr, int files_count) {
bfr.Add_str_a7_w_nl(" ];");
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, 0, function() {");
bfr.Add_str_a7_w_nl(" console.log('javascript files loaded: count=" + files_count + "');");
bfr.Add_str_a7_w_nl(" });");
}
}
}

View File

@@ -1,73 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_wtr_ {
public static void Add__core(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "core");
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("Namespace_.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("String_.js")));
}
public static void Add__xocss(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "core");
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xocss_core-0.0.1.css")));
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xoimg_core-0.0.1.css")));
}
public static void Add__xohelp(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "help");
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xohelp-0.0.1.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("xohelp-0.0.1.js")));
}
public static void Add__xolog(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xolog");
head_tags.Add(Xopg_tag_itm.New_css_file(dir.GenSubFil_nest("xo.log.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.log.js")));
}
public static void Add__xotmpl(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xotmpl");
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.tmpl.js")));
}
public static void Add__xoelem(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoelem");
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.elem.js")));
}
public static void Add__xoajax(Xopg_tag_mgr head_tags, Io_url http_root, Xoa_app app) {
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoajax");
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.app.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest(Get_app_js_file(app))));
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.server.js")));
}
public static void Add__gui__progbars(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "gui", "progbars");
head_tags.Add(Xopg_tag_itm.New_css_file(dir.GenSubFil_nest("Progbar.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("Progbar.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("Progbar_util.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";
}
public static void Add__mustache(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "mustache", "mustache-2.2.1.js")));
}
public static void Add__jquery(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "jquery", "jquery-1.11.3.js")));
}
public static void Add__notifyjs(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "notifyjs", "notifyjs-0.3.1.js")));
}
}

View File

@@ -1,24 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public interface Xopg_tag_wtr_cbk {
void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm);
}
class Xopg_tag_wtr_cbk__basic implements Xopg_tag_wtr_cbk {
public void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm) {itm.To_html(bfr);}
}

View File

@@ -1,21 +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.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_wtr_cbk_ {
public static final Xopg_tag_wtr_cbk Basic = new Xopg_tag_wtr_cbk__basic();
}

View File

@@ -1,57 +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.wikis.pages.wtxts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
public class Xopg_toc_mgr {
private Xop_hdr_tkn[] hdrs_ary = Xop_hdr_tkn.Ary_empty; private int hdrs_max, hdrs_len;
public boolean Enabled() {
return !flag__notoc // __NOTOC__ not set
&& hdrs_len != 0 // never show TOC if 0 headers, even when __FORCETOC__
&& ( hdrs_len > Hdrs_min // show TOC automatically if 4 or more headers
|| flag__toc // or when __TOC__ specified (EX: 2 headers)
|| flag__forcetoc // or when __FORCETOC__ to (a) show TOC when < 4 headers or (b) let TOC show at default position; __TOC__ would force TOC to show at __TOC__; __FORCETOC__ can be placed at bottom of page
)
;
}
public boolean Flag__toc() {return flag__toc;}
public void Flag__toc_y_() {flag__toc = true;} private boolean flag__toc; // __TOC__
public void Flag__forcetoc_y_() {flag__forcetoc = true;} private boolean flag__forcetoc; // __FORCETOC__
public void Flag__notoc_y_() {flag__notoc = true;} private boolean flag__notoc; // __NOTOC__
public int Len() {return hdrs_len;}
public Xop_hdr_tkn Get_at(int i) {return hdrs_ary[i];}
public void Add(Xop_hdr_tkn hdr) {
// add tkn
if (hdrs_len == 0) hdr.First_in_doc_y_(); // if 1st hdr, mark it; easier for toc-insertion logic later
// add to list; logic for bounds checking
int new_len = hdrs_len + 1;
if (new_len > hdrs_max) {
hdrs_max = (new_len * 2) + 1;
hdrs_ary = (Xop_hdr_tkn[])Array_.Resize(hdrs_ary, hdrs_max);
}
hdrs_ary[hdrs_len] = hdr;
hdrs_len = new_len;
}
public void Clear() {
flag__toc = flag__forcetoc = flag__notoc = false;
hdrs_len = 0; hdrs_max = 0;
hdrs_ary = Xop_hdr_tkn.Ary_empty;
}
public static final int Hdrs_min = 3;
}

View File

@@ -1,32 +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.wikis.pages.wtxts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_wtxt_data {
public Xopg_toc_mgr Toc() {return toc;} private final Xopg_toc_mgr toc = new Xopg_toc_mgr();
public int Ctgs__len() {return ctg_hash == null ? 0 : ctg_hash.Len();} private Ordered_hash ctg_hash;
public Xoa_ttl Ctgs__get_at(int i) {return (Xoa_ttl)ctg_hash.Get_at(i);}
public Xoa_ttl[] Ctgs__to_ary() {return (Xoa_ttl[])ctg_hash.To_ary(Xoa_ttl.class);}
public void Ctgs__add(Xoa_ttl ttl) {
if (ctg_hash == null) ctg_hash = Ordered_hash_.New_bry();
ctg_hash.Add_if_dupe_use_1st(ttl.Full_db(), ttl);
}
public void Clear() {
if (ctg_hash != null) ctg_hash.Clear();
toc.Clear();
}
}