add WITH_DYNAMIC_SERVING for theme developing
authorAndrew Karpow <andy@ndyk.de>
Mon, 27 Oct 2014 21:12:10 +0000 (22:12 +0100)
committerAndrew Karpow <andy@ndyk.de>
Mon, 27 Oct 2014 21:12:10 +0000 (22:12 +0100)
CMakeLists.txt
src/config.h.in
src/ympd.c

index 4839c84..4fb845b 100644 (file)
@@ -7,6 +7,7 @@ set(CPACK_PACKAGE_VERSION_MINOR "2")
 set(CPACK_PACKAGE_VERSION_PATCH "3")
 
 option(WITH_MPD_HOST_CHANGE "Let users of the web frontend change the MPD Host" ON)
+option(WITH_DYNAMIC_SERVING "Serve file of ./htdocs dynamically (development)" OFF)
 option(WITH_IPV6 "enable IPv6 support" ON)
 
 find_package(LibMPDClient REQUIRED)
index 242fb0b..202d63a 100644 (file)
@@ -22,8 +22,8 @@
 #define YMPD_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}
 #define YMPD_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR}
 #define YMPD_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH}
-#define DATADIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}"
-#define LOCAL_RESOURCE_PATH DATADIR"/htdocs"
+#define SRC_PATH "${PROJECT_SOURCE_DIR}/htdocs"
 #cmakedefine WITH_MPD_HOST_CHANGE
+#cmakedefine WITH_DYNAMIC_SERVING
 #endif
 
index c6d87c0..cb7912b 100644 (file)
@@ -51,7 +51,11 @@ static int server_callback(struct mg_connection *c, enum mg_event ev) {
                 else
                     return MG_TRUE;
             } else
+#ifdef WITH_DYNAMIC_SERVING
+                return MG_FALSE;
+#else
                 return callback_http(c);
+#endif
         case MG_AUTH:
             return MG_TRUE;
         default:
@@ -69,6 +73,10 @@ int main(int argc, char **argv)
 
     atexit(bye);
     error_msg = mg_set_option(server, "listening_port", "8080");
+#ifdef WITH_DYNAMIC_SERVING
+    mg_set_option(server, "document_root", SRC_PATH);
+#endif
+
     mpd.port = 6600;
     strcpy(mpd.host, "127.0.0.1");