Exemple #1
0
 public Xowv_wiki(Xoav_app app, byte[] domain_bry, Io_url wiki_root_dir) {
   this.app = app;
   this.domain_bry = domain_bry;
   this.domain_str = String_.new_u8(domain_bry);
   this.domain_itm = Xow_domain_itm_.parse(domain_bry);
   this.domain_tid = domain_itm.Domain_type_id();
   this.domain_abrv = Xow_abrv_wm_.To_abrv(Xow_domain_itm_.parse(domain_bry));
   this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr());
   this.lang =
       app.Lang_mgr()
           .Get_by_or_en(
               domain_itm
                   .Lang_actl_key()); // NOTE: must not be null, or causes null ref exception on
                                      // redlinks in drd; DATE:2016-06-28
   this.msg_mgr = new Xow_msg_mgr(this, lang);
   this.html__hdump_mgr = new Xow_hdump_mgr(this);
   this.special_mgr = new Xosp_special_mgr(this);
   this.fsys_mgr =
       new Xow_fsys_mgr(wiki_root_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
   this.fsdb_mgr = new Xof_fsdb_mgr__sql();
   this.url__parser = new Xow_url_parser(this);
   this.xwiki_mgr = new Xow_xwiki_mgr(this);
   this.stats = new Xow_site_stats_mgr(this);
   this.lnki_bldr = new Xoh_lnki_bldr(app, href_wtr);
   this.ctg_catpage_mgr = new Xoctg_catpage_mgr(this);
 }
Exemple #2
0
 public void Init_by_wiki() {
   if (!init_needed) return;
   init_needed = false;
   if (String_.Eq(domain_str, "xowa"))
     return; // HACK: ignore "xowa" for now; WHEN:converting xowa to sqlitedb
   data_mgr__core_mgr = new Xow_db_mgr(this, fsys_mgr.Root_dir());
   data_mgr__core_mgr.Init_by_load(gplx.xowa.wikis.data.Xow_db_file__core_.Find_core_fil(this));
   app.Html__css_installer()
       .Install(this, Xowd_css_core_mgr.Key_mobile); // must init after data_mgr
   this.db_core_mgr = Fsdb_db_mgr_.new_detect(this, fsys_mgr.Root_dir(), fsys_mgr.File_dir());
   if (db_core_mgr
       == null) // no fsdb; occurs during merge; also, will be null for xowa_db; DATE:2016-05-31
   db_core_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(this, true);
   else // fsdb exists; load it
   fsdb_mgr.Mnt_mgr().Ctor_by_load(db_core_mgr);
   file_mgr__repo_mgr.Add_repo(
       app, fsys_mgr.File_dir(), Xow_domain_itm_.Bry__commons, Xow_domain_itm_.Bry__commons);
   file_mgr__repo_mgr.Add_repo(app, fsys_mgr.File_dir(), domain_bry, domain_bry);
   Xof_orig_tbl[] orig_tbls =
       db_core_mgr == null ? new Xof_orig_tbl[0] : db_core_mgr.File__orig_tbl_ary();
   orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, orig_tbls, Xof_url_bldr.new_v2());
   fsdb_mgr.Init_by_wiki(this);
   data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr);
   data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats);
   html__hdump_mgr.Init_by_db(this);
   app.Addon_mgr().Load_by_wiki(this);
   ctg_pagebox_wtr.Init_by_wiki(this);
 }
	public static byte[] Write_wdata_links(List_adp slink_list, Xowe_wiki wiki, Xoa_ttl ttl, Wdata_external_lang_links_data external_links_mgr) {
		try {
			switch (wiki.Domain_tid()) {
				case Xow_domain_type_.Tid_home:		// home will never be in wikidata
				case Xow_domain_type_.Tid_wikidata:	// wikidata will never be in wikidata
					return Qid_null;
			}
			Wdata_wiki_mgr wdata_mgr = wiki.Appe().Wiki_mgr().Wdata_mgr();
			Wdata_doc doc = wdata_mgr.Pages_get(wiki, ttl); if (doc == null) return Qid_null;	// no links
			boolean external_links_mgr_enabled = external_links_mgr.Enabled();
			Ordered_hash links = doc.Slink_list();
			Bry_bfr tmp_bfr = wiki.Appe().Utl__bfr_mkr().Get_k004();
			Xow_wiki_abrv wiki_abrv = new Xow_wiki_abrv();
			int len = links.Count();
			for (int i = 0; i < len; i++) {
				Wdata_sitelink_itm slink = (Wdata_sitelink_itm)links.Get_at(i);
				byte[] xwiki_key = slink.Site();
				Xow_wiki_abrv_.parse_(wiki_abrv, xwiki_key, 0, xwiki_key.length);
				if (wiki_abrv.Domain_tid() == Xow_wiki_abrv_.Tid_null) {
					wiki.Appe().Usr_dlg().Warn_many("", "", "unknown wiki in wikidata: ttl=~{0} wiki=~{1}", ttl.Page_db_as_str(), String_.new_u8(xwiki_key));
					continue;
				}
				if (wiki_abrv.Domain_tid() != wiki.Domain_tid()) continue;	// ignore wikis in a different domain; EX: looking at enwiki:Earth, and wikidata has dewikiquote; ignore dewikiquote; DATE:2014-06-21
				byte[] lang_key = wiki_abrv.Lang_itm().Key();
				if (external_links_mgr_enabled && external_links_mgr.Langs_hide(lang_key, 0, lang_key.length)) continue;
				tmp_bfr.Add(lang_key);
				tmp_bfr.Add_byte(Byte_ascii.Colon);
				tmp_bfr.Add(slink.Name());
				Xoa_ttl slink_ttl = Xoa_ttl.parse_(wiki, tmp_bfr.Xto_bry_and_clear());
				if (slink_ttl == null) continue;								// invalid ttl
				Xow_xwiki_itm xwiki_itm = slink_ttl.Wik_itm();
				if (	xwiki_itm == null									// not a known xwiki; EX: [[zzz:abc]]
					||	Bry_.Eq(xwiki_itm.Domain_bry(), wiki.Domain_bry())	// skip if same as self; i.e.: do not include links to enwiki if already in enwiki
					) continue;
				slink.Page_ttl_(slink_ttl);
				slink_list.Add(slink);
			}
			tmp_bfr.Mkr_rls();
			if (external_links_mgr_enabled && external_links_mgr.Sort())
				slink_list.Sort_by(Xoa_ttl_sorter._);
			return doc.Qid();
		} catch (Exception e) {Err_.Noop(e); return Qid_null;}
	}