Skip to content

Commit

Permalink
admin: expanded work on interface
Browse files Browse the repository at this point in the history
posts/new endpoint.
layout with bootstrap.
  • Loading branch information
slogsdon committed Apr 22, 2014
1 parent 2f12e72 commit 8a76da6
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you wish to run the tests, either run them using `go test ./...` in the proje
## TODO

- Create new posts - 50% (api endpoint complete)
- Edit posts
- Edit posts - 75% (api endpoints [show, update] and admin endpoint [edit] complete)
- Admin interface
- Generation of static files
- Automated revisioning with git
Expand Down
1 change: 1 addition & 0 deletions b.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func Start() {

r.Get("", a.Index)
r.Get("/posts", a.Posts.Index)
r.Get("/posts/new", a.Posts.New)
r.Get("/posts/edit/**", a.Posts.Edit)

}, render.Renderer(render.Options{
Expand Down
161 changes: 153 additions & 8 deletions fixtures/templates/admin/index.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,153 @@
<html>
<head>
<title>admin index</title>
</head>
<body>
hi
</body>
<html>
<h1 class="page-header">Dashboard</h1>

<div class="row placeholders">
<div class="col-xs-6 col-sm-3 placeholder">
<img src="http://placekitten.com/g/200/200" class="img-responsive" alt="Generic placeholder thumbnail">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="http://placekitten.com/g/200/200" class="img-responsive" alt="Generic placeholder thumbnail">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="http://placekitten.com/g/200/200" class="img-responsive" alt="Generic placeholder thumbnail">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="http://placekitten.com/g/200/200" class="img-responsive" alt="Generic placeholder thumbnail">
<h4>Label</h4>
<span class="text-muted">Something else</span>
</div>
</div>

<h2 class="sub-header">Section title</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,001</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
<tr>
<td>1,002</td>
<td>amet</td>
<td>consectetur</td>
<td>adipiscing</td>
<td>elit</td>
</tr>
<tr>
<td>1,003</td>
<td>Integer</td>
<td>nec</td>
<td>odio</td>
<td>Praesent</td>
</tr>
<tr>
<td>1,003</td>
<td>libero</td>
<td>Sed</td>
<td>cursus</td>
<td>ante</td>
</tr>
<tr>
<td>1,004</td>
<td>dapibus</td>
<td>diam</td>
<td>Sed</td>
<td>nisi</td>
</tr>
<tr>
<td>1,005</td>
<td>Nulla</td>
<td>quis</td>
<td>sem</td>
<td>at</td>
</tr>
<tr>
<td>1,006</td>
<td>nibh</td>
<td>elementum</td>
<td>imperdiet</td>
<td>Duis</td>
</tr>
<tr>
<td>1,007</td>
<td>sagittis</td>
<td>ipsum</td>
<td>Praesent</td>
<td>mauris</td>
</tr>
<tr>
<td>1,008</td>
<td>Fusce</td>
<td>nec</td>
<td>tellus</td>
<td>sed</td>
</tr>
<tr>
<td>1,009</td>
<td>augue</td>
<td>semper</td>
<td>porta</td>
<td>Mauris</td>
</tr>
<tr>
<td>1,010</td>
<td>massa</td>
<td>Vestibulum</td>
<td>lacinia</td>
<td>arcu</td>
</tr>
<tr>
<td>1,011</td>
<td>eget</td>
<td>nulla</td>
<td>Class</td>
<td>aptent</td>
</tr>
<tr>
<td>1,012</td>
<td>taciti</td>
<td>sociosqu</td>
<td>ad</td>
<td>litora</td>
</tr>
<tr>
<td>1,013</td>
<td>torquent</td>
<td>per</td>
<td>conubia</td>
<td>nostra</td>
</tr>
<tr>
<td>1,014</td>
<td>per</td>
<td>inceptos</td>
<td>himenaeos</td>
<td>Curabitur</td>
</tr>
<tr>
<td>1,015</td>
<td>sodales</td>
<td>ligula</td>
<td>in</td>
<td>libero</td>
</tr>
</tbody>
</table>
</div>
166 changes: 159 additions & 7 deletions fixtures/templates/admin/layout.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,161 @@
<html>
<head>
<title>Martini Plz</title>
</head>
<body>
<!-- Render the current template here -->
{{ yield }}
</body>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Martini Plz</title>

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" type="text/css" />
<style type="text/css">
/*
* Base structure
*/

/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
}


/*
* Global add-ons
*/

.sub-header {
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}


/*
* Sidebar
*/

/* Hide for mobile, show later */
.sidebar {
display: none;
}
@media (min-width: 768px) {
.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
background-color: #f5f5f5;
border-right: 1px solid #eee;
}
}

/* Sidebar navigation */
.nav-sidebar {
margin-right: -21px; /* 20px padding + 1px border */
margin-bottom: 20px;
margin-left: -20px;
}
.nav-sidebar > li > a {
padding-right: 20px;
padding-left: 20px;
}
.nav-sidebar > .active > a {
color: #fff;
background-color: #428bca;
}


/*
* Main content
*/

.main {
padding: 20px;
}
@media (min-width: 768px) {
.main {
padding-right: 40px;
padding-left: 40px;
}
}
.main .page-header {
margin-top: 0;
}


/*
* Placeholder dashboard ideas
*/

.placeholders {
margin-bottom: 30px;
text-align: center;
}
.placeholders h4 {
margin-bottom: 0;
}
.placeholder {
margin-bottom: 20px;
}
.placeholder img {
display: inline-block;
border-radius: 50%;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="/admin">Dashboard</a></li>
<li><a href="/">Site</a></li>
<!-- <li><a href="#">Settings</a></li> -->
<li><a href="https://github.com/slogsdon/b">Help</a></li>
</ul>
<form class="navbar-form navbar-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
</div>
</div>
</div>

<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li><a href="/admin">Overview</a></li>
<li><a href="/admin/posts">Posts</a></li>
<!-- <li><a href="/admin/statistics">Statistics</a></li> -->
<li><a href="/admin/deploy">Deploy</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<!-- Render the current template here -->
{{ yield }}
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>
9 changes: 1 addition & 8 deletions fixtures/templates/admin/posts/index.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
<html>
<head>
<title>admin posts index</title>
</head>
<body>
hi
</body>
<html>
<h1>Posts <span class="btn btn-normal">&mdash; <a href="/admin/posts/new">Add New Post</a></span></h1>
1 change: 1 addition & 0 deletions fixtures/templates/admin/posts/new.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Add New Posts <span class="btn btn-normal">&mdash; <a href="/admin/posts">Back</a></span></h1>
5 changes: 5 additions & 0 deletions handlers/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func (ap AdminPosts) Index(r render.Render) {
r.HTML(200, "admin/posts/index", "")
}

// New allows for adding new posts.
func (ap AdminPosts) New(r render.Render) {
r.HTML(200, "admin/posts/new", "")
}

// Edit loads a post for editing.
func (ap AdminPosts) Edit(params martini.Params, r render.Render) {
var post models.Post
Expand Down

0 comments on commit 8a76da6

Please sign in to comment.