X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fmeviz%2Fhtmlindexer%2FUtils.java;h=82c4b580df9c5e1961fe33c2bbb288c46966974b;hb=567410640f4e0428caf9de9fc83df4c73f0e5067;hp=69c1c43765aa1832d68f9c46e4296afe4902f5b4;hpb=891ecca562e87bb5d0ab1e49eea566c15fe91c6d;p=meviz.git diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java index 69c1c43..82c4b58 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java @@ -1,26 +1,27 @@ /* * Meviz - Various tools collection to work with multimedia. - * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation. - */ + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. +*/ package eu.svjatoslav.meviz.htmlindexer; import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout; -import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.*; -import java.net.URLEncoder; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.util.HashSet; import java.util.zip.CRC32; -public class Utils { +import static javax.imageio.ImageIO.read; - private static final String UTF_8 = "UTF-8"; +public class Utils { private static File lastLoadedFile; private static BufferedImage lastLoadedBufferedImage; @@ -37,7 +38,7 @@ public class Utils { return lastLoadedBufferedImage; System.out.println("Loading image: " + file.getPath()); - lastLoadedBufferedImage = ImageIO.read(file); + lastLoadedBufferedImage = read(file); lastLoadedFile = file; if (lastLoadedBufferedImage == null) { @@ -118,14 +119,23 @@ public class Utils { return isMevizFile; } + /** + * TODO: URL path component is encoded differently from URL query parameter. + * Also some URL encoding might work for HTML on local filesystem, while other + * stuff works for web. Things must be cleared up here. Currently they are mixed and + * hacked together. + */ public static String urlEncode(String string) { if (string.startsWith("./")) string = string.substring(2); - try { - return URLEncoder.encode(string, UTF_8).replace("+", "%20"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } + // TODO: get rid of UrlParamEncoder. + return UrlParamEncoder.encode(string); + // +// try { +// return URLEncoder.encode(string, UTF_8).replace("+", "%20"); +// } catch (UnsupportedEncodingException e) { +// throw new RuntimeException(e); +// } } }