1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 22:40:50 +00:00

File: Add '.stl' and '.webp' as image extensions [#710]

This commit is contained in:
gnosygnu 2020-04-21 08:31:40 -04:00
parent 9c8650a4d9
commit b05e3cd188
7 changed files with 384 additions and 284 deletions

View File

@ -1,18 +1,18 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.addons.bldrs.updates.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.updates.*; package gplx.xowa.addons.bldrs.updates.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.updates.*;
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.files.*; import gplx.xowa.files.*;
@ -43,6 +43,8 @@ class Xobldr__fsdb_db__delete_small_files_ {
Ext_max_(rv, 1000, Xof_ext_.Id_ogv); Ext_max_(rv, 1000, Xof_ext_.Id_ogv);
Ext_max_(rv, 400, Xof_ext_.Id_pdf); Ext_max_(rv, 400, Xof_ext_.Id_pdf);
Ext_max_(rv, 700, Xof_ext_.Id_djvu); Ext_max_(rv, 700, Xof_ext_.Id_djvu);
Ext_max_(rv, 500, Xof_ext_.Id_stl);
Ext_max_(rv, 500, Xof_ext_.Id_webp);
return rv; return rv;
} }
private static void Ext_max_(int[] ary, int max, int... exts) {for (int ext : exts) ary[ext] = max;} private static void Ext_max_(int[] ary, int max, int... exts) {for (int ext : exts) ary[ext] = max;}

View File

