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:
@@ -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.insiders; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.xtns.pfuncs.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Insider_func extends Pf_func_base {
|
||||
@Override public int Id() {return Xol_kwd_grp_.Id_insider;}
|
||||
@Override public Pf_func New(int id, byte[] name) {return new Insider_func().Name_(name);}
|
||||
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
|
||||
byte[] val = Eval_argx(ctx, src, caller, self);
|
||||
Xopg_xtn_skin_mgr skin_mgr = ctx.Page().Html_data().Xtn_skin_mgr();
|
||||
Insider_xtn_skin_itm skin_itm = (Insider_xtn_skin_itm)skin_mgr.Get_or_null(Insider_xtn_skin_itm.KEY);
|
||||
if (skin_itm == null) {
|
||||
skin_itm = new Insider_xtn_skin_itm(ctx.Wiki().Xtn_mgr().Xtn_insider().Html_bldr());
|
||||
skin_mgr.Add(skin_itm);
|
||||
}
|
||||
skin_itm.Add(val);
|
||||
}
|
||||
public static final Insider_func Instance = new Insider_func(); Insider_func() {}
|
||||
}
|
||||
@@ -1,38 +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.insiders; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Insider_func_tst {
|
||||
@Before public void init() {fxt.Reset();} private Insider_func_fxt fxt = new Insider_func_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse("{{#insider:A}}x{{#insider:B}}", "x", "A", "B");
|
||||
}
|
||||
}
|
||||
class Insider_func_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
public void Reset() {
|
||||
fxt.Reset();
|
||||
}
|
||||
public void Test_parse(String raw, String expd, String... insiders) {
|
||||
fxt.Test_parse_tmpl_str_test(raw, "{{test}}", expd);
|
||||
Insider_xtn_skin_itm skin_itm = (Insider_xtn_skin_itm)fxt.Page().Html_data().Xtn_skin_mgr().Get_or_null(Insider_xtn_skin_itm.KEY);
|
||||
List_adp list = skin_itm.Itms();
|
||||
byte[][] brys = (byte[][])list.To_ary(byte[].class);
|
||||
Tfds.Eq_ary_str(insiders, String_.Ary(brys));
|
||||
}
|
||||
}
|
||||
@@ -1,77 +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.insiders; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
class Insider_xtn_skin_itm implements Xopg_xtn_skin_itm {
|
||||
private List_adp itms = List_adp_.New();
|
||||
private Insider_html_bldr html_bldr;
|
||||
public Insider_xtn_skin_itm(Insider_html_bldr html_bldr) {this.html_bldr = html_bldr;}
|
||||
public byte Tid() {return Xopg_xtn_skin_itm_tid.Tid_sidebar;}
|
||||
public byte[] Key() {return KEY;} public static final byte[] KEY = Bry_.new_a7("Insider");
|
||||
public List_adp Itms() {return itms;}
|
||||
public void Add(byte[] itm) {itms.Add(itm);}
|
||||
public void Write(Bry_bfr bfr, Xoae_page page) {
|
||||
html_bldr.Bld_all(bfr, page, itms);
|
||||
}
|
||||
}
|
||||
public class Insider_html_bldr implements gplx.core.brys.Bfr_arg {
|
||||
private Insider_xtn_mgr xtn_mgr;
|
||||
private Bry_bfr tmp_ttl = Bry_bfr_.Reset(255);
|
||||
private List_adp list; private int list_len;
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Insider_html_bldr(Insider_xtn_mgr xtn_mgr) {this.xtn_mgr = xtn_mgr;}
|
||||
public void Bld_all(Bry_bfr bfr, Xoae_page page, List_adp list) {
|
||||
this.list = list; this.list_len = list.Count();
|
||||
hash.Clear();
|
||||
fmtr_grp.Bld_bfr_many(bfr, xtn_mgr.Msg_sidebar_ttl(), xtn_mgr.Msg_about_page(), xtn_mgr.Msg_about_ttl(), this);
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Xowe_wiki wiki = xtn_mgr.Wiki();
|
||||
Gfo_url_encoder href_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Href;
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
byte[] itm = (byte[])list.Get_at(i);
|
||||
Xoa_ttl user_ttl = Xoa_ttl.Parse(wiki, Xow_ns_.Tid__user, itm);
|
||||
if (user_ttl == null) continue;
|
||||
byte[] user_ttl_bry = user_ttl.Full_db();
|
||||
if (hash.Has(user_ttl_bry)) continue;
|
||||
hash.Add(user_ttl_bry, user_ttl_bry);
|
||||
href_encoder.Encode(tmp_ttl, user_ttl_bry);
|
||||
user_ttl_bry = tmp_ttl.To_bry_and_clear();
|
||||
fmtr_itm.Bld_bfr(bfr, user_ttl_bry, user_ttl.Page_txt());
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr
|
||||
fmtr_grp = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id='p-insiders' class='portal' role='navigation'>"
|
||||
, " <h3>~{hdr}</h3>"
|
||||
, " <div class='body'>"
|
||||
, " <ul>~{itms}"
|
||||
, " <li class='interwiki-insider'><a class='xowa-hover-off' href='/wiki/~{about_href}'>~{about_text}</a></li>"
|
||||
, " </ul>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
), "hdr", "about_href", "about_text", "itms")
|
||||
, fmtr_itm = Bry_fmtr.new_
|
||||
( "\n <li class='interwiki-insider'><a class='xowa-hover-off' href='/wiki/~{href}'>~{name}</a></li>"
|
||||
, "href", "name")
|
||||
;
|
||||
}
|
||||
@@ -1,62 +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.insiders; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Insider_html_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Insider_html_bldr_fxt fxt = new Insider_html_bldr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_insider("A_1");
|
||||
fxt.Test_bld(String_.Concat_lines_nl_skip_last
|
||||
( "<div id='p-insiders' class='portal' role='navigation'>"
|
||||
, " <h3>Docent</h3>"
|
||||
, " <div class='body'>"
|
||||
, " <ul>"
|
||||
, " <li class='interwiki-insider'><a class='xowa-hover-off' href='/wiki/User:A_1'>A 1</a></li>"
|
||||
, " <li class='interwiki-insider'><a class='xowa-hover-off' href='/wiki/Docent_page'>About Docents</a></li>"
|
||||
, " </ul>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Insider_html_bldr_fxt {
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private Insider_xtn_mgr xtn_mgr;
|
||||
private Insider_xtn_skin_itm skin_itm;
|
||||
public void Clear() {
|
||||
this.app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Xop_fxt.Init_msg(wiki, "insider-title", "Docent");
|
||||
Xop_fxt.Init_msg(wiki, "insider-about", "About Docents");
|
||||
Xop_fxt.Init_msg(wiki, "insider-about-page", "Docent_page");
|
||||
this.xtn_mgr = wiki.Xtn_mgr().Xtn_insider();
|
||||
xtn_mgr.Enabled_y_();
|
||||
xtn_mgr.Xtn_init_by_wiki(wiki);
|
||||
this.page = wiki.Parser_mgr().Ctx().Page();
|
||||
skin_itm = new Insider_xtn_skin_itm(xtn_mgr.Html_bldr());
|
||||
page.Html_data().Xtn_skin_mgr().Add(skin_itm);
|
||||
}
|
||||
public void Init_insider(String lnki_ttl) {
|
||||
skin_itm.Add(Bry_.new_u8(lnki_ttl));
|
||||
}
|
||||
public void Test_bld(String expd) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
skin_itm.Write(tmp_bfr, page);
|
||||
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,40 +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.insiders; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.wikis.*;
|
||||
public class Insider_xtn_mgr extends Xox_mgr_base {
|
||||
public Insider_xtn_mgr() {
|
||||
html_bldr = new Insider_html_bldr(this);
|
||||
}
|
||||
@Override public boolean Enabled_default() {return false;}
|
||||
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("Insider");
|
||||
@Override public Xox_mgr Xtn_clone_new() {return new Insider_xtn_mgr();}
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
if (!Enabled()) return;
|
||||
Xox_mgr_base.Xtn_load_i18n(wiki, XTN_KEY);
|
||||
msg_sidebar_ttl = wiki.Msg_mgr().Val_by_key_obj("insider-title");
|
||||
msg_about_ttl = wiki.Msg_mgr().Val_by_key_obj("insider-about");
|
||||
msg_about_page = wiki.Msg_mgr().Val_by_key_obj("insider-about-page");
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Insider_html_bldr Html_bldr() {return html_bldr;} private Insider_html_bldr html_bldr;
|
||||
public byte[] Msg_sidebar_ttl() {return msg_sidebar_ttl;} private byte[] msg_sidebar_ttl;
|
||||
public byte[] Msg_about_ttl() {return msg_about_ttl;} private byte[] msg_about_ttl;
|
||||
public byte[] Msg_about_page() {return msg_about_page;} private byte[] msg_about_page;
|
||||
}
|
||||
Reference in New Issue
Block a user