mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.1.1
This commit is contained in:
@@ -1,78 +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.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.htmls.hdumps.core.*; import gplx.xowa.htmls.hdumps.pages.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.htmls.heads.*;
|
||||
public class Xog_page implements Xoa_page {
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xoa_url Url() {return page_url;} private Xoa_url page_url;
|
||||
public byte[] Url_bry_safe() {return page_url == null ? Bry_.Empty : page_url.Raw();}
|
||||
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public boolean Exists() {return exists;} public Xog_page Exists_n_() {exists = false; return this;} private boolean exists = true;
|
||||
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public int Version_id() {return version_id;} public void Version_id_(int v) {version_id = v;} private int version_id;
|
||||
public int Img_count() {return img_count;} public void Img_count_(int v) {img_count = v;} private int img_count;
|
||||
public Xopg_module_mgr Head_mgr() {return module_mgr;} private Xopg_module_mgr module_mgr = new Xopg_module_mgr();
|
||||
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty;
|
||||
public byte[] Page_body() {return page_body;} public void Page_body_(byte[] v) {this.page_body = v;} private byte[] page_body;
|
||||
public byte[] Display_ttl() {return display_ttl;} public void Display_ttl_(byte[] v) {this.display_ttl = v;} private byte[] display_ttl;
|
||||
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {this.content_sub = v;} private byte[] content_sub;
|
||||
public byte[] Sidebar_div() {return sidebar_div;} public void Sidebar_div_(byte[] v) {this.sidebar_div = v;} private byte[] sidebar_div;
|
||||
public Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public Xohd_data_itm__base[] Img_itms() {return img_itms;} public void Img_itms_(Xohd_data_itm__base[] v) {this.img_itms = v;} private Xohd_data_itm__base[] img_itms;
|
||||
public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New();
|
||||
public Xog_page Init(Xow_wiki wiki, int page_id, Xoa_url page_url, Xoa_ttl page_ttl) {
|
||||
this.wiki = wiki;
|
||||
this.page_id = page_id; this.page_url = page_url; this.page_ttl = page_ttl;
|
||||
content_sub = sidebar_div = Bry_.Empty;
|
||||
display_ttl = null;
|
||||
img_itms = Xohd_data_itm__base.Ary_empty;
|
||||
module_mgr.Clear();
|
||||
gallery_itms.Clear();
|
||||
redlink_uids.Clear();
|
||||
commons_mgr.Clear();
|
||||
return this;
|
||||
}
|
||||
public void Ctor_from_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
page_id = page.Revision_data().Id();
|
||||
page_body = page.Hdump_data().Body();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
Xoh_head_mgr mod_mgr = html_data.Head_mgr();
|
||||
module_mgr.Init(mod_mgr.Itm__mathjax().Enabled(), mod_mgr.Itm__popups().Bind_hover_area(), mod_mgr.Itm__gallery().Enabled(), mod_mgr.Itm__hiero().Enabled());
|
||||
display_ttl = html_data.Display_ttl();
|
||||
content_sub = html_data.Content_sub();
|
||||
sidebar_div = Save_sidebars(tmp_bfr, page, html_data);
|
||||
}
|
||||
private static byte[] Save_sidebars(Bry_bfr tmp_bfr, Xoae_page page, Xopg_html_data html_data) {
|
||||
Xopg_xtn_skin_mgr mgr = html_data.Xtn_skin_mgr();
|
||||
int len = mgr.Count();
|
||||
boolean sidebar_exists = false;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_xtn_skin_itm itm = mgr.Get_at(i);
|
||||
if (itm.Tid() == Xopg_xtn_skin_itm_tid.Tid_sidebar) {
|
||||
sidebar_exists = true;
|
||||
itm.Write(tmp_bfr, page);
|
||||
}
|
||||
}
|
||||
return sidebar_exists ? tmp_bfr.To_bry_and_clear() : null;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.threads.*; import gplx.core.net.*;
|
||||
import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
class Xogv_page_load_wkr implements Gfo_thread_wkr, GfoInvkAble {
|
||||
private final Xoav_wiki_mgr wiki_mgr; private final Gfo_url_parser url_parser;
|
||||
private final Xogv_tab_base tab; private final Xog_history_itm old_itm, new_itm;
|
||||
@@ -28,15 +29,15 @@ class Xogv_page_load_wkr implements Gfo_thread_wkr, GfoInvkAble {
|
||||
public String Name() {return Thread_name;} public static final String Thread_name = "xowa.page_load";
|
||||
public boolean Resume() {return true;}
|
||||
public void Exec() {
|
||||
Xog_page new_hpg = Fetch_page(new_itm.Wiki(), new_itm.Page(), new_itm.Qarg());
|
||||
Xoh_page new_hpg = Fetch_page(new_itm.Wiki(), new_itm.Page(), new_itm.Qarg());
|
||||
tab.Show_page(old_itm, new_itm, new_hpg);
|
||||
}
|
||||
private Xog_page Fetch_page(byte[] wiki_domain, byte[] page_bry, byte[] qarg_bry) {
|
||||
private Xoh_page Fetch_page(byte[] wiki_domain, byte[] page_bry, byte[] qarg_bry) {
|
||||
Xowv_wiki wiki = wiki_mgr.Get_by_domain(wiki_domain);
|
||||
if (wiki == null) return new Xog_page().Exists_n_(); // wiki does not exist; happens with xwiki; PAGE:s.w:Photon; EX:[[wikt:transmit]]; DATE:2015-04-27
|
||||
if (wiki == null) return new Xoh_page().Exists_n_(); // wiki does not exist; happens with xwiki; PAGE:s.w:Photon; EX:[[wikt:transmit]]; DATE:2015-04-27
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(page_bry);
|
||||
Gfo_url url = url_parser.Parse(Bry_.Add(wiki_domain, Byte_ascii.Slash_bry, page_bry, qarg_bry));
|
||||
Xog_page rv = new Xog_page();
|
||||
Xoh_page rv = new Xoh_page();
|
||||
wiki.Pages_get(rv, url, ttl);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.htmls.hdumps.core.*; import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.wikis.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.core.threads.*;
|
||||
public abstract class Xogv_tab_base {
|
||||
@@ -28,28 +28,28 @@ public abstract class Xogv_tab_base {
|
||||
public Xog_history_stack History_stack() {return history_stack;} private final Xog_history_stack history_stack = new Xog_history_stack();
|
||||
public Xog_history_itm Cur_itm() {return history_stack.Cur_itm();}
|
||||
public Xow_wiki Get_wiki_or_null(byte[] key) {return wiki_mgr.Get_by_domain(key);}
|
||||
public Xog_page Go_to(byte[] page) {return Go_to(history_stack.Cur_itm().Wiki(), page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Xog_page Go_to(byte[] wiki, byte[] page) {return Go_to(wiki, page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Xog_page Go_to(byte[] wiki, byte[] page, byte[] anch, byte[] qarg, boolean redirect_force, String bmk_pos) {
|
||||
public Xoh_page Go_to(byte[] page) {return Go_to(history_stack.Cur_itm().Wiki(), page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Xoh_page Go_to(byte[] wiki, byte[] page) {return Go_to(wiki, page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Xoh_page Go_to(byte[] wiki, byte[] page, byte[] anch, byte[] qarg, boolean redirect_force, String bmk_pos) {
|
||||
Xog_history_itm old_itm = this.Cur_itm();
|
||||
Xog_history_itm new_itm = new Xog_history_itm(wiki, page, anch, qarg, redirect_force, bmk_pos);
|
||||
Xog_page rv = Fetch_page_and_show(old_itm, new_itm);
|
||||
Xoh_page rv = Fetch_page_and_show(old_itm, new_itm);
|
||||
if (rv.Exists())
|
||||
history_stack.Add(new_itm);
|
||||
return rv;
|
||||
}
|
||||
public Xog_page Go_bwd() {return Go_by_dir(Bool_.Y);}
|
||||
public Xog_page Go_fwd() {return Go_by_dir(Bool_.N);}
|
||||
public Xog_page Reload() {return Fetch_page_and_show(Cur_itm(), Cur_itm());}
|
||||
private Xog_page Go_by_dir(boolean bwd) {
|
||||
public Xoh_page Go_bwd() {return Go_by_dir(Bool_.Y);}
|
||||
public Xoh_page Go_fwd() {return Go_by_dir(Bool_.N);}
|
||||
public Xoh_page Reload() {return Fetch_page_and_show(Cur_itm(), Cur_itm());}
|
||||
private Xoh_page Go_by_dir(boolean bwd) {
|
||||
Xog_history_itm old_itm = this.Cur_itm();
|
||||
Xog_history_itm new_itm = bwd ? history_stack.Go_bwd() : history_stack.Go_fwd();
|
||||
return Fetch_page_and_show(old_itm, new_itm);
|
||||
}
|
||||
private Xog_page Fetch_page_and_show(Xog_history_itm old_itm, Xog_history_itm new_itm) {
|
||||
if (new_itm == Xog_history_itm.Null) return new Xog_page().Exists_n_();
|
||||
private Xoh_page Fetch_page_and_show(Xog_history_itm old_itm, Xog_history_itm new_itm) {
|
||||
if (new_itm == Xog_history_itm.Null) return new Xoh_page().Exists_n_();
|
||||
Fetch_page__bgn(new_itm.Wiki(), new_itm.Page(), new_itm.Qarg());
|
||||
Xog_page new_hpg = new Xog_page();
|
||||
Xoh_page new_hpg = new Xoh_page();
|
||||
// Thread_adp_.invk_(Xogv_page_load_wkr.Thread_name, new Xogv_page_load_wkr(wiki_mgr, url_parser, this, old_itm, new_itm), Xogv_page_load_wkr.Invk_exec).Start();
|
||||
thread_pool.Add_at_end(new Xogv_page_load_wkr(wiki_mgr, url_parser, this, old_itm, new_itm));
|
||||
thread_pool.Run();
|
||||
@@ -58,5 +58,5 @@ public abstract class Xogv_tab_base {
|
||||
@gplx.Virtual protected void Fetch_page__bgn(byte[] wiki_domain, byte[] page_bry, byte[] qarg_bry) {}
|
||||
public void Srl_save(Bry_bfr bfr) {history_stack.Srl_save(bfr);}
|
||||
public void Srl_load(byte[] raw) {history_stack.Srl_load(raw);}
|
||||
public abstract void Show_page(Xog_history_itm old_itm, Xog_history_itm new_itm, Xog_page new_hpg);
|
||||
public abstract void Show_page(Xog_history_itm old_itm, Xog_history_itm new_itm, Xoh_page new_hpg);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ class Xog_menu_bldr {
|
||||
public Xog_menu_bldr Add_grp_bgn(String key) {
|
||||
Indent();
|
||||
bfr.Add(Const_itm_grp_bgn_lhs);
|
||||
bfr.Add_str(key);
|
||||
bfr.Add_str_u8(key);
|
||||
bfr.Add(Const_itm_grp_bgn_rhs);
|
||||
Indent_add();
|
||||
return this;
|
||||
@@ -231,7 +231,7 @@ class Xog_menu_bldr {
|
||||
public Xog_menu_bldr Add_btn(String key) {
|
||||
Indent();
|
||||
bfr.Add(Const_itm_btn_bgn_lhs);
|
||||
bfr.Add_str(key);
|
||||
bfr.Add_str_u8(key);
|
||||
bfr.Add(Const_itm_btn_bgn_rhs);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Xog_url_wkr {
|
||||
if (!Xof_file_wkr.Show_img(fsdb, Xoa_app_.Usr_dlg(), wiki.File__bin_mgr(), wiki.File__mnt_mgr(), wiki.App().User().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), gplx.xowa.files.gui.Xog_js_wkr_.Noop, img_size, url_bldr, page))
|
||||
return Rslt_handled;
|
||||
}
|
||||
gplx.ios.IoItmFil fil = Io_mgr.Instance.QueryFil(href_url);
|
||||
gplx.core.ios.IoItmFil fil = Io_mgr.Instance.QueryFil(href_url);
|
||||
if (fil.Exists()) {
|
||||
ProcessAdp media_player = app.Prog_mgr().App_by_ext(href_url.Ext());
|
||||
media_player.Run(href_url);
|
||||
@@ -92,7 +92,7 @@ public class Xog_url_wkr {
|
||||
for (int i = 0; i < qargs_len; i++) {
|
||||
Gfo_qarg_itm arg = qargs[i];
|
||||
int anch_pos = Bry_find_.Find_bwd(arg.Val_bry(), Byte_ascii.Hash); // NOTE: must .FindBwd to handle Category args like de.wikipedia.org/wiki/Kategorie:Begriffskl%C3%A4rung?pagefrom=#::12%20PANZERDIVISION#mw-pages; DATE:2013-06-18
|
||||
if (anch_pos != Bry_.NotFound)
|
||||
if (anch_pos != Bry_find_.Not_found)
|
||||
arg.Val_bry_(Bry_.Mid(arg.Val_bry(), 0, anch_pos));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Load_page_wkr implements Gfo_thread_wkr {
|
||||
Thread_adp_.Sleep(10);
|
||||
if (hdump_enabled && page.Revision_data().Html_db_id() != -1) {
|
||||
// wiki.Parser_mgr().Parse(page, false);
|
||||
wiki.Html__hdump_rdr().Get_by_ttl(page);
|
||||
wiki.Html__hdump_mgr().Load_mgr().Load(page);
|
||||
}
|
||||
else
|
||||
wiki.Parser_mgr().Parse(page, false);
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
|
||||
GfoInvkAble_.InvkCmd_msg(cmd_sync, Invk_html_elem_atr_set, m);
|
||||
}
|
||||
}
|
||||
public void Html_redlink(String html_uid) {Html_doc_atr_append_or_set(html_uid, "class", gplx.xowa.htmls.lnkis.Xoh_redlink_utl.New_str);}
|
||||
public void Html_redlink(String html_uid) {Html_doc_atr_append_or_set(html_uid, "class", gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_redlink_utl.New_str);}
|
||||
private void Html_doc_atr_append_or_set(String elem_id, String atr_key, String atr_val) {
|
||||
GfoMsg m = GfoMsg_.new_cast_(Invk_html_doc_atr_append_or_set).Add("elem_id", elem_id).Add("atr_key", atr_key).Add("atr_val", atr_val);
|
||||
GfoInvkAble_.InvkCmd_msg(cmd_sync, Invk_html_doc_atr_append_or_set, m);
|
||||
|
||||
@@ -161,7 +161,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
return;
|
||||
}
|
||||
if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons
|
||||
if (page.Ttl().Anch_bgn() != Bry_.NotFound) page.Url().Anch_bry_(page.Ttl().Anch_txt()); // NOTE: occurs when page is a redirect to an anchor; EX: w:Duck race -> Rubber duck#Races
|
||||
if (page.Ttl().Anch_bgn() != Bry_find_.Not_found) page.Url().Anch_bry_(page.Ttl().Anch_txt()); // NOTE: occurs when page is a redirect to an anchor; EX: w:Duck race -> Rubber duck#Races
|
||||
history_mgr.Add(page);
|
||||
Xog_tab_itm_read_mgr.Show_page(this, page, true);
|
||||
if (app.Api_root().Usr().History().Enabled()) {
|
||||
@@ -177,7 +177,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
Xof_fsdb_mgr fsdb_mgr = wiki.File_mgr().Fsdb_mgr();
|
||||
async_wkr = new Xof_file_wkr(wiki.File__orig_mgr(), fsdb_mgr.Bin_mgr(), fsdb_mgr.Mnt_mgr(), app.Usere().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), html_itm, page, page.Hdump_data().Imgs());
|
||||
if (wiki.Html__hdump_enabled() && page.Revision_data().Html_db_id() == -1) {
|
||||
wiki.Html__hdump_wtr().Save(page);
|
||||
wiki.Html__hdump_mgr().Save_mgr().Save(page);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.gfui.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xog_tab_itm_edit_mgr {
|
||||
@@ -34,7 +34,7 @@ public class Xog_tab_itm_edit_mgr {
|
||||
Invalidate(wiki);
|
||||
page.Data_raw_(new_text);
|
||||
wiki.Parser_mgr().Parse(page, true); // refresh html
|
||||
if (wiki.Html__hdump_enabled()) wiki.Html__hdump_wtr().Save(page); // must go after wiki.Parse
|
||||
if (wiki.Html__hdump_enabled()) wiki.Html__hdump_mgr().Save_mgr().Save(page); // must go after wiki.Parse
|
||||
win_itm.Usr_dlg().Prog_one("", "", "saved page ~{0}", String_.new_u8(page.Ttl().Full_txt_raw())); // NOTE: show message after Parse, b/c Parse will flash "Loading page"; DATE:2014-05-17
|
||||
if (!quick_save) { // full_save; save page and go to read mode
|
||||
page.Html_data().Edit_preview_(Bry_.Empty);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
private void Win__link_clicked(String anchor_raw) {
|
||||
String url = url_box.Text();
|
||||
int pos = String_.FindFwd(url, gplx.langs.htmls.Html_tag_.Anchor_str);
|
||||
if (pos != Bry_.NotFound) url = String_.Mid(url, 0, pos);
|
||||
if (pos != Bry_find_.Not_found) url = String_.Mid(url, 0, pos);
|
||||
String anchor_str = Parse_evt_location_changing(anchor_raw);
|
||||
byte[] anchor_bry = Bry_.new_u8(anchor_str);
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab(); Xoae_page page = tab.Page();
|
||||
@@ -146,7 +146,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
}
|
||||
private static String Parse_evt_location_changing(String v) { // EX: about:blank#anchor -> anchor
|
||||
int pos = String_.FindFwd(v, gplx.langs.htmls.Html_tag_.Anchor_str);
|
||||
return pos == Bry_.NotFound
|
||||
return pos == Bry_find_.Not_found
|
||||
? null
|
||||
: String_.Mid(v, pos + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user