marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tk...@apache.org
Subject [07/14] git commit: MARMOTTA-233: extends module configuration, a first running version
Date Thu, 16 May 2013 10:31:37 GMT
MARMOTTA-233: extends module configuration,
a first running version


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/81503abb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/81503abb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/81503abb

Branch: refs/heads/MARMOTTA-228
Commit: 81503abb7f12f9c967a568950e0a086e1d28cb06
Parents: 1a351ed
Author: tkurz <tkurz@apache.org>
Authored: Fri May 10 18:52:24 2013 +0200
Committer: tkurz <tkurz@apache.org>
Committed: Fri May 10 18:52:24 2013 +0200

----------------------------------------------------------------------
 .../core/api/templating/AdminInterfaceService.java |    3 +-
 .../platform/core/model/template/MenuItem.java     |   73 ++++++++-------
 .../core/services/modules/ModuleServiceImpl.java   |    4 +-
 .../templating/AdminTemplatingServiceImpl.java     |   22 +++--
 .../src/main/resources/config-defaults.properties  |    2 +-
 .../src/main/resources/templates/admin.ftl         |   38 +++-----
 6 files changed, 72 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/AdminInterfaceService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/AdminInterfaceService.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/AdminInterfaceService.java
index 5ec3a6c..cf4e7ff 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/AdminInterfaceService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/AdminInterfaceService.java
@@ -29,7 +29,8 @@ import javax.servlet.ServletContext;
 public interface AdminInterfaceService {
     
     public final static String PATH = "/templates/";
-    public final static String DEFAULT_REST_PATH = "doc/rest/";
+    public final static String DEFAULT_REST_PATH = "/doc/rest/";
+    public final static String DEFAULT_REST_FILE = "overview-index.html";
     public final static String DEFAULT_MENU_ICON = "icon-asterisk";
     public final static String DEFAULT_WEBSERVICE_TITLE = "Webservice";
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/template/MenuItem.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/template/MenuItem.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/template/MenuItem.java
index fd8dfe9..ee5b204 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/template/MenuItem.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/template/MenuItem.java
@@ -36,68 +36,75 @@ import static org.apache.marmotta.platform.core.model.template.MenuItemType.*;
  */
 public class MenuItem {
 
-    private boolean active;
-    private String label;
-    private String path;
-    private MenuItemType type;
+    private boolean initialized = false;
+
+    private HashMap<String,Object> properties;
     private List<MenuItem> items;
-    private String icon;
+    private MenuItemType type;
 
     public MenuItem(String label, MenuItemType type) {
+        this.properties = new HashMap<String, Object>();
         this.type = type;
-        this.label = label;
         this.items = new ArrayList<MenuItem>();
-        this.active = false;
-        this.icon = AdminInterfaceService.DEFAULT_MENU_ICON;
-    }
-
-    public String getIcon() {
-        return icon;
-    }
 
-    public void setIcon(String icon) {
-        this.icon = icon;
+        properties.put("items",items);
+        properties.put("label",label);
+        properties.put("isActive",false);
+        properties.put("icon",AdminInterfaceService.DEFAULT_MENU_ICON);
     }
 
-    public String getLabel() {
-        return label;
-    }
-
-    public String getPath() {
-        return path;
+    public HashMap<String,Object> getProperties() {
+        if(properties.get("items") != null) {
+            List<Object> os = new ArrayList<Object>();
+            for(MenuItem item : items) {
+                os.add(item.getProperties());
+            }
+            properties.put("items",os);
+        }
+        return properties;
     }
 
-    public void setPath(String path) {
-        this.path = path;
+    public void set(String name, Object value) {
+        properties.put(name,value);
     }
 
-    public List<MenuItem> getItems() {
-        return this.items;
+    public Object get(String name) {
+        return properties.get(name);
     }
 
     public void addItem(MenuItem item) {
-        this.addItem(item);
+        items.add(item);
     }
 
     public boolean setActive(String path) {
+        boolean isActive = false;
         switch(type) {
             case ROOT:
             case CONTAINER:
             case MODULE:
                 for(MenuItem item : items) {
                     if(item.setActive(path)) {
-                        active = true;
-                    } else {
-                        active = false;
+                        isActive = true;
                     }
                 }
-                return active;
+                break;
             case PAGE:
-                return active = this.path.equals(path);
+                isActive  = get("path").equals(path);
+                break;
             case WEBSERVICE:
-                return active = path.contains(AdminInterfaceService.DEFAULT_REST_PATH);
+                String s = (String)properties.get("path");
+                isActive = (
+                        path.startsWith(s.substring(0,s.lastIndexOf("/"))) &&
+                        path.contains(AdminInterfaceService.DEFAULT_REST_PATH));
+                break;
             default:
-                return false;
+                isActive = false;
         }
+        set("isActive",isActive);
+        return isActive;
+    }
+
+    public boolean isEmpty() {
+        return items.isEmpty();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java
index 4864fe1..8e4c9ab 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java
@@ -389,7 +389,7 @@ public class ModuleServiceImpl implements ModuleService {
         Configuration config = getModuleConfiguration(moduleName).getConfiguration();
         if(config != null) {
             ArrayList<HashMap<String,String>> l = new ArrayList<HashMap<String,String>>();
-            if(!config.subset("adminpage.").isEmpty()) {
+            if(!config.subset("adminpage").isEmpty()) {
                 while(config.getString("adminpage."+l.size()+".link") != null) {
                     HashMap<String,String> map = new HashMap<String, String>();
                     map.put("link",config.getString("baseurl")+config.getString("adminpage."+l.size()+".link"));
@@ -400,7 +400,7 @@ public class ModuleServiceImpl implements ModuleService {
                 for(String path : config.getStringArray("adminpages")) {
                     HashMap<String,String> map = new HashMap<String, String>();
                     map.put("link",config.getString("baseurl")+path);
-                    map.put("title",path.substring(path.lastIndexOf("/"),path.lastIndexOf(".")).replaceAll("_","
"));
+                    map.put("title",path.substring(path.lastIndexOf("/")+1,path.lastIndexOf(".")).replaceAll("_","
"));
                     l.add(map);
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java
index 247a0b4..7cc816e 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java
@@ -71,7 +71,7 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService
{
      */
     @Override
     public void init(ServletContext context) throws TemplatingException {
-    	buildMenu();
+    	menu = buildMenu();
         this.context = context;
         try {
         	 //try-run to check it from the very beginning
@@ -92,9 +92,11 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService
{
 
         if(!configurationService.getBooleanConfiguration("templating.cache.enabled",true)
&& context!=null) {
             init(context);
-            menu.setActive(path);
         }
 
+        //set active
+        menu.setActive(path);
+
         //fill data model
         Map<String, Object> datamodel = new HashMap<String,Object>();
     	for(Properties p : Properties.values()) {
@@ -105,7 +107,7 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService
{
         //end hack!!!
 
         //add menu
-        datamodel.put("MENU",menu);
+        datamodel.put("MENU",menu.getProperties());
         try {
             String s = new String(bytes);
             Matcher m = PATTERN.matcher(s);
@@ -147,24 +149,26 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService
{
             //add modules
             for(String module_string : moduleService.listSortedModules(container_string))
{
                 MenuItem module = new MenuItem(module_string, MenuItemType.MODULE);
-                module.setPath(moduleService.getModuleWeb(module_string));
-                module.setIcon(moduleService.getIcon(module_string));
+                module.set("path",moduleService.getModuleWeb(module_string));
+                if(moduleService.getIcon(module_string) != null)
+                    module.set("icon",moduleService.getIcon(module_string));
 
                 //add pages
                 for(HashMap<String,String> page_object : moduleService.getAdminPageObjects(module_string))
{
                     MenuItem page = new MenuItem(page_object.get("title"), MenuItemType.PAGE);
-                    page.setPath(page_object.get("path"));
+                    page.set("path",page_object.get("link"));
                     module.addItem(page);
                 }
 
                 //add webservice
                 if(!moduleService.getWebservices(module_string).isEmpty()) {
-                    MenuItem page = new MenuItem(DEFAULT_WEBSERVICE_TITLE, MenuItemType.MODULE);
-                    page.setPath(module.getPath()+DEFAULT_REST_PATH);
+                    MenuItem page = new MenuItem(DEFAULT_WEBSERVICE_TITLE, MenuItemType.WEBSERVICE);
+                    page.set("path",module.get("path")+DEFAULT_REST_PATH+DEFAULT_REST_FILE);
+                    module.addItem(page);
                 }
 
                 //add if there are pages to display
-                if(!module.getItems().isEmpty()) container.addItem(module);
+                if(!module.isEmpty()) container.addItem(module);
             }
             menu.addItem(container);
         }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/config-defaults.properties b/platform/marmotta-core/src/main/resources/config-defaults.properties
index 8d70256..4520300 100644
--- a/platform/marmotta-core/src/main/resources/config-defaults.properties
+++ b/platform/marmotta-core/src/main/resources/config-defaults.properties
@@ -93,7 +93,7 @@ linkeddata.mime.rel.default = meta
 templating.sort_by_weight = true
 
 # recache templating file every time
-templating.cache.enabled = true
+templating.cache.enabled = false
 
 
 ###############################################################################

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/81503abb/platform/marmotta-core/src/main/resources/templates/admin.ftl
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/templates/admin.ftl b/platform/marmotta-core/src/main/resources/templates/admin.ftl
index fa0e2ed..e524a05 100644
--- a/platform/marmotta-core/src/main/resources/templates/admin.ftl
+++ b/platform/marmotta-core/src/main/resources/templates/admin.ftl
@@ -64,19 +64,17 @@
 
 <div class="well sidebar-nav square-corners menu-level-2 span3 full-height">
     <ul class="nav nav-list">
-        <#list MENU as menu>
-        <li class="nav-header">${menu["label"]}</li>
-        <#list menu.modules as submenu>
+        <#list MENU["items"] as menu>
+        <li class="nav-header">${menu.label}</li>
+        <#list menu["items"] as submenu>
             <li
-                <#if submenu["active"]> class="active" </#if>
+                <#if submenu["isActive"]> class="active" </#if>
                     >
-                <a href="${SERVER_URL}${submenu["path"]}
-                <#if submenu["pages"]??>
-                    ${submenu["pages"][0]["link"]}"
+                <#if submenu["items"]?has_content>
+                        <a href="${SERVER_URL}${submenu["items"][0]["path"]?substring(1)}">
                 <#else>
-                        doc/rest/index.html"
+                        <a href="${SERVER_URL}doc/rest/index.html">
                 </#if>
-                >
                     <i class="${submenu["icon"]}"></i>  <!-- TODO icon -->
                     <span>${submenu["label"]}</span>
                 </a>
@@ -90,25 +88,17 @@
     <div class="offset3 span9">
 
         <ul class="nav nav-tabs square-corners">
-        <#list MENU as menu>
-            <#if menu["active"]>
-                <#list menu["modules"] as submenu>
-                    <#if submenu["active"]>
-                        <#list submenu["pages"] as pages>
+        <#list MENU["items"] as menu>
+            <#if menu["isActive"]>
+                <#list menu["items"] as submenu>
+                    <#if submenu["isActive"]>
+                        <#list submenu["items"] as pages>
                                 <li
-                                <#if pages["active"]> class="active" </#if>
+                                <#if pages["isActive"]> class="active" </#if>
                                 >
-                                    <a href="${SERVER_URL}${submenu["path"]}${pages["link"]}">${pages["label"]}</a>
+                                    <a href="${SERVER_URL}${pages["path"]?substring(1)}">${pages["label"]}</a>
                                 </li>
                         </#list>
-                        <#if submenu["webservice"]>
-                            <li
-                            <#if submenu["webservice_active"]> class="active" </#if>
-                            >
-                                <a href="${SERVER_URL}${submenu["path"]}doc/rest/index.html">webservice</a>
-                            </li>
-
-                        </#if>
                     </#if>
                 </#list>
             </#if>


Mime
View raw message