-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.jsp
81 lines (75 loc) · 2.31 KB
/
menu.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ page import="alix.web.JspTools" %>
<%!
static public enum Tab {
lem("Lemmatiser", "lem.jsp", "Fréquences par mots", new String[]{ }) {
},
/*
wordnet("Réseau", "wordnet.jsp", "Réseaux de mots", new String[]{"q", "book", "cat", "right", "left"}) {
},
books("Livres", "books.jsp", "Fréquences par livres", new String[]{"q"}) {
},
chapters("Chapitres", "chapters.jsp", "Fréquences par livres", new String[]{"q"}) {
},
kwic("Concordance", "kwic.jsp", "Recherche de mot", new String[]{"q", "book"}) {
},
doc("Liseuse", "doc.jsp", "Lire un texte", new String[]{"id", "q"}) {
},
*/
;
final public String label;
final public String href;
final public String hint;
final public String[] pars;
private Tab(final String label, final String href, final String hint, final String[] pars) {
this.label = label ;
this.href = href;
this.hint = hint;
if (pars == null) this.pars = new String[0];
else this.pars = pars;
}
public static String nav(final HttpServletRequest request)
{
StringBuilder sb = new StringBuilder();
boolean first = true;
for(Tab tab:Tab.values()) {
tab.a(sb, request);
sb.append("\n");
}
return sb.toString();
}
public void a(final StringBuilder sb, final HttpServletRequest request)
{
String here = request.getRequestURI();
here = here.substring(here.lastIndexOf('/')+1);
sb.append("<a");
sb.append(" href=\"").append(this.href);
boolean first = true;
for (String par: pars) {
String value = request.getParameter(par);
if (value == null) continue;
if (first) {
first = false;
sb.append("?");
}
else {
sb.append("&");
}
sb.append(par).append("=").append(value);
}
sb.append("\"");
if (hint != null) sb.append(" title=\"").append(hint).append("\"");
sb.append(" class=\"tab");
if (this.href.equals(here)) sb.append(" selected");
else if (here.equals("") && this.href.startsWith("index")) sb.append(" selected");
sb.append("\"");
sb.append(">");
sb.append(label);
sb.append("</a>");
}
}
%>
<nav class="tabs">
<a href="." class="tab">▲ Alix</a>
<%= Tab.nav(request) %>
</nav>