inital commit
This commit is contained in:
commit
cef5a32041
10 changed files with 171 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
bin/
|
||||
2
LICENSE
Normal file
2
LICENSE
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
22
implementations/Catcrafts-Blog.cpp
Normal file
22
implementations/Catcrafts-Blog.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
export module Catcrafts:Blog_impl;
|
||||
import :Blog;
|
||||
import std;
|
||||
|
||||
namespace Catcrafts {
|
||||
std::string RenderBlog() {
|
||||
std::string html = "";
|
||||
for(const BlogPost& post : *posts) {
|
||||
html += std::format("{}<br>{}<br><br>{}", post.name, post.date, post.content);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
56
implementations/main.cpp
Normal file
56
implementations/main.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
import Catcrafts;
|
||||
import Crafter.CppDOM;
|
||||
import std;
|
||||
using namespace Catcrafts;
|
||||
using namespace Crafter;
|
||||
using namespace Crafter::CppDOMBindings;
|
||||
|
||||
HtmlElementView* blogButton;
|
||||
|
||||
void RenderRoot(const std::string_view route) {
|
||||
std::string pageContent;
|
||||
if(route == "/blog") { //currently pointless if but for adding more pages in the future
|
||||
pageContent = RenderBlog();
|
||||
} else {
|
||||
pageContent = RenderBlog(); //default route
|
||||
}
|
||||
|
||||
body->SetInnerHTML(std::format(R"(
|
||||
Catcrafts.net
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a id="blog-nav-button">Blog</a></li>
|
||||
<li><a href="https://forgejo.catcrafts.net/">Forgejo</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{}
|
||||
|
||||
<footer>Powered by Crafter.CppDOM, Running near native with WASM!, <a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">View source</a></footer>)", pageContent));
|
||||
|
||||
if(blogButton) {
|
||||
delete blogButton;
|
||||
}
|
||||
blogButton = new HtmlElementView("blog-nav-button");
|
||||
blogButton->AddClickListener([](Crafter::MouseEvent e) {
|
||||
std::cout << "click" << std::endl;
|
||||
PushState("{}", "", "/blog");
|
||||
RenderRoot("blog");
|
||||
});
|
||||
}
|
||||
|
||||
int main() {
|
||||
AddPopStateListener([]() {
|
||||
RenderRoot(GetPathNameString());
|
||||
});
|
||||
|
||||
RenderRoot("/");
|
||||
}
|
||||
28
interfaces/Catcrafts-Blog.cppm
Normal file
28
interfaces/Catcrafts-Blog.cppm
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
export module Catcrafts:Blog;
|
||||
import Crafter.CppDOM;
|
||||
import std;
|
||||
using namespace Crafter;
|
||||
|
||||
export namespace Catcrafts {
|
||||
struct BlogPost {
|
||||
std::string name;
|
||||
std::string date;
|
||||
std::string content;
|
||||
};
|
||||
std::vector<BlogPost>* posts = new std::vector<BlogPost>{
|
||||
{
|
||||
"First post!",
|
||||
"2025-11-12",
|
||||
"Welcome to catcrafts.net!"
|
||||
}
|
||||
};
|
||||
std::string RenderBlog();
|
||||
}
|
||||
16
interfaces/Catcrafts-Component.cppm
Normal file
16
interfaces/Catcrafts-Component.cppm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
export module Catcrafts:Component;
|
||||
using namespace Crafter;
|
||||
|
||||
export namespace Catcrafts {
|
||||
class Component {
|
||||
std::string render();
|
||||
};
|
||||
}
|
||||
16
interfaces/Catcrafts-Views.cppm
Normal file
16
interfaces/Catcrafts-Views.cppm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
export module Catcrafts:Views;
|
||||
import Crafter.CppDOM;
|
||||
using namespace Crafter;
|
||||
|
||||
export namespace Catcrafts {
|
||||
HtmlElementView* body = new HtmlElementView("body");
|
||||
HtmlElementView* head = new HtmlElementView("head");
|
||||
}
|
||||
11
interfaces/Catcrafts.cppm
Normal file
11
interfaces/Catcrafts.cppm
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2025 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
export module Catcrafts;
|
||||
export import :Views;
|
||||
export import :Blog;
|
||||
17
project.json
Normal file
17
project.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "main",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "executable",
|
||||
"interfaces": ["interfaces/Catcrafts", "interfaces/Catcrafts-Views", "interfaces/Catcrafts-Blog"],
|
||||
"implementations": ["implementations/main", "implementations/Catcrafts-Blog"],
|
||||
"target": "wasm32-wasi",
|
||||
"dependencies": [
|
||||
{
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM.git",
|
||||
"configuration":"lib"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
1
run.sh
Executable file
1
run.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
caddy file-server --listen :8085 --root bin/executable
|
||||
Loading…
Add table
Add a link
Reference in a new issue