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

v2.10.3.1

This commit is contained in:
gnosygnu
2015-10-18 22:17:57 -04:00
parent 8e18af05b6
commit 4f43f51b18
1935 changed files with 12500 additions and 12889 deletions

View File

@@ -0,0 +1,28 @@
/*
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.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
public class Xoi_addon_mgr implements GfoInvkAble {
public Xoi_firefox_installer Firefox() {return firefox;} private Xoi_firefox_installer firefox = new Xoi_firefox_installer();
public void Init_by_app(Xoae_app app) {
firefox.Init_by_app(app);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_firefox)) return firefox;
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_firefox = "firefox";
}

View File

@@ -0,0 +1,65 @@
/*
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.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.ios.*;
import gplx.xowa.apps.fsys.*;
public class Xoi_firefox_installer implements GfoInvkAble {
private Io_url src_xpi, trg_xpi;
private Io_url trg_xpi_package;
private ProcessAdp program = new ProcessAdp();
public void Init_by_app(Xoae_app app) {
src_xpi = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("firefox", "xowa_viewer", "default", "xowa_viewer@piotrex.xpi");
trg_xpi = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("firefox", "xowa_viewer", "install", "xowa_viewer@piotrex.xpi");
trg_xpi_package = trg_xpi.OwnerDir().GenSubDir("package");
Xoa_fsys_eval cmd_eval = app.Url_cmd_eval();
ProcessAdp.ini_(this, app.Usr_dlg(), program, cmd_eval, ProcessAdp.Run_mode_async, 0, "firefox", "\"~{url}\"", "url");
}
public void Install_via_process() {
Generate();
program.Run(trg_xpi.Raw());
}
public void Generate() {
Io_mgr.Instance.CopyFil(src_xpi, trg_xpi, true);
Io_zip_mgr_base.Instance.Unzip_to_dir(trg_xpi, trg_xpi_package);
Pref_gen();
Io_zip_mgr_base.Instance.Zip_dir(trg_xpi_package, trg_xpi);
}
private void Pref_gen() {
Io_url prefs_fil = trg_xpi_package.GenSubFil_nest("defaults", "preferences", "prefs.js");
String prefs_str = Io_mgr.Instance.LoadFilStr(prefs_fil);
prefs_str = Pref_update(prefs_str, "extensions.xowa_viewer.xowa_app", Env_.AppUrl().Raw());
Io_mgr.Instance.SaveFilStr(prefs_fil, prefs_str);
}
public static String Pref_update(String src, String key, String val) {
String find = String_.Format("pref(\"{0}\"", key); // EX: 'pref("key"'
int bgn = String_.FindFwd(src, find); // look for 'pref...'
if (bgn == String_.Find_none) return src; // key not found; return;
int end = String_.FindFwd(src, "\n", bgn + String_.Len(find)); // look for '\n'; note that this will trim any comments; EX: pref("key", "val"); // comment will be lost
if (end == String_.Find_none) return src; // nl not found; return;
String repl = String_.Format("{0}, \"{1}\");", find, val); // EX: 'pref("key", "val");'
return String_.Mid(src, 0, bgn)
+ repl
+ String_.Mid(src, end);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_program)) return program;
if (ctx.Match(k, Invk_install)) Install_via_process();
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_program = "program", Invk_install = "install";
}

View File

@@ -0,0 +1,43 @@
/*
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.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import org.junit.*;
import gplx.ios.*;
public class Xoi_firefox_installer_tst {
private Xoi_firefox_pref_fxt fxt = new Xoi_firefox_pref_fxt();
@Test public void Pref_update() {
fxt.Test_pref_update(String_.Concat_lines_nl
( "pref(\"key_0\", \"val_0\"); // comment_0"
, "pref(\"key_1\", \"val_1\"); // comment_1"
, "pref(\"key_2\", \"val_2\"); // comment_2"
)
, "key_1", "val_1_updated"
, String_.Concat_lines_nl
( "pref(\"key_0\", \"val_0\"); // comment_0"
, "pref(\"key_1\", \"val_1_updated\");"
, "pref(\"key_2\", \"val_2\"); // comment_2"
)
);
}
}
class Xoi_firefox_pref_fxt {
public void Test_pref_update(String src, String key, String val, String expd) {
String actl = Xoi_firefox_installer.Pref_update(src, key, val);
Tfds.Eq_str_lines(expd, actl);
}
}