1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-04-05 21:00:31 -04:00
parent 80b9928b5c
commit 18dcd3f89e
615 changed files with 9826 additions and 8619 deletions

View File

@@ -60,6 +60,7 @@ public class Xoae_page implements Xoa_page {
public ListAdp Slink_list() {return slink_list;} private ListAdp slink_list = ListAdp_.new_();
public Wdata_external_lang_links_data Wdata_external_lang_links() {return wdata_external_lang_links;} private Wdata_external_lang_links_data wdata_external_lang_links = new Wdata_external_lang_links_data();
public boolean Pages_recursed() {return pages_recursed;} public void Pages_recursed_(boolean v) {pages_recursed = v; } private boolean pages_recursed;
public int Bldr__ns_ord() {return bldr__ns_ord;} public void Bldr__ns_ord_(int v) {bldr__ns_ord = v;} private int bldr__ns_ord;
public Xopg_tmpl_prepend_mgr Tmpl_prepend_mgr() {return tmpl_prepend_mgr;} private Xopg_tmpl_prepend_mgr tmpl_prepend_mgr = new Xopg_tmpl_prepend_mgr();
public void Tmpl_stack_del() {--tmpl_stack_ary_len;}
public boolean Tmpl_stack_add(byte[] key) {

View File

@@ -30,7 +30,7 @@ class Xoh_file_main_alts implements Bry_fmtr_arg {
if (xfer_itm.Html_w() < size.Val_0()) continue;
xfer_itm.Init_by_lnki(orig_itm.Lnki_ttl(), orig_itm.Orig_redirect(), Xop_lnki_type.Id_none, size.Val_0(), size.Val_1(), Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null);
xfer_itm.Calc_by_meta();
opt.Html_alts().Bld_bfr_many(bfr, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url(), i == len - 1 ? opt.Html_alt_dlm_last() : opt.Html_alt_dlm_default());
opt.Html_alts().Bld_bfr_many(bfr, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url(), i == len - 1 ? opt.Html_alt_dlm_last() : opt.Html_alt_dlm_dflt());
}
}
}

View File

