mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.3.1'
This commit is contained in:
@@ -18,8 +18,8 @@ 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.redirects.*;
|
||||
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;}
|
||||
@@ -69,12 +69,21 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
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);
|
||||
rv.Db().Page().Id_(page_row.Id()).Modified_on_(page_row.Modified_on()).Html_db_id_(page_row.Html_db_id());
|
||||
if (redirect_force) return; // redirect_force passed; return page now, even if page is a redirect elsewhere
|
||||
if (redirect_force) return; // 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;
|
||||
}
|
||||
|
||||
// handle redirects
|
||||
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect(wtxt);
|
||||
@@ -89,6 +98,20 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
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().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();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xopg_db_data {
|
||||
public void Clear() {
|
||||
page.Clear();
|
||||
html.Clear();
|
||||
// text.Clear();
|
||||
// protection.Clear();
|
||||
text.Clear();
|
||||
protection.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@ 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 byte[] Html_bry() {return html_bry;} private byte[] html_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
|
||||
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 = null; zip_tid = -1; hzip_tid = -1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,17 @@ 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 = true;
|
||||
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 = DateAdp_.MinValue; // NOTE: must set to MinValue else some tests will fail
|
||||
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 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;
|
||||
|
||||
@@ -55,6 +56,8 @@ public class Xopg_db_page {
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
exists = true;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,16 @@ 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 byte[] User() {return user;} public Xopg_db_protection User_(byte[] v) {user = v; return this;} private byte[] user = Bry_.Empty;
|
||||
public byte[] Protection_level() {return protection_level;} public Xopg_db_protection Protection_level_(byte[] v) {protection_level = v; return this;} private byte[] protection_level = Bry_.Empty;
|
||||
public byte[] Protection_expiry() {return protection_expiry;} private byte[] protection_expiry = Bry__protection_expiry__infinite;
|
||||
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("infinite");
|
||||
}
|
||||
|
||||
@@ -19,4 +19,7 @@ package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gpl
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@ 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.htmls.tocs.*;
|
||||
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 Xoh_toc_wtr Toc_wtr() {return toc_wtr;} private final Xoh_toc_wtr toc_wtr = new Xoh_toc_wtr();
|
||||
public void Clear() {
|
||||
imgs.Clear();
|
||||
toc_wtr.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ 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.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 {
|
||||
private Ordered_hash ctg_hash;
|
||||
@@ -48,6 +48,9 @@ public class Xopg_html_data {
|
||||
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 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();
|
||||
@@ -68,6 +71,7 @@ public class Xopg_html_data {
|
||||
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;
|
||||
|
||||
57
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_toc_mgr.java
Normal file
57
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_toc_mgr.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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;
|
||||
}
|
||||
24
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_wtxt_data.java
Normal file
24
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_wtxt_data.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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 void Clear() {
|
||||
toc.Clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user