From d9c6f7474cef71fd3b05442bf881d0a258b1e64c Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 23 May 2016 13:24:53 -0400 Subject: add blog, page, and project edit dialogs --- src/guff.cr | 159 +++++++++++---- src/views/admin-page.ecr | 519 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 635 insertions(+), 43 deletions(-) diff --git a/src/guff.cr b/src/guff.cr index b0f57d4..8228e88 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -1332,10 +1332,10 @@ module Guff assets(:style, paths) end - def tabs(rows : Array(Hash(Symbol, String))) + def tabs(prefix : String, rows : Array(Hash(Symbol, String))) String.build do |io| rows.each do |row| - TabView.new(@context, "admin", row).to_s(io) + TabView.new(@context, prefix, row).to_s(io) end end end @@ -1344,48 +1344,123 @@ module Guff class AdminPageView < HTMLView TITLE = "Guff Admin" - 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: "users", - css: "", - icon: "fa-users", - name: "Users", - text: "Manage users and permissions.", - }, { - id: "settings", - css: "", - icon: "fa-cog", - name: "Settings", - text: "Configure site settings.", - }] - - def tabs - super(TABS) - end - - OPTION = "" - - def role_options + TABS = { + "admin": [{ + 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: "users", + css: "", + icon: "fa-users", + name: "Users", + text: "Manage users and permissions.", + }, { + id: "settings", + css: "", + icon: "fa-cog", + name: "Settings", + text: "Configure site settings.", + }], + } + + TEMPLATES = { + option: " + + ", + + new_post_button: " + + + New Post + + + + + + + + + + ", + } + + def tabs(id : String) + super(id, TABS[id]) + end + + private def new_post_button + TEMPLATES[:new_post_button] + end + + private def role_options @role_options ||= String.build do |io| @context.models.role.get_roles.each do |row| - io << OPTION % %w{role name}.map { |key| h(row[key]) } + io << TEMPLATES[:option] % %w{role name}.map { |key| h(row[key]) } end end end diff --git a/src/views/admin-page.ecr b/src/views/admin-page.ecr index 3394096..7614453 100644 --- a/src/views/admin-page.ecr +++ b/src/views/admin-page.ecr @@ -46,7 +46,7 @@
@@ -57,6 +57,11 @@ >
+
+
<%= + new_post_button + %>
+
@@ -74,6 +79,11 @@ >
+
+
<%= + new_post_button + %>
+
@@ -395,6 +405,513 @@
+ + + + + + <%= -- cgit v1.2.3