1 <%@ page import="java.io.*, java.util.*, org.openisis.*"
4 // need at least Field.html
5 static File _dir ; // have no reliable ServletConfig before init
8 static synchronized void refresh ( ServletContext a ) throws IOException {
10 _dir = new File( a.getRealPath("doc") );
11 files = _dir.list( new FilenameFilter() {
12 public boolean accept( File _dir, String name ) {
13 return name.endsWith( ".txt" );
17 timestamp = _dir.lastModified();
20 // mini wiki-style doc
21 static String mikidoc ( Writer o, BufferedReader in )
27 boolean br = false; // break on any line
28 boolean code = false; // code mode
29 while ( null != (l = in.readLine()) ) {
32 char c = 0 == len ? 0 : l.charAt(0);
33 int tab = 1 < len && '\t' == l.charAt(1) ? 2 : 1;
34 if ( code && '$' != c )
40 case '$': // toggle code
41 l = (code = !code) ? "<pre>" : "</pre>";
44 String bg = "#CCCCCC";
46 if ( 1==tab && 2 < len && ' ' != l.charAt(1) ) { /* make anchor */
47 int i = l.indexOf( '\t' );
50 anchor = "<a name=\""+l.substring(1,i)+"\"> </a>";
53 l = "</td></tr><tr><td bgcolor=\""+bg+"\"><b>"
54 +anchor+l.substring(tab)
55 +"</b></td></tr><tr><td align=\"justify\">";
58 if ( l.startsWith("---") ) { // rule
63 l = (inli ? "</li>" : "<ul>") + "<li>" + l.substring(tab);
64 if ( 40 > len ) // break after short heading
68 case '\t': // indented
69 isli = inli; // continue list item, if any
74 isli = inli; // dont't break lists on links
75 int t = l.indexOf('\t',tab);
78 ref = name = l.substring(tab).trim();
80 ref = l.substring(tab,t).trim();
81 name = l.substring(t+1).trim();
83 l = "<a href=\""+ref+"\">"+name+"</a>";
86 if ( l.startsWith("...") ) { // continued
87 notes = l.substring(3).trim();
99 if ( br && ! l.endsWith( "<br>" ) )
108 static String mikidoc ( Writer o, String file )
111 file = _dir+File.separator+file;
113 return mikidoc( o, new BufferedReader( new InputStreamReader(
114 new FileInputStream( file ) ) ) );
115 } catch (IOException e) {
116 o.write( "<!-- schnurps -->" );
122 if ( null == _dir || timestamp != _dir.lastModified() )
123 refresh( application );
126 String file = request.getParameter("file")+".txt";
127 boolean sides = null == request.getParameter("print");
129 int f = files.length;
130 while ( 0 < f-- && !files[f].equals(file) )
132 file = 0 > f ? "OverView.txt" : files[f];
133 name = file.substring( 0, file.length()-4 );
136 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
137 <title>OpenIsis - <%=name%></title>
138 <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
140 <body bgcolor="#FFFFFF"
141 marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
143 <table width="100%" cellpadding="0" cellspacing="0"
144 marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" border="0">
146 <%-- left: the index --%>
147 <td valign="top" width="160">
148 <table border="0" cellspacing="5" width="100%" cols="1">
151 <% mikidoc( out, ".index" ); %>
153 <a href="<%=name%>?print=">print</a><br>
154 <a href="/doc/<%=file%>">plaintext</a>
159 <%-- middle: the content --%>
162 <table border="0" cellspacing="5" width="100%" cols="1">
164 <td valign="top" bgcolor="#000000"><font color="#FFFFFF"><b>
170 <% right = mikidoc( out, file ); %>
176 if ( null != right ) {
178 <%-- right: notes --%>
180 <td valign="top" width="25%">
181 <table border="0" cellspacing="5" width="100%" cols="1">
183 <td valign="top" bgcolor="#000000"><font color="#FFFFFF"><b>
189 <% mikidoc( out, right+".txt" ); %>
201 $Revision: 1.6 $ last changed $Date: 2003/01/06 19:54:29 $ by $Author: kripke $