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

'v3.4.2.1'

This commit is contained in:
gnosygnu
2016-04-11 00:12:19 -04:00
parent b2a06b8125
commit 14471ca656
197 changed files with 1918 additions and 1275 deletions

View File

@@ -20,7 +20,7 @@ import gplx.xowa.users.history.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.specials.*;
import gplx.xowa.specials.*;
import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.nearby.*; import gplx.xowa.specials.randoms.*; import gplx.xowa.specials.statistics.*; import gplx.xowa.xtns.translates.*; import gplx.xowa.specials.movePage.*;
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.specials.xowa.file_browsers.*; import gplx.xowa.specials.xowa.diags.*;
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.addons.apps.file_browsers.*; import gplx.xowa.specials.xowa.diags.*;
import gplx.xowa.xtns.wdatas.specials.*;
import gplx.xowa.addons.apps.searchs.specials.*;
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
@@ -47,46 +47,49 @@ public class Xows_mgr {
public System_data_page Page_system_data() {return page_system_data;} private final System_data_page page_system_data = new System_data_page();
public Default_tab_page Page_default_tab() {return page_default_tab;} private final Default_tab_page page_default_tab = new Default_tab_page();
public Popup_history_page Page_popup_history() {return page_popup_history;} private final Popup_history_page page_popup_history = new Popup_history_page();
public Xosp_fbrow_special Page_file_browser() {return page_file_browser;} private final Xosp_fbrow_special page_file_browser = new Xosp_fbrow_special();
public Xows_bmk_page Page_bmk() {return page_bmk;} private final Xows_bmk_page page_bmk = new Xows_bmk_page();
public Xows_diag_page Page_diag() {return page_diag;} private final Xows_diag_page page_diag = new Xows_diag_page();
public void Evt_lang_changed(Xol_lang_itm lang) {
hash.Clear();
hash.Add_str_obj(Xows_special_meta_.Key__search , page_search);
hash.Add_str_obj(Xows_special_meta_.Key__all_pages , page_allpages);
hash.Add_str_obj(Xows_special_meta_.Ttl__search , page_search);
hash.Add_str_obj(Xows_special_meta_.Ttl__all_pages , page_allpages);
hash.Add_str_obj("prefixindex" , page_allpages);
hash.Add_str_obj(Xows_special_meta_.Key__random , page_random);
hash.Add_str_obj(Xows_special_meta_.Ttl__random , page_random);
hash.Add_str_obj("random" , page_random);
hash.Add_str_obj(Xows_special_meta_.Key__random_root_page , page_randomRootPage);
hash.Add_str_obj(Xows_special_meta_.Ttl__random_root_page , page_randomRootPage);
hash.Add_bry_obj(Xou_history_mgr.Ttl_name , page_history);
hash.Add_str_obj(Xows_special_meta_.Key__page_history , page_history2);
hash.Add_str_obj(Xows_special_meta_.Key__nearby , page_nearby);
hash.Add_str_obj(Xows_special_meta_.Key__my_language , page_mylanguage);
hash.Add_str_obj(Xows_special_meta_.Key__item_by_title , page_itemByTitle);
hash.Add_str_obj(Xows_special_meta_.Key__statistics , page_statistics);
hash.Add_str_obj(Xows_special_meta_.Key__move_page , page_movePage);
hash.Add_str_obj(Xows_special_meta_.Key__system_data , page_system_data);
hash.Add_str_obj(Xows_special_meta_.Key__default_tab , page_default_tab);
hash.Add_str_obj(Xows_special_meta_.Key__popup_history , page_popup_history);
hash.Add_str_obj(Xows_special_meta_.Key__file_browser , page_file_browser);
hash.Add_str_obj(Xows_special_meta_.Key__bookmarks , page_bmk);
hash.Add_str_obj(Xows_special_meta_.Key__diag , page_diag);
hash.Add_str_obj(Xows_special_meta_.Ttl__page_history , page_history2);
hash.Add_str_obj(Xows_special_meta_.Ttl__nearby , page_nearby);
hash.Add_str_obj(Xows_special_meta_.Ttl__my_language , page_mylanguage);
hash.Add_str_obj(Xows_special_meta_.Ttl__item_by_title , page_itemByTitle);
hash.Add_str_obj(Xows_special_meta_.Ttl__statistics , page_statistics);
hash.Add_str_obj(Xows_special_meta_.Ttl__move_page , page_movePage);
hash.Add_str_obj(Xows_special_meta_.Ttl__system_data , page_system_data);
hash.Add_str_obj(Xows_special_meta_.Ttl__default_tab , page_default_tab);
hash.Add_str_obj(Xows_special_meta_.Ttl__popup_history , page_popup_history);
hash.Add_str_obj(Xows_special_meta_.Ttl__bookmarks , page_bmk);
hash.Add_str_obj(Xows_special_meta_.Ttl__diag , page_diag);
}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public void Special__gen(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
int slash_pos = Bry_find_.Find_fwd(ttl.Page_txt_wo_qargs(), Xoa_ttl.Subpage_spr); // check for slash
byte[] special_name = slash_pos == Bry_find_.Not_found
? ttl.Base_txt_wo_qarg() // no slash found; use base_txt; ignore qry args and just get page_names; EX: Search/Earth?fulltext=y; Allpages?from=Earth...
: Bry_.Mid(ttl.Page_txt_wo_qargs(), 0, slash_pos); // slash found; use root page; EX: Special:ItemByTitle/enwiki/Earth
Object o = hash.Get_by_bry(special_name);
if (o == null) {
Xol_specials_itm special_itm = wiki.Lang().Specials_mgr().Get_by_alias(special_name);
if (special_itm != null)
o = hash.Get_by_bry(special_itm.Special());
Xows_page special = app.Special_regy().Get_by_or_null(special_name);
if (special == null) { // special_name not in app_regy; try wiki_regy
special = (Xows_page)hash.Get_by_bry(special_name);
if (special == null) { // special_name not in wiki_regy; try alias;
Xol_specials_itm special_itm = wiki.Lang().Specials_mgr().Get_by_alias(special_name);
if (special_itm != null)
special = (Xows_page)hash.Get_by_bry(special_itm.Special());
}
}
if (o != null) {
Xows_page special = (Xows_page)o;
else {
special = special.Special__clone();
}
if (special != null) { // special found; generate it;
page.Revision_data().Modified_on_(DateAdp_.Now());
special.Special_gen(wiki, page, url, ttl);
special.Special__gen(wiki, page, url, ttl);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.specials; import gplx.*; import gplx.xowa.*;
public interface Xows_page {
Xows_special_meta Special_meta();
void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl);
Xows_special_meta Special__meta();
Xows_page Special__clone();
void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl);
}

View File

@@ -17,18 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.specials; import gplx.*; import gplx.xowa.*;
public class Xows_special_meta {
public Xows_special_meta(int src, int uid, String key_str) {
this.src = src; this.uid = uid; this.key_str = key_str;
public Xows_special_meta(int src, String key_str) {
this.src = src; this.key_str = key_str;
this.key_bry = Bry_.new_u8(key_str);
this.ttl_str = "Special:" + key_str; // canonical name
this.ttl_bry = Bry_.new_u8(ttl_str);
}
public int Src() {return src;} private final int src;
public int Uid() {return uid;} private final int uid;
public String Key_str() {return key_str;} private final String key_str;
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
public String Ttl_str() {return ttl_str;} private final String ttl_str;
public byte[] Ttl_bry() {return ttl_bry;} private final byte[] ttl_bry;
public int Src() {return src;} private final int src;
public String Key_str() {return key_str;} private final String key_str;
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
public String Ttl_str() {return ttl_str;} private final String ttl_str;
public byte[] Ttl_bry() {return ttl_bry;} private final byte[] ttl_bry;
public boolean Match_ttl(Xoa_ttl ttl) {
return ttl.Ns().Id_is_special() && Bry_.Eq(ttl.Root_txt(), key_bry);
}

View File

@@ -18,58 +18,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.specials; import gplx.*; import gplx.xowa.*;
public class Xows_special_meta_ {
public static final int Src__mw = 1, Src__xowa = 2;
public static final int
Uid__all_pages = 1
, Uid__random = 2
, Uid__random_root_page = 3
, Uid__search = 4
, Uid__statistics = 5
, Uid__move_page = 6
, Uid__my_language = 7
, Uid__item_by_title = 8
, Uid__default_tab = 9
, Uid__file_browser = 10
, Uid__popup_history = 11
, Uid__system_data = 12
, Uid__nearby = 13
, Uid__page_history = 14
, Uid__bookmarks = 15
, Uid__diag = 16
;
public static final String
Key__all_pages = "AllPages"
, Key__random = "RandomPage"
, Key__random_root_page = "RandomRootPage"
, Key__search = "Search"
, Key__statistics = "Statistics"
, Key__move_page = "MovePage"
, Key__my_language = "MyLanguage"
, Key__item_by_title = "ItemByTitle"
, Key__default_tab = "XowaDefaultTab"
, Key__file_browser = "XowaFileBrowser"
, Key__popup_history = "XowaPopupHistory"
, Key__system_data = "XowaSystemData"
, Key__nearby = "Nearby"
, Key__page_history = "XowaHistory"
, Key__bookmarks = "XowaBookmarks"
, Key__diag = "XowaDiag"
Ttl__all_pages = "AllPages"
, Ttl__random = "RandomPage"
, Ttl__random_root_page = "RandomRootPage"
, Ttl__search = "Search"
, Ttl__statistics = "Statistics"
, Ttl__move_page = "MovePage"
, Ttl__my_language = "MyLanguage"
, Ttl__item_by_title = "ItemByTitle"
, Ttl__default_tab = "XowaDefaultTab"
, Ttl__popup_history = "XowaPopupHistory"
, Ttl__system_data = "XowaSystemData"
, Ttl__nearby = "Nearby"
, Ttl__page_history = "XowaHistory"
, Ttl__bookmarks = "XowaBookmarks"
, Ttl__diag = "XowaDiag"
;
public static final Xows_special_meta
Itm__all_pages = new Xows_special_meta(Src__mw , Uid__all_pages , Key__all_pages)
, Itm__random = new Xows_special_meta(Src__mw , Uid__random , Key__random)
, Itm__random_root_page = new Xows_special_meta(Src__mw , Uid__random_root_page , Key__random_root_page)
, Itm__search = new Xows_special_meta(Src__mw , Uid__search , Key__search)
, Itm__statistics = new Xows_special_meta(Src__mw , Uid__statistics , Key__statistics)
, Itm__move_page = new Xows_special_meta(Src__xowa , Uid__move_page , Key__move_page)
, Itm__my_language = new Xows_special_meta(Src__xowa , Uid__my_language , Key__my_language)
, Itm__item_by_title = new Xows_special_meta(Src__xowa , Uid__item_by_title , Key__item_by_title)
, Itm__default_tab = new Xows_special_meta(Src__xowa , Uid__default_tab , Key__default_tab)
, Itm__file_browser = new Xows_special_meta(Src__xowa , Uid__file_browser , Key__file_browser)
, Itm__popup_history = new Xows_special_meta(Src__xowa , Uid__popup_history , Key__popup_history)
, Itm__system_data = new Xows_special_meta(Src__xowa , Uid__system_data , Key__system_data)
, Itm__nearby = new Xows_special_meta(Src__xowa , Uid__nearby , Key__nearby)
, Itm__page_history = new Xows_special_meta(Src__xowa , Uid__page_history , Key__page_history)
, Itm__bookmarks = new Xows_special_meta(Src__xowa , Uid__bookmarks , Key__bookmarks)
, Itm__diag = new Xows_special_meta(Src__xowa , Uid__diag , Key__diag)
Itm__all_pages = new Xows_special_meta(Src__mw , Ttl__all_pages)
, Itm__random = new Xows_special_meta(Src__mw , Ttl__random)
, Itm__random_root_page = new Xows_special_meta(Src__mw , Ttl__random_root_page)
, Itm__search = new Xows_special_meta(Src__mw , Ttl__search)
, Itm__statistics = new Xows_special_meta(Src__mw , Ttl__statistics)
, Itm__move_page = new Xows_special_meta(Src__xowa , Ttl__move_page)
, Itm__my_language = new Xows_special_meta(Src__xowa , Ttl__my_language)
, Itm__item_by_title = new Xows_special_meta(Src__xowa , Ttl__item_by_title)
, Itm__default_tab = new Xows_special_meta(Src__xowa , Ttl__default_tab)
, Itm__popup_history = new Xows_special_meta(Src__xowa , Ttl__popup_history)
, Itm__system_data = new Xows_special_meta(Src__xowa , Ttl__system_data)
, Itm__nearby = new Xows_special_meta(Src__xowa , Ttl__nearby)
, Itm__page_history = new Xows_special_meta(Src__xowa , Ttl__page_history)
, Itm__bookmarks = new Xows_special_meta(Src__xowa , Ttl__bookmarks)
, Itm__diag = new Xows_special_meta(Src__xowa , Ttl__diag)
;
}

View File

@@ -27,7 +27,7 @@ public class Xows_page_allpages implements gplx.core.brys.Bfr_arg, GfoInvkAble,
this.wiki = wiki;
html_itm_fmtr = new Xos_pagelist_html_itm_fmtr(this, wiki);
} private Xos_pagelist_html_itm_fmtr html_itm_fmtr;
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__all_pages;}
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__all_pages;}
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
public Bry_fmtr Html_all() {return html_all;} Bry_fmtr html_all = Bry_fmtr.new_(String_.Concat_lines_nl
( "<table class=\"mw-allpages-table-form\">"
@@ -72,7 +72,8 @@ public class Xows_page_allpages implements gplx.core.brys.Bfr_arg, GfoInvkAble,
public Xowd_page_itm Rslt_nxt() {return rslt_nxt;} public void Rslt_nxt_(Xowd_page_itm v) {rslt_nxt = v;} private Xowd_page_itm rslt_nxt;
public int Rslt_list_len() {return rslt_list_len;} public void Rslt_list_len_(int v) {rslt_list_len = v;} private int rslt_list_len;
public Xowd_page_itm[] Rslt_list_ttls() {return rslt_list_ttls;} private Xowd_page_itm[] rslt_list_ttls;
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
wiki.Parser_mgr().Ctx().Page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_wtr does not eliminate qargs; DATE:2013-02-08
if (wiki.Domain_tid() == Xow_domain_tid_.Int__home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
@@ -166,6 +167,8 @@ public class Xows_page_allpages implements gplx.core.brys.Bfr_arg, GfoInvkAble,
public static final String Invk_html_all_ = "html_all_", Invk_html_list_grp_ = "html_list_grp_", Invk_html_list_itm_normal_ = "html_list_itm_normal_", Invk_html_list_itm_redirect_ = "html_list_itm_redirect_"
, Invk_itms_per_page_ = "itms_per_page_", Invk_itms_per_grp_ = "itms_per_grp_", Invk_show_redirects_ = "show_redirects_";
public static final String GRP_KEY = "xowa.special.allpages";
public Xows_page Special__clone() {return this;}
}
class Xos_pagelist_html_itm_fmtr implements gplx.core.brys.Bfr_arg {
public Xos_pagelist_html_itm_fmtr(Xows_page_allpages mgr, Xowe_wiki wiki) {

View File

@@ -173,7 +173,7 @@ class Xows_page_allpages_fxt {
public Xows_page_allpages_fxt Test_special_gen() {
init_url = app.User().Wikii().Utl__url_parser().Parse(Xows_special_meta_.Itm__all_pages.Ttl_bry());
Xoa_ttl init_ttl = Make_init_ttl();
allpages.Special_gen(wiki, wiki.Parser_mgr().Ctx().Page(), init_url, init_ttl);
allpages.Special__gen(wiki, wiki.Parser_mgr().Ctx().Page(), init_url, init_ttl);
if (expd_display_ttl != null) Tfds.Eq(expd_display_ttl, String_.new_u8(wiki.Parser_mgr().Ctx().Page().Html_data().Display_ttl()));
if (expd_address_page != null) Tfds.Eq(expd_address_page, String_.new_u8(init_url.Page_bry()));
return this;

View File

@@ -25,8 +25,9 @@ public class Move_page implements Xows_page {
private Move_trg_ns_list_fmtr ns_list_fmtr = new Move_trg_ns_list_fmtr();
private Move_url_args args = new Move_url_args();
private Xoa_ttl src_ttl;
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__move_page;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__move_page;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
args.Parse(url);
byte[] src_ttl_bry = args.Src_ttl();
src_ttl = Xoa_ttl.parse(wiki, src_ttl_bry);
@@ -119,6 +120,8 @@ public class Move_page implements Xows_page {
, " </fieldset>"
, "</form>"
), "move-page-legend", "src_href", "src_title", "src_text", "newtitle", "trg_ns_list", "trg_title", "move-leave-redirect", "movepagebtn");
public Xows_page Special__clone() {return this;}
}
class Move_trg_ns_list_fmtr implements gplx.core.brys.Bfr_arg {
private Xowe_wiki wiki; private Xoa_ttl ttl;

View File

@@ -29,8 +29,9 @@ public class Nearby_mgr implements Xows_page {
// int pages_count = 0;
Bry_bfr tmp_bfr = Bry_bfr.new_();
public int Results_max() {return results_max;} public Nearby_mgr Results_max_(int v) {results_max = v; return this;} private int results_max = 1;
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__nearby;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__nearby;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
page.Data_raw_(Bld_html(wiki));
page.Html_data().Html_restricted_n_(); // [[Special:]] pages allow all HTML
// wiki.Parser_mgr().Parse(page, false); // do not clear else previous Search_text will be lost
@@ -169,6 +170,8 @@ public class Nearby_mgr implements Xows_page {
}
}
}
public Xows_page Special__clone() {return this;}
}
class Nearby_rslt {
public Nearby_rslt(List_adp trail, Xoa_ttl trg_ttl) {

View File

@@ -22,7 +22,7 @@ public class Xob_rnd_cmd implements Xob_cmd {
private int rndm_uid = 0; private String rndm_where_sql = "AND ~{page_namespace} = 0 AND ~{page_is_redirect} = 0"; private int rndm_interval = 1000;
public Xob_rnd_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.wiki = wiki;}
public String Cmd_key() {return Xob_cmd_keys.Key_util_random;}
public Xob_cmd Cmd_new(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
public void Cmd_run() {
wiki.Special_mgr().Page_random().Mgr().Rebuild(rndm_uid, rndm_where_sql, rndm_interval);
}

View File

@@ -18,11 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.xowa.wikis.nss.*;
public class Xop_randomRootPage_page implements Xows_page {
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__random_root_page;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__random_root_page;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
Xow_ns ns = wiki.Ns_mgr().Names_get_or_main(ttl.Rest_txt());
byte[] random_ttl_bry = wiki.Db_mgr().Load_mgr().Find_random_ttl(ns);
byte[] root_bry = Xoa_ttl.parse(wiki, random_ttl_bry).Root_txt();
wiki.Data_mgr().Redirect(page, ns.Gen_ttl(root_bry));
}
public Xows_page Special__clone() {return this;}
}

View File

@@ -49,7 +49,7 @@ class Xop_randomRootPage_page_fxt {
page.Url_(url);
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(special_url));
page.Ttl_(ttl);
special_page.Special_gen(wiki, page, url, ttl);
special_page.Special__gen(wiki, page, url, ttl);
return page;
}
}

View File

@@ -19,11 +19,14 @@ package gplx.xowa.specials.randoms; import gplx.*; import gplx.xowa.*; import gp
import gplx.xowa.wikis.nss.*;
public class Xows_page_random implements Xows_page {
public Xows_page_random(Xowe_wiki wiki) {}
public Rndm_mgr Mgr() {return mgr;} private final Rndm_mgr mgr = new Rndm_mgr();
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__random;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Rndm_mgr Mgr() {return mgr;} private final Rndm_mgr mgr = new Rndm_mgr();
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__random;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
Xow_ns ns = wiki.Ns_mgr().Names_get_or_main(ttl.Rest_txt());
byte[] random_ttl_bry = wiki.Db_mgr().Load_mgr().Find_random_ttl(ns);
wiki.Data_mgr().Redirect(page, ns.Gen_ttl(random_ttl_bry));
}
public Xows_page Special__clone() {return this;}
}

View File

@@ -23,8 +23,9 @@ public class Xop_statistics_page implements Xows_page {
private Xop_statistics_stats_page_grp stats_page = new Xop_statistics_stats_page_grp();
// private Xop_statistics_stats_wiki_grp stats_wiki = new Xop_statistics_stats_wiki_grp();
private Xop_statistics_stats_ns_grp stats_ns = new Xop_statistics_stats_ns_grp();
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__statistics;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__statistics;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
byte[] html = Build_html(wiki);
page.Html_data().Html_restricted_n_(); // [[Special:]] pages allow all HTML
page.Data_raw_(html);
@@ -43,6 +44,8 @@ public class Xop_statistics_page implements Xows_page {
, "</table>"
, "</div>"
), "page_stats", "ns_stats");
public Xows_page Special__clone() {return this;}
}
class Xop_statistics_stats_page_grp implements gplx.core.brys.Bfr_arg {
public void Wiki_(Xowe_wiki v) {this.wiki = v;} private Xowe_wiki wiki;

View File

@@ -17,11 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.specials.xowa.default_tab; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
public class Default_tab_page implements Xows_page {
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__default_tab;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__default_tab;}
public void Special__gen(Xow_wiki wiki, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xoae_page page = (Xoae_page)pagei;
page.Data_raw_(Bry_.Empty);
page.Html_data().Custom_html_(Bry_.Empty);
page.Html_data().Custom_tab_name_(Tab_name_bry);
}
public static final byte[] Tab_name_bry = Bry_.new_a7("New Tab");
public static final byte[] Tab_name_bry = Bry_.new_a7("New Tab");
public Xows_page Special__clone() {return this;}
}

View File

@@ -20,8 +20,9 @@ import gplx.core.primitives.*; import gplx.core.net.*;
import gplx.xowa.apps.urls.*;
public class Xows_diag_page implements Xows_page {
private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__diag;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__diag;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
arg_hash.Load(url.Qargs_ary());
byte[] cmd_type_bry = arg_hash.Get_val_bry_or(Arg_type, null); if (cmd_type_bry == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; no type: url=~{0}", url.Raw()); return;}
Byte_obj_val cmd_type_val = (Byte_obj_val)type_hash.Get_by_bry(cmd_type_bry); if (cmd_type_val == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; bad type: url=~{0}", url.Raw()); return;}
@@ -35,11 +36,13 @@ public class Xows_diag_page implements Xows_page {
bfr.Add_str_a7("</pre>\n");
page.Data_raw_(bfr.To_bry_and_clear());
}
private static final byte[] Arg_type = Bry_.new_a7("type");
private static final byte[] Arg_type = Bry_.new_a7("type");
private static final byte Type_file_check = 1, Type_fs_check = 2, Type_sql_dump = 3;
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
.Add_str_byte("file.check" , Type_file_check)
.Add_str_byte("fs.check" , Type_fs_check)
.Add_str_byte("sql.dump" , Type_sql_dump)
;
public Xows_page Special__clone() {return this;}
}

View File

@@ -1,72 +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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.core.primitives.*; import gplx.core.net.*;
class Xoa_url_arg_mgr {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
private final Xoa_url_enum_mgr enm_mgr;
public Xoa_url_arg_mgr(Xoa_url_enum_mgr enm_mgr) {this.enm_mgr = enm_mgr;}
public void Init(Gfo_qarg_itm[] args) {
hash.Clear();
int len = args.length;
for (int i = 0; i < len; ++i) {
Gfo_qarg_itm arg = args[i];
hash.Add_bry_obj(arg.Key_bry(), arg);
}
}
public int Read_enm_or_neg1(byte[] key) {
Xoa_url_enum_itm enm = enm_mgr.Get(key); if (enm == null) return -1;
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key); if (arg == null) return -1;
return enm.Get_as_int_or(arg.Val_bry(), -1);
}
public byte[] Read_bry_or_empty(byte[] key) {return Read_bry_or(key, Bry_.Empty);}
public byte[] Read_bry_or_null(byte[] key) {return Read_bry_or(key, null);}
public byte[] Read_bry_or(byte[] key, byte[] or) {
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
return arg == null ? or : arg.Val_bry();
}
public String Read_str_or_null(String key) {return Read_str_or_null(Bry_.new_u8(key));}
public String Read_str_or_null(byte[] key) {
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
return arg == null ? null : String_.new_u8(arg.Val_bry());
}
}
class Xoa_url_enum_mgr {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Xoa_url_enum_itm itm = ary[i];
hash.Add_bry_obj(itm.Key(), itm);
}
}
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
}
class Xoa_url_enum_itm {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
public byte[] Key() {return key;} private final byte[] key;
public Xoa_url_enum_itm Add(String key, int val) {
hash.Add_bry_obj(Bry_.new_u8(key), Int_obj_val.new_(val));
return this;
}
public int Get_as_int_or(byte[] val, int or) {
Int_obj_val rv = (Int_obj_val)hash.Get_by_bry(val);
return rv == null ? or : rv.Val();
}
}

View File

@@ -1,213 +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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.encoders.*;
import gplx.core.ios.*; import gplx.xowa.apps.*; import gplx.xowa.wikis.*;
interface Xosp_fbrow_cmd {
Xosp_fbrow_cmd Make_new();
Xosp_fbrow_rslt Write_html(Xoa_url_arg_mgr arg_mgr, GfoInvkAble select_invkable);
}
abstract class Xosp_fbrow_cmd__base implements Xosp_fbrow_cmd {
public abstract Xosp_fbrow_cmd Make_new();
public Xosp_fbrow_rslt Write_html(Xoa_url_arg_mgr arg_mgr, GfoInvkAble select_invkable) {
// app.I18n_mgr_Get_txt_many("xowa.specials.file_browsers.errs.unknown_path", url.Raw());
Xosp_fbrow_html html_wtr = new Xosp_fbrow_html();
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
String selected_str = arg_mgr.Read_str_or_null("selected");
if (selected_str == null) {
String path_str = arg_mgr.Read_str_or_null("path"); if (path_str == null) return Xosp_fbrow_rslt.err_("url has unknown path");
// if (Op_sys.Cur().Tid_is_wnt()) path_str = String_.Replace(path_str, "/", "\\");
Io_url path_url = Io_url_.new_any_(path_str);
IoItmDir dir = Io_mgr.Instance.QueryDir_args(path_url).DirInclude_(true).ExecAsDir();
dir.SubDirs().Sort(); dir.SubFils().Sort();
Xosp_fbrow_data_dir dir_itm = Xosp_fbrow_data_dir.new_(dir);
Process_itms(dir_itm);
String url_enc = String_.Replace(path_url.Raw(), "\\", "\\\\");
byte[] cmd_src = this.Cmd_src();
byte[] cmd_row = Html_body_cmd_row.Bld_bry_many(tmp_bfr, url_enc, cmd_src, this.Cmd_gui());
html_wtr.Write(tmp_bfr, cmd_src, cmd_row, dir_itm);
return new Xosp_fbrow_rslt(Html_head_default, tmp_bfr.To_bry_and_clear());
}
else
return Write_html_selected(arg_mgr, selected_str, select_invkable);
}
private void Process_itms(Xosp_fbrow_data_dir dir_itm) {
int len = dir_itm.Count();
for (int i = 0; i < len; ++i) {
Xosp_fbrow_data_sub itm = dir_itm.Get_at(i);
this.Process_itm(itm);
}
}
protected abstract byte[] Cmd_src();
protected abstract String Cmd_gui();
protected abstract Xosp_fbrow_rslt Write_html_selected(Xoa_url_arg_mgr arg_mgr, String selected, GfoInvkAble select_invkable);
protected abstract void Process_itm(Xosp_fbrow_data_sub itm);
private static final byte[] Html_head_default = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( " <style type='text/css'>"
, " .xowa_filebrowser_tbl {border: 1px solid #AAAAAA;}"
, " .xowa_filebrowser_tbl td {padding: 0 1em 0 1em;}"
, " .xowa_filebrowser_td_size {text-align:right;}"
, " </style>"
, " <script type='text/javascript'>"
, " function Xo__file_browser__get_selected_chk(url_base, chk_prefix) {"
, " var list = document.getElementsByTagName('input');"
, " var list_len = list.length;"
, " var selected = '';"
, " var chk_prefix_len = chk_prefix.length;"
, " for (var i = 0; i < list_len; ++i) {"
, " var chk = list[i];"
, " if (chk.id.indexOf(chk_prefix) == 0 && chk.checked == true) {"
, " selected = selected + chk.id.substring(chk_prefix_len) + ';';"
, " }"
, " }"
, " window.location.href = url_base + selected;"
, " }"
, " </script>"
))
;
private static final Bry_fmtr Html_body_cmd_row = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <tr>"
, " <td>"
, " <table width='100%'>"
, " <tr>"
, " <td align='left'><a href='javascript:Xo__file_browser__get_selected_chk(\"/wiki/Special:XowaFileBrowser?cmd=~{cmd_src}&amp;path=~{url_enc}&amp;selected=\", \"chk_\");'>~{cmd_gui}</a>"
, " </td>"
, " </tr>"
, " </table>"
, " </td>"
, " </tr>"
), "url_enc", "cmd_src", "cmd_gui")
;
}
class Xosp_fbrow_html implements gplx.core.brys.Bfr_arg {
private final Gfo_url_encoder encoder = Gfo_url_encoder_.Href; private Xosp_fbrow_data_dir dir; private byte[] cmd_src;
public void Write(Bry_bfr bfr, byte[] cmd_src, byte[] cmd_row, Xosp_fbrow_data_dir dir) {
this.dir = dir; this.cmd_src = cmd_src;
// app.I18n_mgr_Get_txt_none("xowa.specials.file_browsers.html.hdr.name");
// i18n.Get_txt_none("html.hdrs.name");
fmtr_hdr.Bld_bfr_many(bfr
, cmd_src, cmd_row
, "name", "size", "modified"
, dir.Url().Raw(), String_.Replace(dir.Url().Raw(), "\\", "\\\\"), encoder.Encode_str(dir.Url().OwnerDir().Raw())
, this
);
}
public void Bfr_arg__add(Bry_bfr bfr) {
int len = dir.Count();
for (int i = 0; i < len; ++i) {
Xosp_fbrow_data_sub itm = (Xosp_fbrow_data_sub)dir.Get_at(i);
String selected_html = itm.Selectable() ? ("<input type='checkbox' id='chk_" + itm.Url().NameAndExt_noDirSpr() + "'/>") : "&nbsp;&nbsp;&nbsp;";
if (itm.Tid_is_dir())
fmtr_row_dir.Bld_bfr_many(bfr, selected_html, encoder.Encode_str(itm.Url().Raw()), itm.Url().NameOnly(), cmd_src);
else {
fmtr_row_fil.Bld_bfr_many(bfr, selected_html, encoder.Encode_str(itm.Url().Raw()), itm.Url().NameAndExt()
, Io_size_.To_str(itm.Size(), 1, "#,###", " ", Bool_.Y), itm.Modified().XtoStr_fmt_yyyy_MM_dd_HH_mm_ss());
}
}
}
private static final Bry_fmtr
fmtr_hdr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<div class='xowa_filebrowser_help'>Please navigate to the directory containing the XOWA wiki. For example, choose 'storage' -> 'external_SD' -> 'xowa' -> 'wiki' -> 'en.wikipedia.org'</div>"
, "<table>~{cmd_row}"
, " <tr>"
, " <td>"
, " <table class='xowa_filebrowser_tbl'>"
, " <caption>~{dir_url_raw}</caption>"
, " <tr>"
, " <td class='xowa_filebrowser_th'><!--selected--></td>"
, " <td class='xowa_filebrowser_th'>~{hdr_name}</td>"
, " <td class='xowa_filebrowser_th'>~{hdr_size}</td>"
, " <td class='xowa_filebrowser_th'>~{hdr_modified}</td>"
, " </tr>"
, " <tr>"
, " <td class='xowa_filebrowser_td_chkd'></td>"
, " <td class='xowa_filebrowser_td_name'><a href='/wiki/Special:XowaFileBrowser?cmd=~{cmd_src}&amp;path=~{owner_url_enc}'>[ parent directory ]</a></td>"
, " <td class='xowa_filebrowser_td_size'></td>"
, " <td class='xowa_filebrowser_td_date'></td>"
, " </tr>~{itms}"
, " </table>"
, " </td>"
, " </tr>"
, "</table>"
), "cmd_src", "cmd_row", "hdr_name", "hdr_size", "hdr_modified", "dir_url_raw", "dir_url_enc", "owner_url_enc", "itms"
)
, fmtr_row_dir = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <tr>"
, " <td class='xowa_filebrowser_td_chkd'>~{selected_html}</td>"
, " <td class='xowa_filebrowser_td_name'><a class='xowa_filebrowser_anch' href='/wiki/Special:XowaFileBrowser?cmd=~{cmd_src}&amp;path=~{path_enc}'>~{name}</a></td>"
, " <td class='xowa_filebrowser_td_size'></td>"
, " <td class='xowa_filebrowser_td_date'></td>"
, " </tr>"
), "selected_html", "path_enc", "name", "cmd_src"
)
, fmtr_row_fil = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <tr>"
, " <td class='xowa_filebrowser_td_chkd'>~{selected_html}</td>"
, " <td class='xowa_filebrowser_td_name'>~{name}</td>"
, " <td class='xowa_filebrowser_td_size'>~{size}</td>"
, " <td class='xowa_filebrowser_td_date'>~{modified}</td>"
, " </tr>"
), "selected_html", "path_enc", "name", "size", "modified"
);
}
class Xosp_fbrow_cmd__err implements Xosp_fbrow_cmd {
public Xosp_fbrow_cmd Make_new() {return this;}
public Xosp_fbrow_rslt Write_html(Xoa_url_arg_mgr arg_mgr, GfoInvkAble select_invkable) {return Rslt;}
private static final Xosp_fbrow_rslt Rslt = new Xosp_fbrow_rslt(Bry_.Empty, Bry_.new_a7("url has unknown cmd"));
public static final Xosp_fbrow_cmd__err Instance = new Xosp_fbrow_cmd__err(); Xosp_fbrow_cmd__err() {}
}
class Xosp_fbrow_cmd__wiki_add extends Xosp_fbrow_cmd__base {
@Override protected byte[] Cmd_src() {return Regy_key;}
@Override protected String Cmd_gui() {return "import";}
@Override public Xosp_fbrow_cmd Make_new() {return new Xosp_fbrow_cmd__wiki_add();}
@Override protected void Process_itm(Xosp_fbrow_data_sub itm) {
byte[] url_bry = itm.Url().RawBry();
if (!Bry_.Has_at_end(url_bry, Ext_xowa)) itm.Selectable_(false);
}
@Override protected Xosp_fbrow_rslt Write_html_selected(Xoa_url_arg_mgr arg_mgr, String selected, GfoInvkAble select_invkable) {
String[] wikis = String_.Split(selected, ";");
String path_str = arg_mgr.Read_str_or_null("path");
Xowv_wiki wiki = (Xowv_wiki)GfoInvkAble_.InvkCmd_val(select_invkable, Xoav_wiki_mgr.Invk_import_by_fil, path_str + wikis[0]);
Bry_bfr bfr = Bry_bfr.reset_(255);
done_fmtr.Bld_bfr_many(bfr, wiki.Domain_str(), wiki.Props().Main_page());
return new Xosp_fbrow_rslt(Bry_.Empty, bfr.To_bry_and_clear());
}
private static final Bry_fmtr done_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<a href='/site/~{domain}/wiki/~{main_page}'>~{domain} Main Page</a>"
), "domain", "main_page");
private static final byte[] Ext_xowa = Bry_.new_a7(".xowa");
public static final byte[] Regy_key = Bry_.new_a7("xowa.wiki.add");
public static final Xosp_fbrow_cmd__wiki_add Instance = new Xosp_fbrow_cmd__wiki_add();
}
class Xosp_fbrow_cmd__root_set extends Xosp_fbrow_cmd__base {
@Override protected byte[] Cmd_src() {return Regy_key;}
@Override protected String Cmd_gui() {return "set root dir";}
@Override public Xosp_fbrow_cmd Make_new() {return new Xosp_fbrow_cmd__root_set();}
@Override protected void Process_itm(Xosp_fbrow_data_sub itm) {
if (itm.Url().Type_fil()) itm.Selectable_(false);
}
@Override protected Xosp_fbrow_rslt Write_html_selected(Xoa_url_arg_mgr arg_mgr, String selected, GfoInvkAble select_invkable) {
return new Xosp_fbrow_rslt(Bry_.Empty, Bry_.new_u8(selected));
}
public static final byte[] Regy_key = Bry_.new_a7("xowa.fsys.root_");
public static final Xosp_fbrow_cmd__root_set Instance = new Xosp_fbrow_cmd__root_set();
}

