mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Http_server: Add special_pages_safelist
This commit is contained in:
@@ -22,6 +22,7 @@ import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.def
|
||||
import gplx.xowa.xtns.wbases.specials.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.specials.mgrs.*; import gplx.xowa.addons.wikis.searchs.specials.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xow_special_mgr {
|
||||
private final Hash_adp_bry hash;
|
||||
private Xoa_app app;
|
||||
@@ -89,11 +90,23 @@ public class Xow_special_mgr {
|
||||
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
|
||||
? ttl.Base_txt_wo_qarg() // slash absent; 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 exists; use root page; EX: Special:ItemByTitle/enwiki/Earth
|
||||
special_name = Xoa_ttl.Replace_spaces(special_name); // handle spaces; EX:Spezial:Zufällige_Seite
|
||||
|
||||
Xow_special_page special = (Xow_special_page)hash.Get_by_bry(special_name);
|
||||
if (special != null) { // special found; generate it;
|
||||
// check safelisted pages; DATE:2017-07-22
|
||||
Hash_adp safelist = app.Special_regy().Safelist_pages();
|
||||
if (safelist.Count() > 0) { // safelist pages enabled
|
||||
if (!safelist.Has(special_name)) {
|
||||
byte[] safelist_failed = Bry_.new_u8("This special page is not listed in the special_pages safelist. Re-run XOWA and list it in the command-line arguments similar to this: \"--http_server.special_pages_safelist " + String_.new_u8(special_name) + "\"");
|
||||
Xopage_html_data page_data = new Xopage_html_data(special.Special__meta().Display_ttl(), safelist_failed);
|
||||
page_data.Apply(page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
special = special.Special__clone();
|
||||
page.Db().Page().Modified_on_(Datetime_now.Get());
|
||||
try {special.Special__gen(wiki, page, url, ttl);}
|
||||
|
||||
@@ -17,6 +17,7 @@ package gplx.xowa.specials.mgrs; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.xowa.specials.*;
|
||||
public class Xoa_special_regy {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry(); // NOTE: case-sensitive; case-insensitive requires lang, but regy is at app level
|
||||
public Hash_adp_bry Safelist_pages() {return safelist_pages;} private final Hash_adp_bry safelist_pages = Hash_adp_bry.ci_u8(gplx.xowa.langs.cases.Xol_case_mgr_.U8());
|
||||
public int Len() {return hash.Len();}
|
||||
public Xow_special_page Get_at(int i) {return (Xow_special_page)hash.Get_at(i);}
|
||||
public Xow_special_page Get_by_or_null(byte[] key) {return (Xow_special_page)hash.Get_by(key);}
|
||||
|
||||
Reference in New Issue
Block a user