From a912b1e3d4f90e26ea13e2c79ac31d2c2f49e81b Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 12 Jun 2017 20:35:52 +0100 Subject: [PATCH] Expose Tawashi's version to mustache. --- src/kamokan_impl/response.cpp | 4 +++- src/tawashi/CMakeLists.txt | 1 + src/tawashi/version.cpp | 31 +++++++++++++++++++++++++++++++ src/tawashi/version.hpp | 24 ++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/tawashi/version.cpp create mode 100644 src/tawashi/version.hpp diff --git a/src/kamokan_impl/response.cpp b/src/kamokan_impl/response.cpp index 2d979ae..4d80f0b 100644 --- a/src/kamokan_impl/response.cpp +++ b/src/kamokan_impl/response.cpp @@ -24,6 +24,7 @@ #include "cgi_env.hpp" #include "num_conv.hpp" #include "kamokan_config.h" +#include "version.hpp" #include #include #include @@ -172,7 +173,8 @@ namespace tawashi { statuslog->info("Sending response"); SPDLOG_TRACE(statuslog, "Preparing mustache dictionary"); mstch::map mustache_context { - {"version", std::string{STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_PATCH)}}, + {"version", boost::string_view{STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_PATCH)}}, + {"tawashi_version", tawashi::version()}, {"base_uri", base_uri()}, {"host_path", make_host_path(this->settings())}, {"languages", make_mstch_langmap(*m_settings)} diff --git a/src/tawashi/CMakeLists.txt b/src/tawashi/CMakeLists.txt index 767fd45..435fc01 100644 --- a/src/tawashi/CMakeLists.txt +++ b/src/tawashi/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(${PROJECT_NAME} ip_utils.cpp mime_split.cpp truncated_string.cpp + version.cpp ) target_include_directories(${PROJECT_NAME} diff --git a/src/tawashi/version.cpp b/src/tawashi/version.cpp new file mode 100644 index 0000000..7dcc964 --- /dev/null +++ b/src/tawashi/version.cpp @@ -0,0 +1,31 @@ +/* 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 "version.hpp" +#include "tawashi_config.h" +#include "duckhandy/stringize.h" + +namespace tawashi { + boost::string_view version() { + return boost::string_view( + STRINGIZE(VERSION_MAJOR) "." + STRINGIZE(VERSION_MINOR) "." + STRINGIZE(VERSION_PATCH) + ); + } +} //namespace tawashi + diff --git a/src/tawashi/version.hpp b/src/tawashi/version.hpp new file mode 100644 index 0000000..2b4ec70 --- /dev/null +++ b/src/tawashi/version.hpp @@ -0,0 +1,24 @@ +/* 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 + +namespace tawashi { + boost::string_view version(); +} //namespace tawashi