blob: 52f533d2eee141c70f65c0d7fbc729412c7f15b7 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include "aCms.hpp"
#include <cppcms/url_mapper.h>
#include <cppcms/http_response.h>
#include <cppcms/json.h>
#include <cppdb/frontend.h>
namespace {
void setup_dbconnection( cppdb::session &sql )
{
std::string driver = sql.driver( );
if( driver == "sqlite3" ) {
sql << "PRAGMA foreign_keys = 1" << cppdb::exec;
}
}
}
namespace apps {
aCms::aCms( cppcms::service &srv )
: cppcms::application( srv ),
master( *this ),
intro( *this ),
user( *this ),
page( *this ),
conn( settings( ).get<std::string>( "aCms.db_connection" ) ),
mail( settings( ).get<std::string>( "aCms.mail.server" ),
settings( ).get<unsigned short>( "aCms.mail.port" ),
settings( ).get<std::string>( "aCms.mail.username" ),
settings( ).get<std::string>( "aCms.mail.password" ),
settings( ).get<std::string>( "aCms.mail.from" )
)
{
locale_name = "en";
script = settings( ).get<std::string>( "aCms.script" );
media = settings( ).get<std::string>( "aCms.media" );
cppdb::session sql( conn );
sql.once( setup_dbconnection );
add( master );
add( intro );
add( user );
add( page );
master.register_common_pages( );
mapper( ).root( root( ) );
}
std::string aCms::root( std::string l )
{
return script;
// TODO: localization later
//~ if( l.empty( ) ) l = locale_name;
//~ return script + "/" + l;
}
std::string aCms::media_root( std::string l )
{
return media;
// TODO: localization later
//~ if( l.empty( ) ) l = locale_name;
//~ return script + "/" + l;
}
}
|