Пример #1
0
 private void Parse_title(Gfh_atr title_atr) {
   // Tfds.Dbg(Bry_.Mid(href_src, href_bgn, href_end), Bry_.Mid(src, capt_bgn, capt_end),
   // Bry_.Mid(src, title_bgn, title_end));
   title_bgn = title_atr.Val_bgn();
   title_end = title_atr.Val_end();
   if (href_ns_name != null) { // ns_name exists
     int title_bgn_wo_ns = title_bgn + href_ns_name_len;
     if (Bry_.Match(src, title_bgn, title_bgn_wo_ns, href_ns_name)) // title matches href_ns;
     title_bgn = title_bgn_wo_ns; // skip ns; "Help:"
     else title_missing_ns = true;
   }
   if (title_end == -1) title_tid = Title__missing;
   else {
     if (Bry_.Match(src, title_bgn, title_end, href_src, href_bgn, href_end)
         && !title_missing_ns) // NOTE: do not mark title=href if href omitted title;
       // PAGE:en.b:Wikibooks:WikiProject; DATE:2016-01-20
       title_tid = Title__href;
     else if (Bry_.Match(src, title_bgn, title_end, src, capt_bgn, capt_end))
       title_tid = Title__capt;
     else {
       title_tid = Title__diff;
       if (href_ns_name != null)
         title_bgn = title_atr.Val_bgn(); // since title is different, add back ns_name; EX: "<a
       // href='/wiki/Help:A_b#c' title='Help:A b'>a</a>"; title should be
       // "Help:A b", not "A b"
     }
   }
 }
Пример #2
0
 @Test
 public void Bidi() {
   fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 142)) + "B").Expd_page_txt("AB").Test();
   fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B")
       .Expd_page_txt("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B")
       .Test();
 }
Пример #3
0
 private void Tkns_add_word(byte tid, int src_bgn, int src_end) {
   if (tkns.Count() > 0) { // at least 1 tkn; check for "auto-and"
     Xow_search_tkn last_tkn = (Xow_search_tkn) tkns.Get_at_last();
     if (last_tkn.Tid()
         == Xow_search_tkn.Tid_word) // previous tkn is word; auto "AND" words; EX: A B -> A AND B
     tkns.Add(Xow_search_tkn.new_bry(Xow_search_tkn.Tid_and, Bry_and));
   }
   if (tid
       == Xow_search_tkn
           .Tid_word) { // if word has symbol, convert to quoted; EX: a-b should become "a-b";
                        // otherwise searcher would search for a single word a-b
     byte[] cur_word = Bry_.Mid(src, src_bgn, src_end);
     byte[][] words =
         gplx.xowa.bldrs.cmds.texts.Xob_search_base.Split_ttl_into_words(
             null, tmp_list, tmp_bfr, cur_word);
     int words_len = words.length;
     if (words_len == 1 // only one word
         && !Bry_.Eq(words[0], cur_word) // split word not same as raw
         && Bry_finder.Find_fwd(cur_word, Byte_ascii.Star) == -1 // no asterisk
     ) {
       tkns.Add(Xow_search_tkn.new_bry(tid, words[0]));
       return;
     }
     if (words.length > 1) // multiple words; add as quoted-term; EX: "a-b"
     tid = Xow_search_tkn.Tid_word_quoted;
   }
   tkns.Add(new_tkn(tid, src_bgn, src_end));
 }
Пример #4
0
 public boolean Eq_wo_bmk_pos(Xog_history_itm comp) {
   return Bry_.Eq(wiki, comp.wiki)
       && Bry_.Eq(page, comp.page)
       && Bry_.Eq(anch, comp.anch)
       && Bry_.Eq(qarg, comp.qarg)
       && redirect_force == comp.redirect_force;
 }
Пример #5
0
 public void Srl_save(Bry_bfr bfr) {
   byte[] bmk_bry =
       Bry_.Replace(
           Bry_.new_u8(bmk_pos),
           Byte_ascii.Pipe,
           Byte_ascii.Tilde); // replace | with ~; EX: "0|1|2" -> "0~1~2"
   bfr.Add(key).Add_byte_pipe().Add(bmk_bry).Add_byte_nl();
 }
 public static byte[] Import_url_build(
     byte[] stylesheet_prefix, byte[] rel_url_prefix, byte[] css_url) {
   return Bry_.Has_at_bgn(
           css_url,
           Bry_http_protocol) // css_url already starts with "http"; return self;
                              // PAGE:tr.n:Main_Page; DATE:2014-06-04
       ? css_url
       : Bry_.Add(stylesheet_prefix, css_url);
 }