View File

@@ -1,61 +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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.core.ios.*;
class Xosp_fbrow_data_dir {
private final Ordered_hash hash = Ordered_hash_.New();
public Xosp_fbrow_data_dir(Io_url url) {this.url = url;}
public Io_url Url() {return url;} private final Io_url url;
public int Count() {return hash.Count();}
public Xosp_fbrow_data_sub Get_at(int i) {return (Xosp_fbrow_data_sub)hash.Get_at(i);}
public void Add(Xosp_fbrow_data_sub itm) {hash.Add(itm.Url().NameAndExt(), itm);}
public static Xosp_fbrow_data_dir new_(IoItmDir owner) {
Xosp_fbrow_data_dir rv = new Xosp_fbrow_data_dir(owner.Url());
new_subs(rv, Bool_.Y, owner.SubDirs());
new_subs(rv, Bool_.N, owner.SubFils());
return rv;
}
private static void new_subs(Xosp_fbrow_data_dir owner, boolean dir, IoItmList itms) {
int len = itms.Count();
for (int i = 0; i < len; ++i) {
IoItm_base src = (IoItm_base)itms.Get_at(i);
Io_url src_url = src.Url();
if (String_.Has_at_bgn(src_url.NameAndExt(), ".")) continue; // ignore hidden "." files; NameAndExt() b/c ".ext" has NameOnly of ""; EX: "/dir/.hidden"
Xosp_fbrow_data_sub trg = null;
if (dir)
trg = new Xosp_fbrow_data_sub(src_url, -1, null);
else {
IoItmFil fil = (IoItmFil)src;
trg = new Xosp_fbrow_data_sub(src_url, fil.Size(), fil.ModifiedTime());
}
owner.Add(trg);
}
}
}
class Xosp_fbrow_data_sub {
public Xosp_fbrow_data_sub(Io_url url, long size, DateAdp modified) {
this.url = url; this.size = size; this.modified = modified;
this.tid_is_dir = url.Type_dir();
}
public boolean Selectable() {return selectable;} public void Selectable_(boolean v) {selectable = v;} private boolean selectable = true;
public String Selectable_style() {return selectable ? "" : "none";}
public boolean Tid_is_dir() {return tid_is_dir;} private final boolean tid_is_dir;
public Io_url Url() {return url;} private final Io_url url;
public long Size() {return size;} private final long size;
public DateAdp Modified() {return modified;} private final DateAdp modified;
}

