diff options
Diffstat (limited to 'src/page.hpp')
-rw-r--r-- | src/page.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/page.hpp b/src/page.hpp new file mode 100644 index 0000000..f3ac5d0 --- /dev/null +++ b/src/page.hpp @@ -0,0 +1,60 @@ +#ifndef PAGE_HPP +#define PAGE_HPP + +#include "master.hpp" + +#include "page_content.hpp" + +#include <cppcms/json.h> + +namespace apps { + +class page : public master { + public: + page( strusCms &cms ); + + private: + void display( std::string slug ); + void api_pages( ); + void api_page( std::string slug ); + void ini( content::page &c ); +}; + +} // namespace apps + +struct Page { + std::string slug; + std::string title; + std::string content; +}; + +namespace cppcms { + namespace json { + +template<> +struct traits<Page> { + + static Page get( value const &v ) + { + Page p; + if( v.type( ) != is_object) { + throw bad_value_cast( ); + } + p.slug = v.get<std::string>( "slug" ); + p.title = v.get<std::string>( "title" ); + p.content = v.get<std::string>( "content" ); + return p; + } + + static void set( value &v, Page const &p ) + { + v.set( "slug", p.slug ); + v.set( "title", p.title ); + v.set( "content", p.content ); + } + +}; + +} } // namespace cppcms::json + +#endif |