1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 23:10:52 +00:00

Mw_parse: Port over more code for thumb links

This commit is contained in:
gnosygnu 2017-02-02 14:20:19 -05:00
parent e7ae5d0435
commit 472f12e60d
9 changed files with 196 additions and 118 deletions

View File

@ -136,6 +136,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
return Bry_.Mid(full_txt, page_bgn, ques_pos == Bry_find_.Not_found ? full_txt_len : ques_pos); return Bry_.Mid(full_txt, page_bgn, ques_pos == Bry_find_.Not_found ? full_txt_len : ques_pos);
} }
public byte[] Get_text() {return Page_txt();}
public byte[] Get_prefixed_text() {return Full_txt_wo_qarg();} public byte[] Get_prefixed_text() {return Full_txt_wo_qarg();}
public byte[] Get_prefixed_db_key() {return Full_db();} public byte[] Get_prefixed_db_key() {return Full_db();}
public boolean Has_fragment() {return anch_bgn != -1;} public boolean Has_fragment() {return anch_bgn != -1;}

View File

@ -19,7 +19,9 @@ package gplx.xowa.mws; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.parsers.*;
import gplx.xowa.mws.filerepos.files.*;
/* TODO.XO /* TODO.XO
* P8: wfMessage
* P7: titleFormatter->getPrefixedText * P7: titleFormatter->getPrefixedText
* P7: $html = HtmlArmor::getHtml($text); * P7: $html = HtmlArmor::getHtml($text);
*/ */
@ -31,12 +33,15 @@ public class Xomw_linker {
private final Btrie_rv trv = new Btrie_rv(); private final Btrie_rv trv = new Btrie_rv();
private final byte[][] split_trail_rv = new byte[2][]; private final byte[][] split_trail_rv = new byte[2][];
private Btrie_slim_mgr split_trail_trie; private Btrie_slim_mgr split_trail_trie;
private final Xomw_atr_mgr tmp_attribs = new Xomw_atr_mgr();
private static final byte[] Atr__class = Bry_.new_a7("class"), Atr__rel = Bry_.new_a7("rel"), Atr__href = Bry_.new_a7("href"), Rel__nofollow = Bry_.new_a7("nofollow"); private static final byte[] Atr__class = Bry_.new_a7("class"), Atr__rel = Bry_.new_a7("rel"), Atr__href = Bry_.new_a7("href"), Rel__nofollow = Bry_.new_a7("nofollow");
public static final byte[] public static final byte[]
Align__frame__center = Bry_.new_a7("center") Align__frame__center = Bry_.new_a7("center")
, Align__frame__none = Bry_.new_a7("none") , Align__frame__none = Bry_.new_a7("none")
, Align__frame__right = Bry_.new_a7("right") , Align__frame__right = Bry_.new_a7("right")
, Prefix__center = Bry_.new_a7("<div class=\"center\">") , Prefix__center = Bry_.new_a7("<div class=\"center\">")
, Class__internal = Bry_.new_a7("internal")
, Class__magnify = Bry_.new_a7("magnify")
; ;
private final Xomw_link_renderer link_renderer; private final Xomw_link_renderer link_renderer;
public Xomw_linker(Xomw_link_renderer link_renderer) { public Xomw_linker(Xomw_link_renderer link_renderer) {
@ -72,23 +77,23 @@ public class Xomw_linker {
// link-target Value for the target attribute, only with link-url // link-target Value for the target attribute, only with link-url
// no-link Boolean, suppress description link // no-link Boolean, suppress description link
// //
// @param array $handlerParams Associative array of media handler parameters, to be passed // @param array handler_params Associative array of media handler parameters, to be passed
// to transform(). Typical keys are "width" and "page". // to transform(). Typical keys are "width" and "page".
// @param String|boolean $time Timestamp of the file, set as false for current // @param String|boolean $time Timestamp of the file, set as false for current
// @param String $query Query params for desc url // @param String $query Query params for desc url
// @param int|null $widthOption Used by the parser to remember the user preference thumbnailsize // @param int|null width_option Used by the parser to remember the user preference thumbnailsize
// @since 1.20 // @since 1.20
// @return String HTML for an image, with links, wrappers, etc. // @return String HTML for an image, with links, wrappers, etc.
public void Make_image_link(Xomw_parser parser, Xoa_ttl title, Object file, Xomw_img_frame frame_params, Object handlerParams, Object time, Object query, Object widthOption) { public void Make_image_link(Bry_bfr bfr, Xomw_parser parser, Xoa_ttl title, Xomw_file file, Xomw_img_prms frame_params, Xomw_mda_prms handler_params, Object time, Object query, Object widthOption) {
// XO.MW.HOOK:ImageBeforeProduceHTML // XO.MW.HOOK:ImageBeforeProduceHTML
// if ($file && !$file->allowInlineDisplay()) { if (file != null && !file.Allow_inline_display()) {
// wfDebug(__METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n"); // this.Link(bfr, title, Bry_.Empty, tmp_attribs, tmp_query, tmp_options);
// return self::link($title); return;
// } }
// Clean up parameters // Clean up parameters
// $page = isset($handlerParams['page']) ? $handlerParams['page'] : false; int page = handler_params.page;
if (frame_params.align == null) { if (frame_params.align == null) {
frame_params.align = Bry_.Empty; frame_params.align = Bry_.Empty;
} }
@ -109,48 +114,50 @@ public class Xomw_linker {
postfix = Gfh_tag_.Div_rhs; postfix = Gfh_tag_.Div_rhs;
frame_params.align = Align__frame__none; frame_params.align = Align__frame__none;
} }
// if ($file && !isset($handlerParams['width'])) { if (file != null && handler_params.width == -1) {
// if (isset($handlerParams['height']) && $file->isVectorized()) { if (handler_params.height != -1 && file.Is_vectorized()) {
// // If its a vector image, and user only specifies height // If its a vector image, and user only specifies height
// // we don't want it to be limited by its "normal" width. // we don't want it to be limited by its "normal" width.
// global $wgSVGMaxSize; // global $wgSVGMaxSize;
// $handlerParams['width'] = $wgSVGMaxSize; // handler_params.width = $wgSVGMaxSize;
// } else { }
// $handlerParams['width'] = $file->getWidth($page); else {
// } handler_params.width = file.Get_width(page);
// }
if ( frame_params.thumbnail != null if ( frame_params.thumbnail != null
|| frame_params.manual_thumb != null || frame_params.manual_thumb != null
|| frame_params.framed != null || frame_params.framed != null
|| frame_params.frameless != null || frame_params.frameless != null
// || !$handlerParams['width'] || handler_params.width == -1
) { ) {
// global $wgThumbLimits, $wgThumbUpright; // global $wgThumbLimits, $wgThumbUpright;
//
// if ($widthOption === null || !isset($wgThumbLimits[$widthOption])) { // if (width_option === null || !isset($wgThumbLimits[width_option])) {
// $widthOption = User::getDefaultOption('thumbsize'); // width_option = User::getDefaultOption('thumbsize');
// }
//
// // Reduce width for upright images when parameter 'upright' is used
// if (isset(frame_params['upright']) && frame_params['upright'] == 0) {
// frame_params['upright'] = $wgThumbUpright;
// }
//
// // For caching health: If width scaled down due to upright
// // parameter, round to full __0 pixel to avoid the creation of a
// // lot of odd thumbs.
// $prefWidth = isset(frame_params['upright']) ?
// round($wgThumbLimits[$widthOption] * frame_params['upright'], -1) :
// $wgThumbLimits[$widthOption];
//
// // Use width which is smaller: real image width or user preference width
// // Unless image is scalable vector.
// if (!isset($handlerParams['height']) && ($handlerParams['width'] <= 0 ||
// $prefWidth < $handlerParams['width'] || $file->isVectorized())) {
// $handlerParams['width'] = $prefWidth;
// } // }
// Reduce width for upright images when parameter 'upright' is used
if (frame_params.upright == 0) {
// frame_params.upright = $wgThumbUpright;
}
// For caching health: If width scaled down due to upright
// parameter, round to full __0 pixel to avoid the creation of a
// lot of odd thumbs.
int pref_width = 0;
// pref_width = isset(frame_params['upright']) ?
// round($wgThumbLimits[width_option] * frame_params['upright'], -1) :
// $wgThumbLimits[width_option];
// Use width which is smaller: real image width or user preference width
// Unless image is scalable vector.
if (handler_params.height == -1 && handler_params.width <= 0 ||
pref_width < handler_params.width || file.Is_vectorized()) {
handler_params.width = pref_width;
}
} }
// } }
if (frame_params.thumbnail != null || frame_params.manual_thumb != null if (frame_params.thumbnail != null || frame_params.manual_thumb != null
|| frame_params.framed != null || frame_params.framed != null
@ -163,32 +170,35 @@ public class Xomw_linker {
if (frame_params.align == Bry_.Empty) { if (frame_params.align == Bry_.Empty) {
// frame_params.align = $parser->getTargetLanguage()->alignEnd(); // frame_params.align = $parser->getTargetLanguage()->alignEnd();
} }
// return prefix . bfr.Add(prefix);
// self::makeThumbLink2($title, $file, frame_params, $handlerParams, $time, $query) . this.Make_thumb_link2(bfr, title, file, frame_params, handler_params, time, query);
// postfix; bfr.Add(postfix);
} }
//
// if ($file && isset(frame_params['frameless'])) { if (file != null && frame_params.frameless != null) {
// $srcWidth = $file->getWidth($page); int src_width = file.Get_width(page);
// // For "frameless" option: do not present an image bigger than the // For "frameless" option: do not present an image bigger than the
// // source (for bitmap-style images). This is the same behavior as the // source (for bitmap-style images). This is the same behavior as the
// // "thumb" option does it already. // "thumb" option does it already.
// if ($srcWidth && !$file->mustRender() && $handlerParams['width'] > $srcWidth) { if (src_width != -1 && !file.Must_render() && handler_params.width > src_width) {
// $handlerParams['width'] = $srcWidth; handler_params.width = src_width;
// } }
// } }
//
// if ($file && isset($handlerParams['width'])) { boolean thumb = false;
// // Create a resized image, without the additional thumbnail features if (file != null && handler_params.width != -1) {
// $thumb = $file->transform($handlerParams); // Create a resized image, without the additional thumbnail features
// } else { // $thumb = $file->transform(handler_params);
// $thumb = false; }
// } else {
// thumb = false;
// if (!$thumb) { }
if (!thumb) {
// $s = self::makeBrokenImageLinkObj($title, frame_params['title'], '', '', '', $time == true); // $s = self::makeBrokenImageLinkObj($title, frame_params['title'], '', '', '', $time == true);
// } else { }
// self::processResponsiveImages($file, $thumb, $handlerParams); else {
// self::processResponsiveImages($file, $thumb, handler_params);
// $params = [ // $params = [
// 'alt' => frame_params['alt'], // 'alt' => frame_params['alt'],
// 'title' => frame_params['title'], // 'title' => frame_params['title'],
@ -200,18 +210,22 @@ public class Xomw_linker {
// $params = self::getImageLinkMTOParams(frame_params, $query, $parser) + $params; // $params = self::getImageLinkMTOParams(frame_params, $query, $parser) + $params;
// //
// $s = $thumb->toHtml($params); // $s = $thumb->toHtml($params);
// }
// if (frame_params['align'] != '') {
// $s = "<div class=\"float{frame_params['align']}\">{$s}</div>";
// }
// return str_replace("\n", ' ', prefix . $s . postfix);
if (prefix == null || postfix == null) {
} }
if (frame_params.align != Bry_.Empty) {
tmp.Add_str_a7("<div class=\"float").Add(frame_params.align).Add_str_a7("\">{$s}</div>");
}
// XO.MW: "str_replace("\n", ' ', prefix . $s . postfix);"
int rv_bgn = bfr.Len();
bfr.Add(prefix);
bfr.Add_bfr_and_clear(tmp);
bfr.Add(postfix);
Bry_.Replace_all_direct(bfr.Bfr(), Byte_ascii.Nl, Byte_ascii.Space, rv_bgn, bfr.Len());
} }
public void Make_thumb_link2(Bry_bfr bfr, Xoa_ttl title, Object file, Xomw_img_frame frame_params, Object handlerParams, Object time, Object query) { public void Make_thumb_link2(Bry_bfr bfr, Xoa_ttl title, Object file, Xomw_img_prms frame_params, Object handler_params, Object time, Object query) {
boolean exists = false; // = $file && $file->exists(); boolean exists = false; // = $file && $file->exists();
// $page = isset($handlerParams['page']) ? $handlerParams['page'] : false; // $page = isset(handler_params['page']) ? handler_params['page'] : false;
if (frame_params.align == null) { if (frame_params.align == null) {
frame_params.align = Align__frame__right; frame_params.align = Align__frame__right;
} }
@ -225,9 +239,9 @@ public class Xomw_linker {
frame_params.caption = Bry_.Empty; frame_params.caption = Bry_.Empty;
} }
// if (empty($handlerParams['width'])) { // if (empty(handler_params['width'])) {
// // Reduce width for upright images when parameter 'upright' is used // // Reduce width for upright images when parameter 'upright' is used
// $handlerParams['width'] = isset(frame_params['upright']) ? 130 : 180; // handler_params['width'] = isset(frame_params['upright']) ? 130 : 180;
// } // }
boolean thumb = false; boolean thumb = false;
boolean no_scale = false; boolean no_scale = false;
@ -235,7 +249,7 @@ public class Xomw_linker {
int outer_width = 0; int outer_width = 0;
if (!exists) { if (!exists) {
// outer_width = $handlerParams['width'] + 2; // outer_width = handler_params['width'] + 2;
} }
else { else {
if (frame_params.manual_thumb != null) { if (frame_params.manual_thumb != null) {
@ -244,7 +258,7 @@ public class Xomw_linker {
// if ($manual_title) { // if ($manual_title) {
// $manual_img = wfFindFile($manual_title); // $manual_img = wfFindFile($manual_title);
// if ($manual_img) { // if ($manual_img) {
// thumb = $manual_img->getUnscaledThumb($handlerParams); // thumb = $manual_img->getUnscaledThumb(handler_params);
// manual_thumb = true; // manual_thumb = true;
// } else { // } else {
// exists = false; // exists = false;
@ -253,31 +267,31 @@ public class Xomw_linker {
} }
else if (frame_params.framed != null) { else if (frame_params.framed != null) {
// Use image dimensions, don't scale // Use image dimensions, don't scale
// thumb = $file->getUnscaledThumb($handlerParams); // thumb = $file->getUnscaledThumb(handler_params);
no_scale = true; no_scale = true;
} }
else { else {
// Do not present an image bigger than the source, for bitmap-style images // Do not present an image bigger than the source, for bitmap-style images
// This is a hack to maintain compatibility with arbitrary pre-1.10 behavior // This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
// $srcWidth = $file->getWidth($page); // src_width = $file->getWidth($page);
// if ($srcWidth && !$file->mustRender() && $handlerParams['width'] > $srcWidth) { // if (src_width && !$file->mustRender() && handler_params['width'] > src_width) {
// $handlerParams['width'] = $srcWidth; // handler_params['width'] = src_width;
// } // }
// thumb = $file->transform($handlerParams); // thumb = $file->transform(handler_params);
} }
if (thumb) { if (thumb) {
// outer_width = thumb->getWidth() + 2; // outer_width = thumb->getWidth() + 2;
} }
else { else {
// outer_width = $handlerParams['width'] + 2; // outer_width = handler_params['width'] + 2;
} }
} }
// ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs // ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
// So we don't need to pass it here in $query. However, the URL for the // So we don't need to pass it here in $query. However, the URL for the
// zoom icon still needs it, so we make a unique query for it. See bug 14771 // zoom icon still needs it, so we make a unique query for it. See bug 14771
// $url = $title->getLocalURL($query); byte[] url = Bry_.Empty; // $title->getLocalURL($query);
// if ($page) { // if ($page) {
// $url = wfAppendQuery($url, [ 'page' => $page ]); // $url = wfAppendQuery($url, [ 'page' => $page ]);
// } // }
@ -295,15 +309,15 @@ public class Xomw_linker {
byte[] zoom_icon = Bry_.Empty; byte[] zoom_icon = Bry_.Empty;
if (!exists) { if (!exists) {
// $s .= self::makeBrokenImageLinkObj($title, frame_params['title'], '', '', '', $time == true); // $s .= self::makeBrokenImageLinkObj($title, frame_params['title'], '', '', '', $time == true);
// zoom_icon = ''; zoom_icon = Bry_.Empty;
} }
else if (!thumb) { else if (!thumb) {
// $s .= wfMessage('thumbnail_error', '')->escaped(); // $s .= wfMessage('thumbnail_error', '')->escaped();
// zoom_icon = ''; zoom_icon = Bry_.Empty;
} }
else { else {
if (!no_scale && !manual_thumb) { if (!no_scale && !manual_thumb) {
// self::processResponsiveImages($file, thumb, $handlerParams); // self::processResponsiveImages($file, thumb, handler_params);
} }
// $params = [ // $params = [
// 'alt' => frame_params['alt'], // 'alt' => frame_params['alt'],
@ -318,13 +332,14 @@ public class Xomw_linker {
zoom_icon = Bry_.Empty; zoom_icon = Bry_.Empty;
} }
else { else {
// html_utl.Raw_element(bfr, Gfh_tag_.Bry__div, html_utl.Raw_element(tmp, Gfh_tag_.Bry__a
// zoom_icon = Html::rawElement('div', [ 'class' => 'magnify' ], , tmp_attribs.Clear()
// Html::rawElement('a', [ .Add(Gfh_atr_.Bry__href , url)
// 'href' => $url, .Add(Gfh_atr_.Bry__class, Class__internal)
// 'class' => '@gplx.Internal protected', // .Add(Gfh_atr_.Bry__title, wfMessage('thumbnail-more')->text())
// 'title' => wfMessage('thumbnail-more')->text() ], , Bry_.Empty);
// "")); byte[] zoom_anch = tmp.To_bry_and_clear();
html_utl.Raw_element(bfr, Gfh_tag_.Bry__div, tmp_attribs.Clear().Add(Gfh_atr_.Bry__class, Class__magnify), zoom_anch);
} }
} }
bfr.Add_str_a7(" <div class=\"thumbcaption\">").Add(zoom_icon).Add(frame_params.caption).Add_str_a7("</div></div></div>"); bfr.Add_str_a7(" <div class=\"thumbcaption\">").Add(zoom_icon).Add(frame_params.caption).Add_str_a7("</div></div></div>");

View File

@ -0,0 +1,32 @@
/*
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.mws.filerepos.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.filerepos.*;
public class Xomw_file {
public boolean Allow_inline_display() {
return true;
}
public boolean Is_vectorized() {
return false;
}
public int Get_width(int page) {
return -1;
}
public boolean Must_render() {
return true;
}
}

View File

@ -24,7 +24,10 @@ public class Xomw_atr_mgr {
public Xomw_atr_mgr Clear() {hash.Clear(); return this;} public Xomw_atr_mgr Clear() {hash.Clear(); return this;}
public void Del(byte[] key) {hash.Del(key);} public void Del(byte[] key) {hash.Del(key);}
public void Add(Xomw_atr_itm itm) {hash.Add(itm.Key_bry(), itm);} public void Add(Xomw_atr_itm itm) {hash.Add(itm.Key_bry(), itm);}
public void Add(byte[] key, byte[] val) {this.Add(new Xomw_atr_itm(-1, key, val));} public Xomw_atr_mgr Add(byte[] key, byte[] val) {
this.Add(new Xomw_atr_itm(-1, key, val));
return this;
}
public void Add_or_set(Xomw_atr_itm src) { public void Add_or_set(Xomw_atr_itm src) {
Xomw_atr_itm trg = (Xomw_atr_itm)hash.Get_by(src.Key_bry()); Xomw_atr_itm trg = (Xomw_atr_itm)hash.Get_by(src.Key_bry());
if (trg == null) if (trg == null)

View File

@ -16,7 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
public class Xomw_img_frame { public class Xomw_img_prms {
public byte[] align = null; public byte[] align = null;
public byte[] valign = null; public byte[] valign = null;
public byte[] caption = null; public byte[] caption = null;
@ -31,4 +31,5 @@ public class Xomw_img_frame {
public byte[] link_title = null; public byte[] link_title = null;
public byte[] link_url = null; public byte[] link_url = null;
public byte[] no_link = null; public byte[] no_link = null;
public double upright = -1;
} }

View File

@ -0,0 +1,23 @@
/*
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.mws.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
public class Xomw_mda_prms {
public int width = -1;
public int height = -1;
public int page = -1;
}

View File

@ -22,6 +22,7 @@ import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*;
import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*;
import gplx.xowa.mws.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.mws.filerepos.files.*;
import gplx.xowa.parsers.uniqs.*; import gplx.xowa.parsers.uniqs.*;
/* TODO.XO /* TODO.XO
* P7: multi-line links; // look at the next 'line' to see if we can close it there * P7: multi-line links; // look at the next 'line' to see if we can close it there
@ -404,7 +405,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
if (ns.Id_is_media()) { if (ns.Id_is_media()) {
// Give extensions a chance to select the file revision for us // Give extensions a chance to select the file revision for us
// options = []; // options = [];
// descQuery = false; // desc_query = false;
// MW.HOOK:BeforeParserFetchFileAndTitle // MW.HOOK:BeforeParserFetchFileAndTitle
// Fetch and register the file (file title may be different via hooks) // Fetch and register the file (file title may be different via hooks)
// list(file, nt) = this->fetchFileAndTitle(nt, options); // list(file, nt) = this->fetchFileAndTitle(nt, options);
@ -464,10 +465,11 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// Give extensions a chance to select the file revision for us // Give extensions a chance to select the file revision for us
// $options = []; // $options = [];
// $descQuery = false; byte[] desc_query = null;
// MW.HOOK:BeforeParserFetchFileAndTitle // MW.HOOK:BeforeParserFetchFileAndTitle
// Fetch and register the file (file title may be different via hooks) // Fetch and register the file (file title may be different via hooks)
Xomw_file file = new Xomw_file();
// list($file, $title) = $this->fetchFileAndTitle($title, $options); // list($file, $title) = $this->fetchFileAndTitle($title, $options);
// Get parameter map // Get parameter map
@ -480,14 +482,14 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// } // }
// Process the input parameters // Process the input parameters
// caption = ''; byte[] caption = Bry_.Empty;
// $params = [ 'frame' => [], 'handler' => [], // XO.MW: $params = [ 'frame' => [], 'handler' => [], 'horizAlign' => [], 'vertAlign' => [] ];
// 'horizAlign' => [], 'vertAlign' => [] ]; Xomw_img_prms frame = new Xomw_img_prms();
// $seenformat = false; Xomw_mda_prms handler = new Xomw_mda_prms();
boolean seen_format = false;
// foreach ($parts as $part) { // foreach ($parts as $part) {
Xomw_prm_mgr param_map = new Xomw_prm_mgr(); Xomw_prm_mgr param_map = new Xomw_prm_mgr();
Xomw_prm_mgr param_mgr = new Xomw_prm_mgr(); Xomw_prm_mgr param_mgr = new Xomw_prm_mgr();
byte[] caption = Bry_.Empty;
byte[] part = null; byte[] part = null;
part = Bry_.Trim(part); part = Bry_.Trim(part);
@ -541,15 +543,16 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// if ($value === '') { // if ($value === '') {
// $paramName = 'no-link'; // $paramName = 'no-link';
// $value = true; // $value = true;
// validated = true; validated = true;
// } else if (preg_match("/^((?i)$prots)/", $value)) { // }
// else if (preg_match("/^((?i)$prots)/", $value)) {
// if (preg_match("/^((?i)$prots)$addr$chars*$/u", $value, $m)) { // if (preg_match("/^((?i)$prots)$addr$chars*$/u", $value, $m)) {
// $paramName = 'link-url'; // $paramName = 'link-url';
// $this->mOutput->addExternalLink($value); // $this->mOutput->addExternalLink($value);
// if ($this->mOptions->getExternalLinkTarget()) { // if ($this->mOptions->getExternalLinkTarget()) {
// $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget(); // $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
// } // }
// validated = true; validated = true;
// } // }
// } else { // } else {
// $linkTitle = Title::newFromText($value); // $linkTitle = Title::newFromText($value);
@ -557,7 +560,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// $paramName = 'link-title'; // $paramName = 'link-title';
// $value = $linkTitle; // $value = $linkTitle;
// $this->mOutput->addLink($linkTitle); // $this->mOutput->addLink($linkTitle);
// validated = true; validated = true;
// } // }
// } // }
break; break;
@ -565,8 +568,8 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
case Xomw_prm_itm.Name__framed: case Xomw_prm_itm.Name__framed:
case Xomw_prm_itm.Name__thumbnail: case Xomw_prm_itm.Name__thumbnail:
// use first appearing option, discard others. // use first appearing option, discard others.
// validated = !$seenformat; validated = !seen_format;
// $seenformat = true; seen_format = true;
break; break;
default: default:
// Most other things appear to be empty or numeric... // Most other things appear to be empty or numeric...
@ -583,7 +586,6 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// Process alignment parameters // Process alignment parameters
Xomw_prm_itm tmp = param_mgr.Get_or_null(Xomw_prm_mgr.Name__horiz_align); Xomw_prm_itm tmp = param_mgr.Get_or_null(Xomw_prm_mgr.Name__horiz_align);
Xomw_img_frame frame = new Xomw_img_frame(); // param_mgr.frame;
if (tmp != null) { if (tmp != null) {
frame.align = tmp.val; frame.align = tmp.val;
} }
@ -620,7 +622,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
if (caption == Bry_.Empty && frame.alt == null) { if (caption == Bry_.Empty && frame.alt == null) {
// No caption or alt text, add the filename as the alt text so // No caption or alt text, add the filename as the alt text so
// that screen readers at least get some description of the image // that screen readers at least get some description of the image
// frame.alt = title.Get_text(); frame.alt = title.Get_text();
} }
// Do not set $params['frame']['title'] because tooltips don't make sense // Do not set $params['frame']['title'] because tooltips don't make sense
// for framed images // for framed images
@ -634,7 +636,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
else { else {
// No caption, fall back to using the filename for the // No caption, fall back to using the filename for the
// alt text // alt text
// frame.alt = title.Get_text(); frame.alt = title.Get_text();
} }
} }
// Use the "caption" for the tooltip text // Use the "caption" for the tooltip text
@ -645,10 +647,11 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// Linker does the rest // Linker does the rest
// byte[] time = options.time; // byte[] time = options.time;
// $ret = Linker::makeImageLink($this, $title, $file, $params['frame'], $params['handler'], Object time = null;
// $time, $descQuery, $this->mOptions->getThumbSize()); // options = $this->mOptions->getThumbSize()
// linker.Make_image_link(bfr, parser, title, file, frame, handler, time, desc_query, null);
// // Give the handler a chance to modify the parser Object
// Give the handler a chance to modify the parser Object
// if (handler != null) { // if (handler != null) {
// $handler->parserTransformHook($this, $file); // $handler->parserTransformHook($this, $file);
// } // }

View File

@ -58,7 +58,7 @@ XOWA has seven dependencies:
#### Setup the XOWA source #### Setup the XOWA source
* Download the latest XOWA source archive. For example: "xowa_source_v1.9.5.1.7z" * Download the latest XOWA source archive. For example: "xowa_source_v1.9.5.1.7z"
* Unzip the source to "/xowa/dev". When you're done, you'll have a file called "/xowa/dev/build.xml" as well as others * Unzip the source to "/xowa/dev". When you're done, you'll have a file called "/xowa/dev/build.xml" as well as others
* NOTE: if you're not on a Linux 64-bit system, overwrite the swt jar at "/xowa/dev/150_gfui/lib/swt.jar" with the copy from your "/bin/OS" directory. For example, if you're on a 64 bit Windows system, replace "/xowa/dev/150_gfui/lib/swt.jar" with "/bin/windows_64/swt/swt/jar" * NOTE: if you're not on a Linux 64-bit system, overwrite the swt jar at "/xowa/dev/150_gfui/lib/swt.jar" with the copy from your "/bin/OS" directory. For example, if you're on a 64 bit Windows system, replace "/xowa/dev/150_gfui/lib/swt.jar" with "/bin/windows_64/swt/swt.jar"
#### Run the ant file #### Run the ant file
* Open up a console, and run "ant -buildfile build.xml -Dplat_name=linux_64" * Open up a console, and run "ant -buildfile build.xml -Dplat_name=linux_64"

View File

@ -1 +1 @@
custom_wikis update Command-Line/dumps