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;
 }
Exemplo n.º 2
0
 public void To_html(Bry_bfr bfr) {
   bfr.Add_byte(Byte_ascii.Angle_bgn);
   bfr.Add(node);
   To_html_atr(bfr, "data-source", "xowa");
   int len = atrs.length;
   for (int i = 0; i < len; ++i) {
     Keyval atr = atrs[i];
     To_html_atr(bfr, atr.Key(), atr.Val_to_str_or_empty());
   }
   bfr.Add_byte(Byte_ascii.Angle_end);
   if (!Bry_.Eq(node, Gfh_tag_.Bry__link)) {
     if (body != null) {
       bfr.Add_byte_nl();
       bfr.Add(body);
       bfr.Add_byte_nl();
     }
     bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
     bfr.Add(node);
     bfr.Add_byte(Byte_ascii.Angle_end);
   }
   bfr.Add_byte_nl();
 }
Exemplo n.º 3
0
 private void Write_body_edit(Bry_bfr bfr, byte[] data_raw, int ns_id, byte page_tid) {
   if (ns_id
           == Xow_ns_
               .Tid__mediawiki // if MediaWiki and wikitext, must be a message; convert args back
                               // to php; DATE:2014-06-13
       && page_tid == Xow_page_tid.Tid_wikitext)
     data_raw = Gfs_php_converter.Xto_php(tmp_bfr, Bool_.N, data_raw);
   int data_raw_len = data_raw.length;
   if (mgr.Html_capable())
     Xoh_html_wtr_escaper.Escape(
         page.Wikie().Appe().Parser_amp_mgr(),
         bfr,
         data_raw,
         0,
         data_raw_len,
         false,
         false); // NOTE: must escape; assume that browser will automatically escape (&lt;) (which
                 // Mozilla does)
   else bfr.Add(data_raw);
   if (data_raw_len > 0) // do not add nl if empty String
   bfr
         .Add_byte_nl(); // per MW:EditPage.php: "Ensure there's a newline at the end, otherwise
                         // adding lines is awkward."
 }