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

Wiki: Support renamed folders (fix)

This commit is contained in:
gnosygnu
2017-02-06 22:12:56 -05:00
parent 6f9e92afff
commit 938beac9f9
4379 changed files with 0 additions and 327818 deletions

View File

@@ -1,49 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.htmls.*;
class Xo_custom_html_pos_ {
public static final byte Tid__head_end = 1, Tid__tail = 2;
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
.Add_str_byte("head_end", Tid__head_end)
.Add_str_byte("tail", Tid__tail)
;
public static byte To_tid(byte[] bry) {
byte tid = hash.Get_as_byte_or(bry, Byte_.Max_value_127);
if (tid == Byte_.Max_value_127) throw Err_.new_wo_type("unknown pos", "pos", bry);
return tid;
}
}
class Xo_custom_html_type_ {
public static final byte Tid__css_code = 1, Tid__js_code = 2;
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
.Add_bry_byte(Gfh_tag_.Bry__style , Tid__css_code)
.Add_bry_byte(Gfh_tag_.Bry__script , Tid__js_code)
;
public static byte[] To_bry(byte tid) {
switch (tid) {
case Tid__css_code: return Gfh_tag_.Bry__style;
case Tid__js_code : return Gfh_tag_.Bry__script;
default: throw Err_.new_unhandled_default(tid);
}
}
public static byte To_tid(byte[] bry) {
byte tid = hash.Get_as_byte_or(bry, Byte_.Max_value_127); if (tid == Byte_.Max_value_127) throw Err_.new_wo_type("unknown type", "type", bry);
return tid;
}
}

View File

@@ -1,44 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
public class Xop_xowa_cmd implements Xox_xnde {
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_cmd.xtn_root should not be called");}
public byte[] Xtn_html() {return xtn_html;} private byte[] xtn_html;
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
int itm_bgn = xnde.Tag_open_end(), itm_end = xnde.Tag_close_bgn();
if (itm_bgn == src.length) return; // NOTE: handle inline where there is no content to parse; EX: <xowa_cmd/>
if (src[itm_bgn] == Byte_ascii.Nl) ++itm_bgn; // ignore 1st \n;
if (src[itm_end - 1] == Byte_ascii.Nl) --itm_end; // ignore last \n;
byte[] raw = Bry_.Mid(src, itm_bgn, itm_end);
byte[] xtn_src = raw;
if (wiki.Sys_cfg().Xowa_cmd_enabled()) { // only exec if enabled for wiki
Object rslt = wiki.Appe().Gfs_mgr().Run_str(String_.new_u8(raw));
xtn_src = Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(rslt));
}
Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
Xop_ctx sub_ctx = Xop_ctx.New__sub__reuse_page(ctx);
Xop_root_tkn sub_root = tkn_mkr.Root(xtn_src);
xtn_html = wiki.Parser_mgr().Main().Expand_tmpl(sub_root, sub_ctx, ctx.Tkn_mkr(), xtn_src);
}
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {
bfr.Add(xtn_html);
//throw Err_.new_unimplemented_w_msg("xowa_cmd.xtn_write should not be called");
}
}

View File

