From de50c30a936b87d79f816790230856347b0dff7e Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 18 Apr 2015 13:14:32 +0200 Subject: introduced a sub-app for intro page --- src/intro.cpp | 24 ++++++++++++++++++++++++ src/intro.hpp | 9 +++++++-- src/intro_content.hpp | 2 +- src/master.cpp | 2 +- src/master.hpp | 2 +- src/strusCms.cpp | 16 ++++------------ src/strusCms.hpp | 7 ++++--- 7 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/intro.cpp b/src/intro.cpp index e69de29..bf0331d 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -0,0 +1,24 @@ +#include "content.hpp" +#include "intro.hpp" +#include "strusCms.hpp" + +#include +#include + +namespace apps { + +intro::intro( strusCms &cms ) + : master( cms ) +{ + cms.dispatcher( ).assign( "", &intro::show, this ); + cms.mapper( ).assign( "" ); +} + +void intro::show( ) +{ + content::intro c; + c.title = "strusCms"; + render( "intro", c ); +} + +} diff --git a/src/intro.hpp b/src/intro.hpp index 8a9f2a0..0f70ed8 100644 --- a/src/intro.hpp +++ b/src/intro.hpp @@ -1,11 +1,16 @@ -#ifndef iNTRO_CONTENT_HPP -#define INTRO_CONTENT_HPP +#ifndef INTRO_HPP +#define INTRO_HPP #include "master.hpp" namespace apps { class intro : public master { + public: + intro( strusCms &cms ); + + private: + void show( ); }; } diff --git a/src/intro_content.hpp b/src/intro_content.hpp index ab508ec..16bd601 100644 --- a/src/intro_content.hpp +++ b/src/intro_content.hpp @@ -1,7 +1,7 @@ #ifndef INTRO_CONTENT_HPP #define INTRO_CONTENT_HPP -#include "master.hpp" +#include "master_content.hpp" namespace content { diff --git a/src/master.cpp b/src/master.cpp index 3243bf6..f05b79a 100644 --- a/src/master.cpp +++ b/src/master.cpp @@ -6,7 +6,7 @@ namespace apps { master::master( strusCms &cms ) - : m_cms( cms ), + : cms( cms ), application( cms.service( ) ) { } diff --git a/src/master.hpp b/src/master.hpp index 75f4eb1..9da1605 100644 --- a/src/master.hpp +++ b/src/master.hpp @@ -9,7 +9,7 @@ class strusCms; class master : public cppcms::application { protected: - strusCms &m_cms; + strusCms &cms; public: master( strusCms &cms ); diff --git a/src/strusCms.cpp b/src/strusCms.cpp index 9190cc3..64cc235 100644 --- a/src/strusCms.cpp +++ b/src/strusCms.cpp @@ -1,20 +1,19 @@ #include "strusCms.hpp" -#include "content.hpp" -#include #include #include #include namespace apps { -strusCms::strusCms( cppcms::service &srv ) : cppcms::application( srv ) +strusCms::strusCms( cppcms::service &srv ) + : cppcms::application( srv ), + intro( *this ) { locale_name = "en"; script = settings( ).get( "strusCms.script" ); - dispatcher( ).assign( "", &strusCms::intro, this ); - mapper( ).assign( "" ); + add( intro ); mapper( ).root( "/strusCms" ); } @@ -25,11 +24,4 @@ std::string strusCms::root( std::string l ) return script + "/" + l; } -void strusCms::intro( ) -{ - content::intro c; - c.title = "strusCms"; - render( "intro", c ); -} - } diff --git a/src/strusCms.hpp b/src/strusCms.hpp index 5d4af13..db7f0d9 100644 --- a/src/strusCms.hpp +++ b/src/strusCms.hpp @@ -3,6 +3,8 @@ #include +#include "intro.hpp" + namespace apps { class strusCms : public cppcms::application { @@ -10,12 +12,11 @@ class strusCms : public cppcms::application { strusCms( cppcms::service &srv ); std::string root( std::string locale_name = "" ); - private: - void intro( ); - private: std::string script; std::string locale_name; + + apps::intro intro; }; } -- cgit v1.2.3-54-g00ecf