package org.loklak.api.cms;

import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;
import org.loklak.data.DAO;
import org.loklak.server.APIHandler;
import org.loklak.server.AbstractAPIHandler;
import org.loklak.server.Authorization;
import org.loklak.server.BaseUserRole;
import org.loklak.server.Query;
import org.loklak.tools.storage.JSONObjectWithDefault;

public class TopMenuService extends AbstractAPIHandler implements APIHandler {

	private static final long serialVersionUID = 1839868262296635665L;

	@Override
	public BaseUserRole getMinimalBaseUserRole() {
		return BaseUserRole.ANONYMOUS;
	}

	@Override
	public JSONObject getDefaultPermissions(BaseUserRole baseUserRole) {
		return null;
	}

	@Override
	public String getAPIPath() {
		return "/cms/topmenu.json";
	}

	@Override
	public JSONObject serviceImpl(Query call, HttpServletResponse response, Authorization rights,
			final JSONObjectWithDefault permissions) {

		int limited_count = (int) DAO.getConfig("download.limited.count", (long) Integer.MAX_VALUE);

		JSONObject json = new JSONObject(true);
		JSONArray topmenu = new JSONArray().put(new JSONObject().put("Home", "http://loklak.org/index.html"))
				.put(new JSONObject().put("About", "http://loklak.org/about.html"))
				.put(new JSONObject().put("Blog", "http://blog.loklak.net"))
				.put(new JSONObject().put("Architecture", "http://loklak.org/architecture.html"))
				.put(new JSONObject().put("Download", "http://loklak.org/download.html"))
				.put(new JSONObject().put("Tutorials", "http://loklak.org/tutorials.html"))
				.put(new JSONObject().put("API", "http://loklak.org/api.html"));
		if (limited_count > 0)
			topmenu.put(new JSONObject().put("Dumps", "http://loklak.org/dump.html"));
		topmenu.put(new JSONObject().put("Apps", "http://apps.loklak.org"));
		json.put("items", topmenu);

		// modify caching
		json.put("$EXPIRES", 600);
		return json;
	}
}

@@ -1185,34 +1185,16 @@
 Home%22, %22
-http://loklak.org/
 index.ht
@@ -1239,34 +1239,16 @@
 bout%22, %22
-http://loklak.org/
 about.ht
@@ -1365,34 +1365,16 @@
 ture%22, %22
-http://loklak.org/
 architec
@@ -1429,34 +1429,16 @@
 load%22, %22
-http://loklak.org/
 download
@@ -1490,34 +1490,16 @@
 ials%22, %22
-http://loklak.org/
 tutorial
@@ -1546,34 +1546,16 @@
 %22API%22, %22
-http://loklak.org/
 api.html
@@ -1634,26 +1634,8 @@
 %22, %22
-http://loklak.org/
 dump

Change links in menubar in index page