<%--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  --%>

<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>

<p>
  <archiva:groupIdLink var="${model.groupId}" includeTop="true" />
  
  <c:set var="url">
    <ww:url action="browseArtifact" namespace="/">
      <ww:param name="groupId" value="%{'${model.groupId}'}"/>
      <ww:param name="artifactId" value="%{'${model.artifactId}'}"/>
    </ww:url>
  </c:set>
  <a href="${url}">${model.artifactId}</a> /
  <strong>${version}</strong>

  <%-- TODO: new versions?
    (<strong class="statusFailed">Newer version available:</strong>
    <a href="artifact.html">2.0.3</a>)
  --%>
</p>

<c:if test="${!empty(model.description)}">
  <blockquote>${model.description}</blockquote>
</c:if>

<table class="infoTable">
  <tr>
    <th>Group ID</th>
    <td>${model.groupId}</td>
  </tr>
  <tr>
    <th>Artifact ID</th>
    <td>${model.artifactId}</td>
  </tr>
  <tr>
    <th>Version</th>
    <td>${model.version}</td>
  </tr>
  <tr>
    <th>Packaging</th>
    <td><code>${model.packaging}</code></td>
  </tr>
  <%-- TODO: derivatives
    <tr>
      <th>Derivatives</th>
      <td>
        <a href="#">Source</a>
        |
        <a href="#">Javadoc</a>
      </td>
    </tr>
  --%>
  <c:if test="${model.parentProject != null}">
    <tr>
      <th>Parent</th>
      <td>
          ${model.parentProject.groupId} ${model.parentProject.artifactId} ${model.parentProject.version}
        <c:set var="url">
          <ww:url action="showArtifact" namespace="/">
            <ww:param name="groupId" value="%{'${model.parentProject.groupId}'}"/>
            <ww:param name="artifactId" value="%{'${model.parentProject.artifactId}'}"/>
            <ww:param name="version" value="%{'${model.parentProject.version}'}"/>
          </ww:url>
        </c:set>
        (<a href="${url}">View</a>)
      </td>
    </tr>
  </c:if>
  <%-- TODO: deployment timestamp
    <tr>
      <th>Deployment Date</th>
      <td>
        15 Jan 2006, 20:38:00 +1000
      </td>
    </tr>
  --%>
  <%-- TODO: origin
    <tr>
      <th>Origin</th>
      <td>
        <a href="TODO">Apache Repository</a>
      </td>
    </tr>
  --%>
</table>

<c:if test="${model.packaging != 'pom'}">
  <h2>POM Dependency Snippet</h2>
<pre class="pom">
    &lt;dependency>
      &lt;groupId>${model.groupId}&lt;/groupId>
      &lt;artifactId>${model.artifactId}&lt;/artifactId>     
      &lt;version>${version}&lt;/version><c:if test="${model.packaging != 'jar'}">
      &lt;type>${model.packaging}&lt;/type></c:if>
    &lt;/dependency>
</pre>
</c:if>

<c:if test="${!empty(model.url) || model.organization != null || !empty(model.licenses)
    || model.issueManagement != null || model.ciManagement != null}">

  <h2>Other Details</h2>
  <table class="infoTable">
    <c:if test="${!empty(model.url)}">
      <tr>
        <th>URL</th>
        <td>
          <a href="${model.url}">${model.url}</a>
        </td>
      </tr>
    </c:if>
    <c:if test="${model.organization != null}">
      <tr>
        <th>Organisation</th>
        <td>
          <c:choose>
            <c:when test="${model.organization != null}">
              <a href="${model.organization.url}">${model.organization.name}</a>
            </c:when>
            <c:otherwise>
              ${model.organization.name}
            </c:otherwise>
          </c:choose>
        </td>
      </tr>
    </c:if>
    <c:if test="${!empty(model.licenses)}">
      <c:forEach items="${model.licenses}" var="license">
        <tr>
          <th>License</th>
          <td>
            <c:choose>
              <c:when test="${!empty(license.url)}">
                <a href="${license.url}">${license.name}</a>
              </c:when>
              <c:otherwise>
                ${license.name}
              </c:otherwise>
            </c:choose>
          </td>
        </tr>
      </c:forEach>
    </c:if>
    <c:if test="${model.issueManagement != null}">
      <tr>
        <th>Issue Tracker</th>
        <td>
          <c:choose>
            <c:when test="${!empty(model.issueManagement.url)}">
              <a href="${model.issueManagement.url}">${model.issueManagement.system}</a>
            </c:when>
            <c:otherwise>
              ${model.issueManagement.system}
            </c:otherwise>
          </c:choose>
        </td>
      </tr>
    </c:if>
    <c:if test="${model.ciManagement != null}">
      <tr>
        <th>Continuous Integration</th>
        <td>
          <c:choose>
            <c:when test="${!empty(model.ciManagement.url)}">
              <a href="${model.ciManagement.url}">${model.ciManagement.system}</a>
            </c:when>
            <c:otherwise>
              ${model.ciManagement.system}
            </c:otherwise>
          </c:choose>
        </td>
      </tr>
    </c:if>
  </table>
</c:if>

<c:if test="${model.scm != null}">
  <h2>SCM</h2>
  <table class="infoTable">
    <c:if test="${!empty(model.scm.connection)}">
      <tr>
        <th>Connection</th>
        <td>
          <code>${model.scm.connection}</code>
        </td>
      </tr>
    </c:if>
    <c:if test="${!empty(model.scm.developerConnection)}">
      <tr>
        <th>Dev. Connection</th>
        <td>
          <code>${model.scm.developerConnection}</code>
        </td>
      </tr>
    </c:if>
    <c:if test="${!empty(model.scm.url)}">
      <tr>
        <th>Viewer</th>
        <td>
          <a href="${model.scm.url}">${model.scm.url}</a>
        </td>
      </tr>
    </c:if>
  </table>
</c:if>

