update author list in license for (JAL-826)
[jalview.git] / utils / help2Website.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 import java.io.*;
19 import java.util.*;
20
21 public class help2Website
22 {
23
24         public static void main(String [] args)
25         {
26                 String line = "";
27                 try{
28                         Hashtable targets = new Hashtable();
29
30                         File toc = new File("helpTOC.xml");
31                         File jhm = new File("help.jhm");
32
33                         BufferedReader in = new BufferedReader(new FileReader(jhm));
34
35                         PrintWriter out = new PrintWriter(new FileWriter("helpTOC.html"));
36                         out.println("<html><head><title>Jalview - Help </title></head>\n"
37                         +"<body bgcolor=#F1F1F1>\n"
38                         +"<p><center><strong>Contents</strong></center></p>\n");
39
40
41                         StringTokenizer st;
42                         StringBuffer indent = new StringBuffer();
43                         String target, url, text;
44                         while( (line = in.readLine()) != null)
45                         {
46                                 if(line.indexOf("target")==-1)
47                                         continue;
48
49
50                                 st = new StringTokenizer(line, "\"");
51                                 st.nextToken(); //<mapID target="
52
53                                 target = st.nextToken();
54                                 st.nextToken(); //" url="
55
56                                 url = st.nextToken();
57                                 targets.put(target, url);
58                         }
59
60                         in = new BufferedReader(new FileReader(toc));
61                         while( (line = in.readLine()) != null)
62                         {
63                                 if(line.indexOf("</tocitem>")!=-1)
64                                         indent.setLength(indent.length()-18);
65
66                                 if(line.indexOf("<tocitem")==-1)
67                                         continue;
68
69                                 st = new StringTokenizer(line, "\"");
70                                 st.nextToken();
71
72                                 text = st.nextToken();
73                                 st.nextToken();
74
75                                 target = st.nextToken();
76
77                                 if(targets.get(target)!=null)
78                                 {
79                                         out.println("<br>"+indent+"<a href=\""
80                                                         + targets.get(target)
81                                                         +"\" target=bodyframe>"
82                                                         +text
83                                                         +"</a>");
84                                 }
85                                 else
86                                         out.println("<br>"+indent+text);
87
88
89                                 if(line.indexOf("/>")==-1)
90                                         indent.append("&nbsp;&nbsp;&nbsp;");
91
92                         }
93                         // Add Googletracker.
94
95
96                         out.close();
97
98                 }
99
100                 catch(Exception ex)
101                 {
102
103                         ex.printStackTrace();
104
105                         System.out.println("\n"+line+"\n");
106
107                         System.out.println("Usage: move to Help directory. help2Website will read"
108                         +"\nhelpTOC.xml and help.jhm producing output helpTOC.html");
109                 }
110         }
111
112
113 }