From 59ff00f53aabc982ea4f138a371bc1077fe1c991 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <daniel.gerhardt@mni.thm.de>
Date: Sun, 18 May 2014 21:10:35 +0200
Subject: [PATCH] Add configuration options to enable/disable features

---
 .../controller/ConfigurationController.java   | 35 ++++++++++++++++---
 src/main/webapp/arsnova.properties.example    | 10 ++++++
 src/test/resources/arsnova.properties.example | 10 ++++++
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/controller/ConfigurationController.java b/src/main/java/de/thm/arsnova/controller/ConfigurationController.java
index 281c3249..560813c4 100644
--- a/src/main/java/de/thm/arsnova/controller/ConfigurationController.java
+++ b/src/main/java/de/thm/arsnova/controller/ConfigurationController.java
@@ -41,23 +41,43 @@ public class ConfigurationController extends AbstractController {
 
 	@Value("${customization.path}")
 	private String customizationPath;
+
 	@Value("${mobile.path}")
 	private String mobilePath;
+
 	@Value("${presenter.path}")
 	private String presenterPath;
+
 	@Value("${links.overlay.url}")
 	private String overlayUrl;
+
 	@Value("${links.organization.url}")
 	private String organizationUrl;
+
 	@Value("${links.imprint.url}")
 	private String imprintUrl;
+
 	@Value("${links.privacy-policy.url}")
 	private String privacyPolicyUrl;
-	
+
+	@Value("${features.mathjax.enabled:true}")
+	private String mathJaxEnabled;
+
+	@Value("${features.markdown.enabled:false}")
+	private String markdownEnabled;
+
+	@Value("${features.question-format.flashcard.enabled:false}")
+	private String flashcardEnabled;
+
+	@Value("${features.question-format.grid-square.enabled:false}")
+	private String gridSquareEnabled;
+
 	@RequestMapping(value = { "/" }, method = RequestMethod.GET)
 	@ResponseBody
-	public final HashMap<String, String> getConfiguration(HttpServletRequest request) {
-		HashMap<String, String> config = new HashMap<String, String>();
+	public final HashMap<String, Object> getConfiguration(HttpServletRequest request) {
+		HashMap<String, Object> config = new HashMap<String, Object>();
+		HashMap<String, Boolean> features = new HashMap<String, Boolean>();
+
 		/* The API path could be unknown to the client in case the request was forwarded */
 		config.put("apiPath", request.getContextPath());
 
@@ -82,7 +102,14 @@ public class ConfigurationController extends AbstractController {
 		if (!"".equals(privacyPolicyUrl)) {
 			config.put("privacyPolicyUrl", privacyPolicyUrl);
 		}
-		
+
+		config.put("features", features);
+
+		features.put("mathJax", "true".equals(mathJaxEnabled));
+		features.put("markdown", "true".equals(markdownEnabled));
+		features.put("flashcard", "true".equals(flashcardEnabled));
+		features.put("gridSquare", "true".equals(gridSquareEnabled));
+
 		return config;
 	}
 }
diff --git a/src/main/webapp/arsnova.properties.example b/src/main/webapp/arsnova.properties.example
index 9fa91c0b..5a0bca24 100644
--- a/src/main/webapp/arsnova.properties.example
+++ b/src/main/webapp/arsnova.properties.example
@@ -75,3 +75,13 @@ socketio.port=10443
 connector.uri=http://localhost:8080/connector-service
 connector.username=test
 connector.password=test
+
+# Enable MathJax to allow the use of Math formulas written in TeX syntax in text fields.
+features.mathJax.enabled=true
+
+# The following features are considered experimental because they have not been
+# tested in a production environment over a longer time frame and/or their behavior
+# will change in future releases.
+features.markdown.enabled=false
+features.question-format.flashcard.enabled=false
+features.question-format.grid-square.enabled=false
diff --git a/src/test/resources/arsnova.properties.example b/src/test/resources/arsnova.properties.example
index 9fa91c0b..5a0bca24 100644
--- a/src/test/resources/arsnova.properties.example
+++ b/src/test/resources/arsnova.properties.example
@@ -75,3 +75,13 @@ socketio.port=10443
 connector.uri=http://localhost:8080/connector-service
 connector.username=test
 connector.password=test
+
+# Enable MathJax to allow the use of Math formulas written in TeX syntax in text fields.
+features.mathJax.enabled=true
+
+# The following features are considered experimental because they have not been
+# tested in a production environment over a longer time frame and/or their behavior
+# will change in future releases.
+features.markdown.enabled=false
+features.question-format.flashcard.enabled=false
+features.question-format.grid-square.enabled=false
-- 
GitLab