Permalink
Browse files

user manifests can be filtered as well

  • Loading branch information...
leafo committed Mar 1, 2014
1 parent e0e0ddf commit ad99b175044aeb2e2a06b156d4b60504457b0123
Showing with 12 additions and 2 deletions.
  1. +11 −1 app.moon
  2. +1 −1 serve_file.moon
View
@@ -8,6 +8,8 @@ lapis = require "lapis.init"
math.randomseed os.time!
+MANIFEST_LUA_VERSIONS = { "5.1", "5.2" }
+
import
assert_error
capture_errors
@@ -147,7 +149,7 @@ class MoonRocks extends lapis.Application
"/manifest-:version": capture_errors_json =>
assert_valid @params, {
- { "version", one_of: {"5.1", "5.2"} }
+ { "version", one_of: MANIFEST_LUA_VERSIONS }
}
modules = Manifests\root!\all_modules!
@@ -159,6 +161,14 @@ class MoonRocks extends lapis.Application
user = assert Users\find(slug: @params.user), "Invalid user"
render_manifest @, user\all_modules!
+ "/manifests/:user/manifest-:version": capture_errors_json =>
+ assert_valid @params, {
+ { "version", one_of: MANIFEST_LUA_VERSIONS }
+ }
+
+ user = assert_error Users\find(slug: @params.user), "Invalid user"
+ render_manifest @, user\all_modules!, @params.version
+
[user_profile: "/modules/:user"]: =>
@user = assert Users\find(slug: @params.user), "Invalid user"
@title = "#{@user.username}'s Modules"
View
@@ -2,7 +2,7 @@
uri = ngx.var.request_uri
-- manifests are served by the app
-return ngx.exec "/" if uri\match "manifest/?$"
+return ngx.exec "/" if uri\match "/manifest[^/]*/?$"
import Users, Modules, Versions, Rocks, Manifests from require "models"

0 comments on commit ad99b17

Please sign in to comment.