mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-08 17:15:45 +00:00
Get more done on packageserver
This commit is contained in:
2
Templates/gui/.crossarchiveignore
Normal file
2
Templates/gui/.crossarchiveignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
bin
|
||||||
|
obj
|
||||||
26
Templates/gui/cross.json
Normal file
26
Templates/gui/cross.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"dependencies": [
|
||||||
|
],
|
||||||
|
"info": {
|
||||||
|
"template_extra_text_ftles": [
|
||||||
|
"res/layout.json"
|
||||||
|
],
|
||||||
|
"template_ignored_files": [
|
||||||
|
"bin",
|
||||||
|
"obj"
|
||||||
|
],
|
||||||
|
"template_info": {
|
||||||
|
"type": "app",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"template_name": "gui",
|
||||||
|
"template_project_dependencies": [
|
||||||
|
],
|
||||||
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
|
"type": "template",
|
||||||
|
"description": "A crosslang gui, using tesses-framework's gui library"
|
||||||
|
},
|
||||||
|
"name": "Tesses.CrossLang.Template.GUI",
|
||||||
|
"version": "1.0.0.0-prod"
|
||||||
|
}
|
||||||
33
Templates/gui/res/layout.json
Normal file
33
Templates/gui/res/layout.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"Child": {
|
||||||
|
"Type": "AbsoluteView",
|
||||||
|
"Items": [
|
||||||
|
{
|
||||||
|
"Bounds": {
|
||||||
|
"X": 42,
|
||||||
|
"Y": 42,
|
||||||
|
"Width": 200,
|
||||||
|
"Height": 50
|
||||||
|
},
|
||||||
|
"Type": "ButtonView",
|
||||||
|
"Text": "Click Me",
|
||||||
|
"Id": "btn1",
|
||||||
|
"Active": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Palette": {
|
||||||
|
"IsDarkMode": true,
|
||||||
|
"Accent": "#DB0",
|
||||||
|
"Border": "#040",
|
||||||
|
"BorderActive":"#A00",
|
||||||
|
"BorderHover": "#00A",
|
||||||
|
"BorderHoverActive": "#A0A",
|
||||||
|
"FontSize": 20
|
||||||
|
},
|
||||||
|
"Size": {
|
||||||
|
"Width": 640,
|
||||||
|
"Height": 480
|
||||||
|
},
|
||||||
|
"Text": "%PROJECT_NAME%"
|
||||||
|
}
|
||||||
18
Templates/gui/src/main.tcross
Normal file
18
Templates/gui/src/main.tcross
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
func btn1_Click(sender,e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Button Clicked");
|
||||||
|
}
|
||||||
|
func main(args)
|
||||||
|
{
|
||||||
|
if(TypeOf(GUI) != "Dictionary")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The GUI is not supported, please build tessesframework with TESSESFRAMEWORK_ENABLE_SDL2.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var window = GUI.Window.FromJSON(embed("layout.json"), SDL2.Window.Resizable);
|
||||||
|
var btn1 = window.FindViewById("btn1");
|
||||||
|
btn1.Click += btn1_Click;
|
||||||
|
VM.RunEventLoop();
|
||||||
|
btn.Click -= btn1_Click;
|
||||||
|
window.Dispose(); //we need to destroy it or it will leak
|
||||||
|
}
|
||||||
14
Tesses.CrossLang.PackageServer/src/pages/api/api.tcross
Normal file
14
Tesses.CrossLang.PackageServer/src/pages/api/api.tcross
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
func Pages.API.Index()
|
||||||
|
{
|
||||||
|
var pages=[{
|
||||||
|
active = true,
|
||||||
|
route = "/api",
|
||||||
|
text = "API Home"
|
||||||
|
}];
|
||||||
|
var html = <null>
|
||||||
|
<h1>API Home</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="./api-v1">v1</a></li>
|
||||||
|
</ul></null>;
|
||||||
|
return Shell("CPKG API Home", pages,html);
|
||||||
|
}
|
||||||
34
Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross
Normal file
34
Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
func Pages.API.V1()
|
||||||
|
{
|
||||||
|
var pages=[{
|
||||||
|
active = false,
|
||||||
|
route = "/api",
|
||||||
|
text = "API Home"
|
||||||
|
}];
|
||||||
|
var html = <null>
|
||||||
|
<h1>API v1</h1>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
GET /api/v1/package_icon.png?name=PACKAGENAME&version=1.0.0.0-prod<br>
|
||||||
|
Gets the package icon for the package<br>
|
||||||
|
<br>
|
||||||
|
query:<br>
|
||||||
|
<code>name</code>: the name of the package<br>
|
||||||
|
<code>version</code>: the version of the package<br>
|
||||||
|
<br>
|
||||||
|
response: image/png of package
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
GET /api/v1/latest?name=PACKAGENAME<br>
|
||||||
|
Gets the latest version of a package<br>
|
||||||
|
<br>
|
||||||
|
query:<br>
|
||||||
|
<code>name</code>: the name of the package<br>
|
||||||
|
<br>
|
||||||
|
response: json dictionary with a single key <code>version</code> with the string value of the latest version<br>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</null>;
|
||||||
|
return Shell("CPKG API v1", pages,html);
|
||||||
|
}
|
||||||
10
Tesses.CrossLang.Shell/src/app/app.tcross
Normal file
10
Tesses.CrossLang.Shell/src/app/app.tcross
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
func Tesses.CrossLang.Shell.App(dd)
|
||||||
|
{
|
||||||
|
if(dd.Arguments.Count == 1)
|
||||||
|
{
|
||||||
|
var window = new GUI.Window("CrossLang",640,480,SDL2.Window.Resizable);
|
||||||
|
window.View = new GUI.ButtonView("My Favorite Button");
|
||||||
|
|
||||||
|
VM.RunEventLoop();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user