mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-09 01:25:46 +00:00
Add std
This commit is contained in:
@@ -8,16 +8,10 @@
|
||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||
"license": "MIT",
|
||||
"template_name": "emptyweb",
|
||||
"description": "An empty website with my template engine",
|
||||
"description": "An empty website",
|
||||
"template_info": {
|
||||
"type": "console"
|
||||
},
|
||||
"template_project_dependencies": [
|
||||
{
|
||||
"name": "Tesses.CrossLang.Markup",
|
||||
"version": "1.0.0.0-prod"
|
||||
}
|
||||
],
|
||||
"template_extra_text_ftles": [],
|
||||
"template_ignored_files": ["bin","obj"]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?page() route="/" ?>
|
||||
<?Shell?>
|
||||
<?arg_component() ?>
|
||||
<h1>Hello, world</h1>
|
||||
<span>Views: <?expr ++count ?></span>
|
||||
|
||||
<?end?>
|
||||
<?end?>
|
||||
<?end?>
|
||||
|
||||
14
Templates/emptyweb/src/components/shell.tcross
Normal file
14
Templates/emptyweb/src/components/shell.tcross
Normal file
@@ -0,0 +1,14 @@
|
||||
func Components.Shell(body)
|
||||
{
|
||||
return <!DOCTYPE html>
|
||||
<html lang={"en"}>
|
||||
<head>
|
||||
<meta charset={"UTF-8"}>
|
||||
<meta name={"viewport"} content={"width=device-width, initial-scale=1.0"}>
|
||||
<title>Hello, world</title>
|
||||
</head>
|
||||
<body>
|
||||
<raw(body)>
|
||||
</body>
|
||||
</html>;
|
||||
}
|
||||
9
Templates/emptyweb/src/pages/index.tcross
Normal file
9
Templates/emptyweb/src/pages/index.tcross
Normal file
@@ -0,0 +1,9 @@
|
||||
var count = 0;
|
||||
|
||||
func Pages.Index()
|
||||
{
|
||||
return Components.Shell(
|
||||
<h1>Hello, world</h1>
|
||||
<span>Views: {++count}</span>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
var count = 0;
|
||||
|
||||
func main(args)
|
||||
{
|
||||
Net.Http.ListenSimpleWithLoop(Router,4206);
|
||||
Net.Http.ListenSimpleWithLoop((ctx)=>{
|
||||
if(ctx.Path == "/")
|
||||
{
|
||||
ctx.WithMimeType("text/html").SendText(Pages.Index());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},4206);
|
||||
}
|
||||
@@ -12,13 +12,6 @@
|
||||
"template_info": {
|
||||
"type": "console"
|
||||
},
|
||||
"template_project_dependencies": [
|
||||
{
|
||||
"name": "Tesses.CrossLang.Markup",
|
||||
"version": "1.0.0.0-prod"
|
||||
}
|
||||
],
|
||||
"template_extra_text_ftles": ["/components/shell.tcrml"],
|
||||
"template_ignored_files": ["bin","obj"]
|
||||
}
|
||||
}
|
||||
|
||||
5
Templates/web/src/components/counter.tcross
Normal file
5
Templates/web/src/components/counter.tcross
Normal file
@@ -0,0 +1,5 @@
|
||||
var count = 0;
|
||||
func Components.Counter()
|
||||
{
|
||||
return <p>Count is {++count}</p>;
|
||||
}
|
||||
35
Templates/web/src/components/shell.tcross
Normal file
35
Templates/web/src/components/shell.tcross
Normal file
@@ -0,0 +1,35 @@
|
||||
func Components.Shell(title,pages,body)
|
||||
{
|
||||
return <!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>%PROJECT_NAME% - {title}</title>
|
||||
<link rel="stylesheet" href="./css/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>%PROJECT_NAME%</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<?code
|
||||
each(var item : pages)
|
||||
{
|
||||
?>
|
||||
<li><a <?code if(item.active) { ?> aria-current="page" <?code } ?> href="<?expr Net.Http.UrlPathEncode(item.route) ?>"><?expr Net.Http.HtmlEncode(item.text) ?></a></li>
|
||||
<?code
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<h1><?expr Net.Http.HtmlEncode(title) ?></h1>
|
||||
<?body?>
|
||||
<?end?>
|
||||
<footer>
|
||||
<p>Created using <a href="https://crosslang.tesseslanguage.com/">CrossLang</a> and <a href="https://simplecss.org/">SimpleCSS</a></p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>;
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
var count = 0;
|
||||
func main(args)
|
||||
{
|
||||
Net.Http.ListenSimpleWithLoop(Router,4206);
|
||||
Net.Http.ListenSimpleWithLoop((ctx)=>{
|
||||
if(ctx.Path == "/")
|
||||
{
|
||||
ctx.WithMimeType("text/html").SendText(Pages.Index());
|
||||
return true;
|
||||
}
|
||||
else if(ctx.Path == "/simple.min.css")
|
||||
{
|
||||
ctx.WithMimeType("text/css").SendBytes(embed("simple.min.css"));
|
||||
return true;
|
||||
}
|
||||
else if(ctx.Path == "/favicon.ico")
|
||||
{
|
||||
ctx.WithMimeType("image/x-icon").SendBytes(embed("favicon.ico"));
|
||||
return true;
|
||||
}
|
||||
},4206);
|
||||
}
|
||||
Reference in New Issue
Block a user