Пример #7
0
	Xof_repo_itm Ini_repo_add(Xof_file_mgr file_mgr, byte[] key, String root, String wiki, boolean trg) {
		Xof_repo_itm repo = file_mgr.Repo_mgr().Set(String_.new_u8(key), root, wiki).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
		if (trg) {
			byte[][] ary = repo.Mode_names();
			ary[0] = Bry_.new_a7("raw");
			ary[1] = Bry_.new_a7("fit");
		}
		return repo;
	}
Пример #8
0
 private static int Get_imap_idx(Bry_err_wkr err_wkr, Gfh_tag img_tag) {
   byte[] val = img_tag.Atrs__get_as_bry(Imap_xtn_mgr.Bry__usemap__name);
   if (Bry_.Len_eq_0(val)) return -1;
   int rv = Bry_.To_int_or(val, Imap_xtn_mgr.Bry__usemap__prefix.length, val.length, -1);
   if (rv == -1) {
     err_wkr.Warn("invalid imap_idx", "val", val);
     return rv;
   }
   return rv;
 }
 private int Import_url_chk(
     byte[] rel_url_prefix,
     byte[] src,
     int src_len,
     int old_pos,
     int find_bgn,
     byte[] url_raw,
     Bry_bfr bfr) {
   if (find_bgn < Bry_import_len) return Bry_find_.Not_found;
   if (!Bry_.Match(src, find_bgn - Bry_import_len, find_bgn, Bry_import))
     return Bry_find_.Not_found;
   byte[] css_url = url_raw;
   int css_url_len = css_url.length;
   if (css_url_len > 0
       && css_url[0]
           == Byte_ascii
               .Slash) { // css_url starts with "/"; EX: "/page" or "//site/page" DATE:2014-02-03
     if (css_url_len > 1
         && css_url[1] != Byte_ascii.Slash) // skip if css_url starts with "//"; EX: "//site/page"
     css_url = Bry_.Add(rel_url_prefix, css_url); // "/w/a.css" -> "//en.wikipedia.org/w/a.css"
   }
   css_url =
       Bry_.Replace(
           css_url,
           Byte_ascii.Space,
           Byte_ascii
               .Underline); // NOTE: must replace spaces with underlines else download will fail;
                            // EX:https://it.wikivoyage.org/w/index.php?title=MediaWiki:Container e
                            // Infobox.css&action=raw&ctype=text/css; DATE:2015-03-08
   byte[] css_src_bry = Import_url_build(stylesheet_prefix, rel_url_prefix, css_url);
   String css_src_str = String_.new_u8(css_src_bry);
   download_wkr.Download_xrg()
       .Prog_fmt_hdr_(
           usr_dlg.Log_many(
               GRP_KEY, "logo.download", "downloading import for '~{0}'", css_src_str));
   byte[] css_trg_bry = download_wkr.Download_xrg().Exec_as_bry(css_src_str);
   if (css_trg_bry == null) {
     usr_dlg.Warn_many("", "", "could not import css: url=~{0}", css_src_str);
     return Bry_find_.Not_found; // css not found
   }
   bfr.Add_mid(src, old_pos, find_bgn - Bry_import_len).Add_byte_nl();
   bfr.Add(Bry_comment_bgn).Add(css_url).Add(Bry_comment_end).Add_byte_nl();
   if (Bry_find_.Find_fwd(css_url, Wikisource_dynimg_ttl) != -1)
     css_trg_bry =
         Bry_.Replace(
             css_trg_bry,
             Wikisource_dynimg_find,
             Wikisource_dynimg_repl); // FreedImg hack;
                                      // PAGE:en.s:Page:Notes_on_Osteology_of_Baptanodon._With_a_Description_of_a_New_Species.pdf/3 DATE:2014-09-06
   bfr.Add(css_trg_bry).Add_byte_nl();
   bfr.Add_byte_nl();
   int semic_pos = Bry_find_.Find_fwd(src, Byte_ascii.Semic, find_bgn + url_raw.length, src_len);
   return semic_pos + Int_.Const_dlm_len;
 }