@@ -20,25 +20,27 @@ import gplx.core.primitives.*;
import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
public class Xoh_file_main_wkr implements Bry_fmtr_arg {
private Xof_xfer_itm xfer_itm; private Xoh_file_main_alts alts = new Xoh_file_main_alts(); private Xoh_file_page opt;
byte[] file_size_bry; Xoa_ttl ttl; Xowe_wiki wiki;
public void Bld_html(Xowe_wiki wiki, Xop_ctx ctx, Bry_bfr bfr, Xoa_ttl ttl, Xoh_file_page opt, Xof_xfer_queue queue) {
this.opt = opt; this.ttl = ttl; this.wiki = wiki;
Int_2_ref size_main = opt.Size_main();
int main_w = size_main.Val_0();
int main_h = size_main.Val_1();
private byte[] file_size_bry; private Xoa_ttl ttl;
private Xof_xfer_itm xfer_itm; private Xoh_file_main_alts alts = new Xoh_file_main_alts(); private Xoh_file_page page_wtr_cfg;
private byte[] play_btn_icon; private Bool_obj_ref queue_add_ref = Bool_obj_ref.n_();
private int elem_id_val;
public void Bld_html(Xowe_wiki wiki, Xop_ctx ctx, Bry_bfr bfr, Xoa_ttl ttl, Xoh_file_page page_wtr_cfg, Xof_xfer_queue queue) {
this.page_wtr_cfg = page_wtr_cfg; this.ttl = ttl;
Int_2_ref main_size = page_wtr_cfg.Size_main();
int main_w = main_size.Val_0();
int main_h = main_size.Val_1();
this.xfer_itm = wiki.Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(ctx, queue, ttl.Page_txt(), Xop_lnki_type.Id_thumb, main_w, main_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null, false, queue_add_ref);
Xof_meta_itm meta_itm = wiki.File_mgr().Meta_mgr().Get_itm_or_new(ttl.Page_db(), Xof_xfer_itm_.Md5_(ttl.Page_db())); // NOTE: can't use Md5 of xfer_itm, b/c xfer_itm.Ttl() b/c may be redirected; EX:w:[[Image:Alcott-L.jpg]]
Xof_repo_itm trg_repo = null;
trg_repo = meta_itm.Repo_itm(wiki);
Xof_repo_itm trg_repo = meta_itm.Repo_itm(wiki);
if (trg_repo == null) trg_repo = wiki.File_mgr().Repo_mgr().Repos_get_at(0).Trg();
xfer_itm.Set__meta(meta_itm, trg_repo, Xof_repo_itm.Thumb_default_null);
xfer_itm.Init_by_orig_old(meta_itm.Orig_w(), meta_itm.Orig_h(), Xof_img_size.Size_null);
xfer_itm.Trg_repo_idx_(meta_itm.Vrtl_repo());
play_btn_icon = wiki.Html_mgr().Img_media_play_btn();
file_size_bry = Bry_.Empty;
if (xfer_itm.Calc_by_meta(true)) {
this.play_btn_icon = wiki.Html_mgr().Img_media_play_btn();
this.file_size_bry = Bry_.Empty;
if (xfer_itm.Calc_by_meta(true)) { // file exists
long file_size = Io_mgr._.QueryFil(xfer_itm.Trg_file(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated)).Size();
file_size_bry = Bry_.new_ascii_(gplx.ios.Io_size_.Xto_str(file_size));
}
@@ -46,22 +48,22 @@ public class Xoh_file_main_wkr implements Bry_fmtr_arg {
xfer_itm = xfer_itm.Clone();
queue.Add(xfer_itm);
}
opt.Html_main().Bld_bfr_many(bfr, this);
} private byte[] play_btn_icon; private Bool_obj_ref queue_add_ref = Bool_obj_ref.n_();
public void Bld_html(Xowe_wiki wiki, Bry_bfr bfr, Xof_xfer_itm xfer_itm, Xoa_ttl ttl, Xoh_file_page opt, byte[] file_size_bry, byte[] play_btn_icon, int elem_id_val) {
page_wtr_cfg.Html_main().Bld_bfr_many(bfr, this);
}
public void Bld_html(Xowe_wiki wiki, Bry_bfr bfr, Xof_xfer_itm xfer_itm, Xoa_ttl ttl, Xoh_file_page page_wtr_cfg, byte[] file_size_bry, byte[] play_btn_icon, int elem_id_val) {
this.xfer_itm = xfer_itm;
this.wiki = wiki; this.ttl = ttl; this.opt = opt; this.file_size_bry = file_size_bry; this.play_btn_icon = play_btn_icon; this.elem_id_val = elem_id_val;
opt.Html_main().Bld_bfr_many(bfr, this);
} private int elem_id_val;
this.ttl = ttl; this.page_wtr_cfg = page_wtr_cfg; this.file_size_bry = file_size_bry; this.play_btn_icon = play_btn_icon; this.elem_id_val = elem_id_val;
page_wtr_cfg.Html_main().Bld_bfr_many(bfr, this);
}
public void XferAry(Bry_bfr bfr, int idx) {
alts.Ctor(xfer_itm, opt);
alts.Ctor(xfer_itm, page_wtr_cfg);
Xof_ext ext = xfer_itm.Lnki_ext();
if (ext.Id_is_thumbable_img())
opt.Html_main_img().Bld_bfr_many(bfr, xfer_itm.Orig_w(), xfer_itm.Orig_h(), xfer_itm.Html_orig_url(), file_size_bry, ext.Mime_type(), elem_id_val, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url(), ttl.Full_txt(), Xoa_app_.Utl__encoder_mgr().Url().Encode(ttl.Page_url()), alts);
page_wtr_cfg.Html_main_img().Bld_bfr_many(bfr, xfer_itm.Orig_w(), xfer_itm.Orig_h(), xfer_itm.Html_orig_url(), file_size_bry, ext.Mime_type(), elem_id_val, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url(), ttl.Full_txt(), Xoa_app_.Utl__encoder_mgr().Url().Encode(ttl.Page_url()), alts);
else if (ext.Id_is_video()) // NOTE: video must precede audio else File:***.ogg will not show thumbs
opt.Html_main_vid().Bld_bfr_many(bfr, elem_id_val, xfer_itm.Html_view_url(), Atr_class_image, ttl.Page_db(), xfer_itm.Html_view_url(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_url(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
page_wtr_cfg.Html_main_vid().Bld_bfr_many(bfr, elem_id_val, xfer_itm.Html_view_url(), Atr_class_image, ttl.Page_db(), xfer_itm.Html_view_url(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_url(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
else if (ext.Id_is_audio())
opt.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_url(), ttl.Page_db(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
page_wtr_cfg.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_url(), ttl.Page_db(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
}
private static final byte[] Atr_class_image = Bry_.new_ascii_("image");
}

View File

@@ -17,15 +17,101 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
public class Xoh_file_page implements GfoInvkAble {
public Int_2_ref Size_main() {return size_main;} Int_2_ref size_main;
public Int_2_ref[] Size_alts() {return size_alts;} Int_2_ref[] size_alts;
public byte[] Html_alt_dlm_default() {return html_alt_dlm_dflt;} private byte[] html_alt_dlm_dflt;
public byte[] Html_alt_dlm_last() {return html_alt_dlm_last;} private byte[] html_alt_dlm_last;
public Bry_fmtr Html_main() {return html_main;} Bry_fmtr html_main = Bry_fmtr.new_("", "media");
public Bry_fmtr Html_main_img() {return html_main_img;} Bry_fmtr html_main_img = Bry_fmtr.new_("", "orig_width", "orig_height", "orig_href", "orig_file_size", "orig_mime_type", "elem_id", "thumb_width", "thumb_height", "thumb_href", "thumb_ttl", "thumb_name", "section_alts");
public Bry_fmtr Html_main_aud() {return html_main_aud;} Bry_fmtr html_main_aud = Bry_fmtr.new_("", "lnki_url", "lnki_title", "play_width", "play_max_width", "play_icon");
public Bry_fmtr Html_main_vid() {return html_main_vid;} Bry_fmtr html_main_vid = Bry_fmtr.new_("", "elem_id", "lnki_href", "lnki_class", "lnki_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt", "lnki_url", "play_width", "play_max_width", "play_icon");
public Bry_fmtr Html_alts() {return html_alts;} Bry_fmtr html_alts = Bry_fmtr.new_("", "thumb_width", "thumb_height", "thumb_href", "thumb_dlm");
public Xoh_file_page() {
html_main.Fmt_(String_.Concat_lines_nl_skip_last
( "<ul id=\"filetoc\">"
, " <li>"
, " <a href=\"#file\">"
, " File"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#filehistory\">"
, " File history"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#filelinks\">"
, " File usage on Commons"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#globalusage\">"
, " File usage on other wikis"
, " </a>"
, " </li>"
, "</ul>"
, "~{media}"
));
html_main_img.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <a href=\"~{orig_href}\" xowa_title=\"~{thumb_name}\">"
, " <img id=\"xowa_file_img_~{elem_id}\" alt=\"~{thumb_ttl}\" src=\"~{thumb_href}\" width=\"~{thumb_width}\" height=\"~{thumb_height}\" />"
, " </a>"
, " <div class=\"mw-filepage-resolutioninfo\">Size of this preview: "
, " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\">"
, " ~{thumb_width} × ~{thumb_height} pixels"
, " </a>"
, " ."
, " <span class=\"mw-filepage-other-resolutions\">"
, " Other resolutions:"
, "~{section_alts}"
, " </span>"
, " </div>"
, "</div>"
, "<div class=\"fullMedia\">"
, " <a href=\"~{orig_href}\" class=\"internal\" title=\"~{thumb_name}\" xowa_title=\"~{thumb_name}\">"
, " Full resolution"
, " </a>"
, " &#8206;"
, " <span class=\"fileInfo\">"
, " (~{orig_width} × ~{orig_height} pixels, file size: ~{orig_file_size}, MIME type: ~{orig_mime_type})"
, " </span>"
, "</div>"
, ""
));
html_main_aud.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <div>"
, " <a href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
, " </a>"
, " </div>"
, "</div>"
, ""
));
html_main_vid.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <div>"
, " <a href=\"~{lnki_href}\" class=\"~{lnki_class}\" title=\"~{lnki_title}\">"
, " <img id=\"xowa_file_img_~{elem_id}\" src=\"~{lnki_src}\" width=\"~{lnki_width}\" height=\"~{lnki_height}\" alt=\"~{lnki_alt}\" />"
, " </a>"
, " </div>"
, " <div>"
, " <a href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
, " </a>"
, " </div>"
, "</div>"
, ""
));
html_alts.Fmt_(String_.Concat_lines_nl_skip_last
( " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\">"
, " ~{thumb_width} × ~{thumb_height}"
, " </a>"
, " ~{thumb_dlm} "
, ""
));
}
public Int_2_ref Size_main() {return size_main;} private Int_2_ref size_main = new Int_2_ref(800, 600);
public Int_2_ref[] Size_alts() {return size_alts;} private Int_2_ref[] size_alts = new Int_2_ref[] {new Int_2_ref(320, 240), new Int_2_ref(640, 480), new Int_2_ref(800, 600), new Int_2_ref(1024, 768), new Int_2_ref(1280, 1024)};
public byte[] Html_alt_dlm_dflt() {return html_alt_dlm_dflt;} private byte[] html_alt_dlm_dflt = Bry_.new_ascii_("|");
public byte[] Html_alt_dlm_last() {return html_alt_dlm_last;} private byte[] html_alt_dlm_last = Bry_.new_ascii_(".");
public Bry_fmtr Html_main() {return html_main;} private final Bry_fmtr html_main = Bry_fmtr.new_("", "media");
public Bry_fmtr Html_main_img() {return html_main_img;} private final Bry_fmtr html_main_img = Bry_fmtr.new_("", "orig_width", "orig_height", "orig_href", "orig_file_size", "orig_mime_type", "elem_id", "thumb_width", "thumb_height", "thumb_href", "thumb_ttl", "thumb_name", "section_alts");
public Bry_fmtr Html_main_aud() {return html_main_aud;} private final Bry_fmtr html_main_aud = Bry_fmtr.new_("", "lnki_url", "lnki_title", "play_width", "play_max_width", "play_icon");
public Bry_fmtr Html_main_vid() {return html_main_vid;} private final Bry_fmtr html_main_vid = Bry_fmtr.new_("", "elem_id", "lnki_href", "lnki_class", "lnki_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt", "lnki_url", "play_width", "play_max_width", "play_icon");
public Bry_fmtr Html_alts() {return html_alts;} private final Bry_fmtr html_alts = Bry_fmtr.new_("", "thumb_width", "thumb_height", "thumb_href", "thumb_dlm");
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_html_main_)) html_main.Fmt_(m.ReadStr("v"));
else if (ctx.Match(k, Invk_html_main_img_)) html_main_img.Fmt_(m.ReadStr("v"));
@@ -38,97 +124,8 @@ public class Xoh_file_page implements GfoInvkAble {
else if (ctx.Match(k, Invk_size_alts_)) size_alts = Int_2_ref.parse_ary_(m.ReadStr("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_html_main_ = "html_main_", Invk_html_main_img_ = "html_main_img_", Invk_html_main_aud_ = "html_main_aud_", Invk_html_main_vid_ = "html_main_vid_", Invk_html_alts_ = "html_alts_"
, Invk_size_main_ = "size_main_" , Invk_size_alts_ = "size_alts_", Invk_html_alt_dlm_dflt_ = "html_alt_dlm_dflt_", Invk_html_alt_dlm_last_ = "html_alt_dlm_last_";
public Xoh_file_page() {
size_main = new Int_2_ref(800, 600);
size_alts = new Int_2_ref[] {new Int_2_ref(320, 240), new Int_2_ref(640, 480), new Int_2_ref(800, 600), new Int_2_ref(1024, 768), new Int_2_ref(1280, 1024)};
html_alt_dlm_dflt = Bry_.new_ascii_("|");
html_alt_dlm_last = Bry_.new_ascii_(".");
html_main.Fmt_(String_.Concat_lines_nl_skip_last
( "<ul id=\"filetoc\">"
, " <li>"
, " <a href=\"#file\">"
, " File"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#filehistory\">"
, " File history"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#filelinks\">"
, " File usage on Commons"
, " </a>"
, " </li>"
, " <li>"
, " <a href=\"#globalusage\">"
, " File usage on other wikis"
, " </a>"
, " </li>"
, "</ul>"
, "~{media}"
));
html_main_img.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <a href=\"~{orig_href}\" xowa_title=\"~{thumb_name}\">"
, " <img id=\"xowa_file_img_~{elem_id}\" alt=\"~{thumb_ttl}\" src=\"~{thumb_href}\" width=\"~{thumb_width}\" height=\"~{thumb_height}\" />"
, " </a>"
, " <div class=\"mw-filepage-resolutioninfo\">Size of this preview: "
, " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\">"
, " ~{thumb_width} × ~{thumb_height} pixels"
, " </a>"
, " ."
, " <span class=\"mw-filepage-other-resolutions\">"
, " Other resolutions:"
, "~{section_alts}"
, " </span>"
, " </div>"
, "</div>"
, "<div class=\"fullMedia\">"
, " <a href=\"~{orig_href}\" class=\"internal\" title=\"~{thumb_name}\" xowa_title=\"~{thumb_name}\">"
, " Full resolution"
, " </a>"
, " &#8206;"
, " <span class=\"fileInfo\">"
, " (~{orig_width} × ~{orig_height} pixels, file size: ~{orig_file_size}, MIME type: ~{orig_mime_type})"
, " </span>"
, "</div>"
, ""
));
html_main_aud.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <div>"
, " <a href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
, " </a>"
, " </div>"
, "</div>"
, ""
));
html_main_vid.Fmt_(String_.Concat_lines_nl_skip_last
( "<div class=\"fullImageLink\" id=\"file\">"
, " <div>"
, " <a href=\"~{lnki_href}\" class=\"~{lnki_class}\" title=\"~{lnki_title}\">"
, " <img id=\"xowa_file_img_~{elem_id}\" src=\"~{lnki_src}\" width=\"~{lnki_width}\" height=\"~{lnki_height}\" alt=\"~{lnki_alt}\" />"
, " </a>"
, " </div>"
, " <div>"
, " <a href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
, " </a>"
, " </div>"
, "</div>"
, ""
));
html_alts.Fmt_(String_.Concat_lines_nl_skip_last
( " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\">"
, " ~{thumb_width} × ~{thumb_height}"
, " </a>"
, " ~{thumb_dlm} "
, ""
));
}
private static final String Invk_html_main_ = "html_main_", Invk_html_main_img_ = "html_main_img_", Invk_html_main_aud_ = "html_main_aud_", Invk_html_main_vid_ = "html_main_vid_", Invk_html_alts_ = "html_alts_"
, Invk_size_main_ = "size_main_" , Invk_size_alts_ = "size_alts_", Invk_html_alt_dlm_dflt_ = "html_alt_dlm_dflt_", Invk_html_alt_dlm_last_ = "html_alt_dlm_last_";
}