From dc080f8fe2697569923ed326f8080cb0baedc46b Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 18 Apr 2015 11:53:48 +0200 Subject: some rearrangement --- CMakeLists.txt | 2 ++ config.js | 2 ++ media/basic-profile.css | 32 ++++++++++++++++++++++++++++++++ media/images/strus_big.jpg | Bin 0 -> 36406 bytes src/content.hpp | 1 + src/intro.cpp | 0 src/intro.hpp | 13 +++++++++++++ src/intro_content.hpp | 13 +++++++++++++ src/main.cpp | 2 +- src/master.cpp | 14 ++++++++++++++ src/master.hpp | 20 ++++++++++++++++++++ src/strusCms.cpp | 16 +++++++++++++++- src/strusCms.hpp | 9 +++++++++ src/user.hpp | 16 ++++++++++++++++ templates/intro.tmpl | 8 +++++--- templates/main.tmpl | 26 ++++++++++++++++++++++---- 16 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 media/basic-profile.css create mode 100644 media/images/strus_big.jpg create mode 100644 src/intro.cpp create mode 100644 src/intro.hpp create mode 100644 src/intro_content.hpp create mode 100644 src/master.cpp create mode 100644 src/master.hpp create mode 100644 src/user.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 375bbba..3ee6c80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ set(TEMPLATES set(SRC src/main.cpp src/strusCms.cpp + src/master.cpp + src/intro.cpp ) add_custom_command( diff --git a/config.js b/config.js index 6673811..ee20fc7 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,7 @@ { "strusCms" : { + "script" : "/strusCms", + "media" : "/media" }, "service" : { diff --git a/media/basic-profile.css b/media/basic-profile.css new file mode 100644 index 0000000..b9813c9 --- /dev/null +++ b/media/basic-profile.css @@ -0,0 +1,32 @@ +/* +Original design: Basic Profile (v2.0 - Sep 11, 2012) - A free xhtml/css website template by Andreas Viklund. +For more information, see http://andreasviklund.com/templates/basic-profile/ +*/ + +*{margin:0; padding:0;} +body {background:#fff url(background.jpg) top center no-repeat; color:#303030; font:84% Arial,Helvetica,sans-serif; line-height:1.6em;} +a {color:#0B0B61; text-decoration:none;} +a:hover {text-decoration:underline;} +p,ul,ol,dl {margin:0 0 30px 0;} +h1 {color:#888; font-size:3.2em; line-height:1.1em; letter-spacing:-3px; margin:20px 0 0 0;} +h1 a {color:#0B0B61; text-transform:none;} +h2 {font-size:2.2em; color:#333; margin:0 0 20px; letter-spacing:-1px; border-bottom:2px solid #eee;} +h3 {font-size:1.8em; margin:10px 0 15px 0; letter-spacing:-1px; border-bottom:2px solid #eee;} +h1,h2,h3 {font-weight:700; line-height:1.4em;} +#wrap {color:#303030; margin:40px auto; padding:0; width:980px;} +#content {text-align:left; width:600px; padding-right:40px;} +#content ul {list-style:none; margin:0; padding:10px 0 0 0; border-top:1px solid #eee;} +#content li {list-style:none; font-size:1.2em; margin:0 0 0; padding:0 0 0 0; color:#888; } +#sidebar {float:right; width:280px; padding-left:40px; border-left:2px solid #ccc; } +#sidebar ul {list-style:none; margin:0; padding:10px 0 0 0; border-top:1px solid #eee;} +#sidebar li {list-style:none; font-size:1.2em; margin:0 0 10px; padding:0 0 10px 0; color:#888; border-bottom:1px solid #eee;} +#sidebar li a {font-size:1.2em;} +#sidebar h2 {font-size: 1.4em;} +.slogan {color:#888; font-size:1.4em; font-weight:700; margin:0 0 20px 0; letter-spacing:-1px;} +.readmore {text-align:right; margin:0 20px 30px 0;} +.timestamp {display:block; font-weight:700; color:#888; text-align:right; width:150px; padding:20px 20px 20px 0; float:left; margin:0 20px 20px 0; border-right:2px solid #eee;} +.timestamp a {font-weight:normal;} +.credits {display:block; clear:left; font-size:0.9em; color:#aaa; margin:20px 0;} +.credits a {color:#888;} +.clear {clear:both;} + diff --git a/media/images/strus_big.jpg b/media/images/strus_big.jpg new file mode 100644 index 0000000..70c0776 Binary files /dev/null and b/media/images/strus_big.jpg differ diff --git a/src/content.hpp b/src/content.hpp index e476702..13cc61d 100644 --- a/src/content.hpp +++ b/src/content.hpp @@ -2,5 +2,6 @@ #define CONTENT_HPP #include "master_content.hpp" +#include "intro_content.hpp" #endif diff --git a/src/intro.cpp b/src/intro.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/intro.hpp b/src/intro.hpp new file mode 100644 index 0000000..8a9f2a0 --- /dev/null +++ b/src/intro.hpp @@ -0,0 +1,13 @@ +#ifndef iNTRO_CONTENT_HPP +#define INTRO_CONTENT_HPP + +#include "master.hpp" + +namespace apps { + +class intro : public master { +}; + +} + +#endif diff --git a/src/intro_content.hpp b/src/intro_content.hpp new file mode 100644 index 0000000..ab508ec --- /dev/null +++ b/src/intro_content.hpp @@ -0,0 +1,13 @@ +#ifndef INTRO_CONTENT_HPP +#define INTRO_CONTENT_HPP + +#include "master.hpp" + +namespace content { + +struct intro : public master { +}; + +} + +#endif diff --git a/src/main.cpp b/src/main.cpp index 9005e20..a1a2e71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ int main( int argc, char *argv[] ) try { BOOSTER_INFO( "strusCms" ) << "Restarting application.."; - srv.applications_pool( ).mount( cppcms::applications_factory( ) ); + srv.applications_pool( ).mount( cppcms::applications_factory( ) ); srv.run( ); diff --git a/src/master.cpp b/src/master.cpp new file mode 100644 index 0000000..3243bf6 --- /dev/null +++ b/src/master.cpp @@ -0,0 +1,14 @@ +#include "master.hpp" +#include "strusCms.hpp" + +#include + +namespace apps { + +master::master( strusCms &cms ) + : m_cms( cms ), + application( cms.service( ) ) +{ +} + +} diff --git a/src/master.hpp b/src/master.hpp new file mode 100644 index 0000000..75f4eb1 --- /dev/null +++ b/src/master.hpp @@ -0,0 +1,20 @@ +#ifndef MASTER_HPP +#define MASTER_HPP + +#include + +namespace apps { + +class strusCms; + +class master : public cppcms::application { + protected: + strusCms &m_cms; + + public: + master( strusCms &cms ); +}; + +} + +#endif diff --git a/src/strusCms.cpp b/src/strusCms.cpp index 9c59adf..9190cc3 100644 --- a/src/strusCms.cpp +++ b/src/strusCms.cpp @@ -4,18 +4,32 @@ #include #include #include +#include + +namespace apps { strusCms::strusCms( cppcms::service &srv ) : cppcms::application( srv ) { + locale_name = "en"; + script = settings( ).get( "strusCms.script" ); + dispatcher( ).assign( "", &strusCms::intro, this ); mapper( ).assign( "" ); mapper( ).root( "/strusCms" ); } +std::string strusCms::root( std::string l ) +{ + if( l.empty( ) ) l = locale_name; + return script + "/" + l; +} + void strusCms::intro( ) { - content::master c; + content::intro c; c.title = "strusCms"; render( "intro", c ); } + +} diff --git a/src/strusCms.hpp b/src/strusCms.hpp index 6c152d0..5d4af13 100644 --- a/src/strusCms.hpp +++ b/src/strusCms.hpp @@ -3,12 +3,21 @@ #include +namespace apps { + class strusCms : public cppcms::application { public: strusCms( cppcms::service &srv ); + std::string root( std::string locale_name = "" ); private: void intro( ); + + private: + std::string script; + std::string locale_name; }; +} + #endif diff --git a/src/user.hpp b/src/user.hpp new file mode 100644 index 0000000..99a0894 --- /dev/null +++ b/src/user.hpp @@ -0,0 +1,16 @@ +#ifndef USER_CONTENT_HPP +#define USER_CONTENT_HPP + +#include + +#include + +namespace content { + +struct user : public cppcms::base_content { + std::string title; +}; + +} + +#endif diff --git a/templates/intro.tmpl b/templates/intro.tmpl index b99ea06..eb7fa49 100644 --- a/templates/intro.tmpl +++ b/templates/intro.tmpl @@ -1,13 +1,15 @@ -<% c++ #include "content.hpp" %> +<% c++ #include "intro_content.hpp" %> <% skin view %> -<% view intro uses content::master extends master %> +<% view intro uses content::intro extends master %> <% template title() %> <% include master::title() %> :: Intro <% end %> <% template page_content() %> - Welcome to StrusCms. +
+ Welcome to StrusCms. +
<% end template %> <% end view %> diff --git a/templates/main.tmpl b/templates/main.tmpl index 8e4592f..0d949d7 100644 --- a/templates/main.tmpl +++ b/templates/main.tmpl @@ -9,12 +9,30 @@ <% include title( ) %> + + -

<% include title( ) %>

-
- <% include page_content( ) %> -
+
+

<% include title( ) %>

+
+ <% include page_content( ) %> + +

© 2015 Patrick Frey
+ Template design by Andreas Viklund / Best hosted at www.svenskadomaner.se

+ +
+ + + <% end template %> -- cgit v1.2.3-54-g00ecf