From 4c86c22ff083cd7e50eb6b6cdeba088eaa23b34c Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 28 Jul 2016 08:42:10 -0400 Subject: reorganize pages --- src/guff/handlers.cr | 7 +-- src/guff/views/admin-page.cr | 100 ------------------------------------ src/guff/views/login-page.cr | 13 ----- src/guff/views/logout-page.cr | 5 -- src/guff/views/pages/admin.cr | 100 ++++++++++++++++++++++++++++++++++++ src/guff/views/pages/login.cr | 13 +++++ src/guff/views/pages/logout.cr | 5 ++ src/views/admin-page.ecr | 32 ------------ src/views/login-page.ecr | 114 ----------------------------------------- src/views/logout-page.ecr | 67 ------------------------ src/views/pages/admin.ecr | 32 ++++++++++++ src/views/pages/login.ecr | 114 +++++++++++++++++++++++++++++++++++++++++ src/views/pages/logout.ecr | 67 ++++++++++++++++++++++++ 13 files changed, 335 insertions(+), 334 deletions(-) delete mode 100644 src/guff/views/admin-page.cr delete mode 100644 src/guff/views/login-page.cr delete mode 100644 src/guff/views/logout-page.cr create mode 100644 src/guff/views/pages/admin.cr create mode 100644 src/guff/views/pages/login.cr create mode 100644 src/guff/views/pages/logout.cr delete mode 100644 src/views/admin-page.ecr delete mode 100644 src/views/login-page.ecr delete mode 100644 src/views/logout-page.ecr create mode 100644 src/views/pages/admin.ecr create mode 100644 src/views/pages/login.ecr create mode 100644 src/views/pages/logout.ecr (limited to 'src') diff --git a/src/guff/handlers.cr b/src/guff/handlers.cr index 2670f89..8c3e550 100644 --- a/src/guff/handlers.cr +++ b/src/guff/handlers.cr @@ -215,7 +215,7 @@ module Guff::Handlers context.response.headers["x-frame-options"] = "SAMEORIGIN" context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - Views::AdminPageView.new(@context).to_s(context.response) + Views::Pages::Admin.new(@context).to_s(context.response) else call_next(context) end @@ -278,7 +278,8 @@ module Guff::Handlers response.headers["x-frame-options"] = "SAMEORIGIN" response.content_type = "text/html; charset=utf-8" response.status_code = 200 - Views::LoginPageView.new(@context, error).to_s(response) + + Views::Pages::Login.new(@context, error).to_s(response) end private def login(body : String?) @@ -340,7 +341,7 @@ module Guff::Handlers context.response.status_code = 200 # draw page - Views::LogoutPageView.new(@context).to_s(context.response) + Views::Pages::Logout.new(@context).to_s(context.response) else call_next(context) end diff --git a/src/guff/views/admin-page.cr b/src/guff/views/admin-page.cr deleted file mode 100644 index 63ebec2..0000000 --- a/src/guff/views/admin-page.cr +++ /dev/null @@ -1,100 +0,0 @@ -require "./html" -require "./dialogs/*" -require "./panes/*" - -class Guff::Views::AdminPageView < Guff::Views::HTMLView - TITLE = "Guff Admin" - - 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 - assets/css/admin.css - } - - SCRIPTS = %w{ - assets/jquery-2.2.1.min.js - assets/luigi-template-0.4.1.min.js - assets/js/util.js - assets/bootstrap-3.3.6/js/bootstrap.min.js - assets/ckeditor-4.5.8-custom/ckeditor.js - assets/js/search-field.js - assets/js/dropdown.js - assets/js/admin/tabs/users.js - assets/js/admin/tabs/posts.js - assets/js/admin/tabs/files.js - assets/js/admin/dialogs/user-add.js - assets/js/admin/dialogs/user-edit.js - assets/js/admin/dialogs/post-edit.js - assets/js/admin/dialogs/blog-edit.js - assets/js/admin/dialogs/page-edit.js - assets/js/admin/dialogs/project-edit.js - } - - TABS = [{ - :id => "home", - :css => "active", - :icon => "fa-home", - :name => "Home", - :text => "View home tab.", - }, { - :id => "posts", - :css => "", - :icon => "fa-cubes", - :name => "Posts", - :text => "Manage blog, pages, and projects.", - }, { - :id => "files", - :css => "", - :icon => "fa-files-o", - :name => "Files", - :text => "Manage files.", - }, { - :id => "settings", - :css => "", - :icon => "fa-cogs", - :name => "Settings", - :text => "Configure settings.", - }] - - private def styles - super(STYLES) - end - - private def scripts - super(SCRIPTS) - end - - private def navbar - AdminNavbarView.new(@context, TITLE) - end - - private def tabs - super("admin", TABS) - end - - private def panes - String.build do |io| - io << Panes::Admin::Home.new(@context) - io << Panes::Admin::Posts.new(@context) - io << Panes::Admin::Files.new(@context) - io << Panes::Admin::Settings.new(@context) - end - end - - private def dialogs - String.build do |io| - io << Dialogs::Admin::UserAdd.new(@context) - io << Dialogs::Admin::UserEdit.new(@context) - io << Dialogs::Admin::BlogEdit.new(@context) - io << Dialogs::Admin::PageEdit.new(@context) - io << Dialogs::Admin::ProjectEdit.new(@context) - end - end - - private def page_data - { post_types: POST_TYPES}.to_json - end - - ECR.def_to_s("src/views/admin-page.ecr") -end diff --git a/src/guff/views/login-page.cr b/src/guff/views/login-page.cr deleted file mode 100644 index 892f3c1..0000000 --- a/src/guff/views/login-page.cr +++ /dev/null @@ -1,13 +0,0 @@ -require "./view" - -class Guff::Views::LoginPageView < Guff::Views::HTMLView - def initialize(context : Context, @error : String? = nil) - super(context) - end - - def get_csrf_token - @context.models.csrf.create_token - end - - ECR.def_to_s("src/views/login-page.ecr") -end diff --git a/src/guff/views/logout-page.cr b/src/guff/views/logout-page.cr deleted file mode 100644 index 164faf7..0000000 --- a/src/guff/views/logout-page.cr +++ /dev/null @@ -1,5 +0,0 @@ -require "./view" - -class Guff::Views::LogoutPageView < Guff::Views::HTMLView - ECR.def_to_s("src/views/logout-page.ecr") -end diff --git a/src/guff/views/pages/admin.cr b/src/guff/views/pages/admin.cr new file mode 100644 index 0000000..15d82dc --- /dev/null +++ b/src/guff/views/pages/admin.cr @@ -0,0 +1,100 @@ +require "../html" +require "../dialogs/*" +require "../panes/*" + +class Guff::Views::Pages::Admin < Guff::Views::HTMLView + TITLE = "Guff Admin" + + 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 + assets/css/admin.css + } + + SCRIPTS = %w{ + assets/jquery-2.2.1.min.js + assets/luigi-template-0.4.1.min.js + assets/js/util.js + assets/bootstrap-3.3.6/js/bootstrap.min.js + assets/ckeditor-4.5.8-custom/ckeditor.js + assets/js/search-field.js + assets/js/dropdown.js + assets/js/admin/tabs/users.js + assets/js/admin/tabs/posts.js + assets/js/admin/tabs/files.js + assets/js/admin/dialogs/user-add.js + assets/js/admin/dialogs/user-edit.js + assets/js/admin/dialogs/post-edit.js + assets/js/admin/dialogs/blog-edit.js + assets/js/admin/dialogs/page-edit.js + assets/js/admin/dialogs/project-edit.js + } + + TABS = [{ + :id => "home", + :css => "active", + :icon => "fa-home", + :name => "Home", + :text => "View home tab.", + }, { + :id => "posts", + :css => "", + :icon => "fa-cubes", + :name => "Posts", + :text => "Manage blog, pages, and projects.", + }, { + :id => "files", + :css => "", + :icon => "fa-files-o", + :name => "Files", + :text => "Manage files.", + }, { + :id => "settings", + :css => "", + :icon => "fa-cogs", + :name => "Settings", + :text => "Configure settings.", + }] + + private def styles + super(STYLES) + end + + private def scripts + super(SCRIPTS) + end + + private def navbar + AdminNavbarView.new(@context, TITLE) + end + + private def tabs + super("admin", TABS) + end + + private def panes + String.build do |io| + io << Panes::Admin::Home.new(@context) + io << Panes::Admin::Posts.new(@context) + io << Panes::Admin::Files.new(@context) + io << Panes::Admin::Settings.new(@context) + end + end + + private def dialogs + String.build do |io| + io << Dialogs::Admin::UserAdd.new(@context) + io << Dialogs::Admin::UserEdit.new(@context) + io << Dialogs::Admin::BlogEdit.new(@context) + io << Dialogs::Admin::PageEdit.new(@context) + io << Dialogs::Admin::ProjectEdit.new(@context) + end + end + + private def page_data + { post_types: POST_TYPES}.to_json + end + + ECR.def_to_s("src/views/pages/admin.ecr") +end diff --git a/src/guff/views/pages/login.cr b/src/guff/views/pages/login.cr new file mode 100644 index 0000000..dae1a82 --- /dev/null +++ b/src/guff/views/pages/login.cr @@ -0,0 +1,13 @@ +require "../html" + +class Guff::Views::Pages::Login < Guff::Views::HTMLView + def initialize(context : Context, @error : String? = nil) + super(context) + end + + def get_csrf_token + @context.models.csrf.create_token + end + + ECR.def_to_s("src/views/pages/login.ecr") +end diff --git a/src/guff/views/pages/logout.cr b/src/guff/views/pages/logout.cr new file mode 100644 index 0000000..e04a916 --- /dev/null +++ b/src/guff/views/pages/logout.cr @@ -0,0 +1,5 @@ +require "../html" + +class Guff::Views::Pages::Logout < Guff::Views::HTMLView + ECR.def_to_s("src/views/pages/logout.ecr") +end diff --git a/src/views/admin-page.ecr b/src/views/admin-page.ecr deleted file mode 100644 index 1eb030a..0000000 --- a/src/views/admin-page.ecr +++ /dev/null @@ -1,32 +0,0 @@ - - - - - <%= h(TITLE) %> - <%= styles %> - - - - <%= navbar %> - -
-
- - -
<%= - panes - %>
-
-
- - <%= dialogs %> - - - - - <%= scripts %> - diff --git a/src/views/login-page.ecr b/src/views/login-page.ecr deleted file mode 100644 index 16f63a4..0000000 --- a/src/views/login-page.ecr +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Guff Login - - <%= - 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 - } - %> - - - - - -
-
-
-
- - - Login - -
- -
- <% if @error %> -
-
- - - Error: Invalid Login - -
-
- <% end %> - -
-
- - - -
- -
- - - -
- -
- -
- - -
-
-
-
-
- - - <%= - scripts %w{ - assets/jquery-2.2.1.min.js - assets/bootstrap-3.3.6/js/bootstrap.min.js - } - %> - diff --git a/src/views/logout-page.ecr b/src/views/logout-page.ecr deleted file mode 100644 index b3c2eae..0000000 --- a/src/views/logout-page.ecr +++ /dev/null @@ -1,67 +0,0 @@ - - - - - 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 - } - %> - - - - - -
-
-
-
- - - Log Out - -
- -
-

