4 Commits
doc ... fixes

Author SHA1 Message Date
311870683e fixes 2025-12-16 21:31:53 -05:00
e2c6f15e5b start beta versioning 2025-12-16 18:41:38 -05:00
10da72a1f6 doc: patch 2025-12-14 19:43:10 -05:00
522cbdece8 Merge pull request 'doc: first' (#4) from doc into main
Reviewed-on: #4
2025-12-14 19:41:43 -05:00
5 changed files with 126 additions and 9 deletions

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Documentation Title</title> <title>Documentation</title>
<style> <style>
html, body { html, body {
min-height: 100%; min-height: 100%;
@@ -267,6 +267,10 @@ footer {
<td><code>:custom()</code></td> <td><code>:custom()</code></td>
<td>Add a custom string to the site body</td> <td>Add a custom string to the site body</td>
</tr> </tr>
<tr>
<td><code>markdown_to_html(str: string)</code></td>
<td>Returns generated HTML from provided Markdown string.</td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>Std</h3> <h3>Std</h3>
@@ -490,10 +494,99 @@ footer {
</tr> </tr>
</tbody> </tbody>
</table> </table>
<h3>Bus</h3>
<table> <thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>bus.url</code></td>
<td>The current url that was given.</td>
</tr>
<tr>
<td><code>bus.params</code></td>
<td>A table of url parameters if any. Ex: ?foo=bar*baz=foobar</td>
</tr>
</tbody>
</table>
<h3>Site</h3>
<table> <thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>site.version</code></td>
<td>The version of the website found in the Fes.toml</td>
</tr>
<tr>
<td><code>site.name</code></td>
<td>The name of the website found in the Fes.toml</td>
</tr>
<tr>
<td><code>site.authors</code></td>
<td>A table of all authors defined in Fes.toml</td>
</tr>
</tbody>
</table>
<h3>App</h3>
Fes's <code>app</code> module is a special table
because it contains user defined functions. These
functions are defined in the <code>include/</code> For
example if you define a <code>include/hello.lua</code>
file with given contents: <pre><code>local hello = {}
hello.render(std) return std.h1("Hello, World!") end
return hello</pre></code> This can be called from another with,
<code>fes.app.hello.render(fes.std)</code>. Do with this
as you will.
<h3>Speical Directories</h3>
<table> <thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>www/</code></td>
<td>The main website is
contained here, this is
where www/index.lua
lives.</td>
</tr>
<tr>
<td><code>static/</code></td>
<td>All static content should
be placed here and can
be accessed at
<code>/static/path-to-file</code>.</td>
</tr>
<tr>
<td><code>include/</code></td>
<td>Contains lua files that are
preloaded and globally
accessible.</td>
</tr>
<tr>
<td><code>archive/</code></td>
<td>Files here can be viewed in
a file browser like
format at
<code>/archive/path-to-dir</code>.</td>
</tr>
</tbody>
</table>
</section> </section>
<footer> <footer>
<p>Last updated: 2025-12-14</p> <p>Last updated: 2025-12-16</p>
</footer> </footer>
</main> </main>
</body> </body>

View File

@@ -13,6 +13,7 @@ import (
"fes/src/doc" "fes/src/doc"
"fes/src/new" "fes/src/new"
"fes/src/server" "fes/src/server"
"fes/src/version"
) )
//go:embed core/* //go:embed core/*
@@ -38,8 +39,14 @@ func main() {
fmt.Println("Options:") fmt.Println("Options:")
flag.PrintDefaults() flag.PrintDefaults()
} }
showVersion := flag.Bool("version", false, "Show version and exit")
flag.Parse() flag.Parse()
if *showVersion {
version.Version()
}
if *config.Color { if *config.Color {
color.NoColor = true color.NoColor = true
} }

View File

@@ -136,7 +136,7 @@ func loadIncludeModules(L *lua.LState, includeDir string) *lua.LTable {
return app return app
} }
func loadLua(luaDir string, entry string, cfg *config.MyConfig, requestData reqData) ([]byte, error) { func loadLua(entry string, cfg *config.MyConfig, requestData reqData) ([]byte, error) {
L := lua.NewState() L := lua.NewState()
defer L.Close() defer L.Close()
@@ -380,7 +380,7 @@ func Start(dir string) error {
</html> </html>
`) `)
if _, err := os.Stat(filepath.Join("www", "404.lua")); err == nil { if _, err := os.Stat(filepath.Join("www", "404.lua")); err == nil {
if nf, err := loadLua(dir, "www/404.lua", &cfg, reqData{}); err == nil { if nf, err := loadLua("www/404.lua", &cfg, reqData{}); err == nil {
notFoundData = nf notFoundData = nf
} }
} else if _, err := os.Stat("www/404.html"); err == nil { } else if _, err := os.Stat("www/404.html"); err == nil {
@@ -444,7 +444,7 @@ func Start(dir string) error {
var data []byte var data []byte
if strings.HasSuffix(route, ".lua") { if strings.HasSuffix(route, ".lua") {
data, err = loadLua(dir, route, &cfg, reqData{path: r.URL.Path, params: params}) data, err = loadLua(route, &cfg, reqData{path: r.URL.Path, params: params})
} else if strings.HasSuffix(route, ".md") { } else if strings.HasSuffix(route, ".md") {
data, err = os.ReadFile(route) data, err = os.ReadFile(route)
data = []byte(markdownToHTML(string(data))) data = []byte(markdownToHTML(string(data)))

View File

@@ -2,10 +2,12 @@ package ui
import ( import (
"errors" "errors"
"fes/src/config"
"fmt" "fmt"
"strings" "strings"
"fes/src/config"
"fes/src/version"
"github.com/fatih/color" "github.com/fatih/color"
) )
@@ -28,17 +30,17 @@ func Path(path string, err error) {
} }
func Warning(msg string, err error) error { func Warning(msg string, err error) error {
fmt.Printf("fes: %s: %v\n", color.MagentaString("warning"), err) fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.MagentaString("warning"), err)
return err return err
} }
func Error(msg string, err error) error { func Error(msg string, err error) error {
fmt.Printf("fes: %s: %v\n", color.RedString("error"), err) fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.RedString("error"), err)
return err return err
} }
func Fatal(msg string, err error) error { func Fatal(msg string, err error) error {
fmt.Printf("fes: %s: %v\n", color.RedString("fatal"), err) fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.RedString("fatal"), err)
panic(err) panic(err)
} }

15
src/version/version.go Normal file
View File

@@ -0,0 +1,15 @@
package version
import (
"fmt"
"os"
)
const PROGRAM_NAME string = "fes"
const PROGRAM_NAME_LONG string = "fes/fSD"
const VERSION string = "beta"
func Version() {
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)
os.Exit(0)
}