@@ -1,95 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
import gplx.xowa.apps.gfs.*;
import gplx.langs.gfs.*;
public class Xop_xowa_cmd_tst {
@Before public void init() {
Xoa_gfs_mgr.Msg_parser_init();
fxt.Reset();
} private final Xop_fxt fxt = new Xop_fxt();
@Test public void Basic() {
GfsCore.Instance.AddCmd(fxt.App(), Xoae_app.Invk_app);
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(false);
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
( "<xowa_cmd>"
, "app.users.get('anonymous').name;"
, "</xowa_cmd>"
), String_.Concat_lines_nl_skip_last
( "app.users.get('anonymous').name;"
));
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(true);
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
( "<xowa_cmd>"
, "app.users.get('anonymous').name;"
, "</xowa_cmd>"
), String_.Concat_lines_nl_skip_last
( "anonymous"
));
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(false);
}
@Test public void Template() { // PURPOSE: xowa_cmd should do template expansion; DATE:2014-05-29
fxt.Init_page_create("Template:Xowa_cmd_test", "val_0");
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
( "<xowa_cmd>{{xowa_cmd_test}}</xowa_cmd>"
), String_.Concat_lines_nl_skip_last
( "val_0"
));
}
@Test public void Ref() { // PURPOSE: ref should not be expanded twice; DATE:2014-05-29
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
( "<xowa_cmd><ref name='a'></ref><references/></xowa_cmd>"
), String_.Concat_lines_nl_skip_last
( "<sup id=\"cite_ref-a_0-0\" class=\"reference\"><a href=\"#cite_note-a-0\">[1]</a></sup><ol class=\"references\">"
, "<li id=\"cite_note-a-0\"><span class=\"mw-cite-backlink\"><a href=\"#cite_ref-a_0-0\">^</a></span> <span class=\"reference-text\"></span></li>"
, "</ol>"
, ""
));
}
// @Test public void Xow_list_fmtrs() {
// fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(true);
// fxt.App().Setup_mgr().Maint_mgr().Wiki_mgr().Add(Bry_.new_a7("en.wikipedia.org"));
// fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
// ( "{|"
// , "<xowa_cmd>"
// , "app.fmtrs.new_grp {"
// , " src = 'app.setup.maint.wikis;';"
// , " fmt ='"
// , "|-"
// , "|~{<>domain;<>}'"
// , ";"
// , " run;"
// , "}"
// , "</xowa_cmd>"
// , "|}"
// ), String_.Concat_lines_nl
// ( "<table>"
// , " <tr>"
// , " <td>en.wikipedia.org"
// , " </td>"
// , " </tr>"
//// , " <tr>"
//// , " <td>home"
//// , " </td>"
//// , " </tr>"
// , "</table>"
// )
// );
// }
}

View File

@@ -1,36 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
public class Xop_xowa_func extends Pf_func_base {
@Override public int Id() {return Xol_kwd_grp_.Id_xowa;}
@Override public Pf_func New(int id, byte[] name) {return new Xop_xowa_func().Name_(name);}
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
if (ctx.Wiki().Sys_cfg().Xowa_cmd_enabled()) { // only exec if enabled for wiki
int args_len = self.Args_len();
byte[] arg_0 = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, args_len, 0);
Object rslt = ctx.App().Gfs_mgr().Run_str(String_.new_u8(arg_0));
bfr.Add(Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(rslt)));
}
else {
bfr.Add_mid(src, self.Src_bgn(), self.Src_end());
}
}
}

View File

@@ -1,31 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
import gplx.xowa.apps.gfs.*; import gplx.langs.gfs.*;
public class Xop_xowa_func_tst {
@Before public void init() {
Xoa_gfs_mgr.Msg_parser_init();
} private final Xop_fxt fxt = new Xop_fxt();
@Test public void Template() {
GfsCore.Instance.AddCmd(fxt.App(), Xoae_app.Invk_app);
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(true);
fxt.Init_defn_add("A", "{{#xowa|{{{1}}}}}");
fxt.Test_parse_page_all_str("{{A|app.users.get('anonymous').name;}}", "anonymous");
}
}

View File

