fix: removed exceed files (tidy).

This commit is contained in:
Andrey Parhomenko 2024-06-09 17:35:28 +05:00
parent 7052724c13
commit 7e14b1d212
16 changed files with 21 additions and 252 deletions

View file

@ -1,10 +0,0 @@
package main
import (
"surdeus.su/util/tpp/server"
"os"
)
func main() {
server.Tool.Run(os.Args[1:])
}

3
go.mod
View file

@ -4,8 +4,5 @@ go 1.22.3
require ( require (
github.com/d5/tengo/v2 v2.17.0 github.com/d5/tengo/v2 v2.17.0
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2
surdeus.su/core/cli v0.1.2 surdeus.su/core/cli v0.1.2
) )
require surdeus.su/core/xgo v0.5.0 // indirect

6
go.sum
View file

@ -1,10 +1,4 @@
github.com/d5/tengo/v2 v2.17.0 h1:BWUN9NoJzw48jZKiYDXDIF3QrIVZRm1uV1gTzeZ2lqM= github.com/d5/tengo/v2 v2.17.0 h1:BWUN9NoJzw48jZKiYDXDIF3QrIVZRm1uV1gTzeZ2lqM=
github.com/d5/tengo/v2 v2.17.0/go.mod h1:XRGjEs5I9jYIKTxly6HCF8oiiilk5E/RYXOZ5b0DZC8= github.com/d5/tengo/v2 v2.17.0/go.mod h1:XRGjEs5I9jYIKTxly6HCF8oiiilk5E/RYXOZ5b0DZC8=
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 h1:yEt5djSYb4iNtmV9iJGVday+i4e9u6Mrn5iP64HH5QM=
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
surdeus.su/core/cli v0.0.2 h1:RdHHk3/Fhwxz9PjaE+vTlCuF9KmhrmNUb5y4oqulrYI=
surdeus.su/core/cli v0.0.2/go.mod h1:UKwCmcSX+x7XX9aF3gOaaAaJcJA3gtUmL4vdnM43+fM=
surdeus.su/core/cli v0.1.2 h1:qPzjawqPyZsO4Z5SaA1u141recVE65yioA83Qs7Jecs= surdeus.su/core/cli v0.1.2 h1:qPzjawqPyZsO4Z5SaA1u141recVE65yioA83Qs7Jecs=
surdeus.su/core/cli v0.1.2/go.mod h1:r9JtQz3aEJzpYzMaNUNQHJoYkoWKNPi047qhd5uGlmA= surdeus.su/core/cli v0.1.2/go.mod h1:r9JtQz3aEJzpYzMaNUNQHJoYkoWKNPi047qhd5uGlmA=
surdeus.su/core/xgo v0.5.0 h1:/Rk3scfFkoSb0qjHRlkUNOp9sr/fd7wAvCiT4fBRo+U=
surdeus.su/core/xgo v0.5.0/go.mod h1:6C/AHbjfvAMvt3TOzLB4eIZ40eU3ahJXtdY+kr4yXoc=

4
readme.md Normal file
View file

@ -0,0 +1,4 @@
# tpp
Tengo preprocessor library.

View file

@ -1,5 +0,0 @@
<main>shit</main>
{{
pp.print("cock")
}}
<main>later</main>

View file

@ -1,12 +0,0 @@
{{#
html := import("html").new_render()
}}
{{
h := html.main().body(
html.p().body(
"some paragraph shit"
)
)
pp.print(h)
}}

View file

@ -1,20 +0,0 @@
{{#
context.is_compo = true
}}
<form hx-put="/contact/1" hx-target="this" hx-swap="outerHTML">
<div>
<label>First Name</label>
<input type="text" name="firstName" value="Joe">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="lastName" value="Blow">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name="email" value="joe@blow.com">
</div>
<button class="btn">Submit</button>
<button class="btn" hx-get="/contact/view.htm">Cancel</button>
</form>

View file

@ -1,13 +0,0 @@
{{#
//context.is_compo = true
}}
<div hx-target="this" hx-swap="outerHTML">
<div><label>First Name</label>: Joe</div>
<div><label>Last Name</label>: Blow</div>
<div><label>Email</label>: joe@blow.com</div>
<button hx-get="/contact/edit.htm" class="btn btn-primary">
Click To Edit
</button>
</div>

View file

@ -1,11 +0,0 @@
html := import("html").new_render()
pp.print(html.html().body(
html.head().body(
html.title().body(
"some title"
)
),
html.body().body(
)
))

