X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FHtml.java;h=900fa0a1772f0ffd5ecfcaf2fecfbd8b248168a0;hb=8831d290121e3a77f535ce06d61968a26ccf172a;hp=1e960bf84978bf1125aececd6d59a47eff38f9f9;hpb=41c3bba7f6fc6f5ec1fa7fe35643c6aace94240d;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/Html.java b/src/be/nikiroo/fanfix/supported/Html.java deleted file mode 100644 index 1e960bf..0000000 --- a/src/be/nikiroo/fanfix/supported/Html.java +++ /dev/null @@ -1,74 +0,0 @@ -package be.nikiroo.fanfix.supported; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import be.nikiroo.fanfix.Instance; - -/** - * Support class for HTML files created with this program (as we need some - * metadata available in those we create). - * - * @author niki - */ -class Html extends InfoText { - @Override - public String getSourceName() { - return "html"; - } - - @Override - protected boolean supports(URL url) { - File txt = getTxt(url); - return txt != null && txt.exists(); - } - - @Override - public URL getCanonicalUrl(URL source) { - File txt = getTxt(source); - if (txt != null) { - try { - source = txt.toURI().toURL(); - } catch (MalformedURLException e) { - Instance.getTraceHandler().error( - new IOException("Cannot convert the right URL for " - + source, e)); - } - } else { - Instance.getTraceHandler().error( - new IOException("Cannot find the right URL for " + source)); - } - - return source; - } - - /** - * Return the associated TXT source file if it can be found. - * - * @param source - * the source URL - * - * @return the supported source text file or NULL - */ - private static File getTxt(URL source) { - try { - File fakeFile = new File(source.toURI()); - if (fakeFile.getName().equals("index.html")) { // "story/index.html" - fakeFile = new File(fakeFile.getParent()); // -> "story/" - } - - if (fakeFile.isDirectory()) { // "story/" - fakeFile = new File(fakeFile, fakeFile.getName() + ".txt"); // "story/story.txt" - } - - if (fakeFile.getName().endsWith(".txt")) { - return fakeFile; - } - } catch (Exception e) { - } - - return null; - } -}