From a36c864bd86f59ed04d3c133cd1ad1fcdf61b9f7 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 28 Jul 2016 09:35:14 -0400 Subject: refactor navbar and clean up logout page --- src/guff/views/admin-navbar.cr | 9 --------- src/guff/views/navbar.cr | 15 +++++++++++++++ src/guff/views/pages/admin.cr | 8 +++++++- src/guff/views/pages/login.cr | 11 ++++++++++- src/guff/views/pages/logout.cr | 30 ++++++++++++++++++++++++++++++ src/views/admin-navbar.ecr | 29 ----------------------------- src/views/navbar.ecr | 31 +++++++++++++++++++++++++++++++ src/views/pages/login.ecr | 17 +---------------- src/views/pages/logout.ecr | 34 ++++------------------------------ 9 files changed, 98 insertions(+), 86 deletions(-) delete mode 100644 src/guff/views/admin-navbar.cr create mode 100644 src/guff/views/navbar.cr delete mode 100644 src/views/admin-navbar.ecr create mode 100644 src/views/navbar.ecr diff --git a/src/guff/views/admin-navbar.cr b/src/guff/views/admin-navbar.cr deleted file mode 100644 index 3d88cd6..0000000 --- a/src/guff/views/admin-navbar.cr +++ /dev/null @@ -1,9 +0,0 @@ -require "./html" - -class Guff::Views::AdminNavbarView < Guff::Views::HTMLView - def initialize(context, @title : String) - super(context) - end - - ECR.def_to_s("src/views/admin-navbar.ecr") -end diff --git a/src/guff/views/navbar.cr b/src/guff/views/navbar.cr new file mode 100644 index 0000000..89331cb --- /dev/null +++ b/src/guff/views/navbar.cr @@ -0,0 +1,15 @@ +require "./html" + +class Guff::Views::Navbar < Guff::Views::HTMLView + def initialize( + context : Context, + @name : String, + @link : String, + @text : String, + @show_logout : Bool = false, + ) + super(context) + end + + ECR.def_to_s("src/views/navbar.ecr") +end diff --git a/src/guff/views/pages/admin.cr b/src/guff/views/pages/admin.cr index 15d82dc..e385cea 100644 --- a/src/guff/views/pages/admin.cr +++ b/src/guff/views/pages/admin.cr @@ -66,7 +66,13 @@ class Guff::Views::Pages::Admin < Guff::Views::HTMLView end private def navbar - AdminNavbarView.new(@context, TITLE) + Guff::Views::Navbar.new( + context: @context, + name: TITLE, + link: "admin.html", + text: "Reload admin page.", + show_logout: true, + ) end private def tabs diff --git a/src/guff/views/pages/login.cr b/src/guff/views/pages/login.cr index 8dc7b65..830623b 100644 --- a/src/guff/views/pages/login.cr +++ b/src/guff/views/pages/login.cr @@ -1,7 +1,7 @@ require "../html" class Guff::Views::Pages::Login < Guff::Views::HTMLView - TITLE = "Guff" + TITLE = "Guff Login" STYLES = %w{ assets/font-awesome-4.5.0/css/font-awesome.min.css @@ -26,6 +26,15 @@ class Guff::Views::Pages::Login < Guff::Views::HTMLView super(SCRIPTS) end + private def navbar + Guff::Views::Navbar.new( + context: @context, + name: TITLE, + link: "../", + text: "Return to site." + ) + end + def get_csrf_token @context.models.csrf.create_token end diff --git a/src/guff/views/pages/logout.cr b/src/guff/views/pages/logout.cr index e04a916..e7837c0 100644 --- a/src/guff/views/pages/logout.cr +++ b/src/guff/views/pages/logout.cr @@ -1,5 +1,35 @@ require "../html" class Guff::Views::Pages::Logout < Guff::Views::HTMLView + TITLE = "Guff Logout" + + STYLES = %w{ + assets/font-awesome-4.5.0/css/font-awesome.min.css + assets/bootstrap-3.3.6/css/bootstrap.min.css + assets/bootstrap-3.3.6/css/bootstrap-theme.min.css + } + + SCRIPTS = %w{ + assets/jquery-2.2.1.min.js + assets/bootstrap-3.3.6/js/bootstrap.min.js + } + + private def styles + super(STYLES) + end + + private def scripts + super(SCRIPTS) + end + + private def navbar + Guff::Views::Navbar.new( + context: @context, + name: TITLE, + link: "../", + text: "Return to site." + ) + end + ECR.def_to_s("src/views/pages/logout.ecr") end diff --git a/src/views/admin-navbar.ecr b/src/views/admin-navbar.ecr deleted file mode 100644 index 4a06b15..0000000 --- a/src/views/admin-navbar.ecr +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/src/views/navbar.ecr b/src/views/navbar.ecr new file mode 100644 index 0000000..4164b90 --- /dev/null +++ b/src/views/navbar.ecr @@ -0,0 +1,31 @@ + diff --git a/src/views/pages/login.ecr b/src/views/pages/login.ecr index 4762104..8be0734 100644 --- a/src/views/pages/login.ecr +++ b/src/views/pages/login.ecr @@ -8,22 +8,7 @@ - + <%= navbar %>
diff --git a/src/views/pages/logout.ecr b/src/views/pages/logout.ecr index b3c2eae..0891823 100644 --- a/src/views/pages/logout.ecr +++ b/src/views/pages/logout.ecr @@ -2,34 +2,13 @@ - Guff Logout + <%= h(TITLE) %> - <%= - styles %w{ - assets/font-awesome-4.5.0/css/font-awesome.min.css - assets/bootstrap-3.3.6/css/bootstrap.min.css - assets/bootstrap-3.3.6/css/bootstrap-theme.min.css - } - %> + <%= styles %> - + <%= navbar %>
@@ -58,10 +37,5 @@
- <%= - scripts %w{ - assets/jquery-2.2.1.min.js - assets/bootstrap-3.3.6/js/bootstrap.min.js - } - %> + <%= scripts %> -- cgit v1.2.3