public void Special__gen(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) { int slash_pos = Bry_find_.Find_fwd(ttl.Page_txt_wo_qargs(), Xoa_ttl.Subpage_spr); // check for slash byte[] special_name = slash_pos == Bry_find_.Not_found ? ttl .Base_txt_wo_qarg() // no slash found; use base_txt; ignore qry args and just get // page_names; EX: Search/Earth?fulltext=y; // Allpages?from=Earth... : Bry_.Mid( ttl.Page_txt_wo_qargs(), 0, slash_pos); // slash found; use root page; EX: Special:ItemByTitle/enwiki/Earth special_name = Xoa_ttl.Replace_spaces(special_name); // handle spaces; EX:Spezial:Zufällige_Seite Xow_special_page special = (Xow_special_page) hash.Get_by_bry(special_name); if (special != null) { // special found; generate it; special = special.Special__clone(); page.Db().Page().Modified_on_(Datetime_now.Get()); try { special.Special__gen(wiki, page, url, ttl); } catch (Exception e) { Gfo_log_.Instance.Warn( "failed to generate special page", "url", url.To_str(), "err", Err_.Message_gplx_log(e)); } } }
private static boolean Navigate( Gfo_usr_dlg usr_dlg, Xoae_app app, Wdata_wiki_mgr wdata_mgr, Xoae_page page, byte[] site_bry, byte[] page_bry) { page_bry = Xoa_app_.Utl__encoder_mgr() .Http_url() .Decode(page_bry); // NOTE: space is converted to + on postback to url; decode byte[] wiki_domain = Xow_wiki_alias.Parse_wmf_key(site_bry); if (wiki_domain == null) { usr_dlg.Warn_many("", "", "site_bry parse failed; site_bry:~{0}", String_.new_u8(site_bry)); return false; } Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain); if (wiki == null) { usr_dlg.Warn_many( "", "", "wiki_domain does not exist; wiki_domain:~{0}", String_.new_u8(wiki_domain)); return false; } Xoa_ttl wdata_ttl = Xoa_ttl.parse_(wiki, page_bry); if (wdata_ttl == null) { usr_dlg.Warn_many("", "", "ttl is invalid; ttl:~{0}", String_.new_u8(page_bry)); return false; } Wdata_doc doc = wdata_mgr.Pages_get(wiki, wdata_ttl); if (doc == null) { usr_dlg.Warn_many( "", "", "ttl cannot be found in wikidata; ttl:~{0}", String_.new_u8(wdata_ttl.Raw())); return false; } byte[] qid_bry = doc.Qid(); Xoae_page qid_page = wdata_mgr.Wdata_wiki().Data_mgr().Redirect(page, qid_bry); if (qid_page.Missing()) { usr_dlg.Warn_many( "", "", "qid cannot be found in wikidata; qid:~{0}", String_.new_u8(qid_bry)); return false; } return true; }
public void Get_by_url1(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) { int slash_pos = Bry_find_.Find_fwd(ttl.Page_txt_wo_qargs(), Xoa_ttl.Subpage_spr); // check for slash byte[] special_name = slash_pos == Bry_find_.Not_found ? ttl.Base_txt_wo_qarg() // no slash found; use base_txt; ignore qry args and just get // page_names; EX: Search/Earth?fulltext=y; // Allpages?from=Earth... : Bry_.Mid( ttl.Page_txt_wo_qargs(), 0, slash_pos); // slash found; use root page; EX: Special:ItemByTitle/enwiki/Earth Object o = hash.Get_by_bry(special_name); if (o == null) { Xol_specials_itm special_itm = wiki.Lang().Specials_mgr().Get_by_alias(special_name); if (special_itm != null) o = hash.Get_by_bry(special_itm.Special()); } if (o != null) { // Xow_special_page special = (Xow_special_page)o; // page.Revision_data().Modified_on_(Datetime_now.Get()); // special.Special__gen(wiki, page, url, ttl); } }
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) { if (cfg == null) cfg = (Wdata_itemByTitle_cfg) wiki.Appe().Special_mgr().Get_or_null(Wdata_itemByTitle_cfg.Key); // Special:ItemByTitle/enwiki/Earth -> www.wikidata.org/wiki/Q2 Gfo_usr_dlg usr_dlg = wiki.Appe().Usr_dlg(); byte[] site_bry = cfg.Site_default(); byte[] page_bry = Bry_.Empty; byte[] raw_bry = ttl.Full_txt_wo_qarg(); // EX: enwiki/Earth int args_len = url.Args().length; if (args_len > 0) { arg_hash.Load(url); site_bry = arg_hash.Get_val_bry_or(Arg_site, Bry_.Empty); page_bry = arg_hash.Get_val_bry_or(Arg_page, Bry_.Empty); } int site_bgn = Bry_finder.Find_fwd(raw_bry, Xoa_ttl.Subpage_spr); if (site_bgn != Bry_.NotFound) { // leaf arg is available int page_bgn = Bry_finder.Find_fwd(raw_bry, Xoa_ttl.Subpage_spr, site_bgn + 1); int raw_bry_len = raw_bry.length; if (page_bgn != Bry_.NotFound && page_bgn < raw_bry_len) { // pipe is found and not last char (EX: "enwiki/" is invalid site_bry = Bry_.Mid(raw_bry, site_bgn + 1, page_bgn); page_bry = Bry_.Mid(raw_bry, page_bgn + 1, raw_bry_len); } } Xoae_app app = wiki.Appe(); if (Bry_.Len_gt_0(site_bry) && Bry_.Len_gt_0(page_bry)) if (Navigate(usr_dlg, app, app.Wiki_mgr().Wdata_mgr(), page, site_bry, page_bry)) return; Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_k004(); html_fmtr.Bld_bfr_many( tmp_bfr, "Search for items by site and title", "Site", site_bry, "Page", page_bry, "Search"); page.Data_raw_(tmp_bfr.To_bry_and_rls()); page.Html_data().Html_restricted_n_(); // [[Special:]] pages allow all HTML }