1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-08-17 23:27:07 -04:00
parent 56128795f5
commit df7fcf8eae
231 changed files with 2433 additions and 3347 deletions

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.gui; import gplx.*; import gplx.xowa.*;
public class Xog_page_mode {
public static final byte Tid_read = 0, Tid_edit = 1, Tid_html = 2;
}

View File

@@ -71,7 +71,7 @@ public class Xog_url_wkr {
Io_url href_url = Io_url_.http_any_(String_.new_utf8_(href_bry), Op_sys.Cur().Tid_is_wnt());
gplx.gfui.Gfui_html html_box = win.Active_html_box();
String xowa_ttl = page.Wiki().Gui_mgr().Cfg_browser().Content_editable()
? html_box.Html_active_atr_get_str(gplx.xowa.html.Xoh_html_tag.Nde_xowa_title_str, null)
? html_box.Html_active_atr_get_str(gplx.xowa.html.Xoh_consts.Atr_xowa_title_str, null)
: Xoh_dom_.Title_by_href(app.Encoder_mgr().Comma(), app.Utl_bry_bfr_mkr().Get_b512().Mkr_rls(), href_bry, Bry_.new_utf8_(html_box.Html_doc_html()));
if (!Io_mgr._.ExistsFil(href_url)) {
Xof_xfer_itm xfer_itm = new Xof_xfer_itm();

View File

@@ -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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.core.btries.*; import gplx.gfui.*; import gplx.html.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*; import gplx.xowa.html.modules.*;
import gplx.core.btries.*; import gplx.gfui.*; import gplx.html.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*; import gplx.xowa.html.modules.*; import gplx.xowa.pages.*;
public class Xog_html_itm implements GfoInvkAble, GfoEvObj {
private Xoa_app app;
public Xog_html_itm(Xog_tab_itm owner_tab) {
@@ -56,7 +56,7 @@ public class Xog_html_itm implements GfoInvkAble, GfoEvObj {
byte view_mode = owner_tab.View_mode();
byte[] html_src = page.Wiki().Html_mgr().Page_wtr_mgr().Gen(page, view_mode);
Html_src_(page, html_src);
if (view_mode == Xog_page_mode.Tid_read){ // used only for Xosrh test; DATE:2014-01-29
if (view_mode == Xopg_view_mode.Tid_read){ // used only for Xosrh test; DATE:2014-01-29
html_box.Html_doc_body_focus(); // NOTE: only focus if read so up / down will scroll box; edit / html should focus edit-box; DATE:2014-06-05
page.Root().Data_htm_(html_src);
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.threads.*; import gplx.gfui.*; import gplx.xowa.gui.history.*; import gplx.xowa.gui.bnds.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.cfgs2.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.cfgs2.*; import gplx.xowa.pages.*;
public class Xog_tab_itm implements GfoInvkAble {
private Xog_win_itm win; private Xocfg_tab_mgr cfg_tab_mgr;
public Xog_tab_itm(Xog_tab_mgr tab_mgr, Gfui_tab_itm_data tab_data) {
@@ -91,9 +91,8 @@ public class Xog_tab_itm implements GfoInvkAble {
tab_box.Tab_name_(tab_name);
}
public Xog_history_mgr History_mgr() {return history_mgr;} private Xog_history_mgr history_mgr = new Xog_history_mgr();
public byte View_mode() {return view_mode;} public Xog_tab_itm View_mode_(byte v) {view_mode = v; return this;} private byte view_mode = Xog_page_mode.Tid_read;
public void Pin_toggle() {
}
public byte View_mode() {return view_mode;} public Xog_tab_itm View_mode_(byte v) {view_mode = v; return this;} private byte view_mode = Xopg_view_mode.Tid_read;
public void Pin_toggle() {}
public void Show_url_bgn(Xoa_url url) {
this.tab_is_loading = true;
Xoa_app app = win.App(); Gfo_usr_dlg usr_dlg = app.Usr_dlg();
@@ -125,7 +124,7 @@ public class Xog_tab_itm implements GfoInvkAble {
if (page.Missing()) {
if (wiki.Db_mgr().Save_mgr().Create_enabled()) {
page = Xoa_page.create_(wiki, ttl);
view_mode = Xog_page_mode.Tid_edit;
view_mode = Xopg_view_mode.Tid_edit;
history_mgr.Add(page); // NOTE: must put new_page on stack so that pressing back will pop new_page, not previous page
Xog_tab_itm_read_mgr.Show_page(this, page, false);
}

View File

@@ -16,10 +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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.html.*;
import gplx.gfui.*; import gplx.xowa.html.*; import gplx.xowa.pages.*;
public class Xog_tab_itm_edit_mgr {
public static void Save(Xog_tab_itm tab, boolean quick_save) {
if (tab.View_mode() != Xog_page_mode.Tid_edit) return; // exit if not edit; handles ctrl+s being pressed on read/html modes
if (tab.View_mode() != Xopg_view_mode.Tid_edit) return; // exit if not edit; handles ctrl+s being pressed in read/html modes
Xoa_page page = tab.Page(); Xow_wiki wiki = page.Wiki(); Xog_win_itm win_itm = tab.Tab_mgr().Win();
byte[] new_text = Get_new_text(tab);
if (page.Edit_mode() == Xoa_page_.Edit_mode_create) {
@@ -37,12 +37,13 @@ public class Xog_tab_itm_edit_mgr {
Xoa_page stack_page = tab.History_mgr().Cur_page(wiki); // NOTE: must be to CurPage() else changes will be lost when going Bwd,Fwd
stack_page.Data_raw_(page.Data_raw()); // NOTE: overwrite with "saved" changes
stack_page.Wiki().ParsePage_root(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
win_itm.Page__mode_(Xog_page_mode.Tid_read);
win_itm.Page__mode_(Xopg_view_mode.Tid_read);
win_itm.Page__async__bgn(tab);
}
wiki.Db_mgr().Html_mgr().Save(page);
}
public static void Preview(Xog_tab_itm tab) {
if (tab.View_mode() != Xog_page_mode.Tid_edit) return; // exit if not edit; handles preview somehow being called?
if (tab.View_mode() != Xopg_view_mode.Tid_edit) return; // exit if not edit; handles preview somehow being called?
Xoa_page page = tab.Page(); Xow_wiki wiki = page.Wiki(); Xog_win_itm win_itm = tab.Tab_mgr().Win();
Xog_html_itm html_itm = tab.Html_itm();
@@ -54,19 +55,19 @@ public class Xog_tab_itm_edit_mgr {
tab.Page_(new_page);
Bry_bfr tmp_bfr = wiki.Utl_bry_bfr_mkr().Get_m001();
Xoh_page_wtr_wkr wkr = wiki.Html_mgr().Page_wtr_mgr().Wkr(Xog_page_mode.Tid_read);
Xoh_page_wtr_wkr wkr = wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_view_mode.Tid_read);
wkr.Page_(new_page);
wkr.XferAry(tmp_bfr, 0);
byte[] new_html = tmp_bfr.Mkr_rls().XtoAryAndClear();
new_page.Html_data().Edit_preview_(new_html);
Invalidate(wiki);
win_itm.Page__mode_(Xog_page_mode.Tid_edit);
win_itm.Page__mode_(Xopg_view_mode.Tid_edit);
html_itm.Scroll_page_by_id_gui(Xog_html_itm.Elem_id__first_heading);// NOTE: was originally directly; changed to call on thread; DATE:2014-05-03
win_itm.Page__async__bgn(tab); // NOTE: needed to show images during preview; DATE:2014-06-21
}
public static void Rename(Xog_tab_itm tab) {
if (tab.View_mode() != Xog_page_mode.Tid_edit) return; // exit if not edit; handles ctrl+r being pressed
if (tab.View_mode() != Xopg_view_mode.Tid_edit) return; // exit if not edit; handles ctrl+r being pressed
Xoa_page page = tab.Page(); Xow_wiki wiki = page.Wiki(); Xog_win_itm win_itm = tab.Tab_mgr().Win();
if (Bry_.Eq(page.Ttl().Page_db(), wiki.Props().Main_page())) {
win_itm.Usr_dlg().Warn_many("", "", "The Main Page cannot be renamed");
@@ -83,7 +84,7 @@ public class Xog_tab_itm_edit_mgr {
}
wiki.Db_mgr().Save_mgr().Data_rename(page, new_ns_id, new_text);
page.Ttl_(Xoa_ttl.parse_(wiki, Bry_.Add(page.Ttl().Ns().Name_db_w_colon(), new_text)));
win_itm.Page__mode_(Xog_page_mode.Tid_read);
win_itm.Page__mode_(Xopg_view_mode.Tid_read);
win_itm.Usr_dlg().Prog_one("", "", "renamed page to {0}", String_.new_utf8_(page.Ttl().Full_txt_raw()));
}
public static void Focus(Xog_win_itm win, String elem_focus_id) {

View File

@@ -17,13 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.gfui.*; import gplx.threads.*;
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.gui.history.*;
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.gui.history.*; import gplx.xowa.pages.*;
public class Xog_tab_itm_read_mgr {
public static void Async(Xog_tab_itm tab) {tab.Async();}
public static void Show_page(Xog_tab_itm tab, Xoa_page new_page, boolean reset_to_read) {Show_page(tab, new_page, reset_to_read, false, false, Xog_history_stack.Nav_fwd);}
public static void Show_page(Xog_tab_itm tab, Xoa_page new_page, boolean reset_to_read, boolean new_page_is_same, boolean show_is_err, byte history_nav_type) {
if (reset_to_read) tab.View_mode_(Xog_page_mode.Tid_read);
if (new_page.Url().Action_is_edit()) tab.View_mode_(Xog_page_mode.Tid_edit);
if (reset_to_read) tab.View_mode_(Xopg_view_mode.Tid_read);
if (new_page.Url().Action_is_edit()) tab.View_mode_(Xopg_view_mode.Tid_edit);
Xoa_page cur_page = tab.Page(); Xog_html_itm html_itm = tab.Html_itm(); Gfui_html html_box = html_itm.Html_box();
Xoa_app app = cur_page.App(); Xog_win_itm win = tab.Tab_mgr().Win();
if (cur_page != null && !new_page_is_same) { // if new_page_is_same, don't update DocPos; will "lose" current position
@@ -51,7 +51,7 @@ public class Xog_tab_itm_read_mgr {
tab.Tab_mgr().Tab_mgr().Focus();
html_box.Focus();
win.Usr_dlg().Prog_none("", "", ""); // blank out status bar
if (tab.View_mode() == Xog_page_mode.Tid_read)
if (tab.View_mode() == Xopg_view_mode.Tid_read)
html_itm.Scroll_page_by_bmk_gui();
else
GfoInvkAble_.InvkCmd_val(tab.Html_itm().Cmd_async(), Xog_html_itm.Invk_html_elem_focus, Xog_html_itm.Elem_id__xowa_edit_data_box); // NOTE: must be async, else won't work; DATE:2014-06-05
@@ -76,7 +76,7 @@ public class Xog_tab_itm_read_mgr {
win.Usr_dlg().Warn_many("", "", err_msg);
win.App().Log_wtr().Queue_enabled_(false);
Xoa_page fail_page = wiki.Data_mgr().Get_page(ttl, false);
tab.View_mode_(Xog_page_mode.Tid_edit);
tab.View_mode_(Xopg_view_mode.Tid_edit);
Update_selected_tab(win.App(), win, url, ttl);
Show_page(tab, fail_page, false, false, true, Xog_history_stack.Nav_fwd);
win.Win_box().Text_(err_msg);

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.threads.*; import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.history.*; import gplx.xowa.xtns.math.*; import gplx.xowa.files.*;
import gplx.xowa.gui.urls.*; import gplx.xowa.gui.views.*;
import gplx.xowa.gui.urls.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*;
import gplx.xowa.parsers.lnkis.redlinks.*;
public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
private GfoInvkAble sync_cmd;
@@ -62,17 +62,17 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size();
else if (ctx.Match(k, Invk_page_refresh)) Page__refresh();
else if (ctx.Match(k, Invk_page_async_exec)) Xog_tab_itm_read_mgr.Async((Xog_tab_itm)m.ReadObj("v"));
else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xog_page_mode.Tid_read);
else if (ctx.Match(k, Invk_page_view_edit)) Page__mode_(Xog_page_mode.Tid_edit);
else if (ctx.Match(k, Invk_page_view_html)) Page__mode_(Xog_page_mode.Tid_html);
else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xopg_view_mode.Tid_read);
else if (ctx.Match(k, Invk_page_view_edit)) Page__mode_(Xopg_view_mode.Tid_edit);
else if (ctx.Match(k, Invk_page_view_html)) Page__mode_(Xopg_view_mode.Tid_html);
else if (ctx.Match(k, Invk_page_edit_save)) Xog_tab_itm_edit_mgr.Save(tab_mgr.Active_tab(), Bool_.N);
else if (ctx.Match(k, Invk_page_edit_save_draft)) Xog_tab_itm_edit_mgr.Save(tab_mgr.Active_tab(), Bool_.Y);
else if (ctx.Match(k, Invk_page_edit_preview)) Xog_tab_itm_edit_mgr.Preview(tab_mgr.Active_tab());
else if (ctx.Match(k, Invk_page_edit_rename)) Xog_tab_itm_edit_mgr.Rename(tab_mgr.Active_tab());
else if (ctx.Match(k, Invk_page_edit_focus_box)) Xog_tab_itm_edit_mgr.Focus(this, Xog_html_itm.Elem_id__xowa_edit_data_box);
else if (ctx.Match(k, Invk_page_edit_focus_first)) Xog_tab_itm_edit_mgr.Focus(this, Xog_html_itm.Elem_id__first_heading);
else if (ctx.Match(k, Invk_page_dbg_html)) Xog_tab_itm_edit_mgr.Debug(this, Xog_page_mode.Tid_html);
else if (ctx.Match(k, Invk_page_dbg_wiki)) Xog_tab_itm_edit_mgr.Debug(this, Xog_page_mode.Tid_edit);
else if (ctx.Match(k, Invk_page_dbg_html)) Xog_tab_itm_edit_mgr.Debug(this, Xopg_view_mode.Tid_html);
else if (ctx.Match(k, Invk_page_dbg_wiki)) Xog_tab_itm_edit_mgr.Debug(this, Xopg_view_mode.Tid_edit);
else if (ctx.Match(k, Invk_page_goto)) Page__navigate_by_url_bar(m.ReadStr("v"));
else if (ctx.Match(k, Invk_page_goto_recent)) Page__navigate_by_url_bar(app.User().History_mgr().Get_at_last(app));
else if (ctx.Match(k, Invk_history_bwd)) {Page__navigate_by_history(Bool_.N);}
@@ -119,7 +119,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.xowa.html.Xoh_html_tag.Const_anchor);
int pos = String_.FindFwd(url, gplx.html.Html_tag_.Anchor_str);
if (pos != Bry_.NotFound) url = String_.Mid(url, 0, pos);
String anchor_str = Parse_evt_location_changing(anchor_raw);
byte[] anchor_bry = Bry_.new_utf8_(anchor_str);
@@ -142,14 +142,14 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
app.Gfs_mgr().Run_str(snippet);
}
private static String Parse_evt_location_changing(String v) { // EX: about:blank#anchor -> anchor
int pos = String_.FindFwd(v, gplx.xowa.html.Xoh_html_tag.Const_anchor);
int pos = String_.FindFwd(v, gplx.html.Html_tag_.Anchor_str);
return pos == Bry_.NotFound
? null
: String_.Mid(v, pos + 1);
}
public void Page__mode_(byte new_mode_tid) {
Xog_tab_itm tab = tab_mgr.Active_tab(); Xoa_page page = tab.Page();
if ( new_mode_tid == Xog_page_mode.Tid_read // used to be && cur_view_tid == Edit; removed clause else redlinks wouldn't show when going form html to read (or clicking read multiple times) DATE: 2013-11-26;
if ( new_mode_tid == Xopg_view_mode.Tid_read // used to be && cur_view_tid == Edit; removed clause else redlinks wouldn't show when going form html to read (or clicking read multiple times) DATE: 2013-11-26;
&& !page.Missing() // if new page, don't try to reload
) {
// NOTE: if moving from "Edit" to "Read", reload page (else Preview changes will still show); NOTE: do not call Exec_page_reload / Exec_page_refresh, which will fire redlinks code