Skip to content

Commit d827b02

Browse files
committed
Initial Source Commit
This is the initial source commit
1 parent 54cb9d4 commit d827b02

File tree

141 files changed

+15869
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+15869
-0
lines changed

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "webd",
3+
"description": "Open-source & Free CMS/E-commerce/Intranet System based on Diamond MVC.",
4+
"authors": [
5+
"Jacob Jensen"
6+
],
7+
"license": "The MIT License (MIT)",
8+
"copyright": "Copyright © 2018 Jacob Jensen",
9+
"targetType": "sourceLibrary",
10+
"sourcePaths": [
11+
"src"
12+
]
13+
}

src/core/config.d

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module webd.core.config;
2+
3+
import vibe.data.serialization : optional;
4+
5+
/// Webd configurations.
6+
class WebdConfig
7+
{
8+
/// The name of the website.
9+
string websiteName;
10+
11+
/// The root path of the website.
12+
@optional string rootPath;
13+
14+
/// The language.
15+
@optional string language;
16+
}
17+
18+
/// The webd configuration.
19+
private static __gshared WebdConfig _webdConfig;
20+
21+
/// Gets the webd configuration.
22+
@property WebdConfig webdConfig() { return _webdConfig; }
23+
24+
/// Loads the webd configuration.
25+
void loadWebdConfig()
26+
{
27+
import vibe.d : deserializeJson;
28+
import std.file : readText;
29+
30+
_webdConfig = deserializeJson!WebdConfig(readText("config/webd.json"));
31+
32+
import std.file : thisExePath;
33+
import std.path : dirName, absolutePath;
34+
35+
if (!_webdConfig.rootPath)
36+
{
37+
_webdConfig.rootPath = absolutePath(dirName(thisExePath));
38+
}
39+
40+
import webd.dal;
41+
auto website = getWebsite(_webdConfig.websiteName);
42+
43+
if (website)
44+
{
45+
if (!_webdConfig.language)
46+
{
47+
_webdConfig.language = website.language;
48+
}
49+
}
50+
}

src/core/package.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module webd.core;
2+
3+
public
4+
{
5+
import webd.core.config;
6+
}

src/dal/modules.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module webd.dal.modules;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getModule(ulong id)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `deleted` = '0' LIMIT 1";
10+
11+
auto params = getParams();
12+
params["id"] = id;
13+
14+
return MySql.readSingle!WebdModule(sql, params);
15+
}

src/dal/package.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module webd.dal;
2+
3+
public
4+
{
5+
import webd.dal.websites;
6+
import webd.dal.webpages;
7+
import webd.dal.webitems;
8+
import webd.dal.webparagraphs;
9+
import webd.dal.webitemlists;
10+
import webd.dal.modules;
11+
}

src/dal/webitemlists.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module webd.dal.webitemlists;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getItemList(ulong id)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `deleted` = '0' LIMIT 1";
10+
11+
auto params = getParams();
12+
params["id"] = id;
13+
14+
return MySql.readSingle!WebdWebItemList(sql, params);
15+
}

src/dal/webitems.d

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module webd.dal.webitems;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getItem(ulong id)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `disabled` = '0' AND `deleted` = '0' LIMIT 1";
10+
11+
auto params = getParams();
12+
params["id"] = id;
13+
14+
return MySql.readSingle!WebdWebItem(sql, params);
15+
}
16+
17+
auto getItemValues(ulong itemId)
18+
{
19+
static const sql = "SELECT * FROM @table WHERE `itemId` = @itemId AND `parentValue` IS NULL AND `deleted` = '0'";
20+
21+
auto params = getParams();
22+
params["itemId"] = itemId;
23+
24+
return MySql.readMany!WebdWebItemEntry(sql, params);
25+
}
26+
27+
auto getItemValues(ulong itemId, ulong parentValue)
28+
{
29+
static const sql = "SELECT * FROM @table WHERE `itemId` = @itemId AND `parentValue` = @parentValue AND `deleted` = '0'";
30+
31+
auto params = getParams();
32+
params["itemId"] = itemId;
33+
params["parentValue"] = parentValue;
34+
35+
return MySql.readMany!WebdWebItemEntry(sql, params);
36+
}

