Working on adding session support

Starting to add API documentation page
Moved footer to base.html - Might move more later
pull/24/head
Jordan Wright 2013-12-09 00:35:07 -06:00
parent ceaf400206
commit 25a06a14a0
6 changed files with 186 additions and 76 deletions

4
api.go
View File

@ -19,3 +19,7 @@ func API_Campaigns_Id(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
fmt.Fprintf(w, "{\"method\" : \""+r.Method+"\", \"id\" : "+vars["id"]+"}")
}
func API_Doc(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "api_doc")
}

View File

@ -49,6 +49,7 @@ func createRouter() http.Handler {
api.HandleFunc("/", API)
api.HandleFunc("/campaigns", API_Campaigns)
api.HandleFunc("/campaigns/{id}", API_Campaigns_Id)
api.HandleFunc("/doc", API_Doc)
//Setup static file serving
router.PathPrefix("/").Handler(http.FileServer(http.Dir("./static/")))
@ -62,11 +63,14 @@ func Register(w http.ResponseWriter, r *http.Request) {
}
func Base(w http.ResponseWriter, r *http.Request) {
//w.Header().Set("Content-Type", "application/json")
session, _ := store.Get(r, "gophish")
// Example of saving session - will be removed.
session.Save(r, w)
renderTemplate(w, "dashboard")
}
func Base_Campaigns(w http.ResponseWriter, r *http.Request) {
session, _ := store.Get(r, "gophish")
renderTemplate(w, "dashboard")
}

View File

@ -1,70 +1,80 @@
.navbar-logo {
margin: 4px 0px;
float: left;
margin: 4px 0px;
float: left;
}
#navbar-login {
padding-top:8px;
padding-bottom:0px;
padding-top:8px;
padding-bottom:0px;
}
.sans {
font-family:'Open Sans', sans-serif !important;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin-heading {
text-align:center;
}
.form-signin .form-signin-heading, .form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
font-family:'Open Sans', sans-serif;
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
#logo {
display: block;
margin-left: auto;
margin-right: auto;
}
footer > p {
color:#444444;
font-family:'Open Sans', sans-serif;
}
.header {
margin-top:10px;
}
.sidebar {
padding-left:0px;
}
.sidebar a {
color:#201e1c;
}
.sidebar a:hover {
color:#201e1c;
}
.api_heading {
font-family:'Open Sans', sans-serif;
background-color:#201e1c;
border-radius: 5px;
padding:10px;
color:#E2E2E2;
width:100%;
}
p {
font-size:1.2em;
}
.sans {
font-family: 'Open Sans', sans-serif;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin-heading {
text-align:center;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
font-family: 'Open Sans', sans-serif;
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
#logo {
display: block;
margin-left: auto;
margin-right: auto;
}
footer > p {
color:#444444;
font-family: 'Open Sans', sans-serif;
}
.header {
margin-top:10px;
}
.sidebar {
padding-left:0px;
}

30
templates/api_doc.html Normal file
View File

@ -0,0 +1,30 @@
{{define "content"}} {{template "nav"}}
<div class="jumbotron">
<div class="container" style="text-align:center;">
<h1 class="sans header">
API Documentation
</h1>
</div>
</div>
<div class="container">
<div class="col-md-3 sidebar">
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#">Dashboard</a>
</li>
<li><a href="/users">Users &amp; Groups</a>
</li>
<li><a href="/settings">Settings</a>
</li>
<li><a href="/api/doc">API Documentation</a>
</li>
</ul>
</div>
<div class="col-md-9 sans">
<h1 style="margin-top:0px"><i class="fa fa-gear"></i> Gophish API</h1>
<p>Gophish runs on top of a RESTful API which allows developers to automate phishing campaigns easily. The following documentation and examples demonstrate the API functionality</p>
<h2 class="api_heading">/api/campaigns</h2>
<p>Test.</p>
</div>
</div>
{{end}}

View File

@ -23,8 +23,13 @@
<body>
{{template "content"}}
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Footer -->
<div class="container">
<hr>
<footer>
<p>&copy; Jordan (<a href="https://github.com/jordan-wright">jordan-wright</a>) 2013</p>
</footer>
</div>
<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>

View File

@ -1,7 +1,7 @@
{{define "content"}} {{template "nav"}}
<div class="jumbotron">
<div class="container" style="text-align:center;">
<h1 class="header">
<h1 class="sans header">
Dashboard
</h1>
</div>
@ -15,16 +15,73 @@
</li>
<li><a href="/settings">Settings</a>
</li>
<li><a href="/api/doc">API Documentation</a>
</li>
</ul>
</div>
<div class="col-md-9">
Testing
<div class="row">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newCampaignModal"><i class="fa fa-plus"></i> New Campaign</button>
</div>
&nbsp;
<div class="row">
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
</tr>
<tr>
<td>3</td>
<td>Mark</td>
<td>Otto</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
</tr>
<tr>
<td>3</td>
<td>Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="container">
<hr>
<footer>
<p>&copy; Jordan (jordan-wright) 2013</p>
</footer>
<!-- New Campaign Modal -->
<div class="modal" id="newCampaignModal" tabindex="-1" role="dialog" aria-labelledby="campaignModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="campaignModalLabel">New Campaign</h4>
</div>
<form action="/">
<div class="modal-body">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name">
<label for="users">Users &amp; Groups:</label>
<input type="text" class="form-control" id="users">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" type="submit">Launch Campaign</button>
</div>
</form>
</div>
</div>
</div>
{{end}}