Skip to content

Commit

Permalink
database saving?
Browse files Browse the repository at this point in the history
  • Loading branch information
TangentFoxy committed Sep 2, 2016
1 parent f905bcb commit b2d499f
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions colors.moon
Expand Up @@ -8,14 +8,30 @@ class extends lapis.Application
@path: "/colors"
@name: "colors_"

[hex: "(/:hex[a-fA-F%d])"]: =>
if @params.hex
@hex = @params.hex\sub 1, 6 -- TODO check me
else
@hex = "FFFFFF"
[hex: "(/:hex[a-fA-F%d])"]: respond_to {
GET: =>
if @params.hex
@hex = @params.hex\sub 1, 6 -- TODO check me
else
@hex = "FFFFFF"

render: "color", layout: "simple"

POST: =>
if @params.code == @params.name
return redirect_to: @url_for "colors_hex", @params.code

render: "color", layout: "simple"
color = Colors\create {
name: @params.name
code: @params.code
}

-- id, code, name
--[colors_add: "/colors/add/:hex[a-fA-F%d]"]: =>
-- @params.hex
return redirect_to: @url_for "colors_named", @params.name
}

[named: "/:name"]: =>
if color = Colors\find name: @params.name
@hex = color.code
return render: "color", layout: "simple"
else
return redirect_to: "colors_hex"

0 comments on commit b2d499f

Please sign in to comment.