add autogenned list of projects

This commit is contained in:
Christine Dodrill 2015-02-01 00:17:40 -08:00
parent 8d3b3e391d
commit 4a1ba50221
5 changed files with 58 additions and 1 deletions

View File

@ -5,6 +5,7 @@ class extends lapis.Application
layout: require "layout.bootstrap" layout: require "layout.bootstrap"
@include "controllers.hire" @include "controllers.hire"
@include "controllers.projects"
[index: "/"]: => [index: "/"]: =>
@user, err = gh\get_authenticated_user() @user, err = gh\get_authenticated_user()

View File

@ -7,3 +7,4 @@ overlay:
dependencies: dependencies:
- moonscript - moonscript
- github - github
- dkjson

35
controllers/projects.moon Normal file
View File

@ -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

View File

@ -43,7 +43,7 @@ class Layout extends Widget
div id: "navbar", class: "collapse navbar-collapse", -> div id: "navbar", class: "collapse navbar-collapse", ->
ul class: "nav navbar-nav", -> ul class: "nav navbar-nav", ->
li -> li ->
a href: "/about", "About" a href: "/projects", "Projects"
li -> li ->
a href: "/hire", "Hire Me" a href: "/hire", "Hire Me"

20
views/projects.moon Normal file
View File

@ -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