Skip to content

Commit

Permalink
Merge pull request oracle#942 from vladak/parents
Browse files Browse the repository at this point in the history
display table with project-repository mappings on front page
  • Loading branch information
Vladimir Kotal committed May 21, 2015
2 parents eb5bdfe + 8882736 commit 2a52c4e
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/org/opensolaris/opengrok/configuration/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public boolean hasTabSizeSetting() {
*/
public static Project getProject(String path) {
Project ret = null;
String lpath=path;
String lpath = path;
if (File.separatorChar != '/') {
lpath = path.replace(File.separatorChar, '/');
}
Expand Down
8 changes: 7 additions & 1 deletion web/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ include file="menu.jspf"
include file="index_body.html"
%></div>
%>
<%@
include file="repos.jspf"
%>
</div>
<%
}
/* ---------------------- index.jsp end --------------------- */
Expand Down
14 changes: 5 additions & 9 deletions web/index_body.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p>
<b>OpenGrok - a "wicked fast" source browser!</b></p>
<b>OpenGrok - a "wicked fast" source browser</b></p>

<p>
This is the front page of your <a
href="xref/">browsable and searchable source tree</a> (<a
href="xref/">xref/</a>).</p>
This is the front page of your
<a href="xref/">browsable</a> and searchable source tree.
</p>

<p>
To setup and configure OpenGrok please refer to
Expand All @@ -17,8 +17,4 @@
information about your source tree and its organization, with direct
links to key parts of code base.
</p>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
120 changes: 120 additions & 0 deletions web/repos.jspf
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<%--
$Id$

CDDL HEADER START

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

See LICENSE.txt included in this distribution for the specific
language governing permissions and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at LICENSE.txt.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]

CDDL HEADER END

Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.

--%>
<%@page import="java.util.Collections"%>
<%@page import="java.util.TreeMap"%>
<%@page import="java.util.Comparator"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.io.File"%>
<%@page import="org.opensolaris.opengrok.configuration.RuntimeEnvironment"%>
<%@page import="org.opensolaris.opengrok.history.RepositoryInfo"%>
<%@page import="org.opensolaris.opengrok.history.Repository"%>
<%@page import="org.opensolaris.opengrok.web.Util"%>
<%@page import="org.opensolaris.opengrok.configuration.Project"%>
<%@page import="java.util.List"%>
<%@page import="org.opensolaris.opengrok.web.PageConfig"%>
<%
{
Comparator<Project> comparatorProj = new Comparator<Project>() {
public int compare(Project p1, Project p2) {
return p1.getDescription().compareTo(p2.getDescription());
}
};

Comparator<RepositoryInfo> comparatorRepo = new Comparator<RepositoryInfo>() {
public int compare(RepositoryInfo r1, RepositoryInfo r2) {
return r1.getDirectoryName().compareTo(r2.getDirectoryName());
}
};

List<Project> projects = cfg.getEnv().getProjects();
if (projects.size() > 0) {
// Create structure for mapping a project to list of related repositories.
RuntimeEnvironment env = cfg.getEnv();
TreeMap<Project, ArrayList<RepositoryInfo>> map =
new TreeMap<Project, ArrayList<RepositoryInfo>>(comparatorProj);
for (RepositoryInfo r: env.getRepositories()) {
Project proj;
String repoPath = env.getPathRelativeToSourceRoot(
new File(r.getDirectoryName()), 0);
if ((proj = Project.getProject(repoPath)) != null) {
ArrayList<RepositoryInfo> values = map.get(proj);
if (values == null) {
values = new ArrayList<RepositoryInfo>();
map.put(proj, values);
}
values.add(r);
}
}

// Print table of project-repository mappings.
%>
<table>
<tr>
<td><b>Project</b></td>
<td><b>SCM type</b></td>
<td><b>Parent (branch)</b></td>
</tr>
<%
Iterator<Project> keySetIterator = map.keySet().iterator();
while (keySetIterator.hasNext()) {
Project proj = keySetIterator.next();
ArrayList<RepositoryInfo> repos = map.get(proj);
String projDesc = proj.getDescription();
Integer cnt = 0;
Collections.sort(repos, comparatorRepo);
for (RepositoryInfo ri : repos) {
if (cnt != 0) {
projDesc = "";
}
%>
<tr><td><%= Util.htmlize(projDesc) %></td><%
String parent = ri.getParent();
if (parent == null) {
parent = "N/A";
}
String type = ri.getType();
if (type == null) {
type = "N/A";
}
String branch = ri.getBranch();
if (branch == null) {
branch = "N/A";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%></tr><%
cnt++;
}
}
%>
</table> <%
}
}
%>
<br/>
<br/>

0 comments on commit 2a52c4e

Please sign in to comment.