2015-02-01 08:17:40 +00:00
|
|
|
lapis = require "lapis"
|
|
|
|
http = require "lapis.nginx.http"
|
|
|
|
json = require "dkjson"
|
|
|
|
|
|
|
|
import respond_to from require "lapis.application"
|
|
|
|
import assert_valid from require "lapis.validate"
|
|
|
|
|
|
|
|
class Projects extends lapis.Application
|
|
|
|
[projects: "/projects"]: =>
|
|
|
|
res, code = http.simple {
|
|
|
|
url: "https://api.github.com/users/Xe/repos"
|
2015-02-01 08:22:32 +00:00
|
|
|
headers: {
|
|
|
|
["User-Agent"]: "http://christine.website #{os.getenv "GIT_REV"}"
|
|
|
|
["Authorization"]: "token #{os.getenv "GITHUB_TOKEN"}"
|
|
|
|
}
|
2015-02-01 08:17:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if code != 200
|
|
|
|
@err = res
|
|
|
|
return render: "error", status: 500
|
|
|
|
|
|
|
|
repos, _, err = json.decode res
|
|
|
|
|
|
|
|
if err
|
|
|
|
@err = err
|
|
|
|
return render: "error", status: 500
|
|
|
|
|
|
|
|
@repos = {}
|
|
|
|
|
|
|
|
for _, repo in pairs(repos)
|
|
|
|
if not repo.fork
|
|
|
|
table.insert repos, repo
|
|
|
|
|
|
|
|
render: true
|
|
|
|
|
|
|
|
[portfolio: "/portfolio"]: =>
|
|
|
|
|
|
|
|
render: true
|
|
|
|
|