View File

@@ -1,24 +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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
public class Xosp_fbrow_rslt {
public Xosp_fbrow_rslt(byte[] html_head, byte[] html_body) {this.html_head = html_head; this.html_body = html_body;}
public byte[] Html_head() {return html_head;} private final byte[] html_head;
public byte[] Html_body() {return html_body;} private final byte[] html_body;
public static Xosp_fbrow_rslt err_(String msg) {return new Xosp_fbrow_rslt(Bry_.Empty, Bry_.new_u8(msg));}
}

View File

@@ -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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.xowa.specials.*; import gplx.core.ios.*; import gplx.core.net.*;
public class Xosp_fbrow_special implements Xows_page {
private static final Xoa_url_arg_mgr url_args = new Xoa_url_arg_mgr(null);
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__file_browser;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
Xosp_fbrow_rslt rslt = Gen(url.Qargs_ary(), GfoInvkAble_.Null);
page.Html_data().Html_restricted_n_();
page.Html_data().Custom_head_end_concat(rslt.Html_head());
page.Data_raw_(rslt.Html_body());
}
public static Xosp_fbrow_rslt Gen(Gfo_qarg_itm[] args, GfoInvkAble select_invkable) {
url_args.Init(args);
byte[] cmd_bry = url_args.Read_bry_or_empty(Arg_cmd);
Xosp_fbrow_cmd cmd = (Xosp_fbrow_cmd)cmd_regy.Get_by_bry(cmd_bry); if (cmd == null) cmd = Xosp_fbrow_cmd__err.Instance;
return cmd.Make_new().Write_html(url_args, select_invkable);
}
private static final byte[] Arg_cmd = Bry_.new_a7("cmd");
private static final Hash_adp_bry cmd_regy = Hash_adp_bry.cs()
.Add_bry_obj(Xosp_fbrow_cmd__wiki_add.Regy_key, Xosp_fbrow_cmd__wiki_add.Instance)
.Add_bry_obj(Xosp_fbrow_cmd__root_set.Regy_key, Xosp_fbrow_cmd__root_set.Instance)
;
}