Пример #10
0
  @Override
  public Xobc_xodir_dir[] Get_dirs(Xoa_app app) {
    Ordered_hash hash = Ordered_hash_.New();

    // add default app dir
    String default_data_dir = context.getApplicationInfo().dataDir + "/";
    String selected =
        app.User()
            .User_db_mgr()
            .Cfg()
            .Get_app_str_or(Xobc_xodir_cfg.Key__selected_dir, default_data_dir);
    Xobc_xodir_dir itm =
        new Xobc_xodir_dir(
            String_.Eq(selected, default_data_dir), false, Bry_.new_u8(default_data_dir));
    hash.Add(default_data_dir, itm);

    // add "guessed" external dirs
    Sdcard_detection_strategy[] strategy_ary =
        new Sdcard_detection_strategy[] {
          new Strategy__storage_dir(-1),
          new Strategy__envvar__external_storage(-1),
          new Strategy__envvar__secondary_storage(
              -1) // NOTE: needed for BLU-STUDIO C 5+5 LTE; DATE: 2016-06-28
        };
    int len = strategy_ary.length;
    String root_rhs = Sdcard_detection_mgr.Get_root_rhs() + "/";
    for (int i = 0; i < len; ++i) {
      Sdcard_detection_strategy strategy = strategy_ary[i];
      String[] dir_strs = strategy.Get_dirs(context);
      for (String dir_str : dir_strs) {
        if (dir_str == null) continue;
        dir_str += root_rhs;
        if (hash.Has(dir_str)) continue;
        File dir = new File(dir_str);
        if (!dir.exists())
          continue; // dir doesn't exist; don't bother trying to create b/c permission won't be
                    // available at 4.4+
        if (!Sdcard_detection_mgr.Dir_is_writeable(dir)) continue;
        itm = new Xobc_xodir_dir(String_.Eq(selected, dir_str), false, Bry_.new_u8(dir_str));
        hash.Add(dir_str, itm);
      }
    }

    // add custom dir
    String custom =
        app.User()
            .User_db_mgr()
            .Cfg()
            .Get_app_str_or(Xobc_xodir_cfg.Key__custom_dir, "(choose your own folder)");
    itm = new Xobc_xodir_dir(String_.Eq(selected, custom), true, Bry_.new_u8(custom));
    hash.Add(custom, itm);
    return (Xobc_xodir_dir[]) hash.To_ary(Xobc_xodir_dir.class);
  }
 public byte[] Clean_img_url(byte[] raw, int raw_len) {
   int pos_bgn = 0;
   if (Bry_.Has_at_bgn(raw, Bry_fwd_slashes, 0, raw_len)) pos_bgn = Bry_fwd_slashes.length;
   if (Bry_.Has_at_bgn(raw, Bry_http, 0, raw_len)) pos_bgn = Bry_http.length;
   int pos_slash = Bry_find_.Find_fwd(raw, Byte_ascii.Slash, pos_bgn, raw_len);
   if (pos_slash == Bry_find_.Not_found)
     return null; // first segment is site_name; at least one slash must be present for image name;
                  // EX: site.org/img_name.jpg
   if (pos_slash == raw_len - 1) return null; // "site.org/" is invalid
   int pos_end = raw_len;
   int pos_question = Bry_find_.Find_bwd(raw, Byte_ascii.Question);
   if (pos_question != Bry_find_.Not_found)
     pos_end = pos_question; // remove query params; EX: img_name?key=val
   return Bry_.Mid(raw, pos_bgn, pos_end);
 }
Пример #12
0
 public void Test_search(String search_word_str, int... expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   List_adp rv = List_adp_.new_();
   byte[] search_word_bry = Bry_.new_a7(search_word_str);
   wiki.Db_mgr_as_sql().Load_mgr().Load_search(Cancelable_.Never, rv, search_word_bry, 100);
   Tfds.Eq_ary(expd, Xto_int_ary(rv));
 }
