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

Wiki.Dom: Refactor Wiki.Props

This commit is contained in:
gnosygnu
2017-02-17 17:57:17 -05:00
parent 22b6d4dbde
commit c9e22b69f7
39 changed files with 216 additions and 635 deletions

View File

@@ -1,25 +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.addons.wikis.directorys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*;
public class Xowdir_wiki_cfg_ {
public static final String
Key__domain = "xowa.wiki.core.domain"
, Key__name = "xowa.wiki.core.name"
, Key__main_page = "props.main_page"
;
}

View File

@@ -16,6 +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.addons.wikis.directorys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*;
import gplx.xowa.wikis.data.*;
public class Xowdir_wiki_props {
public Xowdir_wiki_props() {}
public Xowdir_wiki_props(String domain, String name, String main_page) {
@@ -33,9 +34,9 @@ public class Xowdir_wiki_props {
}
public void Set(String key, String val) {
if (String_.Eq(key, Xowdir_wiki_cfg_.Key__domain)) this.domain = val;
else if (String_.Eq(key, Xowdir_wiki_cfg_.Key__name)) this.name = val;
else if (String_.Eq(key, Xowdir_wiki_cfg_.Key__main_page)) this.main_page = val;
if (String_.Eq(key, Xowd_cfg_key_.Key__wiki_core__domain)) this.domain = val;
else if (String_.Eq(key, Xowd_cfg_key_.Key__wiki_core__name)) this.name = val;
else if (String_.Eq(key, Xowd_cfg_key_.Key__init__main_page)) this.main_page = val;
else throw Err_.new_unhandled_default(key);
}

View File

@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.wikis.directorys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*;
import gplx.langs.jsons.*;
import gplx.xowa.wikis.data.*;
public interface Xowdir_wiki_props_mgr {
void Wiki_cfg__upsert(String key, String val);
String Wiki_cfg__select_or(String key, String or);
@@ -36,9 +37,9 @@ abstract class Xowdir_wiki_props_mgr__base implements Xowdir_wiki_props_mgr {
public Xowdir_wiki_props Verify(boolean mode_is_import, String domain_str, Io_url core_db_url) {
Xowdir_wiki_props rv = new Xowdir_wiki_props();
Verify_or_fix(rv, core_db_url, Xowdir_wiki_cfg_.Key__domain);
Verify_or_fix(rv, core_db_url, Xowdir_wiki_cfg_.Key__main_page);
Verify_or_fix(rv, core_db_url, Xowdir_wiki_cfg_.Key__name);
Verify_or_fix(rv, core_db_url, Xowd_cfg_key_.Key__wiki_core__domain);
Verify_or_fix(rv, core_db_url, Xowd_cfg_key_.Key__init__main_page);
Verify_or_fix(rv, core_db_url, Xowd_cfg_key_.Key__wiki_core__name);
return rv;
}
@@ -54,16 +55,16 @@ abstract class Xowdir_wiki_props_mgr__base implements Xowdir_wiki_props_mgr {
return val;
}
private static String Fix(Xowdir_wiki_props props, Io_url core_db_url, String key) {
if (String_.Eq(key, Xowdir_wiki_cfg_.Key__domain)) {
if (String_.Eq(key, Xowd_cfg_key_.Key__wiki_core__domain)) {
String rv = core_db_url.NameOnly();
if (String_.Has_at_end(rv, "-core"))
rv = String_.Mid(rv, 0, String_.Len(rv) - 5);
return rv;
}
else if (String_.Eq(key, Xowdir_wiki_cfg_.Key__name)) {
else if (String_.Eq(key, Xowd_cfg_key_.Key__wiki_core__name)) {
return props.Domain(); // NOTE: must be called after domain
}
else if (String_.Eq(key, Xowdir_wiki_cfg_.Key__main_page)) {
else if (String_.Eq(key, Xowd_cfg_key_.Key__init__main_page)) {
return Xoa_page_.Main_page_str;
}
else throw Err_.new_unhandled_default(key);

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.addons.wikis.directorys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*;
import org.junit.*; import gplx.core.tests.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.data.*;
public class Xowdir_wiki_props_mgr__tst {
private final Xowdir_wiki_props_mgr__fxt fxt = new Xowdir_wiki_props_mgr__fxt();
@@ -47,9 +47,9 @@ class Xowdir_wiki_props_mgr__fxt {
return new Xowdir_wiki_props(domain, name, main_page);
}
public void Init__props(String domain, String name, String main_page) {
mgr.Wiki_cfg__upsert(Xowdir_wiki_cfg_.Key__domain, domain);
mgr.Wiki_cfg__upsert(Xowdir_wiki_cfg_.Key__name, name);
mgr.Wiki_cfg__upsert(Xowdir_wiki_cfg_.Key__main_page, main_page);
mgr.Wiki_cfg__upsert(Xowd_cfg_key_.Key__wiki_core__domain, domain);
mgr.Wiki_cfg__upsert(Xowd_cfg_key_.Key__wiki_core__name, name);
mgr.Wiki_cfg__upsert(Xowd_cfg_key_.Key__init__main_page, main_page);
}
public void Test__verify(boolean mode_is_import, String url, boolean expd_dirty, Xowdir_wiki_props expd) {
Xowdir_wiki_props actl = mgr.Verify(mode_is_import, "", Io_url_.new_any_(url));

View File

@@ -55,10 +55,8 @@ public class Xow_db_mkr {
Db_cfg_tbl cfg_tbl = Db_cfg_tbl.Get_by_key(core_db, Xowd_cfg_tbl_.Tbl_name);
Xowd_core_db_props props = new Xowd_core_db_props(2, Xow_db_layout.Itm_all, Xow_db_layout.Itm_all, Xow_db_layout.Itm_all, Io_stream_tid_.Tid__raw, Io_stream_tid_.Tid__raw, Bool_.N, Bool_.N);
props.Cfg_save(cfg_tbl);
cfg_tbl.Insert_str(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__modified_latest, Datetime_now.Get().XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time));
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__main_page, mainpage_name);
cfg_tbl.Insert_str(Xow_cfg_consts.Grp__empty, Xowdir_wiki_cfg_.Key__domain , data.Domain());
cfg_tbl.Insert_str(Xow_cfg_consts.Grp__empty, Xowdir_wiki_cfg_.Key__name , wiki_name);
Xowd_cfg_tbl_.Insert__create(cfg_tbl, data.Domain(), wiki_name, mainpage_name);
// insert data: page
Xopg_db_mgr.Create

View File

@@ -38,7 +38,7 @@ public class Xob_css_cmd implements Xob_cmd {
core_db.Tbl__css_core().Create_tbl();
core_db.Tbl__css_file().Create_tbl();
gplx.xowa.addons.wikis.htmls.css.mgrs.Xowd_css_core_mgr.Set(core_db.Tbl__css_core(), core_db.Tbl__css_file(), css_dir, css_key);
core_db.Tbl__cfg().Upsert_yn(Xow_cfg_consts.Grp__wiki_schema, Xow_db_file_schema_props.Key__tbl_css_core, Bool_.Y);
core_db.Tbl__cfg().Upsert_yn(Xowd_cfg_key_.Grp__wiki_schema, Xow_db_file_schema_props.Key__tbl_css_core, Bool_.Y);
core_db.Conn().Txn_end();
usr_dlg.Plog_many("", "", Cmd_key() + ":end;");
}

View File

@@ -51,7 +51,7 @@ public class Xob_css_status {
if ( core_db_mgr == null
|| core_db_mgr.Props() != null
|| !core_db_mgr.Props().Schema_is_1()
|| core_db_mgr.Tbl__cfg().Select_yn_or(Xow_cfg_consts.Grp__wiki_schema, Xow_db_file_schema_props.Key__tbl_css_core, Bool_.N)
|| core_db_mgr.Tbl__cfg().Select_yn_or(Xowd_cfg_key_.Grp__wiki_schema, Xow_db_file_schema_props.Key__tbl_css_core, Bool_.N)
) {
rv.Db_exists_(false);
if (rv.Fs_exists())