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

'v3.7.2.1'

This commit is contained in:
gnosygnu
2016-07-10 23:35:32 -04:00
parent f5f48bb9b1
commit b333db45f8
366 changed files with 4468 additions and 3460 deletions

View File

@@ -34,7 +34,7 @@ class Xogv_page_load_wkr implements Gfo_thread_wkr, Gfo_invk {
}
private Xoh_page Fetch_page(byte[] wiki_domain, byte[] page_bry, byte[] qarg_bry) {
Xowv_wiki wiki = (Xowv_wiki)wiki_mgr.Get_by_or_null(wiki_domain);
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
if (wiki == null) return Xoh_page.New_missing(); // 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));
Xoh_page rv = new Xoh_page();

View File

@@ -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.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.guis.history.*;
import gplx.xowa.htmls.*; 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 {
@@ -34,7 +34,7 @@ public abstract class Xogv_tab_base {
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);
Xoh_page rv = Fetch_page_and_show(old_itm, new_itm);
if (rv.Exists())
if (rv.Db().Page().Exists())
history_stack.Add(new_itm);
return rv;
}
@@ -47,7 +47,7 @@ public abstract class Xogv_tab_base {
return Fetch_page_and_show(old_itm, new_itm);
}
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_();
if (new_itm == Xog_history_itm.Null) return Xoh_page.New_missing();
Fetch_page__bgn(new_itm.Wiki(), new_itm.Page(), new_itm.Qarg());
Xoh_page new_hpg = new Xoh_page();
// Thread_adp_.Start_by_key(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);

View File

@@ -59,7 +59,7 @@ public class Xog_history_mgr {
byte[] page_key = Build_page_key(itm.Wiki(), itm.Page(), itm.Qarg());
Xoae_page rv = (Xoae_page)hash.Get_by(page_key);
if (rv != null) return rv;
Xoa_ttl ttl = Xoa_ttl.parse(wiki, itm.Page());
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, itm.Page());
return wiki.Data_mgr().Load_page_by_ttl(ttl);
}
private static byte[] Build_page_key(Xoae_page page) {return Build_page_key(page.Wiki().Domain_bry(), page.Ttl().Full_url(), page.Url().Qargs_mgr().To_bry());}

View File

@@ -71,7 +71,7 @@ class Xog_history_stack_fxt {
}
public Xog_history_stack_fxt Exec_add_one(String ttl_str, String arg_str) {
byte[] ttl_bry = Bry_.new_u8(ttl_str);
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
Xoae_page page = Xoae_page.New_test(wiki, ttl);
byte[] url_bry = ttl_bry;
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));

View File

