commit 6515955a14d2a832d9058510893615201fe58c57 Author: Sam Dodrill Date: Mon Jan 5 13:41:19 2015 -0800 initial commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b8a4a15 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +app.lua +logs +*_temp +nginx.conf.compiled diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bad67d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.lua +logs +*_temp +nginx.conf.compiled diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4813fb2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM xena/lapis + + diff --git a/app.moon b/app.moon new file mode 100644 index 0000000..9cdea37 --- /dev/null +++ b/app.moon @@ -0,0 +1,28 @@ +lapis = require "lapis" +db = require "lapis.db" +csrf = require "lapis.csrf" + +import respond_to from require "lapis.application" + +import Model from require "lapis.db.model" + +class User extends Model + @primary_key: "login" + +class App extends lapis.Application + "/": => + render: "index" + + [form: "/form"]: respond_to { + GET: => + assert @ + csrf_token = csrf.generate_token @ + @html => + form method: "POST", action: "/form", -> + input type: "hidden", name: "csrf_token", value: csrf_token + input type: "submit" + + POST: => + csrf.assert_token @ + "The form is valid!" + } diff --git a/app.rockspec b/app.rockspec new file mode 100644 index 0000000..cde5dc6 --- /dev/null +++ b/app.rockspec @@ -0,0 +1,3 @@ +dependencies = { + "lapis" +} diff --git a/config.moon b/config.moon new file mode 100644 index 0000000..5e9ea4d --- /dev/null +++ b/config.moon @@ -0,0 +1,14 @@ +config = require "lapis.config" + +config "development", -> + port 8080 + + postgres -> + backend "pgmoon" + host "127.0.0.1" + user "lapis" + password "lapis" + database "panel" + +config "production", -> + port 5000 diff --git a/migrations.moon b/migrations.moon new file mode 100644 index 0000000..f77906c --- /dev/null +++ b/migrations.moon @@ -0,0 +1,16 @@ +import add_column, create_table, types from require "lapis.db.schema" + +{ + [1]: => + create_table "users", { + { "id", types.serial } + { "email", types.text } + { "name", types.text } + { "password", types.text } + + "PRIMARY KEY (id)" + } + + [2]: => + add_column "users", "admin", types.boolean +} diff --git a/mime.types b/mime.types new file mode 100644 index 0000000..5d132eb --- /dev/null +++ b/mime.types @@ -0,0 +1,79 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/x-javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + image/svg+xml svg svgz; + image/webp webp; + + application/java-archive jar war ear; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.ms-excel xls; + application/vnd.ms-powerpoint ppt; + application/vnd.wap.wmlc wmlc; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream eot; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9e88115 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +worker_processes ${{NUM_WORKERS}}; +error_log stderr notice; +daemon off; + +events { + worker_connections 1024; +} + +http { + include mime.types; + + server { + listen ${{PORT}}; + lua_code_cache ${{CODE_CACHE}}; + + location / { + default_type text/html; + content_by_lua ' + require("lapis").serve("app") + '; + } + + location /static/ { + alias static/; + } + + location /favicon.ico { + alias static/favicon.ico; + } + } +} diff --git a/views/index.moon b/views/index.moon new file mode 100644 index 0000000..3f8de32 --- /dev/null +++ b/views/index.moon @@ -0,0 +1,7 @@ +import Widget from require "lapis.html" + +class Index extends Widget + content: => + h1 class: "header", "Hello" + div class: "body", -> + text "Welcome to my site!"