From 3e21b4e4db671ad32cf17313b5ec0865e12e0597 Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Wed, 12 Oct 2016 20:01:51 -0400 Subject: [PATCH] if option is set to use wikitext, but no wikitext is available, and html is available, just use html --- .../gplx/xowa/wikis/pages/Xowe_page_mgr.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java b/400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java index 69de900a1..fa77b9781 100644 --- a/400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java +++ b/400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java @@ -28,30 +28,44 @@ public class Xowe_page_mgr { // load page meta; wait_for_popups Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false); - boolean hdump_exists = page.Db().Page().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred(); - page.Html_data().Hdump_exists_(hdump_exists); Wait_for_popups(wiki.App()); // auto-update gplx.xowa.addons.wikis.pages.syncs.core.Xosync_read_mgr read_mgr = new gplx.xowa.addons.wikis.pages.syncs.core.Xosync_read_mgr(); read_mgr.Auto_update(wiki, page, ttl); - // load page text - boolean parse = true; - if (hdump_exists) { - wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page); - parse = Bry_.Len_eq_0(page.Db().Html().Html_bry()); // NOTE: need to check if actually empty for archive.org wikis which included html_db_id without html_dbs; DATE:2016-06-22 + // load page from html_db + boolean from_html_db = page.Db().Page().Html_db_id() != -1; + if (from_html_db) { + if (wiki.Appe().Api_root().Wiki().Hdump().Read_preferred()) { + wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page); + from_html_db = Bry_.Len_gt_0(page.Db().Html().Html_bry()); // NOTE: archive.org has some wtxt_dbs which included page|html_db_id without actual html_dbs; DATE:2016-06-22 + } + else + from_html_db = false; } - if (parse) + + // load page from wtxt_db; occurs if (a) no html_db_id; (b) option says to use wtxt db; (c) html_db_id exists, but no html_db; + if (!from_html_db) { wiki.Parser_mgr().Parse(page, false); + // load from html_dbs if no wtxt found and option just marked as not read_preferred + if ( Bry_.Len_eq_0(page.Db().Text().Text_bry()) // no wtxt found + && !wiki.Appe().Api_root().Wiki().Hdump().Read_preferred() // read preferred not marked + ) { + wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page); + from_html_db = Bry_.Len_gt_0(page.Db().Html().Html_bry()); + } + } + page.Html_data().Hdump_exists_(from_html_db); + // if [[Category]], generate catlinks (subc; page; file) if (ttl.Ns().Id_is_ctg()) { wiki.Ctg__catpage_mgr().Write_catpage(tmp_bfr, page); - if (parse) - page.Html_data().Catpage_data_(tmp_bfr.To_bry_and_clear()); - else + if (from_html_db) page.Db().Html().Html_bry_(Bry_.Add(page.Db().Html().Html_bry(), tmp_bfr.To_bry_and_clear())); + else + page.Html_data().Catpage_data_(tmp_bfr.To_bry_and_clear()); } return page;