View File

@@ -1,145 +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.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import org.junit.*; import gplx.core.net.*; import gplx.core.ios.*;
public class Xosp_fbrow_special_tst {
@Before public void init() {fxt.Clear();} private Xosp_fbrow_special_fxt fxt = new Xosp_fbrow_special_fxt();
@Test public void Basic() {
// fxt.Init_dir(fxt.Make_dir());
// fxt.Test_nav("mem/root/dir/", String_.Concat_lines_nl_skip_last
// ( "<table>"
// , " <tr>"
// , " <td>"
// , " <table width='100%'>"
// , " <tr>"
// , " <td align='left'><a href='javascript:Xo__file_browser__get_selected_chk(\"/wiki/Special:XowaFileBrowser?cmd=xowa.wiki.add&amp;path=mem/root/dir/&amp;selected=\", \"chk_\");'>import</a>"
// , " </td>"
// , " </tr>"
// , " </table>"
// , " </td>"
// , " </tr>"
// , " <tr>"
// , " <td style='width:100%;border:1px solid #AAAAAA;'>mem/root/dir/"
// , " </td>"
// , " </tr>"
// , " <tr>"
// , " <td>"
// , " <table class='sortable fsys_tb'>"
// , " <tr>"
// , " <th><!--selected--></th>"
// , " <th>name</th>"
// , " <th>size</th>"
// , " <th>modified</th>"
// , " </tr>"
// , " <tr>"
// , " <td></td>"
// , " <td><a href='/wiki/Special:XowaFileBrowser?cmd=xowa.wiki.add&amp;path=mem/root/'>..</a></td>"
// , " <td></td>"
// , " <td></td>"
// , " </tr>"
// , " <tr>"
// , " <td>&nbsp;&nbsp;&nbsp;</td>"
// , " <td><a href='/wiki/Special:XowaFileBrowser?cmd=xowa.wiki.add&amp;path=mem/root/dir/a/'>a</a></td>"
// , " <td></td>"
// , " <td></td>"
// , " </tr>"
// , " <tr>"
// , " <td>&nbsp;&nbsp;&nbsp;</td>"
// , " <td><a href='/wiki/Special:XowaFileBrowser?cmd=xowa.wiki.add&amp;path=mem/root/dir/b/'>b</a></td>"
// , " <td></td>"
// , " <td></td>"
// , " </tr>"
// , " <tr>"
// , " <td>&nbsp;&nbsp;&nbsp;</td>"
// , " <td>1.txt</td>"
// , " <td class='fsys_td_size'>1 KB</td>"
// , " <td>2001-01-01 00:00:00</td>"
// , " </tr>"
// , " <tr>"
// , " <td>&nbsp;&nbsp;&nbsp;</td>"
// , " <td>2.txt</td>"
// , " <td class='fsys_td_size'>1 KB</td>"
// , " <td>2004-01-02 00:00:00</td>"
// , " </tr>"
// , " <tr>"
// , " <td><input type='checkbox' id='chk_3.xowa'/></td>"
// , " <td>3.xowa</td>"
// , " <td class='fsys_td_size'>1 KB</td>"
// , " <td>2004-01-03 00:00:00</td>"
// , " </tr>"
// , " </table>"
// , " </td>"
// , " </tr>"
// , "</table>"
// ));
}
}
class Io_itm_bldr {
public IoItmDir Root(Io_url url, IoItm_base... subs) {
IoItmDir rv = IoItmDir_.top_(url);
Init_dir(rv, url.NameAndExt(), subs);
return rv;
}
public IoItmDir Dir(String name, IoItm_base... subs) {
IoItmDir rv = IoItmDir_.sub_(name);
Init_dir(rv, name, subs);
return rv;
}
public IoItmFil Fil(String name, int size, String date) {return IoItmFil_.sub_(name, size, DateAdp_.parse_iso8561(date));}
private void Init_dir(IoItmDir rv, String name, IoItm_base... subs) {
int len = subs.length;
for (int i = 0; i < len; ++i) {
IoItm_base sub = subs[i];
IoItmList sub_list = sub.Type_fil() ? rv.SubFils() : rv.SubDirs();
sub.OwnerDir_set(rv);
sub_list.Add(sub);
}
}
}
class Xosp_fbrow_special_fxt {
private Io_itm_bldr bldr = new Io_itm_bldr();
public void Clear() {}
public IoItmDir Make_dir() {
return bldr.Root(Io_url_.mem_dir_("mem/root/dir/")
, bldr.Dir("a"
, bldr.Fil("a1.txt", 11, "2011-01-01")
, bldr.Fil("a2.txt", 12, "2011-01-02")
, bldr.Fil("a3.txt", 13, "2011-01-03")
)
, bldr.Dir("b"
, bldr.Fil("b1.txt", 21, "2011-02-01")
, bldr.Fil("b2.txt", 22, "2011-02-02")
, bldr.Fil("b3.txt", 23, "2011-02-03")
)
, bldr.Fil("1.txt", 1, "2001-01-01")
, bldr.Fil("2.txt", 2, "2004-01-02")
, bldr.Fil("3.xowa", 3, "2004-01-03")
);
}
public void Init_dir(IoItmDir dir) {
IoItmDir_.Make(dir);
}
public void Test_nav(String path, String expd) {
Xoa_url_arg_mgr args_mgr = new Xoa_url_arg_mgr(null);
Xoa_url url = Xoa_url.new_(Bry_.Empty, Bry_.Empty).Qargs_ary_(Gfo_qarg_itm.Ary("cmd", "xowa.wiki.add", "mode", "view", "path", path));
args_mgr.Init(url.Qargs_ary());
Xosp_fbrow_cmd__wiki_add cmd = new Xosp_fbrow_cmd__wiki_add();
byte[] actl = cmd.Write_html(args_mgr, GfoInvkAble_.Null).Html_body();
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
}
}

