summaryrefslogtreecommitdiff
path: root/src/master.cpp
blob: 086ebe3a0ad3c2d3f4682248fbd347fa9d4f7e44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "master.hpp"
#include "strusCms.hpp"

#include <cppcms/service.h>
#include <cppcms/url_dispatcher.h>  

namespace apps {

master::master( strusCms &cms )
	: application( cms.service( ) ),
	cms( cms )
{
}

void master::ini( content::master &c )
{
	c.title = "strusCms";	
	if( session( ).is_set( "username" ) ) {
		c.username = session( )["username" ];
	} else {
		c.username = "";
	}
	c.login_link = cms.root( ) + "/login";
	c.logout_link = cms.root( ) + "/logout";
	c.register_link = cms.root( ) + "/register";
	c._root = cms.root( );
}

void master::register_common_pages( )
{
	cms.dispatcher( ).assign( ".*", &master::not_found_404, this );
}

void master::not_found_404( )
{
	content::master c;
	ini( c );
	c.url = cms.request( ).script_name( ) + "/" + cms.request( ).path_info( );
	render( "not_found_404", c );
}

}