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
2015-05-03 22:30:22 -04:00
parent f4b95f5ce6
commit 0b5aa9aefe
207 changed files with 2339 additions and 1460 deletions

View File

@@ -40,23 +40,24 @@ public class Xoa_css_extractor {
failover_dir = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("html", "xowa", "import");
url_encoder = Xoa_app_.Utl__encoder_mgr().Url();
}
public void Install_assert(boolean download_from_css_tbl, Xowe_wiki wiki, Io_url wiki_html_dir) {
public void Install(Xow_wiki wiki, String css_key) {
try {
Io_url css_common_url = wiki_html_dir.GenSubFil(Css_common_name);
Io_url css_wiki_url = wiki_html_dir.GenSubFil(Css_wiki_name);
Xoh_page_wtr_mgr wiki_article = wiki.Html_mgr().Page_wtr_mgr();
wiki_article.Css_common_bry_(css_common_url).Css_wiki_bry_(css_wiki_url);
this.wiki_html_dir = wiki.App().Fsys_mgr().Wiki_css_dir(wiki.Domain_str()); // EX: /xowa/user/anonymous/wiki/en.wikipedia.org
Io_url css_comm_fil = wiki_html_dir.GenSubFil(Css_common_name);
Io_url css_wiki_fil = wiki_html_dir.GenSubFil(Css_wiki_name);
wiki.Html__page_wtr_mgr().Init_css_urls(css_comm_fil, css_wiki_fil);
if (wiki.Domain_tid() == Xow_domain_.Tid_int_home || Env_.Mode_testing()) return; // NOTE: do not download if home_wiki; also needed for TEST
if (Io_mgr._.ExistsFil(css_wiki_url)) return; // css file exists; nothing to generate
wiki.Appe().Usr_dlg().Log_many("", "", "generating css for '~{0}'", wiki.Domain_str());
if (download_from_css_tbl) {
if (Install_by_db(wiki, wiki_html_dir)) return;
if (Io_mgr._.ExistsFil(css_wiki_fil)) return; // css file exists; nothing to generate
wiki.App().Usr_dlg().Log_many("", "", "generating css for '~{0}'", wiki.Domain_str());
if (css_key != null) {
if (Install_by_db(wiki, wiki_html_dir, css_key)) return;
}
this.Install_by_wmf(wiki, wiki_html_dir);
if (wiki.Type_is_edit())
this.Install_by_wmf((Xowe_wiki)wiki, wiki_html_dir);
}
catch (Exception e) { // if error, failover; paranoia catch for outliers like bad network connectivity fail, or MediaWiki: message not existing; DATE:2013-11-21
wiki.Appe().Usr_dlg().Warn_many("", "", "failed while trying to generate css; failing over; wiki='~{0}' err=~{1}", wiki.Domain_str(), Err_.Message_gplx(e));
Css_common_failover(); // only failover xowa_common.css; xowa_wiki.css comes from MediaWiki:Common.css / Vector.css
wiki.App().Usr_dlg().Warn_many("", "", "failed while trying to generate css; failing over; wiki='~{0}' err=~{1}", wiki.Domain_str(), Err_.Message_gplx(e));
Css_common_failover(); // only failover xowa_common.css; xowa_wiki.css comes from MediaWiki:Common.css / Vector.css
}
}
private void Install_by_wmf(Xowe_wiki wiki, Io_url wiki_html_dir) {
@@ -74,7 +75,7 @@ public class Xoa_css_extractor {
Css_wiki_setup();
Logo_setup();
}
private boolean Install_by_db(Xowe_wiki wiki, Io_url wiki_html_dir) {
private boolean Install_by_db(Xow_wiki wiki, Io_url wiki_html_dir, String css_key) {
Xowd_db_mgr core_db_mgr = wiki.Data_mgr__core_mgr();
if ( core_db_mgr == null
|| core_db_mgr.Props() == null
@@ -82,7 +83,7 @@ public class Xoa_css_extractor {
|| !core_db_mgr.Tbl__cfg().Select_yn_or(Xow_cfg_consts.Grp__wiki_schema, Xowd_db_file_schema_props.Key__tbl_css_core, Bool_.N)
) return false;
Xowd_db_file core_db = core_db_mgr.Db__core();
gplx.xowa.html.css.Xowd_css_core_mgr.Get(core_db.Tbl__css_core(), core_db.Tbl__css_file(), wiki_html_dir);
gplx.xowa.html.css.Xowd_css_core_mgr.Get(core_db.Tbl__css_core(), core_db.Tbl__css_file(), wiki_html_dir, css_key);
return true;
}
public void Css_common_setup() {

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; import gplx.*;
import gplx.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.bldrs.*;
import gplx.core.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.bldrs.*;
abstract class Xoi_cmd_base implements Gfo_thread_cmd {
public void Ctor(Xoi_setup_mgr install_mgr, String wiki_key) {
this.install_mgr = install_mgr; this.wiki_key = wiki_key;
@@ -37,7 +37,7 @@ abstract class Xoi_cmd_base implements Gfo_thread_cmd {
public void Async_run() {
running = true;
// install_mgr.App().Gui_wtr().Log_many(GRP_KEY, "import.bgn", "import.bgn ~{0} ~{1} ~{2}", wiki_key, wiki_date, dump_type);
ThreadAdp_.invk_(this.Async_key(), this, Invk_process_async).Start();
Thread_adp_.invk_(this.Async_key(), this, Invk_process_async).Start();
}
public boolean Async_running() {return running;} private boolean running;
public void Process_async() {

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; import gplx.*;
import gplx.threads.*;
import gplx.core.threads.*;
class Xoi_cmd_dumpfile {
public byte[] Domain() {return domain;} private byte[] domain;
public Io_url Bz2_url() {return bz2_url;} Io_url bz2_url;

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; import gplx.*;
import gplx.threads.*;
import gplx.core.threads.*;
public class Xoi_cmd_mgr implements GfoInvkAble {
ListAdp cmds = ListAdp_.new_();
public Xoi_cmd_mgr(Xoi_setup_mgr install_mgr) {this.app = install_mgr.App(); this.install_mgr = install_mgr;} private Xoae_app app; Xoi_setup_mgr install_mgr;
@@ -33,7 +33,7 @@ public class Xoi_cmd_mgr implements GfoInvkAble {
while (cmd.Async_running()) {
if (canceled) {working = false; return;}
if (async_prog_enabled) cmd.Async_prog_run(async_sleep_sum);
ThreadAdp_.Sleep(async_sleep_interval);
Thread_adp_.Sleep(async_sleep_interval);
async_sleep_sum += async_sleep_interval; // NOTE: this is not exact
}
}
@@ -43,7 +43,7 @@ public class Xoi_cmd_mgr implements GfoInvkAble {
else
working = false;
}
private void Run_async(Gfo_thread_cmd cmd) {ThreadAdp_.invk_msg_(cmd.Async_key(), this, GfoMsg_.new_cast_(Invk_process_async).Add("v", cmd)).Start();}
private void Run_async(Gfo_thread_cmd cmd) {Thread_adp_.invk_msg_(cmd.Async_key(), this, GfoMsg_.new_cast_(Invk_process_async).Add("v", cmd)).Start();}
private void Cmds_run() {
if (working) {
app.Gui_mgr().Kit().Ask_ok("", "", "An import is in progress. Please wait for it to complete. If you want to do multiple imports at once, see Help:Import/Script.");

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.gfui.*;
import gplx.threads.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.utils.*;
import gplx.core.threads.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.utils.*;
class Xoi_cmd_wiki_download extends Gfo_thread_cmd_download implements Gfo_thread_cmd { private Xoi_setup_mgr install_mgr; private String wiki_key, dump_date, dump_type;
public Xoi_cmd_wiki_download Ctor_download_(Xoi_setup_mgr install_mgr, String wiki_key, String dump_date, String dump_type) {
this.install_mgr = install_mgr;
@@ -168,7 +168,7 @@ class Xoi_cmd_wiki_zip implements Gfo_thread_cmd {
public void Async_run() {
running = true;
install_mgr.App().Usr_dlg().Log_many(GRP_KEY, "zip.bgn", "zip.bgn ~{0}", wiki_key);
ThreadAdp_.invk_(this.Async_key(), this, Invk_process_async).Start();
Thread_adp_.invk_(this.Async_key(), this, Invk_process_async).Start();
}
public boolean Async_running() {
return running;

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; import gplx.*;
import gplx.threads.*; import gplx.xowa.bldrs.*; import gplx.xowa.gui.views.*; import gplx.xowa.bldrs.cmds.utils.*;
import gplx.core.threads.*; import gplx.xowa.bldrs.*; import gplx.xowa.gui.views.*; import gplx.xowa.bldrs.cmds.utils.*;
class Xoi_cmd_wiki_import implements Gfo_thread_cmd {
public Xoi_cmd_wiki_import(Xoi_setup_mgr install_mgr, String wiki_key, String wiki_date, String dump_type) {this.install_mgr = install_mgr; this.Owner_(install_mgr); this.wiki_key = wiki_key; this.wiki_date = wiki_date; this.dump_type = dump_type;} private Xoi_setup_mgr install_mgr; String wiki_key, wiki_date, dump_type;
public static final String KEY = "wiki.import";
@@ -35,7 +35,7 @@ class Xoi_cmd_wiki_import implements Gfo_thread_cmd {
public void Async_run() {
running = true;
install_mgr.App().Usr_dlg().Log_many(GRP_KEY, "import.bgn", "import.bgn ~{0} ~{1} ~{2}", wiki_key, wiki_date, dump_type);
ThreadAdp_.invk_(this.Async_key(), this, Invk_process_async).Start();
Thread_adp_.invk_(this.Async_key(), this, Invk_process_async).Start();
}
public boolean Async_running() {
return running;

View File

@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import org.junit.*;
import gplx.brys.*; import gplx.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.setup.maints.*; import gplx.xowa.xtns.wdatas.imports.*;
import gplx.brys.*; import gplx.core.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.setup.maints.*; import gplx.xowa.xtns.wdatas.imports.*;
public class Xoi_cmd_wiki_tst {
@Test public void Run() { // MAINT
@Test public void Run() { // MAIN
// Bld_import_list(Xow_wmf_api_mgr.Wikis);
// Bld_cfg_files(Xow_wmf_api_mgr.Wikis); // NOTE: remember to carry over the wikisource / page / index commands from the existing xowa_build_cfg.gfs; also, only run the xowa_build_cfg.gfs once; DATE:2013-10-15; last run: DATE:2014-09-09
}
@@ -75,7 +75,7 @@ public class Xoi_cmd_wiki_tst {
dump_file.Server_url_(Xob_dump_file_.Server_wmf);
if (dump_file.Connect()) break;
Tfds.WriteText(String_.Format("retrying: {0} {1}\n", count, dump_file.File_modified()));
ThreadAdp_.Sleep(15000); // wait for connection to reset
Thread_adp_.Sleep(15000); // wait for connection to reset
}
if (count == 10) {
Tfds.WriteText(String_.Format("failed: {0}\n", dump_file.File_url()));
@@ -101,7 +101,7 @@ public class Xoi_cmd_wiki_tst {
// bfr.Add_byte_pipe();
bfr.Add_str(dump_file.Dump_date());
bfr.Add_byte_nl();
ThreadAdp_.Sleep(1000);
Thread_adp_.Sleep(1000);
}
*/
public void Bld_cfg_files(String... ary) {