]> WPIA git - gigi.git/blob - src/club/wpia/gigi/pages/PolicyIndex.java
upd: keep host names scalable and configurable
[gigi.git] / src / club / wpia / gigi / pages / PolicyIndex.java
1 package club.wpia.gigi.pages;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.PrintWriter;
6
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 public class PolicyIndex extends Page {
11
12     public PolicyIndex() {
13         super("SomeCA.org Policies");
14     }
15
16     File root = new File("static/www/policy");
17
18     public static final String DEFAULT_PATH = "/policy";
19
20     @Override
21     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
22         PrintWriter out = resp.getWriter();
23         out.println("<ul>");
24         File[] files = root.listFiles();
25         if (files != null) {
26             for (File f : files) {
27                 String name = f.getName();
28                 if ( !name.endsWith(".html")) {
29                     continue;
30                 }
31                 String display = name.replaceFirst("\\.html$", "");
32
33                 out.print("<li><a href='");
34                 out.print(name);
35                 out.print("'>");
36                 out.print(display);
37                 out.println("</a></li>");
38             }
39         }
40         out.println("</ul>");
41     }
42
43     @Override
44     public boolean needsLogin() {
45         return false;
46     }
47
48 }