mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.ns_files; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.parsers.lnkis.*;
|
||||
class Xoh_file_page__other_resolutions implements Bry_fmtr_arg {
|
||||
private Xow_repo_mgr repo_mgr; private Xof_file_itm orig_itm; private Xoh_file_page_wtr file_page;
|
||||
private final Xof_img_size img_size = new Xof_img_size(); private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
|
||||
public Xoh_file_page__other_resolutions Init_by_fmtr(Xow_repo_mgr repo_mgr, Xof_file_itm orig_itm, Xoh_file_page_wtr file_page) {this.repo_mgr = repo_mgr; this.orig_itm = orig_itm; this.file_page = file_page; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
Int_2_ref[] ary = file_page.Size_alts();
|
||||
Xof_file_itm xfer_itm = new Xof_fsdb_itm();
|
||||
int len = ary.length;
|
||||
Xof_repo_itm repo = repo_mgr.Get_trg_by_id_or_null(orig_itm.Orig_repo_id(), orig_itm.Lnki_ttl(), Bry_.Empty);
|
||||
if (repo == null) return;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Int_2_ref itm = ary[i];
|
||||
xfer_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.Empty, orig_itm.Lnki_ttl(), Xop_lnki_type.Id_none, Xop_lnki_tkn.Upright_null, itm.Val_0(), itm.Val_1(), Xof_lnki_time.Null, Xof_lnki_page.Null, Xof_patch_upright_tid_.Tid_all);
|
||||
xfer_itm.Init_at_orig(orig_itm.Orig_repo_id(), orig_itm.Orig_repo_name(), orig_itm.Orig_ttl(), orig_itm.Orig_ext(), orig_itm.Orig_w(), orig_itm.Orig_h(), Bry_.Empty);
|
||||
xfer_itm.Init_at_html(Xof_exec_tid.Tid_wiki_page, img_size, repo, url_bldr);
|
||||
byte[] itm_separator = i == len - 1 ? file_page.Html_alt_dlm_last() : file_page.Html_alt_dlm_dflt(); // "|" separator between itms unless last
|
||||
file_page.Html_alts().Bld_bfr_many(bfr, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url().To_http_file_bry(), itm_separator, orig_itm.Lnki_ttl());
|
||||
}
|
||||
}
|
||||
}
|
||||
112
400_xowa/src/gplx/xowa/htmls/ns_files/Xoh_file_page_wtr.java
Normal file
112
400_xowa/src/gplx/xowa/htmls/ns_files/Xoh_file_page_wtr.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.ns_files; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xoh_file_page_wtr {
|
||||
public int Main_img_w() {return 800;}
|
||||
public int Main_img_h() {return 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_a7("|");
|
||||
public byte[] Html_alt_dlm_last() {return html_alt_dlm_last;} private byte[] html_alt_dlm_last = Bry_.new_a7(".");
|
||||
public Bry_fmtr Html_main() {return html_main;} private final Bry_fmtr html_main = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "~{commons_notice}<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}"
|
||||
)
|
||||
, "media", "commons_notice");
|
||||
public Bry_fmtr Html_main_img() {return html_main_img;} private final Bry_fmtr html_main_img = Bry_fmtr.new_(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\" xowa_title=\"~{thumb_name}\">"
|
||||
, " ~{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>"
|
||||
, " ‎"
|
||||
, " <span class=\"fileInfo\">"
|
||||
, " (~{orig_width} × ~{orig_height} pixels, file size: ~{orig_file_size}, MIME type: ~{orig_mime_type})"
|
||||
, " </span>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "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_(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>"
|
||||
, ""
|
||||
), "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_(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>"
|
||||
, ""
|
||||
), "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_(String_.Concat_lines_nl_skip_last
|
||||
( " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\" xowa_title=\"~{xowa_title}\">"
|
||||
, " ~{thumb_width} × ~{thumb_height}"
|
||||
, " </a>"
|
||||
, " ~{thumb_dlm} "
|
||||
, ""
|
||||
), "thumb_width", "thumb_height", "thumb_href", "thumb_dlm", "xowa_title");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.ns_files; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.lnkis.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.xfers.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_ns_file_page_mgr implements Bry_fmtr_arg {
|
||||
private Xoa_ttl ttl; private Xoh_file_page_wtr html_wtr; private final Xoh_file_page__other_resolutions alt_wtr = new Xoh_file_page__other_resolutions();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
private Xow_repo_mgr repo_mgr;
|
||||
private Xof_file_itm xfer_itm; private byte[] file_size_bry; private byte[] play_btn_icon;
|
||||
private final Xof_img_size img_size = new Xof_img_size(); private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
|
||||
public void Bld_html(Xowe_wiki cur_wiki, Xop_ctx ctx, Xoae_page page, Bry_bfr bfr, Xoa_ttl ttl, Xoh_file_page_wtr html_wtr, Xof_xfer_queue queue) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)page.Commons_mgr().Source_wiki_or(cur_wiki);
|
||||
this.ttl = ttl; this.html_wtr = html_wtr; this.repo_mgr = wiki.File__repo_mgr();
|
||||
this.play_btn_icon = wiki.Html_mgr().Img_media_play_btn();
|
||||
this.xfer_itm = wiki.Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_file, ctx, ctx.Cur_page(), queue, ttl.Page_txt()
|
||||
, Xop_lnki_type.Id_thumb, Xop_lnki_tkn.Upright_null, html_wtr.Main_img_w(), html_wtr.Main_img_h(), Xof_lnki_time.Null, Xof_lnki_page.Null, Bool_.N);
|
||||
Xof_orig_itm orig = wiki.File_mgr().Orig_mgr().Find_by_ttl_or_null(xfer_itm.Lnki_ttl());
|
||||
if (orig == Xof_orig_itm.Null) return; // no orig;
|
||||
Xof_repo_itm repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(orig.Repo(), xfer_itm.Lnki_ttl(), Bry_.Empty);
|
||||
if (repo == null) return;
|
||||
xfer_itm.Init_at_orig(orig.Repo(), repo.Wiki_domain(), orig.Ttl(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
|
||||
xfer_itm.Init_at_html(Xof_exec_tid.Tid_wiki_file, img_size, repo, url_bldr);
|
||||
this.file_size_bry = Bry_.Empty;
|
||||
if (xfer_itm.File_exists()) { // file exists
|
||||
long file_size = Io_mgr.Instance.QueryFil(xfer_itm.Html_orig_url()).Size();
|
||||
if (file_size == -1) file_size = 0; // QueryFil returns -1 if file doesn't exist
|
||||
this.file_size_bry = Bry_.new_a7(gplx.ios.Io_size_.To_str(file_size));
|
||||
}
|
||||
String commons_notice = page.Commons_mgr().Xowa_mockup()
|
||||
? String_.Format(Str_commons_notice, gplx.langs.htmls.Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, page.Ttl().Full_db_as_str()))
|
||||
: "";
|
||||
html_wtr.Html_main().Bld_bfr_many(bfr, this, commons_notice);
|
||||
}
|
||||
|
||||
public void Bld_html(Xowe_wiki wiki, Bry_bfr bfr, Xof_file_itm xfer_itm, Xoa_ttl ttl, Xoh_file_page_wtr html_wtr, byte[] file_size_bry, byte[] play_btn_icon) { // TEST:
|
||||
this.ttl = ttl; this.html_wtr = html_wtr; this.repo_mgr = wiki.File__repo_mgr();
|
||||
this.play_btn_icon = play_btn_icon;
|
||||
this.xfer_itm = xfer_itm; this.file_size_bry = file_size_bry;
|
||||
html_wtr.Html_main().Bld_bfr_many(bfr, this, "");
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
alt_wtr.Init_by_fmtr(repo_mgr, xfer_itm, html_wtr);
|
||||
Xof_ext orig_ext = xfer_itm.Orig_ext();
|
||||
if (orig_ext.Id_is_thumbable_img())
|
||||
html_wtr.Html_main_img().Bld_bfr_many(bfr, xfer_itm.Orig_w(), xfer_itm.Orig_h(), xfer_itm.Html_orig_url().To_http_file_bry(), file_size_bry, orig_ext.Mime_type(), xfer_itm.Html_uid(), xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_url().To_http_file_bry(), ttl.Full_txt(), Xoa_app_.Utl__encoder_mgr().Http_url().Encode(ttl.Page_url()), alt_wtr);
|
||||
else if (orig_ext.Id_is_video()) // NOTE: video must precede audio else File:***.ogg will not show thumbs
|
||||
html_wtr.Html_main_vid().Bld_bfr_many(bfr, xfer_itm.Html_uid(), xfer_itm.Html_view_url().To_http_file_bry(), Atr_class_image, ttl.Page_db(), xfer_itm.Html_view_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
|
||||
else if (orig_ext.Id_is_audio())
|
||||
html_wtr.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_url().To_http_file_bry(), ttl.Page_db(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
|
||||
}
|
||||
private static final byte[] Atr_class_image = Bry_.new_a7("image");
|
||||
private static final String Str_commons_notice = String_.Concat_lines_nl_skip_last
|
||||
( "<table class='ambox ambox-delete' style=''>"
|
||||
, " <tr>"
|
||||
, " <td class='mbox-empty-cell'>"
|
||||
, " </td>"
|
||||
, " <td class='mbox-text' style=''>"
|
||||
, "<span class='mbox-text-span'>"
|
||||
, "<p>This offline page is a reduced version of the online one: <a href='https://commons.wikimedia.org/wiki/{0}'>https://commons.wikimedia.org/wiki/{0}</a>.</p>"
|
||||
, "<p>If you want XOWA to show an offline page just like the online version, you should download commons.wikimedia.org at <a href='/site/home/wiki/Help:Import/List'>Import online</a>.</p>"
|
||||
, "<ul>"
|
||||
, "<li>This wiki will use at least another 20 GB of disk space.</li>"
|
||||
, "<li>This wiki only provides wikitext. No extra images are downloaded. Note that the total size of images for commons.wikimedia.org would be too large (approximately 22 TB).</li>"
|
||||
, "</ul>"
|
||||
, "</span>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.ns_files; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_ns_file_page_mgr_tst {
|
||||
private final Xoh_ns_file_page_mgr_fxt fxt = new Xoh_ns_file_page_mgr_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Image() {
|
||||
fxt.Ttl_str_("Test.png").Html_src_("mem/file/cur.png").Html_orig_src_("mem/file/orig.png").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <a href=\"file:///mem/file/orig.png\" xowa_title=\"Test.png\">"
|
||||
, " <img id=\"xowa_file_img_0\" alt=\"Test.png\" src=\"file:///mem/file/cur.png\" width=\"300\" height=\"200\" />"
|
||||
, " </a>"
|
||||
, " <div class=\"mw-filepage-resolutioninfo\">Size of this preview: "
|
||||
, " <a href=\"file:///mem/file/cur.png\" class=\"mw-thumbnail-link\" xowa_title=\"Test.png\">"
|
||||
, " 300 × 200 pixels"
|
||||
, " </a>"
|
||||
, " ."
|
||||
// , " <span class=\"mw-filepage-other-resolutions\">"
|
||||
// , " Other resolutions:"
|
||||
// , ""
|
||||
// , " </span>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, "<div class=\"fullMedia\">"
|
||||
, " <a href=\"file:///mem/file/orig.png\" class=\"internal\" title=\"Test.png\" xowa_title=\"Test.png\">"
|
||||
, " Full resolution"
|
||||
, " </a>"
|
||||
, " ‎"
|
||||
, " <span class=\"fileInfo\">"
|
||||
, " (0 × 0 pixels, file size: 100, MIME type: image/png)"
|
||||
, " </span>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Ttl_str_("Test.oga").Html_src_("mem/file/cur.oga").Html_orig_src_("mem/file/orig.oga").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/orig.oga\" xowa_title=\"Test.oga\" class=\"xowa_anchor_button\" style=\"width:300px;max-width:300px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Ttl_str_("Test.ogv").Html_src_("mem/file/thumb.png").Html_orig_src_("mem/file/orig.ogv").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/thumb.png\" class=\"image\" title=\"Test.ogv\">"
|
||||
, " <img id=\"xowa_file_img_0\" src=\"file:///mem/file/thumb.png\" width=\"300\" height=\"200\" alt=\"\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/orig.ogv\" xowa_title=\"Test.ogv\" class=\"xowa_anchor_button\" style=\"width:300px;max-width:300px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_ns_file_page_mgr_fxt {
|
||||
private final Xoh_ns_file_page_mgr wkr = new Xoh_ns_file_page_mgr();
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoh_file_page_wtr opt;
|
||||
private final Xof_file_itm file = new Xof_fsdb_itm(); private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
public Xoh_ns_file_page_mgr_fxt Ttl_str_(String v) {this.ttl_str = v; return this;} private String ttl_str;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_src_(String v) {this.html_src = v; return this;} private String html_src;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_orig_src_(String v) {this.html_orig_src = v; return this;} private String html_orig_src;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_w_(int v) {this.html_w = v; return this;} private int html_w;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_h_(int v) {this.html_h = v; return this;} private int html_h;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_file_size_(int v) {this.html_file_size = v; return this;} private int html_file_size;
|
||||
public void Reset() {
|
||||
if (app != null) return;
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
opt = new Xoh_file_page_wtr();
|
||||
}
|
||||
public void tst(String expd) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
file.Init_at_gallery_end(html_w, html_h, Io_url_.mem_fil_(html_src), Io_url_.mem_fil_(html_orig_src));
|
||||
// file.Orig_ttl_and_redirect_(ttl_bry, Bry_.Empty);
|
||||
file.Init_at_orig(Byte_.Zero, wiki.Domain_bry(), ttl_bry, Xof_ext_.new_by_ttl_(ttl_bry), 0, 0, Bry_.Empty);
|
||||
file.Init_at_hdoc(0, Xof_html_elem.Tid_img);
|
||||
wkr.Bld_html(wiki, bfr, file, ttl, opt, Bry_.To_a7_bry(html_file_size, 0), play_btn_icon); // TEST: must pass in elem_val b/c test only uses 2nd Bld_html while app uses 1st
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
} static final byte[] play_btn_icon = Bry_.new_a7("file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png");
|
||||
public static final String Hdr = 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>"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user