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 protected boolean supports(URL url
) {
20 File txt
= getTxt(url
);
22 return super.supports(txt
.toURI().toURL());
24 } catch (MalformedURLException e
) {
31 protected File
getInfoFile() {
32 File source
= getSourceFile();
33 if ("index.html".equals(source
.getName())) {
34 source
= source
.getParentFile();
37 String src
= source
.getPath();
38 File infoFile
= new File(src
+ ".info");
39 if (!infoFile
.exists() && src
.endsWith(".txt")) {
41 src
.substring(0, src
.length() - ".txt".length()) + ".info");
48 public URL
getCanonicalUrl(URL source
) {
49 File txt
= getTxt(source
);
52 source
= txt
.toURI().toURL();
53 } catch (MalformedURLException e
) {
54 Instance
.getTraceHandler().error(
55 new IOException("Cannot convert the right URL for "
64 * Return the associated TXT source file if it can be found.
69 * @return the supported source text file or NULL
71 private static File
getTxt(URL source
) {
73 File fakeFile
= new File(source
.toURI());
74 if (fakeFile
.getName().equals("index.html")) { // "story/index.html"
75 fakeFile
= new File(fakeFile
.getParent()); // -> "story/"
78 if (fakeFile
.isDirectory()) { // "story/"
79 fakeFile
= new File(fakeFile
, fakeFile
.getName() + ".txt"); // "story/story.txt"
82 if (fakeFile
.getName().endsWith(".txt")) {
85 } catch (Exception e
) {