1 package be
.nikiroo
.fanfix
.supported
;
4 import java
.io
.IOException
;
5 import java
.net
.MalformedURLException
;
8 import be
.nikiroo
.fanfix
.Instance
;
11 * Support class for HTML files created with this program (as we need some
12 * metadata available in those we create).
16 class Html
extends InfoText
{
18 public String
getSourceName() {
23 protected boolean supports(URL url
) {
25 File txt
= getTxt(url
);
27 return super.supports(txt
.toURI().toURL());
29 } catch (MalformedURLException e
) {
36 protected File
getInfoFile() {
37 File source
= getSourceFile();
38 if ("index.html".equals(source
.getName())) {
39 source
= source
.getParentFile();
42 String src
= source
.getPath();
43 File infoFile
= new File(src
+ ".info");
44 if (!infoFile
.exists() && src
.endsWith(".txt")) {
46 src
.substring(0, src
.length() - ".txt".length()) + ".info");
53 public URL
getCanonicalUrl(URL source
) {
54 File txt
= getTxt(source
);
57 source
= txt
.toURI().toURL();
58 } catch (MalformedURLException e
) {
59 Instance
.getTraceHandler().error(
60 new IOException("Cannot convert the right URL for "
69 * Return the associated TXT source file if it can be found.
74 * @return the supported source text file or NULL
76 private static File
getTxt(URL source
) {
78 File fakeFile
= new File(source
.toURI());
79 if (fakeFile
.getName().equals("index.html")) { // "story/index.html"
80 fakeFile
= new File(fakeFile
.getParent()); // -> "story/"
83 if (fakeFile
.isDirectory()) { // "story/"
84 fakeFile
= new File(fakeFile
, fakeFile
.getName() + ".txt"); // "story/story.txt"
87 if (fakeFile
.getName().endsWith(".txt")) {
90 } catch (Exception e
) {