mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Embeddable: Handle redirects
This commit is contained in:
parent
f129344506
commit
d521299987
@ -30,8 +30,8 @@ public class Xoa_app_ {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final String Name = "xowa";
|
public static final String Name = "xowa";
|
||||||
public static final int Version_id = 526;
|
public static final int Version_id = 527;
|
||||||
public static final String Version = "4.5.4.1705";
|
public static final String Version = "4.5.5.1705";
|
||||||
public static String Build_date = "2012-12-30 00:00:00";
|
public static String Build_date = "2012-12-30 00:00:00";
|
||||||
public static String Build_date_fmt = "yyyy-MM-dd HH:mm:ss";
|
public static String Build_date_fmt = "yyyy-MM-dd HH:mm:ss";
|
||||||
public static String Op_sys_str;
|
public static String Op_sys_str;
|
||||||
|
@ -25,7 +25,7 @@ public class Xop_mediawiki_wkr {
|
|||||||
}
|
}
|
||||||
public void Loader_(Xop_mediawiki_loader loader) {
|
public void Loader_(Xop_mediawiki_loader loader) {
|
||||||
if (loader != null)
|
if (loader != null)
|
||||||
wiki.Cache_mgr().Load_wkr_(new Xow_page_cache_wkr__embeddable(loader));
|
wiki.Cache_mgr().Load_wkr_(new Xow_page_cache_wkr__embeddable(wiki, loader));
|
||||||
}
|
}
|
||||||
public void Free_memory() {
|
public void Free_memory() {
|
||||||
wiki.Cache_mgr().Tmpl_result_cache().Clear();
|
wiki.Cache_mgr().Tmpl_result_cache().Clear();
|
||||||
|
@ -14,12 +14,32 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.addons.parsers.mediawikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.parsers.*;
|
package gplx.xowa.addons.parsers.mediawikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.parsers.*;
|
||||||
|
import gplx.xowa.parsers.utils.*;
|
||||||
class Xow_page_cache_wkr__embeddable implements gplx.xowa.wikis.caches.Xow_page_cache_wkr {
|
class Xow_page_cache_wkr__embeddable implements gplx.xowa.wikis.caches.Xow_page_cache_wkr {
|
||||||
private final Xop_mediawiki_loader cbk;
|
private final Xop_mediawiki_loader cbk;
|
||||||
public Xow_page_cache_wkr__embeddable(Xop_mediawiki_loader cbk) {
|
private final Xop_redirect_mgr redirect_mgr;
|
||||||
|
public Xow_page_cache_wkr__embeddable(Xowe_wiki wiki, Xop_mediawiki_loader cbk) {
|
||||||
this.cbk = cbk;
|
this.cbk = cbk;
|
||||||
|
this.redirect_mgr = new Xop_redirect_mgr(wiki);
|
||||||
}
|
}
|
||||||
public byte[] Get_page_or_null(byte[] full_db) {
|
public byte[] Get_page_or_null(byte[] full_db) {
|
||||||
return Bry_.new_u8(cbk.LoadWikitext(String_.new_u8(full_db)));
|
byte[] wikitext = null;
|
||||||
|
|
||||||
|
// loop to handle redirects
|
||||||
|
int loops = 0;
|
||||||
|
while (loops++ < 5) {
|
||||||
|
wikitext = Bry_.new_u8(cbk.LoadWikitext(String_.new_u8(full_db)));
|
||||||
|
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(wikitext);
|
||||||
|
// not a redirect; exit loop
|
||||||
|
if (redirect_ttl == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// redirect
|
||||||
|
else {
|
||||||
|
full_db = redirect_ttl.Full_db();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wikitext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user