Пример #13
0
 public void Cmd_bgn(Xob_bldr bldr) {
   Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
   Xob_xfer_temp_tbl.Create_table(conn);
   Db_stmt trg_stmt = Xob_xfer_temp_tbl.Insert_stmt(conn);
   conn.Txn_bgn();
   DataRdr rdr = conn.Exec_sql_as_rdr(Sql_select);
   Xob_xfer_temp_itm temp_itm = new Xob_xfer_temp_itm();
   Xof_img_size img_size = new Xof_img_size();
   byte[] cur_ttl = Bry_.Empty;
   byte cur_repo = Byte_.Max_value_127;
   while (rdr.MoveNextPeer()) {
     temp_itm.Clear();
     temp_itm.Load(rdr);
     if (Bry_.Eq(cur_ttl, temp_itm.Orig_file_ttl())) { // same ttl; DATE:2015-03-22
       if (temp_itm.Orig_repo()
           != cur_repo) // if repo is different, ignore 2nd; handles images in both repos; take 1st
         // only (which should be local)
         continue;
     } else { // new ttl; update ttl, repo
       cur_ttl = temp_itm.Orig_file_ttl();
       cur_repo = temp_itm.Orig_repo();
     }
     if (temp_itm.Chk(img_size)) temp_itm.Insert(trg_stmt, img_size);
   }
   conn.Txn_end();
 }
Пример #14
0
 public static Xog_history_itm Srl_load(byte[] raw) {
   byte[][] atrs = Bry_split_.Split(raw, Byte_ascii.Pipe);
   byte[] bmk_bry = atrs.length == 6 ? atrs[5] : Bry_.Empty;
   bmk_bry = Bry_.Replace(bmk_bry, Byte_ascii.Tilde, Byte_ascii.Pipe);
   return new Xog_history_itm(
       atrs[0], atrs[1], atrs[2], atrs[3], atrs[4] == Bool_.Y_bry, String_.new_a7(bmk_bry));
 }
Пример #15
0
 public static byte[] Ttl_standardize(byte[] src) {
   int len = src.length;
   if (len == 0) return src;
   byte[] rv = null;
   boolean dirty = false;
   byte b = src[0];
   if (b > 96 && b < 123) {
     dirty = true;
     rv = new byte[len];
     rv[0] =
         (byte)
             (b
                 - 32); // NOTE: [[File:]] automatically uppercases 1st letter for md5;
                        // EX:en.d:File:wikiquote-logo.png has md5 of "32" (W...) not "82" (w...);
                        // PAGE:en.d:freedom_of_speech DATE:2016-01-21
   }
   for (int i = 1; i < len; ++i) {
     b = src[i];
     if (b == Byte_ascii.Space) {
       if (!dirty) {
         dirty = true;
         rv = new byte[len];
         Bry_.Copy_by_pos(src, 0, i, rv, 0);
       }
       rv[i] = Byte_ascii.Underline;
     } else {
       if (dirty) rv[i] = b;
     }
   }
   return dirty ? rv : src;
 }
Пример #16
0
 public boolean Chk(Xowe_wiki wiki) {
   if (!wiki.App().App_type().Uid_is_gui())
     return true; // NOTE: ignore during Server / Console modes; DATE:2015-04-01
   if (in_progress_hash.Has(wiki.Domain_bry()))
     return true; // NOTE: ignore if currently building; different bldr commands call
                  // wiki.Init_assert() which may lead to fals checks;
   Io_url url = url_(wiki);
   if (!Io_mgr.I.ExistsFil(url)) return true;
   Xoae_app app = wiki.Appe();
   app.Usr_dlg().Log_many("", "", "import.marker: marker found: url=~{0}", url.Raw());
   byte[] incompete_msg_bry =
       app.Usere()
           .Msg_mgr()
           .Val_by_key_args(Bry_.new_a7("api-xowa.import.core.incomplete"), wiki.Domain_str());
   int rslt = app.Gui_mgr().Kit().Ask_yes_no_cancel("", "", String_.new_u8(incompete_msg_bry));
   switch (rslt) {
     case Gfui_dlg_msg_.Btn_yes:
       Xob_cleanup_cmd.Delete_wiki_sql(wiki);
       End(wiki);
       return false; // delete wiki
     case Gfui_dlg_msg_.Btn_no:
       End(wiki);
       return true; // delete marker
     case Gfui_dlg_msg_.Btn_cancel:
       return true; // noop
     default:
       throw Err_.unhandled(rslt);
   }
 }