@ -1,18 +1,18 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.files; import gplx.*; import gplx.xowa.*; package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Xof_ext_ { public class Xof_ext_ {
@ -20,8 +20,10 @@ public class Xof_ext_ {
, Id_png = 1, Id_jpg = 2, Id_jpeg = 3, Id_gif = 4, Id_tif = 5, Id_tiff = 6 , Id_png = 1, Id_jpg = 2, Id_jpeg = 3, Id_gif = 4, Id_tif = 5, Id_tiff = 6
, Id_svg = 7, Id_djvu = 8, Id_pdf = 9 , Id_svg = 7, Id_djvu = 8, Id_pdf = 9
, Id_mid = 10, Id_ogg = 11, Id_oga = 12, Id_ogv = 13, Id_webm = 14 , Id_mid = 10, Id_ogg = 11, Id_oga = 12, Id_ogv = 13, Id_webm = 14
, Id_flac = 15, Id_bmp = 16, Id_xcf = 17, Id_wav = 18, Id_opus = 19; , Id_flac = 15, Id_bmp = 16, Id_xcf = 17, Id_wav = 18, Id_opus = 19
public static final int Id__max = 20; , Id_stl = 20, Id_webp = 21;
;
public static final int Id__max = 22;
public static final byte[] public static final byte[]
Bry_png = Bry_.new_a7("png"), Bry_jpg = Bry_.new_a7("jpg"), Bry_jpeg = Bry_.new_a7("jpeg") Bry_png = Bry_.new_a7("png"), Bry_jpg = Bry_.new_a7("jpg"), Bry_jpeg = Bry_.new_a7("jpeg")
, Bry_gif = Bry_.new_a7("gif"), Bry_tif = Bry_.new_a7("tif"), Bry_tiff = Bry_.new_a7("tiff") , Bry_gif = Bry_.new_a7("gif"), Bry_tif = Bry_.new_a7("tif"), Bry_tiff = Bry_.new_a7("tiff")
@ -29,6 +31,7 @@ public class Xof_ext_ {
, Bry_mid = Bry_.new_a7("mid"), Bry_ogg = Bry_.new_a7("ogg"), Bry_oga = Bry_.new_a7("oga") , Bry_mid = Bry_.new_a7("mid"), Bry_ogg = Bry_.new_a7("ogg"), Bry_oga = Bry_.new_a7("oga")
, Bry_ogv = Bry_.new_a7("ogv"), Bry_webm = Bry_.new_a7("webm"), Bry_flac = Bry_.new_a7("flac") , Bry_ogv = Bry_.new_a7("ogv"), Bry_webm = Bry_.new_a7("webm"), Bry_flac = Bry_.new_a7("flac")
, Bry_bmp = Bry_.new_a7("bmp"), Bry_xcf = Bry_.new_a7("xcf"), Bry_wav = Bry_.new_a7("wav"), Bry_opus = Bry_.new_a7("opus") , Bry_bmp = Bry_.new_a7("bmp"), Bry_xcf = Bry_.new_a7("xcf"), Bry_wav = Bry_.new_a7("wav"), Bry_opus = Bry_.new_a7("opus")
, Bry_stl = Bry_.new_a7("stl"), Bry_webp = Bry_.new_a7("webp")
; ;
public static final byte[][] Bry__ary = new byte[][] public static final byte[][] Bry__ary = new byte[][]
{ Bry_.Empty, Bry_png, Bry_jpg, Bry_jpeg { Bry_.Empty, Bry_png, Bry_jpg, Bry_jpeg
@ -37,6 +40,7 @@ public class Xof_ext_ {
, Bry_mid, Bry_ogg, Bry_oga , Bry_mid, Bry_ogg, Bry_oga
, Bry_ogv, Bry_webm, Bry_flac , Bry_ogv, Bry_webm, Bry_flac
, Bry_bmp, Bry_xcf, Bry_wav, Bry_opus , Bry_bmp, Bry_xcf, Bry_wav, Bry_opus
, Bry_stl, Bry_webp
}; };
public static final byte[][] Mime_type__ary = new byte[][] public static final byte[][] Mime_type__ary = new byte[][]
{ Bry_.new_a7("application/octet-stream"), Bry_.new_a7("image/png"), Bry_.new_a7("image/jpg"), Bry_.new_a7("image/jpeg") { Bry_.new_a7("application/octet-stream"), Bry_.new_a7("image/png"), Bry_.new_a7("image/jpg"), Bry_.new_a7("image/jpeg")
@ -44,7 +48,10 @@ public class Xof_ext_ {
, Bry_.new_a7("image/svg+xml"), Bry_.new_a7("image/x.djvu"), Bry_.new_a7("application/pdf") , Bry_.new_a7("image/svg+xml"), Bry_.new_a7("image/x.djvu"), Bry_.new_a7("application/pdf")
, Bry_.new_a7("application/x-midi"), Bry_.new_a7("video/ogg"), Bry_.new_a7("audio/oga") , Bry_.new_a7("application/x-midi"), Bry_.new_a7("video/ogg"), Bry_.new_a7("audio/oga")
, Bry_.new_a7("video/ogg"), Bry_.new_a7("video/webm"), Bry_.new_a7("audio/flac") , Bry_.new_a7("video/ogg"), Bry_.new_a7("video/webm"), Bry_.new_a7("audio/flac")
, Bry_.new_a7("image/bmp"), Bry_.new_a7("image/xcf"), Bry_.new_a7("audio/x-wav"), Bry_.new_a7("audio/opus") , Bry_.new_a7("image/bmp")
, Bry_.new_a7("image/x-xcf") // changed from "/xcf"; DATE:2020-04-21
, Bry_.new_a7("audio/x-wav"), Bry_.new_a7("audio/opus")
, Bry_.new_a7("model/stl"), Bry_.new_a7("video/webp")
}; };
private static final Hash_adp id_hash = id_hash_new_(); private static final Hash_adp id_hash = id_hash_new_();
private static Hash_adp id_hash_new_() { private static Hash_adp id_hash_new_() {
@ -55,7 +62,7 @@ public class Xof_ext_ {
id_hash_new_(rv, Bry_mid, Id_mid); id_hash_new_(rv, Bry_ogg, Id_ogg); id_hash_new_(rv, Bry_oga, Id_oga); id_hash_new_(rv, Bry_mid, Id_mid); id_hash_new_(rv, Bry_ogg, Id_ogg); id_hash_new_(rv, Bry_oga, Id_oga);
id_hash_new_(rv, Bry_ogv, Id_ogv); id_hash_new_(rv, Bry_webm, Id_webm); id_hash_new_(rv, Bry_flac, Id_flac); id_hash_new_(rv, Bry_ogv, Id_ogv); id_hash_new_(rv, Bry_webm, Id_webm); id_hash_new_(rv, Bry_flac, Id_flac);
id_hash_new_(rv, Bry_bmp, Id_bmp); id_hash_new_(rv, Bry_xcf, Id_xcf); id_hash_new_(rv, Bry_wav, Id_wav); id_hash_new_(rv, Bry_bmp, Id_bmp); id_hash_new_(rv, Bry_xcf, Id_xcf); id_hash_new_(rv, Bry_wav, Id_wav);
id_hash_new_(rv, Bry_opus, Id_opus); id_hash_new_(rv, Bry_opus, Id_opus); id_hash_new_(rv, Bry_stl, Id_stl); id_hash_new_(rv, Bry_webp, Id_webp);
return rv; return rv;
} }
private static void id_hash_new_(Hash_adp hash, byte[] key, int val) {hash.Add(key, new Int_obj_val(val));} private static void id_hash_new_(Hash_adp hash, byte[] key, int val) {hash.Add(key, new Int_obj_val(val));}
@ -67,7 +74,7 @@ public class Xof_ext_ {
.Add_bry_bry(Bry_mid).Add_bry_bry(Bry_ogg).Add_bry_bry(Bry_oga) .Add_bry_bry(Bry_mid).Add_bry_bry(Bry_ogg).Add_bry_bry(Bry_oga)
.Add_bry_bry(Bry_ogv).Add_bry_bry(Bry_webm).Add_bry_bry(Bry_flac) .Add_bry_bry(Bry_ogv).Add_bry_bry(Bry_webm).Add_bry_bry(Bry_flac)
.Add_bry_bry(Bry_bmp).Add_bry_bry(Bry_xcf).Add_bry_bry(Bry_wav) .Add_bry_bry(Bry_bmp).Add_bry_bry(Bry_xcf).Add_bry_bry(Bry_wav)
.Add_bry_bry(Bry_opus) .Add_bry_bry(Bry_opus).Add_bry_bry(Bry_stl).Add_bry_bry(Bry_webp)
; ;
private static final Xof_ext[] Ary = new Xof_ext[Id__max]; private static final Xof_ext[] Ary = new Xof_ext[Id__max];
@ -134,6 +141,7 @@ public class Xof_ext_ {
case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff: case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff:
case Xof_ext_.Id_svg: case Xof_ext_.Id_svg:
case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf: case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf:
case Xof_ext_.Id_stl: case Xof_ext_.Id_webp:
return true; return true;
default: default:
return false; return false;
@ -144,6 +152,7 @@ public class Xof_ext_ {
case Xof_ext_.Id_png: case Xof_ext_.Id_jpg: case Xof_ext_.Id_jpeg: case Xof_ext_.Id_png: case Xof_ext_.Id_jpg: case Xof_ext_.Id_jpeg:
case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff: case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff:
case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf: case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf:
case Xof_ext_.Id_stl: case Xof_ext_.Id_webp:
return true; return true;
default: default:
return false; return false;
@ -155,6 +164,7 @@ public class Xof_ext_ {
case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff: case Xof_ext_.Id_gif: case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff:
case Xof_ext_.Id_svg: case Xof_ext_.Id_djvu: case Xof_ext_.Id_pdf: case Xof_ext_.Id_svg: case Xof_ext_.Id_djvu: case Xof_ext_.Id_pdf:
case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf: case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf:
case Xof_ext_.Id_stl: case Xof_ext_.Id_webp:
return true; return true;
default: default:
return false; return false;
@ -196,10 +206,23 @@ public class Xof_ext_ {
} }
public static int Id_view(int id) { public static int Id_view(int id) {
switch (id) { switch (id) {
case Xof_ext_.Id_svg: case Xof_ext_.Id_bmp: case Xof_ext_.Id_xcf: return Xof_ext_.Id_png; // example image is rendered as .png; see wiki articles
case Xof_ext_.Id_tif: case Xof_ext_.Id_tiff: case Xof_ext_.Id_djvu: case Xof_ext_.Id_pdf: case Xof_ext_.Id_svg:
case Xof_ext_.Id_ogg: case Xof_ext_.Id_ogv: case Xof_ext_.Id_webm: return Xof_ext_.Id_jpg; case Xof_ext_.Id_bmp:
default: return id; case Xof_ext_.Id_xcf:
case Xof_ext_.Id_stl: // https://en.wikipedia.org/wiki/STL_(file_format)
case Xof_ext_.Id_webp:// https://en.wikipedia.org/wiki/WebP
return Xof_ext_.Id_png;
case Xof_ext_.Id_tif:
case Xof_ext_.Id_tiff:
case Xof_ext_.Id_djvu:
case Xof_ext_.Id_pdf:
case Xof_ext_.Id_ogg:
case Xof_ext_.Id_ogv:
case Xof_ext_.Id_webm:
return Xof_ext_.Id_jpg;
default:
return id;
} }
} }
} }

View File

@ -1,18 +1,18 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.files; import gplx.*; import gplx.xowa.*; package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Xof_mime_minor_ { public class Xof_mime_minor_ {
@ -48,6 +48,8 @@ public class Xof_mime_minor_ {
mime_hash_itm_(rv, Mime_xcf , Xof_ext_.Id_xcf); mime_hash_itm_(rv, Mime_xcf , Xof_ext_.Id_xcf);
mime_hash_itm_(rv, Xof_ext_.Bry_wav , Xof_ext_.Id_wav); mime_hash_itm_(rv, Xof_ext_.Bry_wav , Xof_ext_.Id_wav);
mime_hash_itm_(rv, Xof_ext_.Bry_opus , Xof_ext_.Id_opus); mime_hash_itm_(rv, Xof_ext_.Bry_opus , Xof_ext_.Id_opus);
mime_hash_itm_(rv, Xof_ext_.Bry_stl , Xof_ext_.Id_stl);
mime_hash_itm_(rv, Xof_ext_.Bry_webp , Xof_ext_.Id_webp);
return rv; return rv;
} }
private static void mime_hash_itm_(Hash_adp hash, byte[] key, int val) {hash.Add(key, new Int_obj_val(val));} private static void mime_hash_itm_(Hash_adp hash, byte[] key, int val) {hash.Add(key, new Int_obj_val(val));}

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,217 +13,214 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.files; import gplx.*; import gplx.xowa.*; package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.envs.*; import gplx.core.envs.*;
import gplx.langs.htmls.encoders.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.files.repos.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.imgs.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.imgs.*;
public class Xof_url_bldr { public class Xof_url_bldr {
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(400); private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(400);
private final Gfo_url_encoder encoder_src_http = Gfo_url_encoder_.New__http_url().Make(); // NOTE: changed from new_html_href_mw_ to new_url_ on 2012-11-19; issues with A%2Cb becoming A%252Cb private final Gfo_url_encoder encoder_src_http = Gfo_url_encoder_.New__http_url().Make(); // NOTE: changed from new_html_href_mw_ to new_url_ on 2012-11-19; issues with A%2Cb becoming A%252Cb
private byte[] ttl; private byte[] md5; private Xof_ext ext; private boolean file_is_thumb; private int file_w; private byte[] ttl; private byte[] md5; private Xof_ext ext; private boolean file_is_thumb; private int file_w;
private double time = Xof_lnki_time.Null; private int page = Xof_lnki_page.Null; private byte time_dlm = Byte_ascii.At; private double time = Xof_lnki_time.Null; private int page = Xof_lnki_page.Null; private byte time_dlm = Byte_ascii.At;
private byte repo_tid; private byte repo_tid;
private byte[] root; private byte dir_spr; private boolean fsys_is_wnt; private boolean wmf_dir_hive; private boolean wmf_protocol_is_file; private int md5_dir_depth; private byte[] area; private byte[] root; private byte dir_spr; private boolean fsys_is_wnt; private boolean wmf_dir_hive; private boolean wmf_protocol_is_file; private int md5_dir_depth; private byte[] area;
public Xof_url_bldr Root_(byte[] v) {root = v; return this;} public Xof_url_bldr Root_(byte[] v) {root = v; return this;}
public Xof_url_bldr Init_by_repo(byte repo_tid, byte[] root, boolean fsys_is_wnt, byte dir_spr, boolean wmf_dir_hive, boolean wmf_protocol_is_file, int md5_dir_depth) { public Xof_url_bldr Init_by_repo(byte repo_tid, byte[] root, boolean fsys_is_wnt, byte dir_spr, boolean wmf_dir_hive, boolean wmf_protocol_is_file, int md5_dir_depth) {
this.repo_tid = repo_tid; this.repo_tid = repo_tid;
this.root = root; this.dir_spr = dir_spr; this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.md5_dir_depth = md5_dir_depth; this.root = root; this.dir_spr = dir_spr; this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.md5_dir_depth = md5_dir_depth;
this.fsys_is_wnt = fsys_is_wnt; this.fsys_is_wnt = fsys_is_wnt;
return this; return this;
} }
public Xof_url_bldr Init_by_itm(byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) { public Xof_url_bldr Init_by_itm(byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
this.ttl = ttl; this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page; this.ttl = ttl; this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page;
if (wmf_protocol_is_file && fsys_is_wnt) this.ttl = Xof_itm_ttl_.Remove_invalid(tmp_bfr, ttl); // NOTE: changed ttl does not change md5 if (wmf_protocol_is_file && fsys_is_wnt) this.ttl = Xof_itm_ttl_.Remove_invalid(tmp_bfr, ttl); // NOTE: changed ttl does not change md5
this.file_is_thumb = mode == Xof_img_mode_.Tid__thumb; this.file_is_thumb = mode == Xof_img_mode_.Tid__thumb;
this.area = Xof_img_mode_.Names_ary[mode]; this.area = Xof_img_mode_.Names_ary[mode];
return this; return this;
} }
public Xof_url_bldr Init_for_src_file(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) { public Xof_url_bldr Init_for_src_file(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
this.repo_tid = repo.Tid(); this.repo_tid = repo.Tid();
this.wmf_dir_hive = Bool_.Y; this.wmf_protocol_is_file = repo.Tarball(); this.wmf_dir_hive = Bool_.Y; this.wmf_protocol_is_file = repo.Tarball();
this.dir_spr = repo.Dir_spr(); this.root = repo.Root_bry(); this.area = repo.Mode_names()[mode]; this.dir_spr = repo.Dir_spr(); this.root = repo.Root_bry(); this.area = repo.Mode_names()[mode];
this.ttl = repo.Gen_name_src(tmp_bfr, ttl); this.md5 = md5; this.ext = ext; this.ttl = repo.Gen_name_src(tmp_bfr, ttl); this.md5 = md5; this.ext = ext;
this.file_is_thumb = mode == Xof_img_mode_.Tid__thumb; this.file_w = file_w; this.time = time; this.page = page; this.file_is_thumb = mode == Xof_img_mode_.Tid__thumb; this.file_w = file_w; this.time = time; this.page = page;
return this; return this;
} }
public Xof_url_bldr Init_for_trg_file(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) { public Xof_url_bldr Init_for_trg_file(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
return Init(repo.Tid(), Bool_.N, Bool_.N, repo.Dir_spr(), repo.Root_bry() return Init(repo.Tid(), Bool_.N, Bool_.N, repo.Dir_spr(), repo.Root_bry()
, repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(tmp_bfr, ttl, md5, ext), md5, ext, mode, file_w, time, page); , repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(tmp_bfr, ttl, md5, ext), md5, ext, mode, file_w, time, page);
} }
public Xof_url_bldr Init_for_trg_html(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) { public Xof_url_bldr Init_for_trg_html(Xof_repo_itm repo, byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
return Init(repo.Tid(), Bool_.N, Bool_.N, Byte_ascii.Slash, repo.Root_http() return Init(repo.Tid(), Bool_.N, Bool_.N, Byte_ascii.Slash, repo.Root_http()
, repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(tmp_bfr, ttl, md5, ext), md5, ext, mode, file_w, time, page); , repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(tmp_bfr, ttl, md5, ext), md5, ext, mode, file_w, time, page);
} }
private Xof_url_bldr Init(byte repo_tid, boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr private Xof_url_bldr Init(byte repo_tid, boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr
, byte[] root, byte[] area, int md5_dir_depth , byte[] root, byte[] area, int md5_dir_depth
, byte[] ttl, byte[] md5, Xof_ext ext , byte[] ttl, byte[] md5, Xof_ext ext
, byte file_mode, int file_w, double time, int page , byte file_mode, int file_w, double time, int page
) { ) {
this.repo_tid = repo_tid; this.repo_tid = repo_tid;
this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.dir_spr = dir_spr; this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.dir_spr = dir_spr;
this.root = root; this.area = area; this.md5_dir_depth = md5_dir_depth; this.root = root; this.area = area; this.md5_dir_depth = md5_dir_depth;
this.ttl = ttl; this.md5 = md5; this.ext = ext; this.ttl = ttl; this.md5 = md5; this.ext = ext;
this.file_is_thumb = file_mode == Xof_img_mode_.Tid__thumb; this.file_w = file_w; this.time = time; this.page = page; this.file_is_thumb = file_mode == Xof_img_mode_.Tid__thumb; this.file_w = file_w; this.time = time; this.page = page;
return this; return this;
} }
public byte[] Xto_bry() {Bld(); byte[] rv = tmp_bfr.To_bry_and_clear(); Clear(); return rv;} public byte[] Xto_bry() {Bld(); byte[] rv = tmp_bfr.To_bry_and_clear(); Clear(); return rv;}
public String Xto_str() {Bld(); String rv = tmp_bfr.To_str(); Clear(); return rv;} public String Xto_str() {Bld(); String rv = tmp_bfr.To_str(); Clear(); return rv;}
public Io_url Xto_url() {Bld(); Io_url rv = Io_url_.new_fil_(tmp_bfr.To_str()); Clear(); return rv;} public Io_url Xto_url() {Bld(); Io_url rv = Io_url_.new_fil_(tmp_bfr.To_str()); Clear(); return rv;}
public Io_url Xto_url_by_http() {Bld(); Io_url rv = Io_url_.New__http_or_fail(tmp_bfr.To_str()); Clear(); return rv;} public Io_url Xto_url_by_http() {Bld(); Io_url rv = Io_url_.New__http_or_fail(tmp_bfr.To_str()); Clear(); return rv;}
public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_fsdb_itm itm, boolean orig) { public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_fsdb_itm itm, boolean orig) {
byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb; byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb;
return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url(); return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
} }
public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_file_itm itm, boolean orig) { public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_file_itm itm, boolean orig) {
byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb; byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb;
return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url(); return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
} }
public Io_url To_url_trg(Xof_repo_itm repo_itm, gplx.xowa.files.caches.Xou_cache_itm itm, boolean orig) { public Io_url To_url_trg(Xof_repo_itm repo_itm, gplx.xowa.files.caches.Xou_cache_itm itm, boolean orig) {
byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb; byte mode = orig ? Xof_img_mode_.Tid__orig : Xof_img_mode_.Tid__thumb;
return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext_itm(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url(); return this.Init_for_trg_file(repo_itm, mode, itm.Orig_ttl(), itm.Orig_ttl_md5(), itm.Orig_ext_itm(), itm.File_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
} }
private static final byte[] Bry__http = Bry_.new_a7("http"); private static final byte[] Bry__http = Bry_.new_a7("http");
private void Bld() { private void Bld() {
if (repo_tid == Xof_repo_tid_.Tid__math) { if (repo_tid == Xof_repo_tid_.Tid__math) {
tmp_bfr.Add(root); // add root; EX: "C:\xowa\file\"; assume trailing dir_spr tmp_bfr.Add(root); // add root; EX: "C:\xowa\file\"; assume trailing dir_spr
boolean root_is_http = Bry_.Has_at_bgn(root, Bry__http); boolean root_is_http = Bry_.Has_at_bgn(root, Bry__http);
if (root_is_http) if (root_is_http)
tmp_bfr.Add_mid(ttl, 0, ttl.length - 4); // -4 to remove ".svg". note that XO stores ".svg", but WM doesn't; EX: "596f8baf206a81478afd4194b44138715dc1a05c.svg" tmp_bfr.Add_mid(ttl, 0, ttl.length - 4); // -4 to remove ".svg". note that XO stores ".svg", but WM doesn't; EX: "596f8baf206a81478afd4194b44138715dc1a05c.svg"
else else
tmp_bfr.Add(ttl); tmp_bfr.Add(ttl);
} }
else { else {
Add_core(); Add_core();
if (file_is_thumb) { if (file_is_thumb) {
if (wmf_dir_hive) Add_thumb_wmf(); if (wmf_dir_hive) Add_thumb_wmf();
else Add_thumb_xowa(); else Add_thumb_xowa();
} }
} }
} }
private Xof_url_bldr Add_core() { private Xof_url_bldr Add_core() {
tmp_bfr.Add(root); // add root; EX: "C:\xowa\file\"; assume trailing dir_spr tmp_bfr.Add(root); // add root; EX: "C:\xowa\file\"; assume trailing dir_spr
if (area != null && !(wmf_dir_hive && !file_is_thumb)) // !(wmf_dir_hive && !thumb) means never add if wmf_dir_hive and orig if (area != null && !(wmf_dir_hive && !file_is_thumb)) // !(wmf_dir_hive && !thumb) means never add if wmf_dir_hive and orig
tmp_bfr.Add(area).Add_byte(dir_spr); // add area; EX: "thumb\" tmp_bfr.Add(area).Add_byte(dir_spr); // add area; EX: "thumb\"
byte b0 = md5[0]; byte b0 = md5[0];
if (wmf_dir_hive) { if (wmf_dir_hive) {
tmp_bfr.Add_byte(b0).Add_byte(dir_spr); // add md5_0 EX: "0/" tmp_bfr.Add_byte(b0).Add_byte(dir_spr); // add md5_0 EX: "0/"
tmp_bfr.Add_byte(b0).Add_byte(md5[1]).Add_byte(dir_spr); // add md5_01 EX: "01/" tmp_bfr.Add_byte(b0).Add_byte(md5[1]).Add_byte(dir_spr); // add md5_01 EX: "01/"
} }
else { else {
for (int i = 0; i < md5_dir_depth; i++) for (int i = 0; i < md5_dir_depth; i++)
tmp_bfr.Add_byte(md5[i]).Add_byte(dir_spr); // add md5_0123 EX: "0/1/2/3" tmp_bfr.Add_byte(md5[i]).Add_byte(dir_spr); // add md5_0123 EX: "0/1/2/3"
} }
if (wmf_dir_hive) { if (wmf_dir_hive) {
if (wmf_protocol_is_file) // sitting on local file system (as opposed to http) if (wmf_protocol_is_file) // sitting on local file system (as opposed to http)
tmp_bfr.Add(ttl); // NOTE: file_names are not url-encoded; this includes symbols (') and foreign characters (ö) tmp_bfr.Add(ttl); // NOTE: file_names are not url-encoded; this includes symbols (') and foreign characters (ö)
else // wmf_http else // wmf_http
tmp_bfr.Add(encoder_src_http.Encode(ttl)); // NOTE: file_names must be url-encoded; JAVA will default to native charset which on Windows will be 1252; foreign character urls will fail due to conversion mismatch (1252 on windows; UTF-8 on WMF); PAGE:en.w:Möbius strip tmp_bfr.Add(encoder_src_http.Encode(ttl)); // NOTE: file_names must be url-encoded; JAVA will default to native charset which on Windows will be 1252; foreign character urls will fail due to conversion mismatch (1252 on windows; UTF-8 on WMF); PAGE:en.w:Möbius strip
} }
else else
tmp_bfr.Add(ttl); // add title; EX: "A.png" tmp_bfr.Add(ttl); // add title; EX: "A.png"
return this; return this;
} }
private Xof_url_bldr Add_thumb_xowa() { private Xof_url_bldr Add_thumb_xowa() {
tmp_bfr.Add_byte(dir_spr); // add dir_spr; EX: "\" tmp_bfr.Add_byte(dir_spr); // add dir_spr; EX: "\"
tmp_bfr.Add_int_variable(file_w).Add(Bry_px); // add file_w; EX: "220px" tmp_bfr.Add_int_variable(file_w).Add(Bry_px); // add file_w; EX: "220px"
if (Xof_lnki_time.Null_n(time)) if (Xof_lnki_time.Null_n(time))
tmp_bfr.Add_byte(time_dlm).Add_str_a7(Xof_lnki_time.X_str(time)); // add time EX: "@5" tmp_bfr.Add_byte(time_dlm).Add_str_a7(Xof_lnki_time.X_str(time)); // add time EX: "@5"
else if (page != Xof_lnki_page.Null) else if (page != Xof_lnki_page.Null)
tmp_bfr.Add_byte(Byte_ascii.Dash).Add_int_variable(page); // add page EX: "-5" tmp_bfr.Add_byte(Byte_ascii.Dash).Add_int_variable(page); // add page EX: "-5"
tmp_bfr.Add_byte(Byte_ascii.Dot); // add . EX: "." tmp_bfr.Add_byte(Byte_ascii.Dot); // add . EX: "."
if (file_is_thumb) if (file_is_thumb)
tmp_bfr.Add(ext.Ext_view()); // add view_ext EX: ".png" tmp_bfr.Add(ext.Ext_view()); // add view_ext EX: ".png"
else else
tmp_bfr.Add(ext.Ext()); // add orig_ext EX: ".svg" tmp_bfr.Add(ext.Ext()); // add orig_ext EX: ".svg"
return this; return this;
} }
private Xof_url_bldr Add_thumb_wmf() { private Xof_url_bldr Add_thumb_wmf() {
tmp_bfr.Add_byte(dir_spr); // add dir_spr; EX: "\" tmp_bfr.Add_byte(dir_spr); // add dir_spr; EX: "\"
int file_ext_id = ext.Id(); int file_ext_id = ext.Id();
switch (file_ext_id) { switch (file_ext_id) {
case Xof_ext_.Id_ogg: case Xof_ext_.Id_ogg:
case Xof_ext_.Id_ogv: case Xof_ext_.Id_ogv:
case Xof_ext_.Id_webm: case Xof_ext_.Id_webm:
tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220"; PAGE:en.w:Alice_Brady; DATE:2015-08-06 tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220"; PAGE:en.w:Alice_Brady; DATE:2015-08-06
tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-" tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-"
if (Xof_lnki_time.Null_n(time)) if (Xof_lnki_time.Null_n(time))
tmp_bfr.Add(Bry_seek).Add_str_a7(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-" tmp_bfr.Add(Bry_seek).Add_str_a7(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
else else
tmp_bfr.Add_byte(Byte_ascii.Dash); // add mid; EX: "-"; NOTE: was "mid-"; DATE:2015-08-06 tmp_bfr.Add_byte(Byte_ascii.Dash); // add mid; EX: "-"; NOTE: was "mid-"; DATE:2015-08-06
break; break;
case Xof_ext_.Id_tif: case Xof_ext_.Id_tif:
case Xof_ext_.Id_tiff: case Xof_ext_.Id_tiff:
Add_thumb_wmf_page(Bry_lossy_page1, Bry_lossy_page); Add_thumb_wmf_page(Bry_lossy_page1, Bry_lossy_page);
tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220" tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220"
tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-" tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-"
break; break;
case Xof_ext_.Id_pdf: case Xof_ext_.Id_pdf:
case Xof_ext_.Id_djvu: case Xof_ext_.Id_djvu:
Add_thumb_wmf_page(Bry_page1, Bry_page); Add_thumb_wmf_page(Bry_page1, Bry_page);
tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220" tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220"
tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-" tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-"
break; break;
default: default:
tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220" tmp_bfr.Add_int_variable(file_w); // add file_w; EX: "220"
tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-" tmp_bfr.Add(Bry_px_dash); // add px; EX: "px-"
break; break;
} }
int ttl_len = ttl.length; int ttl_len = ttl.length;
if (ttl_len > 160) { // long file name if (ttl_len > 160) { // long file name
tmp_bfr.Add(Bry_thumnbail_w_dot); tmp_bfr.Add(Bry_thumnbail_w_dot);
tmp_bfr.Add(ext.Ext()); tmp_bfr.Add(ext.Ext());
} }
else else {
tmp_bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png" tmp_bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png"
switch (file_ext_id) { }
case Xof_ext_.Id_svg: // add ".png" / ".jpg" suffix if file is image; NOTE: don't add if already .png or .jpg
case Xof_ext_.Id_bmp: if ( file_ext_id != Xof_ext_.Id_png
case Xof_ext_.Id_xcf: && file_ext_id != Xof_ext_.Id_jpg) {
tmp_bfr.Add_byte(Byte_ascii.Dot).Add(Xof_ext_.Bry_png); // add .png; EX: "A.svg" -> "A.svg.png" NOTE: MediaWiki always adds as lowercase int file_view_id = Xof_ext_.Id_view(file_ext_id);
break; switch (file_view_id) {
case Xof_ext_.Id_pdf: case Xof_ext_.Id_png:
case Xof_ext_.Id_tif: // add .jpg EX: "A.tif" -> "A.tif.jpg" NOTE: MediaWiki always adds as lowercase tmp_bfr.Add_byte(Byte_ascii.Dot).Add(Xof_ext_.Bry_png); // add .png; EX: "A.svg" -> "A.svg.png" NOTE: MediaWiki always adds as lowercase
case Xof_ext_.Id_tiff: break;
case Xof_ext_.Id_ogg: case Xof_ext_.Id_jpg: // add .jpg EX: "A.tif" -> "A.tif.jpg" NOTE: MediaWiki always adds as lowercase
case Xof_ext_.Id_ogv: tmp_bfr.Add_byte(Byte_ascii.Dot).Add(Xof_ext_.Bry_jpg);
case Xof_ext_.Id_djvu: break;
case Xof_ext_.Id_webm: }
tmp_bfr.Add_byte(Byte_ascii.Dot).Add(Xof_ext_.Bry_jpg); }
break; return this;
} }
return this; private void Add_thumb_wmf_page(byte[] bry_page_1, byte[] bry_page) {
} if (Xof_lnki_time.Null_y(page))
private void Add_thumb_wmf_page(byte[] bry_page_1, byte[] bry_page) { tmp_bfr.Add(bry_page_1); // add "lossy-page1-" EX: "lossy-page1-"
if (Xof_lnki_time.Null_y(page)) else {
tmp_bfr.Add(bry_page_1); // add "lossy-page1-" EX: "lossy-page1-" tmp_bfr.Add(bry_page); // add "lossy-page" EX: "lossy-page"
else { tmp_bfr.Add_int_variable(page); // add page EX: 123
tmp_bfr.Add(bry_page); // add "lossy-page" EX: "lossy-page" tmp_bfr.Add_byte(Byte_ascii.Dash); // add - EX: "-"
tmp_bfr.Add_int_variable(page); // add page EX: 123 }
tmp_bfr.Add_byte(Byte_ascii.Dash); // add - EX: "-" }
} private Xof_url_bldr Clear() {
} root = area = ttl = md5 = null;
private Xof_url_bldr Clear() { file_w = Xof_img_size.Null;
root = area = ttl = md5 = null; time = Xof_lnki_time.Null;
file_w = Xof_img_size.Null; ext = null;
time = Xof_lnki_time.Null; tmp_bfr.Clear();
ext = null; repo_tid = Xof_repo_tid_.Tid__null;
tmp_bfr.Clear(); return this;
repo_tid = Xof_repo_tid_.Tid__null; }
return this; public static final byte[]
} Bry_reg = Bry_.new_a7("reg.csv")
public static final byte[] , Bry_px = Bry_.new_a7("px"), Bry_px_dash = Bry_.new_a7("px-")
Bry_reg = Bry_.new_a7("reg.csv") , Bry_thumb = Bry_.new_a7("thumb")
, Bry_px = Bry_.new_a7("px"), Bry_px_dash = Bry_.new_a7("px-") , Bry_thumnbail_w_dot = Bry_.new_a7("thumbnail.")
, Bry_thumb = Bry_.new_a7("thumb") ;
, Bry_thumnbail_w_dot = Bry_.new_a7("thumbnail.") private static final byte[]
; Bry_lossy_page = Bry_.new_a7("lossy-page"), Bry_page = Bry_.new_a7("page")
private static final byte[] , Bry_lossy_page1 = Bry_.new_a7("lossy-page1-"), Bry_page1 = Bry_.new_a7("page1-"), Bry_seek = Bry_.new_a7("seek%3D");
Bry_lossy_page = Bry_.new_a7("lossy-page"), Bry_page = Bry_.new_a7("page") public static Xof_url_bldr new_v2() {
, Bry_lossy_page1 = Bry_.new_a7("lossy-page1-"), Bry_page1 = Bry_.new_a7("page1-"), Bry_seek = Bry_.new_a7("seek%3D"); Xof_url_bldr rv = new Xof_url_bldr();
public static Xof_url_bldr new_v2() { rv.time_dlm = Byte_ascii.Dash;
Xof_url_bldr rv = new Xof_url_bldr(); return rv;
rv.time_dlm = Byte_ascii.Dash; }
return rv; }
}
public static final int Md5_dir_depth_2 = 2;
}

View File

@ -1,18 +1,18 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.files; import gplx.*; import gplx.xowa.*; package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.imgs.*; import org.junit.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.imgs.*;
public class Xof_url_bldr__tst { public class Xof_url_bldr__tst {
@ -25,6 +25,8 @@ public class Xof_url_bldr__tst {
@Test public void Bmp() {fxt.Root_("http://test/").Md5_("70").Ttl_("A.bmp").W_(220).Expd_src_("http://test/thumb/7/70/A.bmp/220px-A.bmp.png").Test();} @Test public void Bmp() {fxt.Root_("http://test/").Md5_("70").Ttl_("A.bmp").W_(220).Expd_src_("http://test/thumb/7/70/A.bmp/220px-A.bmp.png").Test();}
@Test public void Pdf() {fxt.Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page1-220px-A.pdf.jpg").Test();} @Test public void Pdf() {fxt.Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page1-220px-A.pdf.jpg").Test();}
@Test public void Pdf__page_2() {fxt.Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-220px-A.pdf.jpg").Page_(2).Test();} @Test public void Pdf__page_2() {fxt.Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-220px-A.pdf.jpg").Page_(2).Test();}
@Test public void Stl() {fxt.Root_("http://test/").Md5_("62").Ttl_("A.stl").W_(220).Expd_src_("http://test/thumb/6/62/A.stl/220px-A.stl.png").Test();}
@Test public void Webp() {fxt.Root_("http://test/").Md5_("d9").Ttl_("A.webp").W_(220).Expd_src_("http://test/thumb/d/d9/A.webp/220px-A.webp.png").Test();}
@Test public void Long() { @Test public void Long() {
String filename = String_.Repeat("A", 200) + ".png"; String filename = String_.Repeat("A", 200) + ".png";
fxt.Root_("http://test/").Md5_("14").Ttl_(filename).W_(220) fxt.Root_("http://test/").Md5_("14").Ttl_(filename).W_(220)

View File

@ -0,0 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.files.fsdb.tsts;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class Xof_file_ext__stl_tst {
@Before public void init() {fxt.Reset();} private final Xof_file_fxt fxt = new Xof_file_fxt();
@After public void term() {fxt.Rls();}
@Test public void Make_orig() {
fxt.Init_orig_db(Xof_orig_arg.new_comm("A.stl", 440, 400));
fxt.Init_fsdb_db(Xof_fsdb_arg.new_comm_orig("A.stl", 440, 400));
fxt.Exec_get(Xof_exec_arg.new_orig("A.stl").Rslt_orig_exists_y().Rslt_file_exists_y().Rslt_file_resized_y());
fxt.Test_fsys("mem/root/common/thumb/6/2/A.stl/440px.png", "440,400");
}
@Test public void Make_thumb() {
fxt.Init_orig_db(Xof_orig_arg.new_comm("A.stl", 440, 400));
fxt.Init_fsdb_db(Xof_fsdb_arg.new_comm_orig("A.stl", 440, 400));
fxt.Exec_get(Xof_exec_arg.new_thumb("A.stl").Rslt_orig_exists_y().Rslt_file_exists_y().Rslt_file_resized_y());
fxt.Test_fsys("mem/root/common/thumb/6/2/A.stl/220px.png", "220,200");
}
}

View File

@ -0,0 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.files.fsdb.tsts;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class Xof_file_ext__webp_tst {
@Before public void init() {fxt.Reset();} private final Xof_file_fxt fxt = new Xof_file_fxt();
@After public void term() {fxt.Rls();}
@Test public void Make_orig() {
fxt.Init_orig_db(Xof_orig_arg.new_comm("A.webp", 440, 400));
fxt.Init_fsdb_db(Xof_fsdb_arg.new_comm_orig("A.webp", 440, 400));
fxt.Exec_get(Xof_exec_arg.new_orig("A.webp").Rslt_orig_exists_y().Rslt_file_exists_y().Rslt_file_resized_y());
fxt.Test_fsys("mem/root/common/thumb/d/9/A.webp/440px.png", "440,400");
}
@Test public void Make_thumb() {
fxt.Init_orig_db(Xof_orig_arg.new_comm("A.webp", 440, 400));
fxt.Init_fsdb_db(Xof_fsdb_arg.new_comm_orig("A.webp", 440, 400));
fxt.Exec_get(Xof_exec_arg.new_thumb("A.webp").Rslt_orig_exists_y().Rslt_file_exists_y().Rslt_file_resized_y());
fxt.Test_fsys("mem/root/common/thumb/d/9/A.webp/220px.png", "220,200");
}
}