@@ -1,60 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.htmls.*;
public class Xox_xowa_html_cmd implements Xox_xnde, Mwh_atr_itm_owner2 {
private byte tag_pos = Xo_custom_html_pos_.Tid__head_end, tag_type = Xo_custom_html_type_.Tid__css_code;
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
switch (xatr_id) {
case Xatr__pos: tag_pos = Xo_custom_html_pos_.To_tid(xatr.Val_as_bry()); break;
case Xatr__type: tag_type = Xo_custom_html_type_.To_tid(xatr.Val_as_bry()); break;
default: throw Err_.new_unhandled(xatr_id);
}
}
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
if (!wiki.Sys_cfg().Xowa_cmd_enabled()) { // not allowed; warn and exit
wiki.Appe().Usr_dlg().Warn_many("", "", "xowa_html command only allowed in xowa_home");
return;
}
// parse xnde for tag_name, tag_body
Xox_xnde_.Parse_xatrs(wiki, this, xatr_hash, src, xnde);
byte[] name = Xo_custom_html_type_.To_bry(tag_type);
int raw_bgn = xnde.Tag_open_end(), raw_end = xnde.Tag_close_bgn();
raw_bgn = Bry_find_.Find_fwd_while_ws(src, raw_bgn, raw_end);
raw_end = Bry_find_.Find_bwd__skip_ws(src, raw_end, raw_bgn);
if (src[raw_bgn] == Byte_ascii.Nl) ++raw_bgn;
if (src[raw_bgn] == Byte_ascii.Nl) ++raw_bgn;
byte[] raw = Bry_.Mid(src, raw_bgn, raw_end);
// add to custom tags
Xopg_html_data html_data = ctx.Page().Html_data();
Xopg_tag_mgr tag_mgr = tag_pos == Xo_custom_html_pos_.Tid__tail ? html_data.Custom_tail_tags() : html_data.Custom_head_tags();
Xopg_tag_itm tag_itm = Bry_.Eq(name, Gfh_tag_.Bry__style) ? Xopg_tag_itm.New_css_code(raw) : Xopg_tag_itm.New_js_code(raw);
tag_mgr.Add(tag_itm);
}
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {}
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_html_cmd.xtn_root should not be called");}
public byte[] Xtn_html() {throw Err_.new_unimplemented_w_msg("xowa_html_cmd.xtn_html should not be called");}
private static final byte Xatr__pos = 1, Xatr__type = 2;
private static final Hash_adp_bry xatr_hash = Hash_adp_bry.ci_a7().Add_str_byte("pos", Xatr__pos).Add_str_byte("type", Xatr__type);
}

View File