Пример #17
0
 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));
     }
   }
 }
Пример #18
0
 public void Test_category_v2(String ctg_name_str, int... expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   byte[] ctg_name_bry = Bry_.new_a7(ctg_name_str);
   Xoctg_data_ctg ctg = new Xoctg_data_ctg(ctg_name_bry);
   wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_v2(ctg, ctg_name_bry);
   Tfds.Eq_ary(expd, Xto_int_ary(ctg));
 }
Пример #19
0
 //	public Io_url[] Src_fils() {return src_fils;} public Io_line_rdr_fxt Src_fils_(Io_url[] v)
 // {src_fils = v; return this;} Io_url[] src_fils;
 public Io_line_rdr_fxt tst_Match(String match, String expd) {
   rdr.Key_gen_(Io_line_rdr_key_gen_.first_pipe);
   boolean match_v = rdr.Match(Bry_.new_u8(match));
   String actl = match_v ? String_.new_u8(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end()) : "";
   Tfds.Eq(expd, actl);
   return this;
 }
Пример #20
0
 public static void Val_by_obj(Db_stmt stmt, String key, Object val) {
   int tid = Type_adp_.To_tid_obj(val);
   switch (tid) {
     case Type_adp_.Tid__bool:
       stmt.Val_bool_as_byte(key, Bool_.cast(val));
       break;
     case Type_adp_.Tid__byte:
       stmt.Val_byte(key, Byte_.cast(val));
       break;
     case Type_adp_.Tid__int:
       stmt.Val_int(key, Int_.cast(val));
       break;
     case Type_adp_.Tid__long:
       stmt.Val_long(key, Long_.cast(val));
       break;
     case Type_adp_.Tid__float:
       stmt.Val_float(key, Float_.cast(val));
       break;
     case Type_adp_.Tid__double:
       stmt.Val_double(key, Double_.cast(val));
       break;
     case Type_adp_.Tid__str:
       stmt.Val_str(key, String_.cast(val));
       break;
     case Type_adp_.Tid__bry:
       stmt.Val_bry(key, Bry_.cast(val));
       break;
     default:
       throw Err_.new_unhandled_default(tid);
   }
 }
Пример #21
0
 public Mustache_doc_itm[] Mustache__subs(String key) {
   if (String_.Eq(key, "is_dir")) return Mustache_doc_itm_.Ary__bool(is_dir);
   else if (String_.Eq(key, "dir_cmd_exists"))
     return Mustache_doc_itm_.Ary__bool(Bry_.Len_gt_0(dir_cmd));
   else if (String_.Eq(key, "is_core_xowa")) return Mustache_doc_itm_.Ary__bool(is_core_xowa);
   else if (String_.Eq(key, "subs")) return subs;
   return Mustache_doc_itm_.Ary__empty;
 }
