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
) {
24 File txt
= getTxt(url
);
25 return txt
!= null && txt
.exists();
29 public URL
getCanonicalUrl(URL source
) {
30 File txt
= getTxt(source
);
33 source
= txt
.toURI().toURL();
34 } catch (MalformedURLException e
) {
35 Instance
.getTraceHandler().error(
36 new IOException("Cannot convert the right URL for "
40 Instance
.getTraceHandler().error(
41 new IOException("Cannot find the right URL for " + source
));
48 * Return the associated TXT source file if it can be found.
53 * @return the supported source text file or NULL
55 private static File
getTxt(URL source
) {
57 File fakeFile
= new File(source
.toURI());
58 if (fakeFile
.getName().equals("index.html")) { // "story/index.html"
59 fakeFile
= new File(fakeFile
.getParent()); // -> "story/"
62 if (fakeFile
.isDirectory()) { // "story/"
63 fakeFile
= new File(fakeFile
, fakeFile
.getName() + ".txt"); // "story/story.txt"
66 if (fakeFile
.getName().endsWith(".txt")) {
69 } catch (Exception e
) {