diff --git a/html/index.html.mstch b/html/index.html.mstch
index f654765..9a102c4 100644
--- a/html/index.html.mstch
+++ b/html/index.html.mstch
@@ -13,7 +13,7 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ab82adc..c104894 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -26,6 +26,7 @@ add_executable(${PROJECT_NAME}
ini_file.cpp
pathname/pathname.cpp
response_factory.cpp
+ list_highlight_langs.cpp
)
configure_file(
diff --git a/src/list_highlight_langs.cpp b/src/list_highlight_langs.cpp
new file mode 100644
index 0000000..f7b367b
--- /dev/null
+++ b/src/list_highlight_langs.cpp
@@ -0,0 +1,34 @@
+/* Copyright 2017, Michele Santullo
+ * This file is part of "tawashi".
+ *
+ * "tawashi" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "tawashi" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "tawashi". If not, see .
+ */
+
+#include "list_highlight_langs.hpp"
+#include
+#include
+#include
+#include
+
+namespace tawashi {
+ HighlightLangList list_highlight_langs() {
+ const char langmap_path[] = "/usr/share/source-highlight";
+ srchilite::LangMap lang_map(langmap_path, "lang.map");
+ lang_map.open();
+
+ const auto lang_range = boost::make_iterator_range(lang_map.begin(), lang_map.end());
+ return boost::copy_range(lang_range | boost::adaptors::map_keys);
+ }
+} //namespace tawashi
+
diff --git a/src/list_highlight_langs.hpp b/src/list_highlight_langs.hpp
new file mode 100644
index 0000000..76b409b
--- /dev/null
+++ b/src/list_highlight_langs.hpp
@@ -0,0 +1,27 @@
+/* Copyright 2017, Michele Santullo
+ * This file is part of "tawashi".
+ *
+ * "tawashi" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "tawashi" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "tawashi". If not, see .
+ */
+
+#pragma once
+
+#include
+#include
+
+namespace tawashi {
+ typedef std::vector HighlightLangList;
+
+ HighlightLangList list_highlight_langs();
+} //namespace tawashi
diff --git a/src/response.cpp b/src/response.cpp
index c7367dc..32ff60e 100644
--- a/src/response.cpp
+++ b/src/response.cpp
@@ -21,6 +21,7 @@
#include "tawashiConfig.h"
#include "duckhandy/stringize.h"
#include "pathname/pathname.hpp"
+#include "list_highlight_langs.hpp"
#include
#include
#include
@@ -87,6 +88,15 @@ namespace tawashi {
buffer << if_mstch.rdbuf();
return boost::make_optional(buffer.str());
}
+
+ mstch::array make_mstch_langmap() {
+ mstch::array retval;
+
+ for (auto&& lang : list_highlight_langs()) {
+ retval.push_back(mstch::map{{"language_name", std::move(lang)}});
+ }
+ return retval;
+ }
} //unnamed namespace
Response::Response (Types parRespType, std::string&& parValue, std::string&& parPageBaseName, const IniFile& parIni, bool parWantRedis) :
@@ -119,7 +129,8 @@ namespace tawashi {
void Response::send() {
mstch::map mustache_context {
{"version", std::string{STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_PATCH)}},
- {"base_uri", std::string(m_base_uri.data(), m_base_uri.size())}
+ {"base_uri", std::string(m_base_uri.data(), m_base_uri.size())},
+ {"languages", make_mstch_langmap()}
};
if (m_redis)