Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting ready to have ksp plane submission #37

Merged
merged 1 commit into from Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions app.moon
Expand Up @@ -3,6 +3,7 @@ lapis = require "lapis"
import respond_to, json_params from require "lapis.application"

class extends lapis.Application
@include "ksp"
@include "redirects"
@include "misc"

Expand All @@ -22,8 +23,4 @@ class extends lapis.Application
}

"/": =>
@html ->
p ->
text "My server is soon to be running on Lapis moreso than hand-coded HTML. In the meantime, "
a href: @build_url("map.html"), "here's a link"
text " to my old site map."
render: true
24 changes: 24 additions & 0 deletions ksp.moon
@@ -0,0 +1,24 @@
lapis = require "lapis"

import respond_to, json_params from require "lapis.application"

class extends lapis.Application
@path: "/ksp"
@name: "ksp_"
[submit_planes: "/submit"]: respond_to {
GET: =>
@html ->
form {
action: @url_for "submit_planes" --this might break!
method: "POST"
enctype: "multipart/form-data"
}, ->
p "Stuff"
input type: "text", name: "stuff"

POST: json_params =>
-- process input, place in database
}

--[plane_list: "/planes(/:page[%d])"]: =>
-- do stuff! @params.page
21 changes: 20 additions & 1 deletion migrations.moon
@@ -1,6 +1,25 @@
--import create_table, types from require "lapis.db.schema"
import create_table, types from require "lapis.db.schema"

{
[1]: =>
print "Test first migration just to stop erroring worked?"
[2]: =>
create_table "planes", {
{"id", types.serial primary_key: true}
{"craft_name", types.text}
{"download_link", types.text unique: true}
{"description", types.text}
{"mods_used", types.text}
{"creator_name", types.varchar}
{"ksp_version", types.varchar}
{"status", types.integer default: 0} -- enum for whether I've done anything or not
{"action_groups", types.text}
{"episode", types.varchar} -- video ID, internal use
{"rejection_reason", types.text default: "not rejected"}
{"picture", types.text} -- URL to image or imgur album
--NOTE this is how imgur embeds work (I think) <blockquote class="imgur-embed-pub" lang="en" data-id="gw22T2m"><a href="//imgur.com/gw22T2m">Some of us black people are fighting for our community from within.</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

{"created_at", types.time}
{"updated_at", types.time}
}
}
30 changes: 30 additions & 0 deletions models/Planes.moon
@@ -0,0 +1,30 @@
import Model, enum from require "lapis.db.model"

class Planes extends Model
@timestamp: true

@status: enum {
unseen: 0
pending: 1
reviewed: 2
rejected: 3
}

@constraints: {
craft_name: (value) =>
unless value
return "Craft must have a name!"
download_link: (value) =>
unless value
return "You must enter a download link!"
--TODO validate URL here!
--description: (value) =>
-- unless value
-- return "You must enter a description of the craft!"
--creator_name: (value) =>
-- unless value
-- return "You must enter a name for the crafts' creator."
--ksp_version: (value) =>
-- unless value
-- return "You must tell me what version of KSP this craft was made in."
}
9 changes: 9 additions & 0 deletions views/index.moon
@@ -0,0 +1,9 @@
import Widget from require "lapis.html"

class extends Widget
content: =>
h1 "Welcome"
p ->
text "My server is soon to be running on Lapis moreso than hand-coded HTML. In the meantime, "
a href: @build_url("map.html"), "here's a link"
text " to my old site map."