1 package be
.nikiroo
.fanfix
.supported
;
4 import java
.io
.IOException
;
5 import java
.net
.MalformedURLException
;
6 import java
.net
.URISyntaxException
;
9 import be
.nikiroo
.fanfix
.Instance
;
12 * Support class for HTML files created with this program (as we need some
13 * metadata available in those we create).
17 class Html
extends InfoText
{
19 public String
getSourceName() {
24 protected boolean supports(URL url
) {
26 File file
= new File(url
.toURI());
27 if (file
.getName().equals("index.html")) {
28 file
= file
.getParentFile();
31 file
= new File(file
, file
.getName());
33 return super.supports(file
.toURI().toURL());
34 } catch (URISyntaxException e
) {
35 } catch (MalformedURLException e
) {
42 public URL
getCanonicalUrl(URL source
) {
45 File fakeFile
= new File(source
.toURI());
46 if (fakeFile
.getName().equals("index.html")) { // "story/index.html"
47 fakeFile
= new File(fakeFile
.getParent()); // -> "story/"
50 if (fakeFile
.isDirectory()) { // "story/"
51 fakeFile
= new File(fakeFile
, fakeFile
.getName() + ".txt"); // "story/story.txt"
54 return fakeFile
.toURI().toURL();
55 } catch (Exception e
) {
56 Instance
.getTraceHandler().error(
57 new IOException("Cannot find the right URL for " + source
,