add autogenned list of projects
This commit is contained in:
parent
8d3b3e391d
commit
4a1ba50221
1
app.moon
1
app.moon
|
@ -5,6 +5,7 @@ class extends lapis.Application
|
|||
layout: require "layout.bootstrap"
|
||||
|
||||
@include "controllers.hire"
|
||||
@include "controllers.projects"
|
||||
|
||||
[index: "/"]: =>
|
||||
@user, err = gh\get_authenticated_user()
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
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"
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -43,7 +43,7 @@ class Layout extends Widget
|
|||
div id: "navbar", class: "collapse navbar-collapse", ->
|
||||
ul class: "nav navbar-nav", ->
|
||||
li ->
|
||||
a href: "/about", "About"
|
||||
a href: "/projects", "Projects"
|
||||
|
||||
li ->
|
||||
a href: "/hire", "Hire Me"
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import Widget from require "lapis.html"
|
||||
|
||||
class Projects extends Widget
|
||||
content: =>
|
||||
h1 "My Projects"
|
||||
|
||||
element "table" class: "table table-striped", ->
|
||||
tr ->
|
||||
td "Name"
|
||||
td "Description"
|
||||
td "Language"
|
||||
td "Star Count"
|
||||
|
||||
for _, repo in pairs @repos
|
||||
tr ->
|
||||
td ->
|
||||
a href: repo.html_url, repo.name
|
||||
td repo.description or ""
|
||||
td repo.language
|
||||
td repo.stargazers_count
|
Loading…
Reference in New Issue