@@ -1,57 +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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
import gplx.xowa.htmls.*; import gplx.xowa.guis.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
import gplx.xowa.parsers.*;
public class Xox_xowa_html_cmd_tst {
@Before public void init() {Xopg_tag_wtr.Loader_as_script_static = Bool_.N; fxt.Clear();} private Xox_xowa_html_cmd_fxt fxt = new Xox_xowa_html_cmd_fxt();
@Test public void term() {Xopg_tag_wtr.Loader_as_script_static = Bool_.Y;}
@Test public void Head_end() {
fxt.Test_parse_w_skin
( "<xowa_html pos='head_end'>test</xowa_html>"
, "<html><head><style data-source=\"xowa\" type=\"text/css\">\ntest\n</style>\n</head><body></body></html>"
);
}
@Test public void Tail() {
fxt.Test_parse_w_skin
( "<xowa_html pos='tail'>test</xowa_html>"
, "<html><head></head><body></body><style data-source=\"xowa\" type=\"text/css\">\ntest\n</style>\n</html>"
);
}
}
class Xox_xowa_html_cmd_fxt {
private Bry_bfr bfr = Bry_bfr_.Reset(16);
private final Xop_fxt fxt = new Xop_fxt();
private Xowe_wiki wiki; private Xow_html_mgr html_mgr;
public void Clear() {
this.wiki = fxt.Wiki();
html_mgr = wiki.Html_mgr();
wiki.Sys_cfg().Xowa_cmd_enabled_(true);
fxt.Page().Html_data().Head_mgr().Itm__css().Enabled_(false);
html_mgr.Page_wtr_mgr().Page_read_fmtr().Fmt_("<html><head></head><body>~{page_data}</body></html>");
}
public void Test_parse_w_skin(String raw, String expd) {
byte[] raw_bry = Bry_.new_u8(raw);
Xop_root_tkn root = fxt.Exec_parse_page_all_as_root(raw_bry);
fxt.Page().Root_(root);
html_mgr.Html_wtr().Write_doc(bfr, fxt.Ctx(), raw_bry, root);
html_mgr.Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_page(bfr, fxt.Page(), fxt.Ctx());
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
}

View File

@@ -1,76 +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.xtns.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.mustaches.*;
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*;
import gplx.xowa.addons.bldrs.exports.packs.files.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
import gplx.xowa.parsers.*;
class Xop_wiki_setup_mgr {
private final Mustache_tkn_parser parser = new Mustache_tkn_parser();
private Xobc_data_db data_db;
public Xop_root_tkn Write(Xoae_app app, Xowe_wiki wiki, Xop_ctx ctx, Xoae_page wpg, byte[] language, byte[][] wiki_domains) {
Io_url mustache_url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "wiki_setup", "wiki_setup_main.mustache.html");
Mustache_tkn_itm root = parser.Parse(Io_mgr.Instance.LoadFilBry(mustache_url));
Mustache_render_ctx mctx = new Mustache_render_ctx();
Bry_bfr tmp_bfr = Bry_bfr_.New();
Mustache_bfr mbfr = new Mustache_bfr(tmp_bfr);
this.data_db = Xobc_data_db.New(app.Fsys_mgr());
root.Render(mbfr, mctx.Init(Make_root(language, wiki_domains)));
return wiki.Parser_mgr().Main().Parse_text_to_wdom(Xop_ctx.New__sub(wiki, ctx, wpg), mbfr.To_bry_and_clear(), true);
}
private Xows_root_itm Make_root(byte[] language, byte[][] wiki_domains) {
Bry_bfr url_list_bfr = Bry_bfr_.New();
int len = wiki_domains.length;
Xows_wiki_itm[] wiki_ary = new Xows_wiki_itm[len];
for (int i = 0; i < len; ++i) {
byte[] wiki_domain = wiki_domains[i];
wiki_ary[i] = new Xows_wiki_itm(wiki_domain, Make_task_ary(url_list_bfr, wiki_domain));
}
return new Xows_root_itm(language, url_list_bfr.To_bry_and_clear(), wiki_ary);
}
private Xows_task_itm[] Make_task_ary(Bry_bfr url_list_bfr, byte[] wiki_domain) {
Xobc_task_regy_itm[] task_rows = data_db.Tbl__task_regy().Select_by_wiki(wiki_domain);
int len = task_rows.length;
Xows_task_itm[] rv = new Xows_task_itm[len];
for (int i = 0; i < len; ++i) {
Xobc_task_regy_itm task_row = task_rows[i];
Xobc_task_key task_key = Xobc_task_key.To_itm(String_.new_u8(task_row.Key()));
String task_key_type = task_key.Task_type_ui();
Xows_file_itm[] files = Make_file_ary(url_list_bfr, wiki_domain, task_row.Id());
rv[i] = new Xows_task_itm(task_row.Seqn(), wiki_domain, task_row.Name(), Bry_.new_u8(task_key_type), Bry_.new_u8(task_key.Wiki_date_ui()), files);
}
Array_.Sort(rv, new Xows_task_itm_sorter());
return rv;
}
private Xows_file_itm[] Make_file_ary(Bry_bfr url_list_bfr, byte[] wiki_domain, int task_id) {
Xobc_import_step_itm[] rows = data_db.Tbl__import_step().Select_by_task_id(task_id);
int len = rows.length;
Xows_file_itm[] rv = new Xows_file_itm[len];
Host_eval_itm host_eval = new Host_eval_itm();
for (int i = 0; i < len; ++i) {
Xobc_import_step_itm row = rows[i];
String src_fil = host_eval.Eval_src_fil(data_db, row.Host_id, gplx.xowa.wikis.domains.Xow_domain_itm_.parse(wiki_domain), row.Import_name);
url_list_bfr.Add_str_u8(src_fil).Add_byte_nl();
rv[i] = new Xows_file_itm(row.Step_id, Bry_.new_u8(src_fil));
}
Array_.Sort(rv, new Xows_file_itm_sorter());
return rv;
}
}

View File

