added layouts, db support
This commit is contained in:
parent
bb7c69e749
commit
dd40016775
24
app.lua
24
app.lua
@ -1,17 +1,24 @@
|
||||
local lapis = require("lapis")
|
||||
local app = lapis.Application()
|
||||
local say = require('lua_scripts/main')
|
||||
local player = require('player')
|
||||
|
||||
local db = require("lapis.db")
|
||||
local Model = require("lapis.db.model").Model
|
||||
|
||||
app:enable("etlua")
|
||||
app.layout = require "views.layout"
|
||||
|
||||
app:post("/clickme", function(self)
|
||||
self.plane = "P-38L"
|
||||
return self.plane
|
||||
return {self.plane, layout = false}
|
||||
end)
|
||||
|
||||
app:get("/", function(self)
|
||||
self.text = say.hello()
|
||||
return {render = "index"}
|
||||
return {render = "index",
|
||||
|
||||
}
|
||||
end)
|
||||
|
||||
return app
|
||||
@ -33,6 +40,19 @@ return app
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,5 +3,9 @@ local config = require("lapis.config")
|
||||
config("development", {
|
||||
server = "nginx",
|
||||
code_cache = "off",
|
||||
num_workers = "1"
|
||||
num_workers = "1",
|
||||
sqlite = {
|
||||
database = "my_database.sqlite",
|
||||
-- open_flags = ...
|
||||
}
|
||||
})
|
||||
|
0
player.lua
Normal file
0
player.lua
Normal file
@ -1,29 +1,14 @@
|
||||
<!-- views/index.etlua -->
|
||||
<script src="/static/htmx.min.js"></script>
|
||||
|
||||
<h1>Hello world</h1>
|
||||
<p>Welcome to my page</p>
|
||||
<p>The missile guidance system works as follows</p>
|
||||
|
||||
<form>
|
||||
<fieldset>
|
||||
<legend>Give Us Money</legend>
|
||||
<input type="file"></input>
|
||||
<input type="text"></input>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>Do it</label>
|
||||
<input type="number"></input>
|
||||
</fieldset>
|
||||
</form>
|
||||
<br>
|
||||
|
||||
<button hx-post="/clickme" hx-target="#clickable">Click me</button>
|
||||
<button hx-post="/clickme" hx-target="#clickable">Start</button>
|
||||
<p id="clickable"></p>
|
||||
|
||||
<ol>
|
||||
<!--
|
||||
<p><% for i, thing in pairs(text) do %>
|
||||
<li><%= thing %></li>
|
||||
<% end %>
|
||||
</p>
|
||||
</ol>
|
||||
-->
|
||||
|
12
views/layout.etlua
Normal file
12
views/layout.etlua
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><%= page_title or "My Page" %></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Peradventure</h1>
|
||||
<% content_for("inner") %>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user