@@ -62,11 +62,11 @@ class Xog_launcher_tabs {
Xoae_app app = win.App();
Xoa_url launch_url = home_wiki.Utl__url_parser().Parse_by_urlbar_or_null(launch_str); if (launch_url == null) return;
Xowe_wiki launch_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(launch_url.Wiki_bry());
Xoa_ttl launch_ttl = Xoa_ttl.parse(launch_wiki, launch_url.Page_bry());
Xoa_ttl launch_ttl = Xoa_ttl.Parse(launch_wiki, launch_url.Page_bry());
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(launch_wiki, Xoae_page.New(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
tab.Show_url_bgn(launch_url);
}
public static final Xog_launcher_tabs Instance = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
public static final Xog_launcher_tabs Instance = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
}
class Io_fil_marker {
private Io_url url;

View File

@@ -120,7 +120,7 @@ public class Xog_tab_itm implements Gfo_invk {
this.wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(url.Wiki_bry()); // NOTE: must update wiki variable; DATE:????-??-??; NOTE: must load wiki; DATE:2015-07-22
if (url.Page_is_main()) url.Page_bry_(wiki.Props().Main_page());
if (url.Vnt_bry() != null) Cur_vnt_(wiki, url.Vnt_bry());
Xoa_ttl ttl = Xoa_ttl.parse(wiki, url.Page_bry());
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.Page_bry());
if (ttl == null) {usr_dlg.Prog_one("", "", "title is invalid: ~{0}", String_.new_u8(url.Raw())); return;}
Tab_name_(String_.new_u8(ttl.Full_txt_w_ttl_case()));
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw()));
@@ -143,7 +143,7 @@ public class Xog_tab_itm implements Gfo_invk {
try {
if (page.Tab_data().Cancel_show()) return; // Special:Search canceled show; NOTE: must be inside try b/c finally handles thread
wiki.Parser_mgr().Ctx().Page_(page);
if (page.Missing()) {
if (page.Db().Page().Exists_n()) {
if (wiki.Db_mgr().Save_mgr().Create_enabled()) {
page = Xoae_page.New_edit(wiki, ttl);
view_mode = Xopg_page_.Tid_edit;
@@ -152,8 +152,8 @@ public class Xog_tab_itm implements Gfo_invk {
}
else {
wkr.Page().Tab_data().Tab().Page_(page); // NOTE: must set tab's page to current page, so that switching to it will update url bar; EX:pt.b:A"MANUAL_DE_PROCEDURI_.Sectiunea:""CONTABILITATE_SI_MANAGEMENT_FINANCIAR""" DATE:2015-09-17
if (page.Redirected_ttls().Count() > 0)
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_u8(page.Url().Page_bry()), String_.new_u8((byte[])page.Redirected_ttls().Get_at(0)));
if (page.Redirect().Itms__len() > 0)
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_u8(page.Url().Page_bry()), page.Redirect().Itms__get_at(0).Ttl().Full_db());
else {
if (ttl.Ns().Id_is_file())
usr_dlg.Prog_one("", "", "commons.wikimedia.org must be installed in order to view the file. See [[App/Wiki_types/Commons]]: ~{0}", String_.new_u8(url.Raw()));// HOME
@@ -164,7 +164,7 @@ public class Xog_tab_itm implements Gfo_invk {
app.Log_wtr().Queue_enabled_(false);
return;
}
if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons
// if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons; COMMENTED: part of redirect rewrite; DATE:2016-07-05
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);
@@ -179,9 +179,9 @@ public class Xog_tab_itm implements Gfo_invk {
if (page.Html_data().Hdump_exists()) {
// wiki.File_mgr().Init_file_mgr_by_load(wiki);
// 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());
// 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_mgr().Imgs());
async_wkr = new Load_files_wkr(this);
if (wiki.Html__hdump_enabled() && page.Revision_data().Html_db_id() == -1) {
if (wiki.Html__hdump_enabled() && page.Db().Page().Html_db_id() == -1) {
wiki.Html__hdump_mgr().Save_mgr().Save(page);
}
}

View File

@@ -26,22 +26,22 @@ public class Xog_tab_itm_edit_mgr {
byte[] new_text = Get_new_text(tab);
if (page.Edit_mode() == Xoa_page_.Edit_mode_create) {
int page_id = wiki.Db_mgr().Save_mgr().Data_create(page.Ttl(), new_text);
page.Revision_data().Id_(page_id);
page.Db().Page().Id_(page_id);
page.Edit_mode_update_(); // set to update so that next save does not try to create
}
else {
wiki.Db_mgr().Save_mgr().Data_update(page, new_text);
}
Invalidate(wiki);
page.Data_raw_(new_text);
page.Db().Text().Text_bry_(new_text);
wiki.Parser_mgr().Parse(page, true); // refresh html
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);
Xoae_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.Wikie().Parser_mgr().Parse(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
stack_page.Db().Text().Text_bry_(page.Db().Text().Text_bry()); // NOTE: overwrite with "saved" changes
stack_page.Wikie().Parser_mgr().Parse(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
win_itm.Page__mode_(Xopg_page_.Tid_read);
win_itm.Page__async__bgn(tab);
}
@@ -54,8 +54,8 @@ public class Xog_tab_itm_edit_mgr {
byte[] new_text = Get_new_text(tab);
Xoae_page new_page = Xoae_page.New(wiki, page.Ttl());
new_page.Revision_data().Id_(page.Revision_data().Id()); // NOTE: page_id needed for sqlite (was not needed for xdat)
new_page.Data_raw_(new_text);
new_page.Db().Page().Id_(page.Db().Page().Id()); // NOTE: page_id needed for sqlite (was not needed for xdat)
new_page.Db().Text().Text_bry_(new_text);
wiki.Parser_mgr().Parse(new_page, true); // refresh html
tab.Page_(new_page); new_page.Tab_data().Tab_(tab); // replace old page with new_page; DATE:2014-10-09
@@ -81,14 +81,14 @@ public class Xog_tab_itm_edit_mgr {
byte[] new_text = Bry_.new_u8(tab.Html_itm().Get_elem_value(Xog_html_itm.Elem_id__xowa_edit_rename_box));
if (Bry_.Len_eq_0(new_text)) return; // no ttl given; exit
new_text = Xoa_ttl.Replace_spaces(new_text); // ttls cannot have spaces; only underscores
Xoa_ttl new_ttl = Xoa_ttl.parse(wiki, new_text);
Xoa_ttl new_ttl = Xoa_ttl.Parse(wiki, new_text);
int new_ns_id = new_ttl.Ns().Id();
if (new_ns_id != Xow_ns_.Tid__main) {
win_itm.Usr_dlg().Warn_many("", "", "The new page name must remain in the same namespace");
return;
}
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)));
page.Ttl_(Xoa_ttl.Parse(wiki, Bry_.Add(page.Ttl().Ns().Name_db_w_colon(), new_text)));
win_itm.Page__mode_(Xopg_page_.Tid_read);
win_itm.Usr_dlg().Prog_one("", "", "renamed page to {0}", String_.new_u8(page.Ttl().Full_txt_raw()));
}
@@ -105,12 +105,12 @@ public class Xog_tab_itm_edit_mgr {
Xoa_ttl ttl = page.Ttl();
Xoae_page new_page = Xoae_page.New(wiki, ttl);
byte[] data = tab.Html_itm().Get_elem_value_for_edit_box_as_bry();
new_page.Data_raw_(data);
new_page.Db().Text().Text_bry_(data);
wiki.Parser_mgr().Parse(new_page, true);
Bry_bfr bfr = win.App().Utl__bfr_mkr().Get_m001();
bfr.Add(new_page.Root().Root_src());
wiki.Parser_mgr().Ctx().Defn_trace().Print(data, bfr);
new_page.Data_raw_(bfr.To_bry_and_rls());
new_page.Db().Text().Text_bry_(bfr.To_bry_and_rls());
byte old = tab.View_mode();
tab.View_mode_(view_tid);
Xog_tab_itm_read_mgr.Show_page(tab, new_page, false);
@@ -118,7 +118,7 @@ public class Xog_tab_itm_edit_mgr {
tab.View_mode_(old);
}
private static void Invalidate(Xowe_wiki wiki) {// invalidate everything on updates; especially needed for page transclusion; {{/my_subpage}} DATE:2014-04-10
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
wiki.Parser_mgr().Scrib().Core().Term();
wiki.Cache_mgr().Free_mem_all();
}
private static byte[] Get_new_text(Xog_tab_itm tab) {

View File

@@ -78,7 +78,7 @@ public class Xog_tab_mgr implements Gfo_evt_itm {
public Xog_tab_itm Tabs_new_dflt(boolean focus) {
boolean active_tab_is_null = this.Active_tab_is_null();
Xowe_wiki cur_wiki = active_tab_is_null ? win.App().Usere().Wiki() : active_tab.Wiki();
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, Xow_special_meta_.Itm__default_tab.Ttl_bry());
Xoa_ttl ttl = Xoa_ttl.Parse(cur_wiki, Xow_special_meta_.Itm__default_tab.Ttl_bry());
Xoa_url url = cur_wiki.Utl__url_parser().Parse_by_urlbar_or_null(ttl.Full_db_as_str()); if (url == null) throw Err_.new_("url", "invalid url", "url", url);
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, cur_wiki, Xoae_page.New(cur_wiki, ttl));
rv.Page_update_ui();

View File

@@ -155,7 +155,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
public void Page__mode_(byte new_mode_tid) {
Xog_tab_itm tab = tab_mgr.Active_tab(); Xoae_page page = tab.Page(); Xowe_wiki wiki = tab.Wiki();
if ( new_mode_tid == Xopg_page_.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
&& page.Db().Page().Exists() // 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
page = tab_mgr.Active_tab().History_mgr().Cur_page(wiki); // NOTE: must set to CurPage() else changes will be lost when going Bwd,Fwd
@@ -166,7 +166,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
url = tab.Wiki().Utl__url_parser().Parse(url.To_bry_full_wo_qargs()); // remove all query args; handle (1) s.w:Earth?action=edit; (2) click on Read; DATE:2014-03-06
}
tab.View_mode_(new_mode_tid);
if (page.Missing()) return;
if (page.Db().Page().Exists_n()) return;
Xog_tab_itm_read_mgr.Show_page(tab, page, false);
// Exec_page_refresh(); // commented out; causes lnke to show as [2] instead of [1] when saving page; EX: [http://a.org b] DATE:2014-04-24
}
@@ -186,7 +186,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
if (tab == Xog_tab_itm_.Null) return;
Xoae_page cur_page = tab.Page(); Xowe_wiki cur_wiki = tab.Wiki();
Xoae_page new_page = tab.History_mgr().Go_by_dir(cur_wiki, fwd);
if (new_page.Missing()) return;
if (new_page.Db().Page().Exists_n()) return;
if (new_page.Ttl().Ns().Id_is_special()) // if Special, reload page; needed for Special:Search (DATE:2015-04-19; async loading) and Special:XowaBookmarks DATE:2015-10-05
new_page = new_page.Wikie().Data_mgr().Load_page_and_parse(new_page.Url(), new_page.Ttl()); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
byte history_nav_type = fwd ? Xog_history_stack.Nav_fwd : Xog_history_stack.Nav_bwd;
@@ -213,7 +213,6 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
}
public void Page__async__bgn(Xog_tab_itm tab) {
page__async__thread = Thread_adp_.Start_by_val(gplx.xowa.apps.Xoa_thread_.Key_page_async, this, Invk_page_async_exec, tab);
page__async__thread.Thread__start();
} private Thread_adp page__async__thread = Thread_adp.Noop;
public boolean Page__async__working(Xoa_url url) {
if (page__async__thread.Thread__is_alive()) { // cancel pending image downloads
@@ -257,16 +256,16 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
Xowe_wiki home_wiki = app.Usere().Wiki();
Xoa_url url = home_wiki.Utl__url_parser().Parse_by_urlbar_or_null(url_str); if (url == null) return Bry_.Empty;
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(url.Wiki_bry());
Xoa_ttl ttl = Xoa_ttl.parse(wiki, url.Page_bry());
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.Page_bry());
Xoae_page new_page = wiki.Data_mgr().Load_page_and_parse(url, ttl);
if (new_page.Missing()) {return Bry_.Empty;}
if (new_page.Db().Page().Exists_n()) {return Bry_.Empty;}
gplx.xowa.apps.servers.Gxw_html_server.Assert_tab(app, new_page); // HACK: assert at least 1 tab for Firefox addon; DATE:2015-01-23
Xog_tab_itm tab = tab_mgr.Active_tab();
tab.Page_(new_page);
tab.History_mgr().Add(new_page);
byte[] rv = output_html
? wiki.Html_mgr().Page_wtr_mgr().Gen(new_page, tab.View_mode())
: new_page.Data_raw();
: new_page.Db().Text().Text_bry();
if (app.Shell().Fetch_page_exec_async())
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
return rv;

View File

@@ -81,14 +81,16 @@ public class Xog_error_win extends JFrame implements Gfo_invk {
String subject = url_encoder.Encode_str("XOWA boot error: " + error_data.Err_msg());
String body = url_encoder.Encode_str(error_data.Err_details());
Desktop.getDesktop().mail(new URI("mailto:gnosygnu+xowa_error_boot@gmail.com?subject=" + subject + "&body=" + body));
} catch (URISyntaxException | IOException ex) {
}
}
catch (URISyntaxException ex) {}
catch (IOException ex) {}
}
else if (ctx.Match(k, Invk_open_site)) {
try {
Desktop.getDesktop().browse(new URI("https://github.com/gnosygnu/xowa/issues"));
} catch (URISyntaxException | IOException ex) {
}
}
catch (URISyntaxException ex) {}
catch (IOException ex) {}
}
else return Gfo_invk_.Rv_unhandled;
return this;