- You have logged out. -

- -

- Go to Login page -

-
-
-
-
- - - <%= - scripts %w{ - assets/jquery-2.2.1.min.js - assets/bootstrap-3.3.6/js/bootstrap.min.js - } - %> - diff --git a/src/views/pages/admin.ecr b/src/views/pages/admin.ecr new file mode 100644 index 0000000..1eb030a --- /dev/null +++ b/src/views/pages/admin.ecr @@ -0,0 +1,32 @@ + + + + + <%= h(TITLE) %> + <%= styles %> + + + + <%= navbar %> + +
+
+ + +
<%= + panes + %>
+
+
+ + <%= dialogs %> + + + + + <%= scripts %> + diff --git a/src/views/pages/login.ecr b/src/views/pages/login.ecr new file mode 100644 index 0000000..16f63a4 --- /dev/null +++ b/src/views/pages/login.ecr @@ -0,0 +1,114 @@ + + + + + Guff Login + + <%= + 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 + } + %> + + + + + +
+
+
+
+ + + Login + +
+ +
+ <% if @error %> +
+
+ + + Error: Invalid Login + +
+
+ <% end %> + +
+
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+
+
+
+
+ + + <%= + scripts %w{ + assets/jquery-2.2.1.min.js + assets/bootstrap-3.3.6/js/bootstrap.min.js + } + %> + diff --git a/src/views/pages/logout.ecr b/src/views/pages/logout.ecr new file mode 100644 index 0000000..b3c2eae --- /dev/null +++ b/src/views/pages/logout.ecr @@ -0,0 +1,67 @@ + + + + + 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 + } + %> + + + + + +
+
+
+
+ + + Log Out + +
+ +
+

+ You have logged out. +

+ +

+ Go to Login page +

+
+
+
+
+ + + <%= + scripts %w{ + assets/jquery-2.2.1.min.js + assets/bootstrap-3.3.6/js/bootstrap.min.js + } + %> + -- cgit v1.2.3