mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
'v3.6.3.1'
This commit is contained in:
parent
d4e8590345
commit
d43e0d2341
@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.6.3.1";
|
||||
public static final String Version = "3.6.3.2";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
@ -16,15 +16,15 @@ 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; import gplx.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
public interface Xoa_page {
|
||||
Xow_wiki Wiki();
|
||||
Xoa_url Url();
|
||||
byte[] Url_bry_safe();
|
||||
Xoa_url Url(); byte[] Url_bry_safe();
|
||||
Xoa_ttl Ttl();
|
||||
boolean Exists();
|
||||
Xopg_revision_data Revision_data();
|
||||
Xopg_html_data Html_data();
|
||||
Xopg_lnki_list Redlink_list();
|
||||
byte[] Redirect_to_ttl(); void Redirect_to_ttl_(byte[] v);
|
||||
|
||||
Xoa_page__commons_mgr Commons_mgr();
|
||||
|
@ -19,14 +19,14 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.xtns.cites.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.xtns.cites.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.htmls.modules.popups.*;
|
||||
public class Xoae_page implements Xoa_page {
|
||||
Xoae_page(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
this.wiki = wiki; this.ttl = ttl;
|
||||
this.lang = wiki.Lang(); // default to wiki.lang; can be override later by wikitext
|
||||
hdr_mgr = new Xow_hdr_mgr(this);
|
||||
redlink_lnki_list = new Xopg_redlink_lnki_list(ttl.Ns().Id_is_module());
|
||||
redlink_list = new Xopg_lnki_list(ttl.Ns().Id_is_module());
|
||||
Ttl_(ttl);
|
||||
} Xoae_page() {} // called by Empty
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
@ -38,10 +38,10 @@ public class Xoae_page implements Xoa_page {
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list;
|
||||
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public Xowe_wiki Wikie() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xopg_redlink_lnki_list Redlink_lnki_list() {return redlink_lnki_list;} private Xopg_redlink_lnki_list redlink_lnki_list;
|
||||
public Xol_lang_itm Lang() {return lang;} public Xoae_page Lang_(Xol_lang_itm v) {lang = v; return this;} private Xol_lang_itm lang;
|
||||
public Xopg_tab_data Tab_data() {return tab_data;} private final Xopg_tab_data tab_data = new Xopg_tab_data();
|
||||
public Xopg_hdump_data Hdump_data() {return hdump_data;} private final Xopg_hdump_data hdump_data = new Xopg_hdump_data();
|
||||
|
@ -438,7 +438,7 @@ public class Xop_fxt {
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump;
|
||||
Xoh_html_wtr html_wtr = wiki.Html_mgr().Html_wtr();
|
||||
html_wtr.Cfg().Toc__show_(Bool_.Y); // needed for hdr to show <span class='mw-headline' id='A'>
|
||||
ctx.Page().Redlink_lnki_list().Clear();
|
||||
ctx.Page().Redlink_list().Clear();
|
||||
html_wtr.Write_all(tmp_bfr, ctx, hctx, src_bry, root);
|
||||
// Tfds.Dbg(tmp_bfr.To_str());
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
|
@ -83,7 +83,7 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
long data_cur = this.Load_checkpoint_hook();
|
||||
this.Prog_data_cur_(data_cur);
|
||||
if (data_cur > 0)
|
||||
this.Prog_status_(Gfo_prog_ui_.Status__working); // set status to working, else js won't warn about accidental removal
|
||||
this.Prog_status_(Gfo_prog_ui_.Status__suspended); // set status to suspended, else js won't warn about accidental removal
|
||||
}
|
||||
@gplx.Virtual protected long Load_checkpoint_hook() {return 0;}
|
||||
|
||||
@ -101,7 +101,7 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
|
||||
rate_cur = rate_now; // update it now
|
||||
else {
|
||||
double rate_new = ((rate_now - rate_cur) * .05) + rate_cur; // calc new rate as 5% of difference
|
||||
Tfds.Dbg(delta, rate_now, rate_cur, rate_new);
|
||||
// Tfds.Dbg(delta, rate_now, rate_cur, rate_new);
|
||||
rate_cur = rate_new;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Xobc_step_factory {
|
||||
step.Step_name_(String_.Format("{0} ·({1}/{2})", step_name.Val(), step_seqn + List_adp_.Base1, task.Step_count()));
|
||||
task.Step_(step);
|
||||
step.Cmd().Load_checkpoint();
|
||||
if (step.Cmd().Prog_status() == gplx.core.progs.Gfo_prog_ui_.Status__working)
|
||||
if (step.Cmd().Prog_status() == gplx.core.progs.Gfo_prog_ui_.Status__suspended)
|
||||
task.Task_status_(step.Cmd().Prog_status());
|
||||
}
|
||||
private Xobc_cmd_itm[] Make_wiki_import_cmds(Xobc_import_step_itm import_itm, int task_id, int step_id, String_obj_ref step_name, int step_seqn) {
|
||||
|
@ -97,7 +97,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
page.Clear_all();
|
||||
page.Bldr__ns_ord_(ns_ord);
|
||||
page.Ttl_(ttl).Revision_data().Id_(db_page.Id());
|
||||
page.Redlink_lnki_list().Clear();
|
||||
page.Redlink_list().Clear();
|
||||
page.Url_(Xoa_url.new_(wiki.Domain_bry(), ttl.Full_db()));
|
||||
if (ns.Id_is_tmpl())
|
||||
parser.Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), ttl_bry, page_src);
|
||||
|
@ -25,7 +25,7 @@ public class Xog_redlink_thread implements Gfo_thread_wkr {
|
||||
public void Thread__exec() {
|
||||
int len = redlink_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
js_wkr.Html_redlink(gplx.xowa.parsers.lnkis.redlinks.Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(redlink_ary[i]));
|
||||
js_wkr.Html_redlink(gplx.xowa.wikis.pages.lnkis.Xopg_lnki_list.Lnki_id_prefix + Int_.To_str(redlink_ary[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class Js_img_mgr {
|
||||
public static void Update_img(Xoa_page page, Xog_js_wkr js_wkr, Xof_file_itm itm) {
|
||||
Js_img_mgr.Update_img(page, js_wkr, itm.Html_img_wkr(), itm.Html_uid(), itm.Lnki_type(), itm.Html_elem_tid(), itm.Html_w(), itm.Html_h(), itm.Html_view_url(), itm.Orig_w(), itm.Orig_h(), itm.Html_orig_url(), itm.Orig_ttl(), itm.Html_gallery_mgr_h());
|
||||
}
|
||||
public static void Update_link_missing(Xog_html_itm html_itm, String html_id) {
|
||||
public static void Update_link_missing(Xog_js_wkr html_itm, String html_id) {
|
||||
html_itm.Html_redlink(html_id);
|
||||
}
|
||||
private static void Update_img(Xoa_page page, Xog_js_wkr js_wkr, Js_img_wkr img_wkr, int uid, byte lnki_type, byte elem_tid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl, int gallery_mgr_h) {
|
||||
|
@ -17,9 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
import gplx.xowa.wikis.pages.lnkis.*;
|
||||
import gplx.xowa.files.gui.*;
|
||||
public class Xog_async_wkr {
|
||||
public static void Async(Xog_tab_itm tab) {Xog_async_wkr.Async(tab.Page(), tab.Html_itm());}
|
||||
public static void Async(Xoae_page page, Xog_html_itm js_wkr) {
|
||||
if (page == null) return; // TEST: occurs during Xog_win_mgr_tst
|
||||
|
||||
@ -94,8 +95,8 @@ public class Xog_async_wkr {
|
||||
private static void Async_redlinks(Gfo_usr_dlg usr_dlg, Xoae_app app, Xoae_page page, Xog_js_wkr js_wkr) {
|
||||
if (page.Tab_data().Tab() == null) return; // needed b/c Preview has page.Tab of null which causes null_ref error in redlinks
|
||||
try {
|
||||
Xog_redlink_mgr redlinks_wkr = new Xog_redlink_mgr(page);
|
||||
Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, redlinks_wkr, gplx.xowa.parsers.lnkis.redlinks.Xog_redlink_mgr.Invk_run);
|
||||
Xopg_redlink_mgr redlinks_wkr = new Xopg_redlink_mgr(page, js_wkr);
|
||||
Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, redlinks_wkr, gplx.xowa.wikis.pages.lnkis.Xopg_redlink_mgr.Invk_run);
|
||||
} catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.redlinks: page=~{0} err=~{1}", page.Ttl().Raw(), Err_.Message_gplx_full(e));}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.gfui.kits.core.*; impor
|
||||
import gplx.xowa.guis.history.*; import gplx.xowa.guis.bnds.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
public class Xog_tab_itm implements Gfo_invk {
|
||||
private Xog_win_itm win; private Xocfg_tab_mgr cfg_tab_mgr;
|
||||
@ -262,8 +262,8 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
}
|
||||
try {
|
||||
if (page.Tab_data().Tab() != null) { // needed b/c Preview has page.Tab of null which causes null_ref error in redlinks
|
||||
Xog_redlink_mgr redlinks_wkr = new Xog_redlink_mgr(page);
|
||||
Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, redlinks_wkr, gplx.xowa.parsers.lnkis.redlinks.Xog_redlink_mgr.Invk_run);
|
||||
Xopg_redlink_mgr redlinks_wkr = new Xopg_redlink_mgr(page, html_itm);
|
||||
Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, redlinks_wkr, gplx.xowa.wikis.pages.lnkis.Xopg_redlink_mgr.Invk_run);
|
||||
usr_dlg.Prog_none("", "imgs.done", "");
|
||||
}
|
||||
} catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.redlinks: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));}
|
||||
@ -286,6 +286,7 @@ class Load_files_wkr implements Gfo_thread_wkr {
|
||||
public String Thread__name() {return "xowa.load_files_wkr";}
|
||||
public boolean Thread__resume() {return true;}
|
||||
public void Thread__exec() {
|
||||
// try {Xog_async_wkr.Async(tab);}
|
||||
try {tab.Async();}
|
||||
catch (Exception e) {
|
||||
tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().To_str(), Err_.Message_gplx_full(e));
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.gfui.*; import gplx.gfui.controls.standards.*; import gplx.xowa.guis.langs.*; import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xog_tab_itm_read_mgr {
|
||||
public static void Show_page(Xog_tab_itm tab, Xoae_page new_page, boolean reset_to_read) {Show_page(tab, new_page, reset_to_read, false, false, Xog_history_stack.Nav_fwd);}
|
||||
public static void Show_page(Xog_tab_itm tab, Xoae_page new_page, boolean reset_to_read, boolean new_page_is_same, boolean show_is_err, byte history_nav_type) {
|
||||
|
@ -22,7 +22,7 @@ import gplx.xowa.guis.*; import gplx.xowa.guis.history.*; import gplx.xowa.guis.
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.apps.urls.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.math.*;
|
||||
public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
private Gfo_invk sync_cmd;
|
||||
private Xog_url_box__selection_changed url_box__selection_changed;
|
||||
@ -67,6 +67,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
else if (ctx.Match(k, Gfui_html.Evt_location_changing)) Page__navigate_by_href(tab_mgr.Active_tab(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size();
|
||||
else if (ctx.Match(k, Invk_page_refresh)) Page__refresh();
|
||||
// else if (ctx.Match(k, Invk_page_async_exec)) Xog_async_wkr.Async(((Xog_tab_itm)m.ReadObj("v")));
|
||||
else if (ctx.Match(k, Invk_page_async_exec)) ((Xog_tab_itm)m.ReadObj("v")).Async();
|
||||
else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xopg_page_.Tid_read);
|
||||
else if (ctx.Match(k, Invk_page_view_edit)) Page__mode_(Xopg_page_.Tid_edit);
|
||||
|
@ -16,7 +16,7 @@ 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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
public class Xoh_page implements Xoa_page {
|
||||
// core
|
||||
@ -44,8 +44,8 @@ public class Xoh_page implements Xoa_page {
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
|
||||
|
||||
// util
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list;
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
|
||||
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser
|
||||
@ -53,6 +53,7 @@ public class Xoh_page implements Xoa_page {
|
||||
public void Init(Xow_wiki wiki, Xoa_url page_url, Xoa_ttl page_ttl, int page_id) {
|
||||
this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id;
|
||||
this.Clear();
|
||||
this.redlink_list = new Xopg_lnki_list(page_ttl.Ns().Id_is_module());
|
||||
}
|
||||
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, int zip_tid, int hzip_tid, byte[] body) {
|
||||
head_mgr.Flag_(head_flag);
|
||||
|
@ -40,7 +40,7 @@ public class Xoh_page_wtr_wkr {
|
||||
case Xopg_page_.Tid_edit: fmtr = mgr.Page_edit_fmtr(); break;
|
||||
case Xopg_page_.Tid_html: fmtr = mgr.Page_read_fmtr(); view_mode = Xopg_page_.Tid_read; break; // set view_mode to read, so that "read" is highlighted in HTML
|
||||
case Xopg_page_.Tid_read: fmtr = mgr.Page_read_fmtr();
|
||||
ctx.Page().Redlink_lnki_list().Clear(); // not sure if this is the best place to put it, but redlinks (a) must only fire once; (b) must fire before html generation; (c) cannot fire during edit (preview will handle separately)
|
||||
ctx.Page().Redlink_list().Clear(); // not sure if this is the best place to put it, but redlinks (a) must only fire once; (b) must fire before html generation; (c) cannot fire during edit (preview will handle separately)
|
||||
break;
|
||||
}
|
||||
Bry_bfr page_bfr = Xoa_app_.Utl__bfr_mkr().Get_m001(); // NOTE: get separate page bfr to output page; do not reuse tmp_bfr b/c it will be used inside Fmt_do
|
||||
|
@ -140,6 +140,11 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// generate stub for redlink
|
||||
// Xopg_lnki_itm__hdump lnki_itm = new Xopg_lnki_itm__hdump(null);
|
||||
// hpg.Redlink_list().Add(lnki_itm);
|
||||
|
||||
// gen html
|
||||
bfr.Add(Gfh_bldr_.Bry__a_lhs_w_href);
|
||||
switch (href_type) {
|
||||
@ -166,7 +171,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
}
|
||||
if (cls_bry != null) bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(cls_bry);
|
||||
if (!hctx.Mode_is_diff())
|
||||
bfr.Add(Gfh_bldr_.Bry__id__nth).Add_str_a7(gplx.xowa.parsers.lnkis.redlinks.Xopg_redlink_lnki_list.Lnki_id_prefix).Add_int_variable(hctx.Uid__lnki_nxt());
|
||||
bfr.Add(Gfh_bldr_.Bry__id__nth).Add_str_a7(gplx.xowa.wikis.pages.lnkis.Xopg_lnki_list.Lnki_id_prefix).Add_int_variable(hctx.Uid__lnki_nxt());
|
||||
if ( href_type != Xoh_anch_href_data.Tid__anch) { // anchs never have title;
|
||||
if (title_bry != null) {
|
||||
bfr.Add(Gfh_bldr_.Bry__title__nth);
|
||||
|
@ -15,19 +15,10 @@ 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.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xopg_redlink_idx_list {
|
||||
private final Int_list list = new Int_list();
|
||||
public int Len() {return list.Len();}
|
||||
public int Max() {return max;} private int max;
|
||||
public int Get_at(int i) {return list.Get_at(i);}
|
||||
public void Clear() {
|
||||
list.Clear();
|
||||
max = 0;
|
||||
}
|
||||
public void Add(int i) {
|
||||
list.Add(i);
|
||||
if (i > max) max = i;
|
||||
}
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.xowa.wikis.pages.lnkis.*;
|
||||
class Xopg_lnki_itm__hdump implements Xopg_lnki_itm {
|
||||
public Xopg_lnki_itm__hdump(Xoa_ttl ttl) {this.ttl = ttl;}
|
||||
public Xoa_ttl Ttl() {return ttl;} private final Xoa_ttl ttl;
|
||||
public int Html_uid() {return html_uid;} private int html_uid; public void Html_uid_(int v) {html_uid = v;}
|
||||
}
|
@ -20,14 +20,14 @@ import gplx.langs.htmls.*; import gplx.xowa.files.*; import gplx.xowa.users.hist
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.xwikis.*; import gplx.xowa.xtns.wdatas.core.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
public class Xoh_lnki_wtr {
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page; private Xop_ctx ctx;
|
||||
private Xoh_html_wtr_cfg cfg;
|
||||
private Xou_history_mgr history_mgr;
|
||||
private Xop_lnki_caption_wtr_tkn caption_tkn_wtr;
|
||||
private Xop_lnki_caption_wtr_bry caption_bry_wtr;
|
||||
private Xopg_redlink_lnki_list redlinks_mgr;
|
||||
private Xopg_lnki_list redlinks_mgr;
|
||||
public Xoh_lnki_wtr(Xoh_html_wtr html_wtr, Xowe_wiki wiki, Xow_html_mgr html_mgr, Xoh_html_wtr_cfg cfg) {
|
||||
caption_tkn_wtr = new Xop_lnki_caption_wtr_tkn(html_wtr);
|
||||
caption_bry_wtr = new Xop_lnki_caption_wtr_bry();
|
||||
@ -38,7 +38,7 @@ public class Xoh_lnki_wtr {
|
||||
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {
|
||||
this.ctx = ctx; this.page = page; // NOTE: must set ctx for file.v2; DATE:2014-06-22
|
||||
this.wiki = ctx.Wiki();
|
||||
redlinks_mgr = page.Redlink_lnki_list(); // NOTE: need to set redlinks_mgr, else toc parse may fail; EX:pl.d:head_sth_off;DATE:2014-05-07
|
||||
redlinks_mgr = page.Redlink_list(); // NOTE: need to set redlinks_mgr, else toc parse may fail; EX:pl.d:head_sth_off;DATE:2014-05-07
|
||||
file_wtr.Init_by_page(hctx, page);
|
||||
this.history_mgr = app.Usere().History_mgr();
|
||||
if (hctx.Mode_is_hdump()) cfg.Lnki__id_(false);
|
||||
@ -61,7 +61,7 @@ public class Xoh_lnki_wtr {
|
||||
return;
|
||||
}
|
||||
boolean literal_link = lnki_ttl.ForceLiteralLink(); // NOTE: if literal link, then override ns behavior; for File, do not show image; for Ctg, do not display at bottom of page
|
||||
redlinks_mgr.Lnki_add(lnki);
|
||||
redlinks_mgr.Add(lnki);
|
||||
boolean stage_is_alt = hctx.Mode_is_alt();
|
||||
switch (lnki.Ns_id()) {
|
||||
case Xow_ns_.Tid__media: if (!stage_is_alt) file_wtr.Write_or_queue(bfr, page, ctx, hctx, src, lnki); return; // NOTE: literal ":" has no effect; PAGE:en.w:Beethoven and [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]
|
||||
|
@ -1,86 +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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.to_delete {
|
||||
// using gplx.core.primitives; using gplx.core.btries; using gplx.dbs; using gplx.core.ios;
|
||||
// using gplx.xowa.wikis.dbs; using gplx.xowa.wikis.pages; using gplx.xowa.htmls.core.makes.imgs; using gplx.xowa.wikis.pages.skins;
|
||||
// using gplx.xowa.wikis.data; using gplx.xowa.wikis.data.tbls; using gplx.xowa.guis;
|
||||
// public class Xohd_page_html_mgr__load {
|
||||
// private final Bry_rdr_old rdr = new Bry_rdr_old(); private final List_adp rows = List_adp_.New(), imgs = List_adp_.New();
|
||||
// public void Load_page(Xow_wiki wiki, Xoh_page hpg, Xowd_html_tbl tbl, int page_id, Xoa_ttl page_ttl) {
|
||||
// Xoa_app_.Usr_dlg().Plog_many("", "", "hdump.load.text: ttl=~{0}", page_ttl.Full_db_as_str());
|
||||
// tbl.Select_by_page(rows, page_id);
|
||||
// Parse_rows(wiki, hpg, page_id, Xoa_url.blank(), page_ttl, rows);
|
||||
// }
|
||||
// public void Parse_rows(Xow_wiki wiki, Xoh_page hpg, int page_id, Xoa_url page_url, Xoa_ttl page_ttl, List_adp rows) { // TEST:
|
||||
// hpg.Init(wiki, page_id, page_url, page_ttl);
|
||||
// imgs.Clear();
|
||||
// int len = rows.Count();
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Xowd_html_row row = (Xowd_html_row)rows.Get_at(i);
|
||||
// switch (row.Tid()) {
|
||||
// case Xowd_html_row.Tid__img:
|
||||
// case Xowd_html_row.Tid__redlink:
|
||||
// Parse_data(hpg, row); break;
|
||||
// }
|
||||
// }
|
||||
// rows.Clear();
|
||||
// }
|
||||
// private void Parse_data(Xoh_page hpg, Xowd_html_row row) {
|
||||
// rdr.Init(row.Data());
|
||||
// while (!rdr.Pos_is_eos()) {
|
||||
// int tid = rdr.Read_int_to_pipe();
|
||||
// switch (tid) {
|
||||
// case Xohd_img_tid.Tid_img : Load_data_img(); break; // 1|0|A.png|0|220|110|...
|
||||
// case Xohd_img_tid.Tid_gallery : Load_data_gallery(hpg); break; // 3|0|800
|
||||
// case Xohd_img_tid.Tid_redlink : Load_data_redlink(hpg); break; // 2|2|0|1
|
||||
// }
|
||||
// }
|
||||
// if (imgs.Count() > 0) hpg.Img_itms_((Xohd_img_itm__base[])imgs.To_ary_and_clear(typeof(Xohd_img_itm__base)));
|
||||
// }
|
||||
// public static Xohd_img_itm__base Load_img(Bry_rdr_old rdr) {
|
||||
// int tid = rdr.Read_int_to_pipe();
|
||||
// Xohd_img_itm__base img_itm = null;
|
||||
// switch (tid) {
|
||||
// case Xohd_img_itm__base.Tid_basic : img_itm = new Xohd_img_itm__img(); break;
|
||||
// case Xohd_img_itm__base.Tid_gallery : img_itm = new Xohd_img_itm__gallery_itm(); break;
|
||||
// default : throw Err_.new_unhandled(tid);
|
||||
// }
|
||||
// img_itm.Data_parse(rdr);
|
||||
// // Xoa_app_.Usr_dlg().Log_many("", "", "itm: ~{0}", img_itm.Data_print());
|
||||
// rdr.Pos_add_one();
|
||||
// return img_itm;
|
||||
// }
|
||||
// private void Load_data_img() {
|
||||
// Xohd_img_itm__base img = Load_img(rdr);
|
||||
// if (img == null) return;
|
||||
// imgs.Add(img);
|
||||
// }
|
||||
// private void Load_data_redlink(Xoh_page hpg) {
|
||||
// Ordered_hash redlink_hash = hpg.Redlink_uids();
|
||||
// while (!rdr.Pos_is_eos()) {
|
||||
// Int_obj_ref redlink_uid = Int_obj_ref.New(rdr.Read_int_to_pipe());
|
||||
// redlink_hash.Add(redlink_uid, redlink_uid);
|
||||
// }
|
||||
// }
|
||||
// private void Load_data_gallery(Xoh_page hpg) {
|
||||
// int uid = rdr.Read_int_to_pipe();
|
||||
// int box_max = rdr.Read_int_to_pipe();
|
||||
// hpg.Gallery_itms().Add_if_dupe_use_nth(uid, new Xohd_img_itm__gallery_mgr(uid, box_max)); // TODO_OLD: temporarily added b/c last build did not add gallery uid correctly
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,50 +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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.to_delete {
|
||||
// using gplx.xowa.wikis.data; using gplx.xowa.wikis.data.tbls; using gplx.xowa.htmls.core.makes.imgs;
|
||||
// using gplx.xowa.guis; using gplx.xowa.wikis.pages; using gplx.xowa.parsers.lnkis.redlinks;
|
||||
// public class Xohd_page_html_mgr__save {
|
||||
// public void Update(Bry_bfr tmp_bfr, Xowd_html_tbl tbl, Xoae_page page) {
|
||||
// Xoh_page hpg = new Xoh_page().Ctor_by_page(tmp_bfr, page);
|
||||
// tbl.Delete(page.Revision_data().Id());
|
||||
// this.Insert(tmp_bfr, tbl, hpg, page.Hdump_data());
|
||||
// }
|
||||
// public int Insert(Bry_bfr tmp_bfr, Xowd_html_tbl tbl, Xoh_page hpg, Xopg_hdump_data hdump_data) {
|
||||
// int rv = 0;
|
||||
// int page_id = hpg.Page_id();
|
||||
// rv += Insert_row(tbl, page_id, Xowd_html_row.Tid__img , Write_imgs(tmp_bfr, hdump_data.Imgs()));
|
||||
// rv += Insert_row(tbl, page_id, Xowd_html_row.Tid__redlink , Write_redlinks(tmp_bfr, hdump_data.Redlink_mgr()));
|
||||
// return rv;
|
||||
// }
|
||||
// private int Insert_row(Xowd_html_tbl tbl, int page_id, int row_tid, byte[] bry) {return bry == null ? 0 : tbl.Insert(page_id, row_tid, bry);}
|
||||
// public static byte[] Write_redlinks(Bry_bfr bfr, Xopg_redlink_idx_list redlink_mgr) {
|
||||
// int len = redlink_mgr.Len(); if (len == 0) return null;
|
||||
// for (int i = 0; i < len; ++i)
|
||||
// bfr.Add_int_variable(redlink_mgr.Get_at(i)).Add_byte_pipe();
|
||||
// return bfr.To_bry_and_clear();
|
||||
// }
|
||||
// public static byte[] Write_imgs(Bry_bfr bfr, List_adp imgs) {
|
||||
// int len = imgs.Count(); if (len == 0) return null; // no images; exit early, else will write blank String
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Xohd_img_itm itm = (Xohd_img_itm)imgs.Get_at(i);
|
||||
// itm.Data_write(bfr);
|
||||
// }
|
||||
// return bfr.To_bry_and_clear();
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -37,19 +37,19 @@ public class Xol_convert_mgr {
|
||||
converter.Convert_text(tmp_bfr, src, bgn, end);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Xoa_ttl ttl) {return Convert_ttl(wiki, ttl.Ns(), ttl.Page_db());} // NOTE: not Full_db as ttl.Ns is passed; EX:Шаблон:Šablon:Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
public Xowd_page_itm Convert_ttl(Xow_wiki wiki, Xoa_ttl ttl) {return Convert_ttl(wiki, ttl.Ns(), ttl.Page_db());} // NOTE: not Full_db as ttl.Ns is passed; EX:Шаблон:Šablon:Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
public Xowd_page_itm Convert_ttl(Xow_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b512();
|
||||
Xowd_page_itm rv = Convert_ttl(wiki, tmp_bfr, ns, ttl_bry);
|
||||
tmp_bfr.Mkr_rls();
|
||||
return rv;
|
||||
}
|
||||
private Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) { // REF.MW:LanguageConverter.php|findVariantLink
|
||||
private Xowd_page_itm Convert_ttl(Xow_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) { // REF.MW:LanguageConverter.php|findVariantLink
|
||||
synchronized (tmp_page_list) { // THREAD:
|
||||
int converted = Convert_ttl__convert_each_vnt(wiki, tmp_bfr, ns, ttl_bry); // convert ttl for each vnt
|
||||
if (converted == 0) return Xowd_page_itm.Null; // ttl_bry has no conversions; exit;
|
||||
// wiki.Data__core_mgr().Tbl__page().Select_in__ns_ttl(Cancelable_.Never, tmp_page_list, wiki.Ns_mgr(), true, 0, converted); // TODO_OLD: use this call; when defaulting test to use db_mgr, not txt_mgr
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(Cancelable_.Never, tmp_page_list, Bool_.Y, 0, converted);
|
||||
((Xowe_wiki)wiki).Db_mgr().Load_mgr().Load_by_ttls(Cancelable_.Never, tmp_page_list, Bool_.Y, 0, converted);
|
||||
for (int i = 0; i < converted; i++) {
|
||||
Xowd_page_itm page = (Xowd_page_itm)tmp_page_list.Get_at(i);
|
||||
if (page.Exists()) return page; // return 1st found page
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.xtns.pfuncs.ttls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xop_lnki_tkn extends Xop_tkn_itm_base {
|
||||
public class Xop_lnki_tkn extends Xop_tkn_itm_base implements gplx.xowa.wikis.pages.lnkis.Xopg_lnki_itm {
|
||||
@Override public byte Tkn_tid() {return tkn_tid;} private byte tkn_tid = Xop_tkn_itm_.Tid_lnki;
|
||||
public void Tkn_tid_to_txt() {tkn_tid = Xop_tkn_itm_.Tid_txt;}
|
||||
public int Ns_id() {return ns_id;} public Xop_lnki_tkn Ns_id_(int v) {ns_id = v; return this;} private int ns_id;
|
||||
@ -46,7 +46,7 @@ public class Xop_lnki_tkn extends Xop_tkn_itm_base {
|
||||
public boolean Alt_exists() {return alt_tkn != Arg_nde_tkn.Null;}
|
||||
public int Subpage_tid() {return subpage_tid;} public Xop_lnki_tkn Subpage_tid_(int v) {subpage_tid = v; return this;} private int subpage_tid = Pfunc_rel2abs.Id_null;
|
||||
public boolean Subpage_slash_at_end() {return subpage_slash_at_end;} public Xop_lnki_tkn Subpage_slash_at_end_(boolean v) {subpage_slash_at_end = v; return this;} private boolean subpage_slash_at_end;
|
||||
public int Html_uid() {return html_uid;} public Xop_lnki_tkn Html_uid_(int v) {html_uid = v; return this;} private int html_uid;
|
||||
public int Html_uid() {return html_uid;} public void Html_uid_(int v) {html_uid = v;} private int html_uid;
|
||||
public int Pipe_count() {return pipe_count;} private int pipe_count;
|
||||
public boolean Pipe_count_is_zero() {return pipe_count++ == 0;}
|
||||
public boolean Xtn_sites_link() {return xtn_sites_link;} public void Xtn_sites_link_(boolean v) {xtn_sites_link = v;} private boolean xtn_sites_link;
|
||||
|
@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.xtns.relatedSites.*;
|
||||
import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
import gplx.xowa.parsers.tmpls.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
public class Xop_lnki_wkr_ {
|
||||
private static final Int_obj_ref rel2abs_tid = Int_obj_ref.New_zero();
|
||||
public static final int Invalidate_lnki_len = 128;
|
||||
|
@ -1,117 +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.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xog_redlink_mgr implements Gfo_invk {
|
||||
private Gfo_usr_dlg usr_dlg; private Xog_html_itm html_itm; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private Xopg_redlink_lnki_list redlink_lnki_list; private List_adp lnki_list; private int thread_id;
|
||||
public Xog_redlink_mgr(Xoae_page page) {
|
||||
this.page = page; this.wiki = page.Wikie();
|
||||
this.html_itm = page.Tab_data().Tab().Html_itm(); // NOTE: caching locally b/c page.Tab() is sometimes null
|
||||
this.redlink_lnki_list = page.Redlink_lnki_list();
|
||||
this.lnki_list = redlink_lnki_list.Lnki_list();
|
||||
this.thread_id = redlink_lnki_list.Thread_id();
|
||||
this.usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_run)) Redlink();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_run = "run";
|
||||
public void Redlink() {
|
||||
synchronized (this) { // NOTE: attempt to eliminate random IndexBounds errors; DATE:2014-09-02
|
||||
if (redlink_lnki_list.Disabled()) return;
|
||||
List_adp work_list = List_adp_.New();
|
||||
Ordered_hash page_hash = Ordered_hash_.New_bry();
|
||||
page_hash.Clear(); // NOTE: do not clear in Page_bgn, else will fail b/c of threading; EX: Open Page -> Preview -> Save; DATE:2013-11-17
|
||||
work_list.Clear();
|
||||
int len = lnki_list.Count();
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_bgn: page=~{0} total_links=~{1}", String_.new_u8(page.Ttl().Raw()), len);
|
||||
for (int i = 0; i < len; i++) { // make a copy of list else thread issues
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
work_list.Add(lnki_list.Get_at(i));
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)work_list.Get_at(i);
|
||||
Xoa_ttl ttl = lnki.Ttl();
|
||||
Xowd_page_itm db_page = new Xowd_page_itm().Ttl_(ttl);
|
||||
byte[] full_txt = ttl.Full_db();
|
||||
if (!page_hash.Has(full_txt))
|
||||
page_hash.Add(full_txt, db_page);
|
||||
}
|
||||
int page_len = page_hash.Count();
|
||||
for (int i = 0; i < page_len; i += Batch_size) {
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
int end = i + Batch_size;
|
||||
if (end > page_len) end = page_len;
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(usr_dlg, page_hash, Bool_.Y, i, end);
|
||||
}
|
||||
int redlink_count = 0;
|
||||
boolean variants_enabled = wiki.Lang().Vnt_mgr().Enabled();
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
Xopg_redlink_idx_list redlink_mgr = page.Hdump_data().Redlink_mgr();
|
||||
for (int j = 0; j < len; j++) {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)work_list.Get_at(j);
|
||||
byte[] full_db = lnki.Ttl().Full_db();
|
||||
Xowd_page_itm db_page = (Xowd_page_itm)page_hash.Get_by(full_db);
|
||||
if (db_page == null) continue; // pages shouldn't be null, but just in case
|
||||
if (!db_page.Exists()) {
|
||||
String lnki_id = Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(lnki.Html_uid());
|
||||
if (variants_enabled) {
|
||||
Xowd_page_itm vnt_page = vnt_mgr.Convert_mgr().Convert_ttl(wiki, lnki.Ttl());
|
||||
if (vnt_page != null) {
|
||||
Xoa_ttl vnt_ttl = Xoa_ttl.parse(wiki, lnki.Ttl().Ns().Id(), vnt_page.Ttl_page_db());
|
||||
html_itm.Html_atr_set(lnki_id, "href", "/wiki/" + String_.new_u8(vnt_ttl.Full_url()));
|
||||
if (!String_.Eq(vnt_mgr.Html__lnki_style(), ""))
|
||||
html_itm.Html_atr_set(lnki_id, "style", vnt_mgr.Html__lnki_style());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
int uid = lnki.Html_uid();
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(uid));
|
||||
redlink_mgr.Add(uid);
|
||||
++redlink_count;
|
||||
}
|
||||
}
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0}", redlink_count);
|
||||
}
|
||||
}
|
||||
public static final Xog_redlink_mgr Null = new Xog_redlink_mgr(); Xog_redlink_mgr() {}
|
||||
private static final int Batch_size = 32;
|
||||
}
|
||||
class Xog_redlink_wkr {
|
||||
public static void Redlink(Xog_html_itm html_itm, Int_list list) {
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int uid = list.Get_at(i);
|
||||
Redlink(html_itm, uid);
|
||||
}
|
||||
}
|
||||
public static void Redlink(Xog_html_itm html_itm, int uid) {
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(uid));
|
||||
}
|
||||
}
|
@ -17,10 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
import gplx.xowa.wikis.pages.lnkis.*;
|
||||
public class Xopg_hdump_data {
|
||||
public byte[] Body() {return body;} public void Body_(byte[] v) {body = v;} private byte[] body;
|
||||
public Xopg_redlink_idx_list Redlink_mgr() {return redlink_mgr;} private final Xopg_redlink_idx_list redlink_mgr = new Xopg_redlink_idx_list();
|
||||
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
|
||||
public void Imgs_add(Xohd_img_itm itm) {imgs.Add(itm);}
|
||||
public void Imgs_add_img(Xohd_img_itm__base img, Xof_file_itm xfer, int tid) {
|
||||
@ -34,6 +33,5 @@ public class Xopg_hdump_data {
|
||||
public void Clear() {
|
||||
body = null;
|
||||
imgs.Clear();
|
||||
redlink_mgr.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,8 @@ 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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.xowa.files.gui.*;
|
||||
class Xof_redlink_wkr implements Gfo_thread_wkr {
|
||||
private Xog_js_wkr js_wkr; private int[] uids;
|
||||
public Xof_redlink_wkr(Xog_js_wkr js_wkr, int[] uids) {
|
||||
this.js_wkr = js_wkr; this.uids = uids;
|
||||
}
|
||||
public String Thread__name() {return "xowa.redlinks";}
|
||||
public boolean Thread__resume() {return true;}
|
||||
public void Thread__exec() {
|
||||
int len = uids.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int uid = uids[i];
|
||||
js_wkr.Html_atr_set(Int_.To_str(uid), "", "");
|
||||
}
|
||||
}
|
||||
package gplx.xowa.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public interface Xopg_lnki_itm {
|
||||
Xoa_ttl Ttl();
|
||||
int Html_uid(); void Html_uid_(int v);
|
||||
}
|
@ -15,26 +15,21 @@ 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.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.users.*;
|
||||
public class Xopg_redlink_lnki_list {
|
||||
private int lnki_idx = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_lnki_wtr.Lnki_id_min; // NOTE: default to 1, not 0, b/c 0 is ignored by wtr; DATE:2014-10-09
|
||||
public Xopg_redlink_lnki_list(boolean ttl_is_module) { // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
package gplx.xowa.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xopg_lnki_list {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private int lnki_idx;
|
||||
public Xopg_lnki_list(boolean ttl_is_module) { // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
this.disabled = ttl_is_module;
|
||||
this.Clear();
|
||||
}
|
||||
public boolean Disabled() {return disabled;} private final boolean disabled;
|
||||
public List_adp Lnki_list() {return lnki_list;} private final List_adp lnki_list = List_adp_.New();
|
||||
public int Thread_id() {return thread_id;} private int thread_id = 1;
|
||||
public void Clear() {
|
||||
public boolean Disabled() {return disabled;} private final boolean disabled;
|
||||
public int Len() {return list.Len();}
|
||||
public Xopg_lnki_itm Get_at(int i) {return (Xop_lnki_tkn)list.Get_at(i);}
|
||||
public void Add(Xopg_lnki_itm lnki) {
|
||||
if (disabled) return;
|
||||
lnki_idx = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_lnki_wtr.Lnki_id_min; // NOTE: must start at 0, so that ++lnki_idx is > 0; html_wtr checks for > 0
|
||||
lnki_list.Clear();
|
||||
thread_id++;
|
||||
}
|
||||
public void Lnki_add(Xop_lnki_tkn lnki) {
|
||||
if (disabled) return;
|
||||
Xoa_ttl ttl = lnki.Ttl(); if (ttl == null) return; // occurs for invalid links
|
||||
Xoa_ttl ttl = lnki.Ttl(); if (ttl == null) return; // ttl is null for invalid links
|
||||
Xow_ns ns = ttl.Ns();
|
||||
lnki.Html_uid_(++lnki_idx); // NOTE: set html_id in order html to print out "id='xowa_lnki_1'; want to print out id for consistency's sake, even if these links won't be check for redlinks; DATE:2015-05-07
|
||||
if ( ns.Id_is_file_or_media() // ignore files which will usually not be in local wiki (most are in commons), and whose html is built up separately
|
||||
@ -44,8 +39,12 @@ public class Xopg_redlink_lnki_list {
|
||||
|| ttl.Wik_itm() != null // xwiki lnki; EX: simplewiki links in homewiki; [[simplewiki:Earth]]
|
||||
)
|
||||
return;
|
||||
lnki_list.Add(lnki);
|
||||
list.Add(lnki);
|
||||
}
|
||||
public void Clear() {
|
||||
lnki_idx = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_lnki_wtr.Lnki_id_min; // NOTE: must start at 0, so that ++lnki_idx is > 0; html_wtr checks for > 0; DATE:2014-10-09
|
||||
list.Clear();
|
||||
}
|
||||
|
||||
public static final String Lnki_id_prefix = "xolnki_";
|
||||
public static final int Lnki_id_prefix_len = String_.Len(Lnki_id_prefix);
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
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.wikis.pages.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.files.gui.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.vnts.*;
|
||||
public class Xopg_redlink_mgr implements Gfo_invk {
|
||||
private final Xoa_page page; private final Xog_js_wkr js_wkr;
|
||||
public Xopg_redlink_mgr(Xoa_page page, Xog_js_wkr js_wkr) {this.page = page; this.js_wkr = js_wkr; }
|
||||
private void Redlink() {
|
||||
Xopg_lnki_list lnki_list = page.Redlink_list(); if (lnki_list.Disabled()) return;
|
||||
Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
Xow_wiki wiki = page.Wiki();
|
||||
Ordered_hash lnki_hash = Ordered_hash_.New_bry();
|
||||
|
||||
// create unique list of page_rows
|
||||
int len = lnki_list.Len();
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_bgn: page=~{0} total_links=~{1}", page.Ttl().Raw(), len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (usr_dlg.Canceled()) return;
|
||||
Xoa_ttl ttl = lnki_list.Get_at(i).Ttl();
|
||||
Xowd_page_itm page_row = new Xowd_page_itm().Ttl_(ttl);
|
||||
byte[] full_db = ttl.Full_db();
|
||||
if (!lnki_hash.Has(full_db)) // only search page_table once for multiple identical redlinks; EX: "[[Missing]] [[Missing]]"
|
||||
lnki_hash.Add(full_db, page_row);
|
||||
}
|
||||
|
||||
// load page_rows from page_tbl
|
||||
int page_len = lnki_hash.Len();
|
||||
for (int i = 0; i < page_len; i += Batch_size) {
|
||||
if (usr_dlg.Canceled()) return;
|
||||
int end = i + Batch_size; if (end > page_len) end = page_len;
|
||||
wiki.Data__core_mgr().Tbl__page().Select_in__ns_ttl(usr_dlg, lnki_hash, wiki.Ns_mgr(), Bool_.Y, i, end);
|
||||
// wiki.Db_mgr().Load_mgr().Load_by_ttls(usr_dlg, lnki_hash, Bool_.Y, i, end);
|
||||
}
|
||||
|
||||
// cross-check page_rows against lnki_list; redlink if missing;
|
||||
boolean vnt_enabled = wiki.Lang().Vnt_mgr().Enabled();
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
int redlink_count = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_lnki_itm lnki = lnki_list.Get_at(i);
|
||||
byte[] full_db = lnki.Ttl().Full_db();
|
||||
Xowd_page_itm page_row = (Xowd_page_itm)lnki_hash.Get_by(full_db);
|
||||
if (page_row.Exists()) continue; // page exists; nothing to do;
|
||||
|
||||
// for vnt languages, convert missing ttl to vnt and check again; EX: [[zh_cn]] will check for page_ttl for [[zh_tw]]
|
||||
String html_uid = Xopg_lnki_list.Lnki_id_prefix + Int_.To_str(lnki.Html_uid());
|
||||
if (vnt_enabled) {
|
||||
Xowd_page_itm vnt_page = vnt_mgr.Convert_mgr().Convert_ttl(wiki, lnki.Ttl()); // check db
|
||||
if (vnt_page != null) { // vnt found; update href to point to vnt
|
||||
Xoa_ttl vnt_ttl = wiki.Ttl_parse(lnki.Ttl().Ns().Id(), vnt_page.Ttl_page_db());
|
||||
js_wkr.Html_atr_set(html_uid, "href", "/wiki/" + String_.new_u8(vnt_ttl.Full_url()));
|
||||
if (!String_.Eq(vnt_mgr.Html__lnki_style(), "")) js_wkr.Html_atr_set(html_uid, "style", vnt_mgr.Html__lnki_style()); // colorize for debugging
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// lnki is missing; redlink it
|
||||
if (usr_dlg.Canceled()) return;
|
||||
Js_img_mgr.Update_link_missing(js_wkr, html_uid);
|
||||
++redlink_count;
|
||||
}
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0}", redlink_count);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_run)) {synchronized (this) {Redlink();}} // NOTE: attempt to eliminate random IndexBounds errors; DATE:2014-09-02
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_run = "run";
|
||||
private static final int Batch_size = 32;
|
||||
}
|
Loading…
Reference in New Issue
Block a user