From e9024e057f4718e5b7cba2256023ff46a5bd2b17 Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Wed, 13 Nov 2019 08:43:34 -0500 Subject: [PATCH] HTTP Server: Show error page when navigating to wikis which are not installed [#613] --- 400_xowa/src/gplx/xowa/Xowe_wiki.java | 1 + .../gplx/xowa/apps/servers/http/Http_server_page.java | 5 +++++ .../xowa/specials/xowa/errors/Xoerror_special.java | 11 +++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/400_xowa/src/gplx/xowa/Xowe_wiki.java b/400_xowa/src/gplx/xowa/Xowe_wiki.java index 6833f8b43..9ec6e0e40 100644 --- a/400_xowa/src/gplx/xowa/Xowe_wiki.java +++ b/400_xowa/src/gplx/xowa/Xowe_wiki.java @@ -126,6 +126,7 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm { public byte[] Wtxt__expand_tmpl(byte[] src) {return parser_mgr.Main().Expand_tmpl(src);} public boolean Embeddable_enabled() {return embeddable_enabled;} public void Embeddable_enabled_(boolean v) {this.embeddable_enabled = v;} private boolean embeddable_enabled; public Hxtn_page_mgr Hxtn_mgr() {return hxtn_mgr;} private final Hxtn_page_mgr hxtn_mgr = new Hxtn_page_mgr(); + public boolean Installed() {return this.Data__core_mgr() != null;} // not sure if this is the best way public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr; public Xoae_app Appe() {return app;} private Xoae_app app; diff --git a/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_page.java b/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_page.java index 8adf38a45..7225a7122 100644 --- a/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_page.java +++ b/400_xowa/src/gplx/xowa/apps/servers/http/Http_server_page.java @@ -40,6 +40,11 @@ public class Http_server_page { public boolean Make_url(byte[] wiki_domain, byte[] ttl_bry_arg, byte[] qarg) { // get wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(wiki_domain); // assert init for Main_Page; EX:click zh.w on wiki sidebar; DATE:2015-07-19 + if (!wiki.Installed()) { + this.ttl = wiki.Ttl_parse(Xow_special_meta_.Itm__error.Ttl_bry()); + this.url = wiki.Utl__url_parser().Parse(Xoerror_special.Make_url__invalidWiki(wiki_domain)); + return true; + } if (Runtime_.Memory_total() > Io_mgr.Len_gb) Xowe_wiki_.Rls_mem(wiki, true); // release memory at 1 GB; DATE:2015-09-11 // get url diff --git a/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java b/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java index 6b004e915..29b6e25c7 100644 --- a/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java +++ b/400_xowa/src/gplx/xowa/specials/xowa/errors/Xoerror_special.java @@ -31,6 +31,10 @@ public class Xoerror_special implements Xow_special_page { title = "Invalid title"; msg = "The title has invalid characters: " + data + ""; } + else if (String_.Eq(type, "InvalidWiki")) { + title = "Invalid wiki"; + msg = "The wiki is not installed: " + data + ""; + } page.Db().Text().Text_bry_(fmt.Bld_many_to_bry(Bry_bfr_.New(), title, msg)); } @@ -41,7 +45,10 @@ public class Xoerror_special implements Xow_special_page { )); public Xow_special_page Special__clone() {return this;} - public static byte[] Make_url__invalidTitle(byte[] invalid_title) { - return Bry_.Add(Xow_special_meta_.Itm__error.Ttl_bry(), Bry_.new_a7("?type=InvalidTitle&data="), invalid_title); + public static byte[] Make_url__invalidTitle(byte[] ttl_bry) { + return Bry_.Add(Xow_special_meta_.Itm__error.Ttl_bry(), Bry_.new_a7("?type=InvalidTitle&data="), ttl_bry); + } + public static byte[] Make_url__invalidWiki(byte[] wiki) { + return Bry_.Add(Xow_special_meta_.Itm__error.Ttl_bry(), Bry_.new_a7("?type=InvalidWiki&data="), wiki); } }