v1 running live
This commit is contained in:
parent
f3f679da35
commit
fa367a28f1
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.lua
|
||||||
|
*_temp/
|
||||||
|
logs/
|
||||||
|
import/
|
||||||
|
nginx.conf.compiled
|
33
app.moon
Normal file
33
app.moon
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
lapis = require "lapis"
|
||||||
|
console = require "lapis.console"
|
||||||
|
|
||||||
|
import respond_to from require "lapis.application"
|
||||||
|
import Tracks from require "models"
|
||||||
|
|
||||||
|
class extends lapis.Application
|
||||||
|
"/console": console.make!
|
||||||
|
|
||||||
|
[index: "/(:page[%d])"]: respond_to {
|
||||||
|
GET: =>
|
||||||
|
tracks = Tracks\paginated "* ORDER BY id", per_page: 32
|
||||||
|
@page = tonumber(@params.page) or 1
|
||||||
|
@tracks = tracks\get_page @page
|
||||||
|
render: true
|
||||||
|
POST: =>
|
||||||
|
if @params.id
|
||||||
|
track = Tracks\find id: @params.id
|
||||||
|
track\update {
|
||||||
|
artist: @params.artist
|
||||||
|
name: @params.name
|
||||||
|
url: @params.url
|
||||||
|
status: tonumber @params.status
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Tracks\create {
|
||||||
|
artist: @params.artist
|
||||||
|
name: @params.name
|
||||||
|
url: @params.url
|
||||||
|
status: @params.status
|
||||||
|
}
|
||||||
|
redirect_to: @url_for "index", page: @params.page
|
||||||
|
}
|
9
config.moon
Normal file
9
config.moon
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import config from require "lapis.config"
|
||||||
|
|
||||||
|
config "development", ->
|
||||||
|
port 8042
|
||||||
|
postgres ->
|
||||||
|
host "127.0.0.1"
|
||||||
|
user "music"
|
||||||
|
password "EditAnacronTango"
|
||||||
|
database "music"
|
12
migrations.moon
Normal file
12
migrations.moon
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import create_table, types from require "lapis.db.schema"
|
||||||
|
|
||||||
|
{
|
||||||
|
[1]: =>
|
||||||
|
create_table "tracks", {
|
||||||
|
{ "id", types.serial primary_key: true }
|
||||||
|
{ "artist", types.text null: true }
|
||||||
|
{ "name", types.text null: true }
|
||||||
|
{ "url", types.text null: true }
|
||||||
|
{ "status", types.integer default: 1 }
|
||||||
|
}
|
||||||
|
}
|
81
mime.types
Normal file
81
mime.types
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
types {
|
||||||
|
text/html html htm shtml;
|
||||||
|
text/css css;
|
||||||
|
text/xml xml;
|
||||||
|
image/gif gif;
|
||||||
|
image/jpeg jpeg jpg;
|
||||||
|
application/x-lua lua;
|
||||||
|
application/x-moonscript moon;
|
||||||
|
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;
|
||||||
|
}
|
2
models.moon
Normal file
2
models.moon
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import autoload from require "lapis.util"
|
||||||
|
autoload "models"
|
11
models/Tracks.moon
Normal file
11
models/Tracks.moon
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import Model, enum from require "lapis.db.model"
|
||||||
|
|
||||||
|
class Tracks extends Model
|
||||||
|
@statuses: enum {
|
||||||
|
new: 1
|
||||||
|
downloaded: 2
|
||||||
|
owned: 3
|
||||||
|
duplicate: 4
|
||||||
|
ignored: 5
|
||||||
|
imported: 6
|
||||||
|
}
|
33
nginx.conf
Normal file
33
nginx.conf
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
worker_processes ${{NUM_WORKERS}};
|
||||||
|
error_log stderr notice;
|
||||||
|
daemon off;
|
||||||
|
pid logs/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
charset UTF-8;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
views/index.moon
Normal file
61
views/index.moon
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import Widget from require "lapis.html"
|
||||||
|
|
||||||
|
import Tracks from require "models"
|
||||||
|
|
||||||
|
class extends Widget
|
||||||
|
content: =>
|
||||||
|
div ->
|
||||||
|
a href: @url_for("index", page: @page - 1), "<"
|
||||||
|
raw " "
|
||||||
|
a href: @url_for("index", page: @page + 1), ">"
|
||||||
|
element "table", ->
|
||||||
|
tr ->
|
||||||
|
th "Artist"
|
||||||
|
th "Name"
|
||||||
|
th "URL"
|
||||||
|
th "Status"
|
||||||
|
th "✓"
|
||||||
|
|
||||||
|
for track in *@tracks
|
||||||
|
tr ->
|
||||||
|
form {
|
||||||
|
action: @url_for "index", page: @page
|
||||||
|
method: "POST"
|
||||||
|
enctype: "multipart/form-data"
|
||||||
|
}, ->
|
||||||
|
td -> input type: "text", name: "artist", value: track.artist
|
||||||
|
td -> input type: "text", name: "name", value: track.name
|
||||||
|
td ->
|
||||||
|
if track.url and #track.url > 0
|
||||||
|
a href: track.url, "*"
|
||||||
|
else
|
||||||
|
text "+"
|
||||||
|
text " "
|
||||||
|
input type: "text", name: "url", value: track.url
|
||||||
|
td ->
|
||||||
|
element "select", name: "status", ->
|
||||||
|
for status in *Tracks.statuses
|
||||||
|
if status == Tracks.statuses[track.status]
|
||||||
|
option value: Tracks.statuses[status], selected: true, status
|
||||||
|
else
|
||||||
|
option value: Tracks.statuses[status], status
|
||||||
|
td ->
|
||||||
|
input type: "hidden", name: "id", value: track.id
|
||||||
|
input type: "submit", value: "Update"
|
||||||
|
|
||||||
|
tr ->
|
||||||
|
form {
|
||||||
|
action: @url_for "index", page: @page
|
||||||
|
method: "POST"
|
||||||
|
enctype: "multipart/form-data"
|
||||||
|
}, ->
|
||||||
|
td -> input type: "text", name: "artist", placeholder: "artist"
|
||||||
|
td -> input type: "text", name: "name", placeholder: "name"
|
||||||
|
td ->
|
||||||
|
raw " "
|
||||||
|
input type: "text", name: "url", placeholder: "url"
|
||||||
|
td ->
|
||||||
|
element "select", name: "status", ->
|
||||||
|
for status in *Tracks.statuses
|
||||||
|
option value: Tracks.statuses[status], status
|
||||||
|
td -> input type: "submit", value: "Submit"
|
Reference in New Issue
Block a user