aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-28 09:35:14 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-28 09:35:14 -0400
commita36c864bd86f59ed04d3c133cd1ad1fcdf61b9f7 (patch)
treef877eff1b1d5db8c6e9fe2b834ff1ff8e6f43eb6 /src
parentdfb1eb89909076b5d76ba27c1b5e558ea7914c5b (diff)
downloadguff-a36c864bd86f59ed04d3c133cd1ad1fcdf61b9f7.tar.bz2
guff-a36c864bd86f59ed04d3c133cd1ad1fcdf61b9f7.zip
refactor navbar and clean up logout page
Diffstat (limited to 'src')
-rw-r--r--src/guff/views/admin-navbar.cr9
-rw-r--r--src/guff/views/navbar.cr15
-rw-r--r--src/guff/views/pages/admin.cr8
-rw-r--r--src/guff/views/pages/login.cr11
-rw-r--r--src/guff/views/pages/logout.cr30
-rw-r--r--src/views/admin-navbar.ecr29
-rw-r--r--src/views/navbar.ecr31
-rw-r--r--src/views/pages/login.ecr17
-rw-r--r--src/views/pages/logout.ecr34
9 files changed, 98 insertions, 86 deletions
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 @@
-<div
- class='navbar navbar-inverse navbar-static-top'
- role='navigation'
->
- <div class='container-fluid'>
- <div class='navbar-header'>
- <a
- href='admin.html'
- class='navbar-brand'
- title='Reload admin page.'
- >
- <i class='fa fa-bomb'></i>
- <%= h(@title) %>
- </a><!-- navbar-brand -->
- </div><!-- navbar-default -->
-
- <ul class='nav navbar-nav navbar-right'>
- <li>
- <a
- href='logout.html'
- title='Log out.'
- >
- <i class='fa fa-power-off'></i>
- Log Out
- </a>
- </li>
- </ul><!-- nav -->
- </div><!-- container-fluid -->
-</div><!-- navbar -->
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 @@
+<div
+ class='navbar navbar-inverse navbar-static-top'
+ role='navigation'
+>
+ <div class='container-fluid'>
+ <div class='navbar-header'>
+ <a
+ href='<%= h(@link) %>'
+ class='navbar-brand'
+ title='<%= h(@text) %>'
+ >
+ <i class='fa fa-bomb'></i>
+ <%= h(@name) %>
+ </a><!-- navbar-brand -->
+ </div><!-- navbar-default -->
+
+ <% if @show_logout %>
+ <ul class='nav navbar-nav navbar-right'>
+ <li>
+ <a
+ href='logout.html'
+ title='Log out.'
+ >
+ <i class='fa fa-power-off'></i>
+ Log Out
+ </a>
+ </li>
+ </ul><!-- nav -->
+ <% end %>
+ </div><!-- container-fluid -->
+</div><!-- navbar -->
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 @@
</head>
<body>
- <div
- class='navbar navbar-inverse navbar-static-top'
- role='navigation'
- >
- <div class='container-fluid'>
- <div class='navbar-header'>
- <a
- href='../'
- class='navbar-brand'
- >
- <i class='fa fa-bomb'></i>
- <%= h(TITLE) %>
- </a><!-- navbar-brand -->
- </div><!-- navbar-default -->
- </div><!-- container-fluid -->
- </div><!-- navbar -->
+ <%= navbar %>
<div class='container'>
<div class='col-md-6 col-md-offset-3'>
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 @@
<html lang='en-US'>
<head>
<meta charset="utf-8"/>
- <title>Guff Logout</title>
+ <title><%= h(TITLE) %></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 %>
</head>
<body>
- <div
- class='navbar navbar-inverse navbar-static-top'
- role='navigation'
- >
- <div class='container-fluid'>
- <div class='navbar-header'>
- <a
- href='../'
- class='navbar-brand'
- >
- <i class='fa fa-bomb'></i>
- Guff
- </a><!-- navbar-brand -->
- </div><!-- navbar-default -->
- </div><!-- container-fluid -->
- </div><!-- navbar -->
+ <%= navbar %>
<div class='container'>
<div class='col-md-6 col-md-offset-3'>
@@ -58,10 +37,5 @@
</div><!-- container -->
</body>
- <%=
- scripts %w{
- assets/jquery-2.2.1.min.js
- assets/bootstrap-3.3.6/js/bootstrap.min.js
- }
- %>
+ <%= scripts %>
</html>