Пример #22
0
 private static void New_subs(Io_url owner_dir, List_adp list, IoItmList subs, byte[] dir_cmd) {
   subs.Sort();
   int len = subs.Len();
   int list_total = list.Len();
   byte[] owner_dir_bry = owner_dir.RawBry();
   for (int i = 0; i < len; ++i) {
     IoItm_base src = (IoItm_base) subs.Get_at(i);
     Xow_import_doc trg = null;
     if (src.Type_dir()) {
       byte[] trg_url = src.Url().RawBry();
       trg =
           new Xow_import_doc(
               Bool_.Y,
               Bool_.N,
               list_total + i,
               owner_dir_bry,
               trg_url,
               Bry_.new_u8(src.Url().NameAndExt_noDirSpr()),
               Bry_.Empty,
               Bry_.Empty,
               dir_cmd,
               Ary_empty);
     } else {
       IoItmFil src_as_fil = (IoItmFil) src;
       String size_str = Io_size_.To_str(src_as_fil.Size(), "#,###");
       boolean is_xowa_core =
           gplx.xowa.wikis.data.Xow_db_file__core_.Is_core_fil_name(
               owner_dir.NameOnly(), src.Url().NameAndExt());
       trg =
           new Xow_import_doc(
               Bool_.N,
               is_xowa_core,
               list_total + i,
               owner_dir_bry,
               src.Url().RawBry(),
               Bry_.new_u8(src.Name()),
               Bry_.new_u8(src_as_fil.ModifiedTime().XtoStr_fmt("yyyy-MM-dd")),
               Bry_.new_u8(size_str),
               dir_cmd,
               Ary_empty);
     }
     list.Add(trg);
   }
 }
 public void Chk(byte[] wiki_domain, Io_url css_fil) {
   this.wiki_domain = wiki_domain;
   List_adp img_list = List_adp_.New();
   byte[] old_bry = Io_mgr.Instance.LoadFilBry(css_fil);
   byte[] rel_url_prefix = Bry_.Add(Bry_fwd_slashes, wiki_domain);
   byte[] new_bry = Convert_to_local_urls(rel_url_prefix, old_bry, img_list);
   Io_url img_dir = css_fil.OwnerDir();
   Download_fils(img_dir, img_list.To_str_ary());
   Io_mgr.Instance.SaveFilBry(css_fil, new_bry);
 }
Пример #24
0
 private void Format_durations_init() {
   Xol_msg_mgr msg_mgr = lang.Msg_mgr();
   int len = Xol_duration_itm_.Ary_default.length;
   interval_msgs = new Xol_msg_itm[len];
   for (int i = 0; i < len; i++) {
     Xol_duration_itm itm = Xol_duration_itm_.Ary_default[i];
     byte[] msg_key = Bry_.Add(Bry_duration, itm.Name_bry());
     interval_msgs[i] = msg_mgr.Itm_by_key_or_new(msg_key);
   }
 }
Пример #25
0
 public void Test_load_ttl(int ns_id, String ttl_str, Xowd_page_itm expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
   byte[] ttl_bry = Bry_.new_a7(ttl_str);
   wiki.Db_mgr_as_sql().Load_mgr().Load_by_ttl(actl, ns, ttl_bry);
   Tfds.Eq(expd.Id(), actl.Id());
   Tfds.Eq_date(expd.Modified_on(), actl.Modified_on());
   Tfds.Eq(expd.Redirected(), actl.Redirected());
   Tfds.Eq(expd.Text_len(), actl.Text_len());
 }
Пример #26
0
 public Xog_history_itm(
     byte[] wiki, byte[] page, byte[] anch, byte[] qarg, boolean redirect_force, String bmk_pos) {
   this.key =
       Bry_.Add_w_dlm(
           Byte_ascii.Pipe, wiki, page, anch, qarg, redirect_force ? Bool_.Y_bry : Bool_.N_bry);
   this.wiki = wiki;
   this.page = page;
   this.anch = anch;
   this.qarg = qarg;
   this.redirect_force = redirect_force;
   this.bmk_pos = bmk_pos;
 }
Пример #27
0
public class Xop_lnki_align_h_ {
  public static final byte Null = 0, None = 1, Left = 2, Center = 3, Right = 4; // SERIALIZED
  public static final byte[][] Html_names =
      new byte[][] {
        Object_.Bry__null,
        Bry_.new_a7("none"),
        Bry_.new_a7("left"),
        Bry_.new_a7("center"),
        Bry_.new_a7("right")
      };
  public static final Hash_adp_bry Hash =
      Hash_adp_bry.ci_a7()
          .Add_str_byte("tnone", None)
          .Add_str_byte("tleft", Left)
          .Add_str_byte("tcenter", Center)
          .Add_str_byte("tright", Right);

  public static byte[] To_bry(int v) {
    return Html_names[v];
  }
}
Пример #28
0
 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
 }
