X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FHtml.java;h=fffbcd7f0ad6507ccb026f7fd49fcc83aa987b1a;hp=036479d21758797c403bbf17686222880832f157;hb=a4143cd74a90e17a811a4581cbeb213fed1f6304;hpb=d649ced99f929e1fcf2421a2357f5fdb8d2fcfe1 diff --git a/src/be/nikiroo/fanfix/supported/Html.java b/src/be/nikiroo/fanfix/supported/Html.java index 036479d..fffbcd7 100644 --- a/src/be/nikiroo/fanfix/supported/Html.java +++ b/src/be/nikiroo/fanfix/supported/Html.java @@ -1,17 +1,10 @@ package be.nikiroo.fanfix.supported; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; -import java.util.List; -import java.util.Map.Entry; - -import be.nikiroo.fanfix.data.MetaData; -import be.nikiroo.utils.MarkableFileInputStream; /** * Support class for HTML files created with this program (as we need some @@ -20,8 +13,6 @@ import be.nikiroo.utils.MarkableFileInputStream; * @author niki */ class Html extends InfoText { - private URL fakeSource; - @Override public String getSourceName() { return "html"; @@ -43,41 +34,20 @@ class Html extends InfoText { } @Override - protected MetaData getMeta(URL source, InputStream in) throws IOException { - return super.getMeta(fakeSource, in); - } - - @Override - protected String getDesc(URL source, InputStream in) throws IOException { - return super.getDesc(fakeSource, in); - } - - @Override - protected List> getChapters(URL source, InputStream in) - throws IOException { - return super.getChapters(fakeSource, in); - } - - @Override - protected String getChapterContent(URL source, InputStream in, int number) - throws IOException { - return super.getChapterContent(fakeSource, in, number); - } - - @Override - protected InputStream openInput(URL source) throws IOException { - try { - File fakeFile = new File(source.toURI()); // "story/index.html" - fakeFile = new File(fakeFile.getParent()); // "story" - fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story" - fakeSource = fakeFile.toURI().toURL(); - return new MarkableFileInputStream(new FileInputStream(fakeFile)); - } catch (URISyntaxException e) { - throw new IOException( - "file not supported (maybe not created with this program or corrupt)", - e); - } catch (MalformedURLException e) { - throw new IOException("file not supported (bad URL)", e); + public URL getCanonicalUrl(URL source) throws IOException { + if (source.toString().endsWith(File.separator + "index.html")) { + try { + File fakeFile = new File(source.toURI()); // "story/index.html" + fakeFile = new File(fakeFile.getParent()); // "story" + fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story" + return fakeFile.toURI().toURL(); + } catch (URISyntaxException e) { + throw new IOException( + "file not supported (maybe not created with this program or corrupt)", + e); + } } + + return source; } }