First commit

This commit is contained in:
Mike Nolan 2025-07-03 14:04:50 -05:00
commit 0192479c73
11 changed files with 203 additions and 0 deletions

7
cross.json Normal file
View File

@ -0,0 +1,7 @@
{
"info": {
"type": "console"
},
"name": "cross",
"version": "1.0.0.0-prod"
}

BIN
res/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
res/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

1
res/simple.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
var count = 0;
func Components.Counter()
{
return <p>Count is {++count}</p>;
}

View File

@ -0,0 +1,38 @@
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>cross - {title}</title>
<link rel="stylesheet" href="./css/simple.min.css">
</head>
<body>
<header>
<h1>cross</h1>
<nav>
<ul>
<each(var item : pages)>
<li>
<if(item.active)>
<true>
<a aria-current="page" href={item.route}>{item.text}</a>
</true>
<false>
<a aria-current="page" href={item.route}>{item.text}</a>
</false>
</if>
</li>
</each>
</ul>
</nav>
</header>
<h1>{title}</h1>
<raw(body)>
<footer>
<p>Created using <a href="https://crosslang.tesseslanguage.com/">CrossLang</a> and <a href="https://simplecss.org/">SimpleCSS</a></p>
</footer>
</body>
</html>;
}

26
src/pages/about.tcross Normal file
View File

@ -0,0 +1,26 @@
func Pages.About()
{
var pages = [
{
active = false,
route = "/",
text = "Home"
},
{
active = false,
route = "/counter",
text = "Counter"
},
{
active = true,
route = "/about",
text = "About"
}
];
return Components.Shell(
"About Me",
pages,
<null><img src="./image.png"><p>{ipsum}</p></null>
);
}
var ipsum="";

25
src/pages/counter.tcross Normal file
View File

@ -0,0 +1,25 @@
func Pages.Counter()
{
var pages = [
{
active = false,
route = "/",
text = "Home"
},
{
active = true,
route = "/counter",
text = "Counter"
},
{
active = false,
route = "/about",
text = "About"
}
];
return Components.Shell(
"Counter",
pages,
<null><h1>This is a counter</h1><raw(Components.Counter())></null>
);
}

32
src/pages/echo.tcross Normal file
View File

@ -0,0 +1,32 @@
func Pages.Echo(text)
{
var pages = [
{
active = false,
route = "/",
text = "Home"
},
{
active = false,
route = "/counter",
text = "Counter"
},
{
active = false,
route = "/about",
text = "About"
}
];
return Components.Shell(
"Echo",
pages,
<if(text != null)>
<true>
<p>{text}</p>
</true>
<false>
<p>No text available</p>
</false>
</if>
);
}

27
src/pages/index.tcross Normal file
View File

@ -0,0 +1,27 @@
func Pages.Index()
{
var pages = [
{
active = true,
route = "/",
text = "Home"
},
{
active = false,
route = "/counter",
text = "Counter"
},
{
active = false,
route = "/about",
text = "About"
}
];
return Components.Shell("Main Page",pages,<section>
<form action="./echo" method="GET">
<input type="text" name="text" placeholder="Text to echo">
<input type="submit" value="Echo it">
</form>
<p>1 John 4:4: You, dear children, are from God and have overcome them, because the one who is in you is greater than the one who is in the world.</p>
</section>);
}

42
src/program.tcross Normal file
View File

@ -0,0 +1,42 @@
var count = 0;
func main(args)
{
Net.Http.ListenSimpleWithLoop((ctx)=>{
if(ctx.Path == "/")
{
ctx.WithMimeType("text/html").SendText(Pages.Index());
return true;
}
else if(ctx.Path == "/counter")
{
ctx.WithMimeType("text/html").SendText(Pages.Counter());
return true;
}
else if(ctx.Path == "/about")
{
ctx.WithMimeType("text/html").SendText(Pages.Index());
return true;
}
else if(ctx.Path == "/echo")
{
ctx.WithMimeType("text/html").SendText(Pages.Echo(ctx.QueryParams.TryGetFirst("text")));
return true;
}
else if(ctx.Path == "/image.png")
{
ctx.WithMimeType("image/png").SendBytes(embed("image.png"));
return true;
}
else if(ctx.Path == "/css/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;
}
return false;
},4206);
}