src/dal/webpages.d

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module webd.dal.webpages;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getWebPage(string name)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `name` = @name AND `published` = '1' AND `deleted` = '0' LIMIT 1";
10+
11+
auto params = getParams();
12+
params["name"] = name;
13+
14+
return MySql.readSingle!WebdWebPage(sql, params);
15+
}
16+
17+
auto getWebPageFromRoute(string route)
18+
{
19+
static const sql = "SELECT * FROM @table WHERE `route` = @route AND `published` = '1' AND `deleted` = '0' LIMIT 1";
20+
21+
auto params = getParams();
22+
params["route"] = route;
23+
24+
return MySql.readSingle!WebdWebPage(sql, params);
25+
}
26+
27+
auto getWebPage(ulong id)
28+
{
29+
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `published` = '1' AND `deleted` = '0' LIMIT 1";
30+
31+
auto params = getParams();
32+
params["id"] = id;
33+
34+
return MySql.readSingle!WebdWebPage(sql, params);
35+
}
36+
37+
auto getAllWebPages()
38+
{
39+
static const sql = "SELECT * FROM @table WHERE `published` = '1' AND `deleted` = '0' ORDER BY `id` DESC";
40+
41+
return MySql.readMany!WebdWebPage(sql, null);
42+
}
43+
44+
WebdWebPage[] getAllSubWebPages(ulong parentPageId)
45+
{
46+
static const sql = "SELECT * FROM @table WHERE `parentPage` = @parentPage AND `published` = '1' AND `deleted` = '0' ORDER BY `id` DESC";
47+
auto params = getParams();
48+
params["parentPage"] = parentPageId;
49+
50+
import std.array : array;
51+
52+
auto result = MySql.readMany!WebdWebPage(sql, params).array;
53+
54+
foreach (page; result)
55+
{
56+
result ~= getAllSubWebPages(page.id);
57+
}
58+
59+
return result;
60+
}
61+
62+
auto getAllDeletedWebPages()
63+
{
64+
static const sql = "SELECT * FROM @table WHERE `deleted` = '1' ORDER BY `id` DESC";
65+
66+
return MySql.readMany!WebdWebPage(sql, null);
67+
}

src/dal/webparagraphs.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module webd.dal.webparagraphs;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getParagraphs(ulong pageId)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `pageId` = @pageId AND `disabled` = '0' AND `deleted` = '0'";
10+
11+
auto params = getParams();
12+
params["pageId"] = pageId;
13+
14+
return MySql.readMany!WebdWebParagraph(sql, params);
15+
}

src/dal/websites.d

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module webd.dal.websites;
2+
3+
import diamond.database;
4+
5+
import webd.models.database;
6+
7+
auto getWebsite(string name)
8+
{
9+
static const sql = "SELECT * FROM @table WHERE `name` = @name LIMIT 1";
10+
11+
auto params = getParams();
12+
params["name"] = name;
13+
14+
return MySql.readSingle!WebdWebsite(sql, params);
15+
}
16+
17+
auto getWebsite(ulong id)
18+
{
19+
static const sql = "SELECT * FROM @table WHERE `id` = @id LIMIT 1";
20+
21+
auto params = getParams();
22+
params["id"] = id;
23+
24+
return MySql.readSingle!WebdWebsite(sql, params);
25+
}
26+
27+
auto getAllWebsites()
28+
{
29+
static const sql = "SELECT * FROM @table WHERE ORDER BY `id` DESC";
30+
31+
return MySql.readMany!WebdWebsite(sql, null);
32+
}

0 commit comments

Comments
 (0)