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) vars := mux.Vars(r)
fmt.Fprintf(w, "{\"method\" : \""+r.Method+"\", \"id\" : "+vars["id"]+"}") 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("/", API)
api.HandleFunc("/campaigns", API_Campaigns) api.HandleFunc("/campaigns", API_Campaigns)
api.HandleFunc("/campaigns/{id}", API_Campaigns_Id) api.HandleFunc("/campaigns/{id}", API_Campaigns_Id)
api.HandleFunc("/doc", API_Doc)
//Setup static file serving //Setup static file serving
router.PathPrefix("/").Handler(http.FileServer(http.Dir("./static/"))) 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) { 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") renderTemplate(w, "dashboard")
} }
func Base_Campaigns(w http.ResponseWriter, r *http.Request) { func Base_Campaigns(w http.ResponseWriter, r *http.Request) {
session, _ := store.Get(r, "gophish")
renderTemplate(w, "dashboard") renderTemplate(w, "dashboard")
} }

View File

@ -6,23 +6,18 @@
padding-top:8px; padding-top:8px;
padding-bottom:0px; padding-bottom:0px;
} }
.sans { .sans {
font-family: 'Open Sans', sans-serif; font-family:'Open Sans', sans-serif !important;
} }
.form-signin { .form-signin {
max-width: 330px; max-width: 330px;
padding: 15px; padding: 15px;
margin: 0 auto; margin: 0 auto;
} }
.form-signin-heading { .form-signin-heading {
text-align:center; text-align:center;
} }
.form-signin .form-signin-heading, .form-signin .checkbox {
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px; margin-bottom: 10px;
} }
.form-signin .checkbox { .form-signin .checkbox {
@ -51,7 +46,6 @@
border-top-left-radius: 0; border-top-left-radius: 0;
border-top-right-radius: 0; border-top-right-radius: 0;
} }
#logo { #logo {
display: block; display: block;
margin-left: auto; margin-left: auto;
@ -61,10 +55,26 @@ footer > p {
color:#444444; color:#444444;
font-family:'Open Sans', sans-serif; font-family:'Open Sans', sans-serif;
} }
.header { .header {
margin-top:10px; margin-top:10px;
} }
.sidebar { .sidebar {
padding-left:0px; 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;
}

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> <body>
{{template "content"}} {{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 --> <!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery.js"></script> <script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>

View File

@ -1,7 +1,7 @@
{{define "content"}} {{template "nav"}} {{define "content"}} {{template "nav"}}
<div class="jumbotron"> <div class="jumbotron">
<div class="container" style="text-align:center;"> <div class="container" style="text-align:center;">
<h1 class="header"> <h1 class="sans header">
Dashboard Dashboard
</h1> </h1>
</div> </div>
@ -15,16 +15,73 @@
</li> </li>
<li><a href="/settings">Settings</a> <li><a href="/settings">Settings</a>
</li> </li>
<li><a href="/api/doc">API Documentation</a>
</li>
</ul> </ul>
</div> </div>
<div class="col-md-9"> <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>
<!-- 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> </div>
<div class="container">
<hr>
<footer>
<p>&copy; Jordan (jordan-wright) 2013</p>
</footer>
</div> </div>
{{end}} {{end}}