mirror of https://github.com/gophish/gophish
Previewing Landing pages in a different window seems to work now.
Working on getting some site clone functionality working.pull/24/head
parent
f21d40d77a
commit
4211abe78b
|
@ -1,6 +1,7 @@
|
||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -30,7 +31,8 @@ func CreateAdminRouter() http.Handler {
|
||||||
router.HandleFunc("/logout", Use(Logout, mid.RequireLogin))
|
router.HandleFunc("/logout", Use(Logout, mid.RequireLogin))
|
||||||
router.HandleFunc("/register", Register)
|
router.HandleFunc("/register", Register)
|
||||||
router.HandleFunc("/settings", Use(Settings, mid.RequireLogin))
|
router.HandleFunc("/settings", Use(Settings, mid.RequireLogin))
|
||||||
router.HandleFunc("/preview", Use(Preview, mid.RequireLogin))
|
router.HandleFunc("/html/preview", Use(Preview, mid.RequireLogin))
|
||||||
|
router.HandleFunc("/html/clone", Use(Clone, mid.RequireLogin))
|
||||||
// Create the API routes
|
// Create the API routes
|
||||||
api := router.PathPrefix("/api").Subrouter()
|
api := router.PathPrefix("/api").Subrouter()
|
||||||
api = api.StrictSlash(true)
|
api = api.StrictSlash(true)
|
||||||
|
@ -236,7 +238,19 @@ func Preview(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "Method not allowed", http.StatusBadRequest)
|
http.Error(w, "Method not allowed", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
getTemplate(w, "dashboard").ExecuteTemplate(w, "base", struct{}{})
|
fmt.Fprintf(w, "%s", r.FormValue("html"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone takes a URL as a POST parameter and returns the site HTML
|
||||||
|
func Clone(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
if r.Method != "POST" {
|
||||||
|
http.Error(w, "Method not allowed", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
if url, ok := vars["url"]; ok {
|
||||||
|
Logger.Println(url)
|
||||||
|
}
|
||||||
|
http.Error(w, "No URL given.", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTemplate(w http.ResponseWriter, tmpl string) *template.Template {
|
func getTemplate(w http.ResponseWriter, tmpl string) *template.Template {
|
||||||
|
|
|
@ -785,6 +785,7 @@ var LandingPageModalCtrl = function($scope, $modalInstance) {
|
||||||
$modalInstance.dismiss('')
|
$modalInstance.dismiss('')
|
||||||
$scope.savePage(page)
|
$scope.savePage(page)
|
||||||
};
|
};
|
||||||
|
$scope.csrf_token = csrf_token
|
||||||
};
|
};
|
||||||
|
|
||||||
app.controller('SettingsCtrl', function($scope, $http, $window) {
|
app.controller('SettingsCtrl', function($scope, $http, $window) {
|
||||||
|
|
|
@ -51,10 +51,10 @@
|
||||||
<span class="sr-only">Toggle Dropdown</span>
|
<span class="sr-only">Toggle Dropdown</span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" style="left:auto; right:0;" role="menu">
|
<ul class="dropdown-menu" style="left:auto; right:0;" role="menu">
|
||||||
<li><a ng-click="editTemplate(template)">Edit</a>
|
<li><a ng-click="editPage(page)">Edit</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a ng-click="deleteTemplate(template)" ng-href="#">Delete</a>
|
<li><a ng-click="deletePage(page)" ng-href="#">Delete</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<h4 class="modal-title" ng-show="newPage" id="pageModalLabel">New Page</h4>
|
<h4 class="modal-title" ng-show="newPage" id="pageModalLabel">New Page</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<form action="/html/preview" method="post" target="_blank">
|
||||||
<label class="control-label" for="name">Name:</label>
|
<label class="control-label" for="name">Name:</label>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" class="form-control" ng-model="page.name" placeholder="Page name" id="name" autofocus/>
|
<input type="text" class="form-control" ng-model="page.name" placeholder="Page name" id="name" autofocus/>
|
||||||
|
@ -17,18 +18,18 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<tabset>
|
<tabset>
|
||||||
<tab heading="HTML">
|
<tab heading="HTML">
|
||||||
<textarea rows="10" class="form-control" ng-model="page.html" placeholder="HTML"></textarea>
|
<textarea rows="10" class="form-control" ng-model="page.html" name="html" placeholder="HTML"></textarea>
|
||||||
</tab>
|
</tab>
|
||||||
<tab heading="Preview">
|
<tab heading="Preview">
|
||||||
<div ng-model="page.html" contenteditable></div>
|
<div ng-model="page.html" contenteditable></div>
|
||||||
</tab>
|
</tab>
|
||||||
</tabset>
|
</tabset>
|
||||||
<br />
|
<br />
|
||||||
<fieldset disabled>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-danger btn-disabled"><i class="fa fa-external-link-square"></i> Preview in New Window (Coming Soon!)</button>
|
<button type="submit" class="btn btn-danger btn-disabled"><i class="fa fa-external-link-square"></i> Preview in New Window</button>
|
||||||
|
<input type="hidden" name="csrf_token" value="{{csrf_token}}"/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
|
<button type="button" class="btn btn-default" ng-click="cancel()">Cancel</button>
|
||||||
|
|
Loading…
Reference in New Issue