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 public URL
getCanonicalUrl(URL source
) {
37 File txt
= getTxt(source
);
40 source
= txt
.toURI().toURL();
41 } catch (MalformedURLException e
) {
42 Instance
.getTraceHandler().error(
43 new IOException("Cannot convert the right URL for "
52 * Return the associated TXT source file if it can be found.
57 * @return the supported source text file or NULL
59 private static File
getTxt(URL source
) {
61 File fakeFile
= new File(source
.toURI());
62 if (fakeFile
.getName().equals("index.html")) { // "story/index.html"
63 fakeFile
= new File(fakeFile
.getParent()); // -> "story/"
66 if (fakeFile
.isDirectory()) { // "story/"
67 fakeFile
= new File(fakeFile
, fakeFile
.getName() + ".txt"); // "story/story.txt"
70 if (fakeFile
.getName().endsWith(".txt")) {
73 } catch (Exception e
) {