Пример #29
0
  private void Parse_capt(Gfh_tag_rdr tag_rdr, Gfh_tag anch_head) {
    this.capt_bgn = anch_head.Src_end(); // capt starts after <a>
    Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // </a>
    this.capt_end = anch_tail.Src_bgn(); // get capt between "<a>" and "</a>
    this.src_end = anch_tail.Src_end();

    // skip ns in href / capt
    if (href_ns_id != Xow_ns_.Tid__main) { // not main; try to remove template name;		
      int capt_bgn_wo_ns = capt_bgn + href_ns_name_len;
      href_bgn +=
          href_ns_name_len; // skip ns_name for href; EX: "Help:A" -> "A"; "Help" will be saved as
      // encoded number
      if (Bry_.Match(
          capt_src,
          capt_bgn,
          capt_bgn_wo_ns,
          href_ns_name)) { // capt matches ns_name; EX: <a href='/wiki/Help:A'>Help:A</a> ->
        // "Help:A" matches "Help:"
        capt_bgn = capt_bgn_wo_ns; // skip ns; "Help:"
        capt_has_ns = true;
      }
    }

    // get text splits
    this.text_tid =
        href_itm.Tid() == Xoh_anch_href_data.Tid__anch
            ? Xoh_anch_capt_itm.Tid__diff
            : capt_itm.Parse(
                rdr, capt_has_ns, href_src, href_bgn, href_end, src, capt_bgn, capt_end);
    int split_pos = capt_itm.Split_pos();
    this.text_0_src = href_src;
    this.text_0_bgn = href_bgn;
    this.text_0_end = href_end;
    this.text_1_src = capt_src;
    this.text_1_bgn = capt_bgn;
    this.text_1_end = capt_end;
    switch (text_tid) {
      case Xoh_anch_capt_itm.Tid__same:
        // case Xoh_anch_capt_itm.Tid__href_pipe:
      case Xoh_anch_capt_itm.Tid__diff: // nothing to do; href / capt already set above
        break;
      case Xoh_anch_capt_itm.Tid__more:
        this.text_1_bgn = split_pos;
        break;
      case Xoh_anch_capt_itm.Tid__less:
        this.text_0_end = split_pos;
        this.text_1_src = href_src;
        this.text_1_bgn = split_pos;
        this.text_1_end = href_end;
        break;
    }
  }
Пример #30
0
	@gplx.Virtual public void Clear(boolean src_repo_is_wmf) {
		Io_mgr.I.InitEngine_mem();
		if (app == null) {
			app = Xoa_app_fxt.app_();
			en_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_enwiki);
			commons = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_commons);
			app.Wiki_mgr().Add(commons);
			app.Wiki_mgr().Add(en_wiki);
			
			Xof_file_mgr file_mgr = app.File_mgr();
			file_mgr.Img_mgr().Wkr_resize_img_(Xof_img_wkr_resize_img_mok._);
			file_mgr.Img_mgr().Wkr_query_img_size_(new Xof_img_wkr_query_img_size_test());
			app.Wmf_mgr().Api_mgr().Api_orig_(api_size);

			byte[] src_commons = Bry_.new_a7("src_commons");
			byte[] src_en_wiki = Bry_.new_a7("src_en_wiki");
			byte[] trg_commons = Bry_.new_a7("trg_commons");
			byte[] trg_en_wiki = Bry_.new_a7("trg_en_wiki");
			src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, false);
			src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/"		, Xow_domain_.Domain_str_enwiki, false);
			Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, true).Primary_(true);
			Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/"		, Xow_domain_.Domain_str_enwiki, true).Primary_(true);
			Xowe_repo_mgr wiki_repo_mgr = en_wiki.File_mgr().Repo_mgr();
			Xof_repo_pair pair = null;
			pair = wiki_repo_mgr.Add_repo(src_commons, trg_commons);
			pair.Src().Fsys_is_wnt_(true).Wmf_fsys_(src_repo_is_wmf).Tarball_(!src_repo_is_wmf);
			pair.Trg().Fsys_is_wnt_(true);

			pair = wiki_repo_mgr.Add_repo(src_en_wiki, trg_en_wiki);
			pair.Src().Fsys_is_wnt_(true).Wmf_fsys_(src_repo_is_wmf);
			pair.Trg().Fsys_is_wnt_(true);
		}
		en_wiki.Clear_for_tests();
		commons.Clear_for_tests();
		src_fils = trg_fils = Io_fil.Ary_empty;
		html_view_str = null;
		html_w = html_h = -1;
	}