From e1eadc3892e5f66d088aae2b75e2b3b39c8ddaef Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jun 2015 16:49:16 -0500 Subject: [PATCH] Re-organizing files to use Jquery instead of Angular --- controllers/route.go | 70 +++++++++++++++-- templates/base.html | 48 ++++++------ templates/campaign_results.html | 83 ++++++++++++++++++++ templates/campaigns.html | 73 ++++++++++++++++++ templates/dashboard.html | 130 ++++++++++++-------------------- templates/flashes.html | 22 +++--- templates/landing_pages.html | 67 ++++++++++++++++ templates/login.html | 10 +-- templates/register.html | 23 +----- templates/settings.html | 6 +- templates/templates.html | 69 +++++++++++++++++ templates/users.html | 73 ++++++++++++++++++ 12 files changed, 525 insertions(+), 149 deletions(-) create mode 100644 templates/campaign_results.html create mode 100644 templates/campaigns.html create mode 100644 templates/landing_pages.html create mode 100644 templates/templates.html create mode 100644 templates/users.html diff --git a/controllers/route.go b/controllers/route.go index eb7fecc3..9ce43590 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -16,8 +16,6 @@ import ( "github.com/justinas/nosurf" ) -var templateDelims = []string{"{{%", "%}}"} - // Logger is used to send logging messages to stdout. var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile) @@ -29,6 +27,11 @@ func CreateAdminRouter() http.Handler { router.HandleFunc("/", Use(Base, mid.RequireLogin)) router.HandleFunc("/login", Login) router.HandleFunc("/logout", Use(Logout, mid.RequireLogin)) + router.HandleFunc("/campaigns", Use(Campaigns, mid.RequireLogin)) + router.HandleFunc("/campaigns/{id:[0-9]+}", Use(CampaignID, mid.RequireLogin)) + router.HandleFunc("/templates", Use(Templates, mid.RequireLogin)) + router.HandleFunc("/users", Use(Users, mid.RequireLogin)) + router.HandleFunc("/landing_pages", Use(LandingPages, mid.RequireLogin)) router.HandleFunc("/register", Register) router.HandleFunc("/settings", Use(Settings, mid.RequireLogin)) // Create the API routes @@ -141,7 +144,6 @@ func Register(w http.ResponseWriter, r *http.Request) { params.Flashes = session.Flashes() session.Save(r, w) templates := template.New("template") - templates.Delims(templateDelims[0], templateDelims[1]) _, err := templates.ParseFiles("templates/register.html", "templates/flashes.html") if err != nil { Logger.Println(err) @@ -190,6 +192,66 @@ func Base(w http.ResponseWriter, r *http.Request) { getTemplate(w, "dashboard").ExecuteTemplate(w, "base", params) } +// Campaigns handles the default path and template execution +func Campaigns(w http.ResponseWriter, r *http.Request) { + // Example of using session - will be removed. + params := struct { + User models.User + Title string + Flashes []interface{} + Token string + }{Title: "Campaigns", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)} + getTemplate(w, "campaigns").ExecuteTemplate(w, "base", params) +} + +// CampaignID handles the default path and template execution +func CampaignID(w http.ResponseWriter, r *http.Request) { + // Example of using session - will be removed. + params := struct { + User models.User + Title string + Flashes []interface{} + Token string + }{Title: "Dashboard", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)} + getTemplate(w, "campaign_results").ExecuteTemplate(w, "base", params) +} + +// Templates handles the default path and template execution +func Templates(w http.ResponseWriter, r *http.Request) { + // Example of using session - will be removed. + params := struct { + User models.User + Title string + Flashes []interface{} + Token string + }{Title: "Dashboard", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)} + getTemplate(w, "templates").ExecuteTemplate(w, "base", params) +} + +// Users handles the default path and template execution +func Users(w http.ResponseWriter, r *http.Request) { + // Example of using session - will be removed. + params := struct { + User models.User + Title string + Flashes []interface{} + Token string + }{Title: "Dashboard", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)} + getTemplate(w, "users").ExecuteTemplate(w, "base", params) +} + +// LandingPages handles the default path and template execution +func LandingPages(w http.ResponseWriter, r *http.Request) { + // Example of using session - will be removed. + params := struct { + User models.User + Title string + Flashes []interface{} + Token string + }{Title: "Dashboard", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)} + getTemplate(w, "landing_pages").ExecuteTemplate(w, "base", params) +} + // Settings handles the changing of settings func Settings(w http.ResponseWriter, r *http.Request) { switch { @@ -222,7 +284,6 @@ func Login(w http.ResponseWriter, r *http.Request) { params.Flashes = session.Flashes() session.Save(r, w) templates := template.New("template") - templates.Delims(templateDelims[0], templateDelims[1]) _, err := templates.ParseFiles("templates/login.html", "templates/flashes.html") if err != nil { Logger.Println(err) @@ -277,7 +338,6 @@ func Clone(w http.ResponseWriter, r *http.Request) { func getTemplate(w http.ResponseWriter, tmpl string) *template.Template { templates := template.New("template") - templates.Delims(templateDelims[0], templateDelims[1]) _, err := templates.ParseFiles("templates/base.html", "templates/"+tmpl+".html", "templates/flashes.html") if err != nil { Logger.Println(err) diff --git a/templates/base.html b/templates/base.html index 9d64120f..07419c23 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,16 +1,16 @@ -{{% define "base" %}} +{{ define "base" }} - + - + - Gophish - {{% .Title %}} + Gophish - {{ .Title }} @@ -22,15 +22,15 @@ @@ -64,9 +64,9 @@
  • API Documentation
  • - {{%if .User%}} + {{if .User}}
  • - {{%else%}} + {{else}} - {{%end%}} + {{end}} -
    + {{template "body" .}} - + - - + - + - +