View File

@@ -19,8 +19,9 @@ package gplx.xowa.specials.xowa.popup_history; import gplx.*; import gplx.xowa.*
import gplx.core.brys.fmtrs.*;
import gplx.xowa.htmls.modules.popups.*;
public class Popup_history_page implements Xows_page {
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__popup_history;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__popup_history;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
Xoae_page cur_page = wiki.Appe().Gui_mgr().Browser_win().Active_page(); if (cur_page == null) return;
Ordered_hash hash = cur_page.Popup_mgr().Itms();
int len = hash.Count();
@@ -38,4 +39,6 @@ public class Popup_history_page implements Xows_page {
return ttl.Ns().Id_is_special()
&& Bry_.Eq(ttl.Page_db(), Xows_special_meta_.Itm__popup_history.Key_bry());
}
public Xows_page Special__clone() {return this;}
}

View File

@@ -21,8 +21,9 @@ import gplx.xowa.langs.*;
import gplx.xowa.apps.urls.*;
public class System_data_page implements Xows_page {
private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__system_data;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__system_data;}
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
arg_hash.Load(url.Qargs_ary());
byte[] file_type = arg_hash.Get_val_bry_or(Arg_type, null); if (file_type == null) return;
Byte_obj_val type_val = (Byte_obj_val)type_hash.Get_by_bry(file_type); if (type_val == null) return;
@@ -46,9 +47,9 @@ public class System_data_page implements Xows_page {
}
}
private static final byte[] Arg_type = Bry_.new_a7("type");
private static final byte[] Arg_type = Bry_.new_a7("type");
private static final byte Type_log_session = 1, Type_cfg_app = 2, Type_cfg_lang = 3, Type_cfg_user = 4, Type_cfg_custom = 5, Type_usr_history = 6;
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
.Add_str_byte("log_session" , Type_log_session)
.Add_str_byte("cfg_app" , Type_cfg_app)
.Add_str_byte("cfg_lang" , Type_cfg_lang)
@@ -62,4 +63,6 @@ public class System_data_page implements Xows_page {
, "<pre style='overflow:auto;'>"
, "~{text}</pre>"
), "path", "text");
public Xows_page Special__clone() {return this;}
}