@@ -1,52 +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.xtns.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.htmls.*;
public class Xop_wiki_setup_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
private byte[] language;
private byte[][] wikis_ary;
private Xop_root_tkn root;
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
switch (xatr_id) {
case Xatr__language: language = xatr.Val_as_bry(); break;
case Xatr__wikis: wikis_ary = Bry_split_.Split(xatr.Val_as_bry(), Byte_ascii.Pipe_bry); break;
default: Gfo_usr_dlg_.Instance.Warn_many("", "", "unhandled xnde atr; key=~{0}", xatr.Key_bry()); break;
}
}
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
if (!wiki.Sys_cfg().Xowa_cmd_enabled()) { // not allowed; warn and exit
wiki.Appe().Usr_dlg().Warn_many("", "", "xowa_wiki_setup only allowed in xowa_home");
return;
}
Xox_xnde_.Parse_xatrs(wiki, this, xatr_hash, src, xnde);
this.root = new Xop_wiki_setup_mgr().Write(wiki.Appe(), wiki, ctx, ctx.Page(), language, wikis_ary);
}
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {
html_wtr.Write_tkn_to_html(bfr, ctx, hctx, root.Root_src(), xnde, Xoh_html_wtr.Sub_idx_null, root);
//
}
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_wiki_setup.xtn_root should not be called");}
public byte[] Xtn_html() {throw Err_.new_unimplemented_w_msg("xowa_wiki_setup.xtn_html should not be called");}
private static final byte Xatr__language = 1, Xatr__wikis = 2;
private static final Hash_adp_bry xatr_hash = Hash_adp_bry.ci_a7().Add_str_byte("language", Xatr__language).Add_str_byte("wikis", Xatr__wikis);
}

View File

@@ -1,108 +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.xtns.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.mustaches.*;
class Xows_root_itm implements Mustache_doc_itm {
private final byte[] language, url_list;
private final Xows_wiki_itm[] wiki_ary;
public Xows_root_itm(byte[] language, byte[] url_list, Xows_wiki_itm[] wiki_ary) {
this.language = language;
this.url_list = url_list;
this.wiki_ary = wiki_ary;
}
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "language")) bfr.Add_bry(language);
else if (String_.Eq(key, "url_list")) bfr.Add_bry(url_list);
else if (String_.Eq(key, "wikis__1st")) bfr.Add_bry(wiki_ary[0].Wiki_domain());
else return false;
return false;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "wikis")) return wiki_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_wiki_itm implements Mustache_doc_itm {
private final Xows_task_itm[] task_ary;
public Xows_wiki_itm(byte[] wiki_domain, Xows_task_itm[] task_ary) {
this.wiki_domain = wiki_domain;
this.task_ary = task_ary;
}
public byte[] Wiki_domain() {return wiki_domain;} private final byte[] wiki_domain;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "tasks")) return task_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_task_itm implements Mustache_doc_itm {
private final byte[] wiki_domain, task_full_name, task_name, task_date;
private final Xows_file_itm[] file_ary;
public Xows_task_itm(int seqn_id, byte[] wiki_domain, byte[] task_full_name, byte[] task_name, byte[] task_date, Xows_file_itm[] file_ary) {
this.seqn_id = seqn_id;
this.wiki_domain = wiki_domain; this.task_full_name = task_full_name; this.task_name = task_name; this.task_date = task_date;
this.file_ary = file_ary;
}
public int Seqn_id() {return seqn_id;} private final int seqn_id;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain);
else if (String_.Eq(key, "task_name")) bfr.Add_bry(task_name);
else if (String_.Eq(key, "task_full_name")) bfr.Add_bry(task_full_name);
else if (String_.Eq(key, "task_date")) bfr.Add_bry(task_date);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "files")) return file_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_file_itm implements Mustache_doc_itm {
private final byte[] file_href;
public Xows_file_itm(int step_id, byte[] file_href) {
this.step_id = step_id;
this.file_href = file_href;
}
public int Step_id() {return step_id;} private final int step_id;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "file_href")) bfr.Add_bry(file_href);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_task_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Xows_task_itm lhs = (Xows_task_itm)lhsObj;
Xows_task_itm rhs = (Xows_task_itm)rhsObj;
return Int_.Compare(lhs.Seqn_id(), rhs.Seqn_id());
}
}
class Xows_file_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Xows_file_itm lhs = (Xows_file_itm)lhsObj;
Xows_file_itm rhs = (Xows_file_itm)rhsObj;
return Int_.Compare(lhs.Step_id(), rhs.Step_id());
}
}