View file

@ -1,78 +0,0 @@
{{#
context.title = "The example.site main page"
fmt := import("fmt")
html := import("html").new_render()
}}
<h1>This is the example page for the THT</h1>
{{
/*if !context.global.int {
context.global.int = 0
} else {
context.global.int++
}*/
if !context.global.val {
context.global.val = 1
} else {
context.global.val += 1
}
fmt.println("global: ", context.global)
req := context.http.request
q := req.url.query
// List checking.
list := []
rng := int(q.range[0])
fmt.println("range:", q.range)
if rng {
pp.print(`<ul name="range">`)
for i:=0 ; i < rng ; i++ {
pp.printf("<li>%d</li>", i)
}
pp.print("</ul>")
}
if q.name {
pp.print("<div id=\"name\">", q.name[0], "</div>")
}
}}
<div name="counter">
{{ pp.print(context.global.val) }}
</div>
<div>
Hello, Cock!
</div>
<div check>
{{
pp.print(req.url.path)
}}
</div>
<ul>{{
for v in list {
pp.print("<li>", v, "</li>")
}
}}</ul>
{{
vals := ["die", "with", "them", "as", "you", 1, "could", "do"]
pp.print(html.div({
id: "the-uniq-shit"
}).body(
html.ul(
).body(
func(){
ret := []
for i:=0 ; i<len(vals) ; i++{
ret += [html.li({
class: "someclass"
}).body(i, ": ", vals[i])]
}
return ret
}()...
)
))
}}
<script src="/script.js" ></script>
<div></div>

View file

@ -1,41 +0,0 @@
{{#
context.title = "The example.site main page"
fmt := import("fmt")
html := import("html").new_render()
}}
<h1>This is the example page for the THT</h1>
{{
pp.print(
html.h1().body("This is the example page for THT")
)
if !context.global.val {
context.global.val = 1
} else {
context.global.val += 1
}
req
("global: ", context.global)
}}
{{
req := context.http.request
q := req.url.query
// List checking.
rng := int(q.range[0])
fmt.println("range:", q.range)
if rng {
pp.print(`<ul name="range">`)
for i:=0 ; i < rng ; i++ {
pp.printf("<li>%d</li>", i)
}
pp.print("</ul>")
}
if q.name {
pp.print("<div id=\"name\">", q.name[0], "</div>")
}
}}

View file

@ -1,35 +0,0 @@
{{#
context.title = "Let's celebrate and suck, SOME DICK"
}}
{{markdown(`
# Hello, World!
This is the markdown example shit.
func main() {
print("Fuck you")
}
## Yet another level of header
And even more text
> Cheap is talk, show me the code.
(c) Linus Torvalds
`)}}
<div id="uniq">
Even <strong>more</strong> HTML
</div>
{{markdown(`
### Third level header
Some shit
#### `, 135, `
`)}}

View file

@ -1,8 +0,0 @@
{
"error": null,
"data": {
"name": "Andrey",
"surname": "Parhomenko",
"age": 22
}
}

View file

@ -1,3 +0,0 @@
{
"name":"Andrew"
}

View file

@ -1,3 +0,0 @@
console.log("Hello, World!")

21
tool.go
View file

@ -11,17 +11,30 @@ import (
"context" "context"
) )
var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){ var Tool = mtool.T("tpp").Func(func(flags *mtool.Flags){
var (
modDir string
)
flags.StringVar(
&modDir,
"mod",
".",
"set the import directory",
)
filePaths := flags.Parse()
t := NewTengo(). t := NewTengo().
SetPreCompile(func(ctx context.Context, s *Script){ SetPreCompile(func(ctx context.Context, s *Script){
s.SetImports(stdlib.GetModuleMap( s.SetImports(stdlib.GetModuleMap(
stdlib.AllModuleNames()..., stdlib.AllModuleNames()...,
)) ))
s.EnableFileImport(true) s.EnableFileImport(true)
s.SetImportDir(".") s.SetImportDir(modDir)
}) })
pp := New(t) pp := New(t)
filePaths := flags.Parse()
for _, filePath := range filePaths { for _, filePath := range filePaths {
pth := filepath.FromSlash(filePath) pth := filepath.FromSlash(filePath)
bts, err := os.ReadFile(pth) bts, err := os.ReadFile(pth)
@ -41,4 +54,4 @@ var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){
} }
os.Stdout.Write(out) os.Stdout.Write(out)
} }
}) }).Usage("[files]")