<snapshotRepository>
<id>svjatoslav.eu</id>
<name>svjatoslav.eu</name>
- <url>scp://svjatoslav.eu:7022/var/www/maven</url>
+ <url>scp://svjatoslav.eu/var/www/svjatoslav.eu/maven</url>
</snapshotRepository>
<repository>
<id>svjatoslav.eu</id>
<name>svjatoslav.eu</name>
- <url>scp://svjatoslav.eu:7022/var/www/maven</url>
+ <url>scp://svjatoslav.eu/var/www/svjatoslav.eu/maven</url>
</repository>
</distributionManagement>
<scm>
- <connection>scm:git:ssh://git@svjatoslav.eu:7022/home/git/repositories/svjatoslav_commons.git</connection>
- <developerConnection>scm:git:ssh://git@svjatoslav.eu:7022/home/git/repositories/svjatoslav_commons.git</developerConnection>
+ <connection>scm:git:ssh://git@svjatoslav.eu/home/git/repositories/svjatoslav_commons.git</connection>
+ <developerConnection>scm:git:ssh://git@svjatoslav.eu/home/git/repositories/svjatoslav_commons.git</developerConnection>
</scm>
</project>
--- /dev/null
+package eu.svjatoslav.commons.network.navigation;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class Navigation {
+
+ private NavigationItem rootNavigationItem;
+
+ private NavigationItem defaultNavigationItem;
+
+ public NavigationItem getRootNavigationItem() {
+ return rootNavigationItem;
+ }
+
+ public NavigationItem getSelectedItem(final String requestUrl) {
+
+ try {
+ final String requestPath = new URL(requestUrl).getPath();
+
+ for (final NavigationItem item : rootNavigationItem.subElements)
+ if (item.matchesUrl(requestPath))
+ return item;
+ } catch (final MalformedURLException e) {
+ System.out.println("Cannot handle URL: " + requestUrl);
+ e.printStackTrace();
+ }
+
+ return defaultNavigationItem;
+ }
+
+ public String getTopMenu(final String requestUrl) {
+
+ final NavigationItem selectedItem = getSelectedItem(requestUrl);
+ final StringBuffer result = new StringBuffer();
+
+ result.append("<div id=\"topNavigation\">");
+
+ for (final NavigationItem item : rootNavigationItem.getSubElements()) {
+
+ if (item == selectedItem)
+ result.append("<a class=\"selected\" href=\"" + item.getLink()
+ + "\">");
+ else
+ result.append("<a href=\"" + item.getLink() + "\">");
+
+ result.append(item.getTitle());
+ result.append("</a>");
+ }
+
+ result.append("</div>");
+
+ return result.toString();
+ }
+
+ public void setRootNavigationItem(final NavigationItem rootNavigationItem) {
+ this.rootNavigationItem = rootNavigationItem;
+ }
+
+}
--- /dev/null
+package eu.svjatoslav.commons.network.navigation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.svjatoslav.commons.string.WildCardMatcher;
+
+public class NavigationItem {
+
+ private final String title;
+ private final String link;
+ private final String matchingWildcard;
+
+ ArrayList<NavigationItem> subElements = new ArrayList<NavigationItem>();
+
+ public NavigationItem(final String title, final String link) {
+ this.title = title;
+ this.link = link;
+ matchingWildcard = link;
+ }
+
+ public NavigationItem(final String title, final String link,
+ final String wildcard) {
+ this.title = title;
+ this.link = link;
+ matchingWildcard = wildcard;
+ }
+
+ public void addSubNavigation(final NavigationItem item) {
+ subElements.add(item);
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public List<NavigationItem> getSubElements() {
+ return subElements;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public boolean matchesUrl(final String url) {
+
+ return WildCardMatcher.match(url, matchingWildcard);
+
+ }
+
+}