Removed
[jalview.git] / utils / help2Website.java
1 import java.io.*;\r
2 import java.util.*;\r
3 \r
4 public class help2Website\r
5 {\r
6 \r
7         public static void main(String [] args)\r
8         {\r
9                 try{\r
10                         Hashtable targets = new Hashtable();\r
11 \r
12                         File toc = new File("helpTOC.xml");\r
13                         File jhm = new File("help.jhm");\r
14 \r
15                         BufferedReader in = new BufferedReader(new FileReader(jhm));\r
16 \r
17                         PrintWriter out = new PrintWriter(new FileWriter("helpTOC.html"));\r
18                         out.println("<html><head></head><title>Jalview - Help </title></head>\n"\r
19                         +"<body bgcolor=#F1F1F1>\n"\r
20                         +"<p><center><strong>Contents</strong></center></p>\n");\r
21 \r
22                         String line;\r
23 \r
24                         StringTokenizer st;\r
25                         StringBuffer indent = new StringBuffer();\r
26                         String target, url, text;\r
27                         while( (line = in.readLine()) != null)\r
28                         {\r
29                                 if(line.indexOf("target")==-1)\r
30                                         continue;\r
31 \r
32                                 st = new StringTokenizer(line, "\"");\r
33                                 st.nextToken(); //<mapID target="\r
34 \r
35                                 target = st.nextToken();\r
36                                 st.nextToken(); //" url="\r
37 \r
38                                 url = st.nextToken();\r
39                                 targets.put(target, url);\r
40                         }\r
41 \r
42                         in = new BufferedReader(new FileReader(toc));\r
43                         while( (line = in.readLine()) != null)\r
44                         {\r
45                                 if(line.indexOf("</tocitem>")!=-1)\r
46                                         indent.setLength(indent.length()-18);\r
47 \r
48                                 if(line.indexOf("<tocitem")==-1)\r
49                                         continue;\r
50 \r
51                                 st = new StringTokenizer(line, "\"");\r
52                                 st.nextToken();\r
53 \r
54                                 text = st.nextToken();\r
55                                 st.nextToken();\r
56 \r
57                                 target = st.nextToken();\r
58 \r
59                                 if(targets.get(target)!=null)\r
60                                         out.println("<br>"+indent+"<a href=\""\r
61                                                         + targets.get(target)\r
62                                                         +"\" target=bodyframe>"\r
63                                                         +text\r
64                                                         +"</a>");\r
65                                 else\r
66                                         out.println("<br>"+indent+text);\r
67 \r
68 \r
69                                 if(line.indexOf("/>")==-1)\r
70                                         indent.append("&nbsp;&nbsp;&nbsp;");\r
71 \r
72                         }\r
73 \r
74                         out.println("</body>\n</html>");\r
75 \r
76 \r
77                         out.close();\r
78 \r
79                 }\r
80 \r
81                 catch(Exception ex)\r
82                 {\r
83                         ex.printStackTrace();\r
84 \r
85                         System.out.println("Usage: move to Help directory. help2Website will read"\r
86                         +"\nhelpTOC.xml and help.jhm producing output helpTOC.html");\r
87                 }\r
88         }\r
89 \r
90 \r
91 }