From 7f994c65451a90d55cfd8ca6f863d2f7e475e8fb Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 28 Jul 2016 00:30:33 -0400 Subject: mv admin-page to admin/page --- src/guff/handlers.cr | 2 +- src/guff/views/admin-page.cr | 226 ------- src/guff/views/admin/dialogs/user.cr | 2 +- src/guff/views/admin/page.cr | 226 +++++++ src/views/admin-page.ecr | 1111 ---------------------------------- src/views/admin/page.ecr | 1111 ++++++++++++++++++++++++++++++++++ 6 files changed, 1339 insertions(+), 1339 deletions(-) delete mode 100644 src/guff/views/admin-page.cr create mode 100644 src/guff/views/admin/page.cr delete mode 100644 src/views/admin-page.ecr create mode 100644 src/views/admin/page.ecr (limited to 'src') diff --git a/src/guff/handlers.cr b/src/guff/handlers.cr index 2670f89..a44140a 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::Admin::PageView.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 c51ee1b..0000000 --- a/src/guff/views/admin-page.cr +++ /dev/null @@ -1,226 +0,0 @@ -require "./html" -require "./admin/dialogs/*" - -class Guff::Views::AdminPageView < Guff::Views::HTMLView - TITLE = "Guff Admin" - - POST_TYPES = { - blog: { - id: "blog", - name: "Blog Post", - icon: "fa-sticky-note-o", - }, - - page: { - id: "page", - name: "Page", - icon: "fa-file-text-o", - }, - - project: { - id: "project", - name: "Project", - icon: "fa-cube", - }, - } - - 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 => "settings", - :css => "", - :icon => "fa-cogs", - :name => "Settings", - :text => "Configure settings.", - }], - - "settings" => [{ - :id => "general", - :css => "active", - :icon => "fa-cog", - :name => "General", - :text => "Manage general settings.", - }, { - :id => "backups", - :css => "", - :icon => "fa-archive", - :name => "Backups", - :text => "Manage backups.", - }, { - :id => "import", - :css => "", - :icon => "fa-upload", - :name => "Import / Export", - :text => "Import and export posts.", - }, { - :id => "sites", - :css => "", - :icon => "fa-sitemap", - :name => "Sites", - :text => "Manage sites and domains.", - }, { - :id => "themes", - :css => "", - :icon => "fa-eye", - :name => "Themes", - :text => "Manage themes.", - }, { - :id => "users", - :css => "", - :icon => "fa-users", - :name => "Users", - :text => "Manage users and permissions.", - }], - } - - NEW_POST_MENU_ITEM = " -
  • - - - %s - -
  • - " - - TEMPLATES = { - :option => " - - ", - - :new_post_button => " - - - Create - - - - - ", - - :state_button => " - - - %s - - ", - } - - def tabs(id : String) - super(id, TABS[id]) - end - - private def new_post_button - TEMPLATES[:new_post_button] - end - - private def state_buttons - @state_buttons ||= String.build do |io| - @context.models.state.get_states.each do |row| - io << TEMPLATES[:state_button] % [ - h(row["name"]), - h(row["state"]), - h(row["icon"]), - h(row["name"]) - ] - end - end - end - - private def authors_menu_items - @context.models.user.get_users.map do |row| - { - :id => row["user_id"], - :name => row["name"], - :text => "Show author \"%s\"." % [row["name"]], - } - end - end - - private def sites_menu_items - @context.models.site.get_sites.map do |row| - { - :id => row["site_id"], - :name => row["name"], - :text => "Show site \"%s\"." % [row["name"]], - } - end - end - - private def states_menu_items - @context.models.state.get_states.map do |row| - { - :id => row["state"], - :name => row["name"], - :icon => row["icon"], - :text => "Show state \"%s\"." % [row["name"]], - } - end - end - - private def theme_options - [{ - "id" => "site-default", - "name" => "Site Default", - }].concat(@context.models.theme.all.map { |row| - { - "id" => row["theme_id"], - "name" => "%s (%s)" % %w{ - name - version - }.map { |k| row["theme_#{k}"] }, - } - }).map { |row| - TEMPLATES[:option] % %w{id name}.map { |k| row[k] } - }.join("") - end - - private def page_data - { post_types: POST_TYPES}.to_json - end - - private def dialogs - String.build do |io| - io << Admin::Dialogs::UserAddDialog.new(@context) - io << Admin::Dialogs::UserEditDialog.new(@context) - end - end - - ECR.def_to_s("src/views/admin-page.ecr") -end diff --git a/src/guff/views/admin/dialogs/user.cr b/src/guff/views/admin/dialogs/user.cr index 4bae8da..98a632e 100644 --- a/src/guff/views/admin/dialogs/user.cr +++ b/src/guff/views/admin/dialogs/user.cr @@ -1,6 +1,6 @@ class Guff::Views::Admin::Dialogs::UserDialog < Guff::Views::HTMLView protected def role_options - tmpl = Guff::Views::AdminPageView::TEMPLATES[:option] + tmpl = Guff::Views::Admin::PageView::TEMPLATES[:option] @role_options ||= String.build do |io| @context.models.role.get_roles.each do |row| diff --git a/src/guff/views/admin/page.cr b/src/guff/views/admin/page.cr new file mode 100644 index 0000000..a61f52a --- /dev/null +++ b/src/guff/views/admin/page.cr @@ -0,0 +1,226 @@ +require "../html" +require "./dialogs/*" + +class Guff::Views::Admin::PageView < Guff::Views::HTMLView + TITLE = "Guff Admin" + + POST_TYPES = { + blog: { + id: "blog", + name: "Blog Post", + icon: "fa-sticky-note-o", + }, + + page: { + id: "page", + name: "Page", + icon: "fa-file-text-o", + }, + + project: { + id: "project", + name: "Project", + icon: "fa-cube", + }, + } + + 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 => "settings", + :css => "", + :icon => "fa-cogs", + :name => "Settings", + :text => "Configure settings.", + }], + + "settings" => [{ + :id => "general", + :css => "active", + :icon => "fa-cog", + :name => "General", + :text => "Manage general settings.", + }, { + :id => "backups", + :css => "", + :icon => "fa-archive", + :name => "Backups", + :text => "Manage backups.", + }, { + :id => "import", + :css => "", + :icon => "fa-upload", + :name => "Import / Export", + :text => "Import and export posts.", + }, { + :id => "sites", + :css => "", + :icon => "fa-sitemap", + :name => "Sites", + :text => "Manage sites and domains.", + }, { + :id => "themes", + :css => "", + :icon => "fa-eye", + :name => "Themes", + :text => "Manage themes.", + }, { + :id => "users", + :css => "", + :icon => "fa-users", + :name => "Users", + :text => "Manage users and permissions.", + }], + } + + NEW_POST_MENU_ITEM = " +
  • + + + %s + +
  • + " + + TEMPLATES = { + :option => " + + ", + + :new_post_button => " + + + Create + + + + + ", + + :state_button => " + + + %s + + ", + } + + def tabs(id : String) + super(id, TABS[id]) + end + + private def new_post_button + TEMPLATES[:new_post_button] + end + + private def state_buttons + @state_buttons ||= String.build do |io| + @context.models.state.get_states.each do |row| + io << TEMPLATES[:state_button] % [ + h(row["name"]), + h(row["state"]), + h(row["icon"]), + h(row["name"]) + ] + end + end + end + + private def authors_menu_items + @context.models.user.get_users.map do |row| + { + :id => row["user_id"], + :name => row["name"], + :text => "Show author \"%s\"." % [row["name"]], + } + end + end + + private def sites_menu_items + @context.models.site.get_sites.map do |row| + { + :id => row["site_id"], + :name => row["name"], + :text => "Show site \"%s\"." % [row["name"]], + } + end + end + + private def states_menu_items + @context.models.state.get_states.map do |row| + { + :id => row["state"], + :name => row["name"], + :icon => row["icon"], + :text => "Show state \"%s\"." % [row["name"]], + } + end + end + + private def theme_options + [{ + "id" => "site-default", + "name" => "Site Default", + }].concat(@context.models.theme.all.map { |row| + { + "id" => row["theme_id"], + "name" => "%s (%s)" % %w{ + name + version + }.map { |k| row["theme_#{k}"] }, + } + }).map { |row| + TEMPLATES[:option] % %w{id name}.map { |k| row[k] } + }.join("") + end + + private def page_data + { post_types: POST_TYPES}.to_json + end + + private def dialogs + String.build do |io| + io << Dialogs::UserAddDialog.new(@context) + io << Dialogs::UserEditDialog.new(@context) + end + end + + ECR.def_to_s("src/views/admin/page.ecr") +end diff --git a/src/views/admin-page.ecr b/src/views/admin-page.ecr deleted file mode 100644 index c06b5f0..0000000 --- a/src/views/admin-page.ecr +++ /dev/null @@ -1,1111 +0,0 @@ - - - - - <%= 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 - assets/css/admin.css - } - %> - - - - - -
    -
    - - -
    -
    -
    -
    -
    -
    <%= - new_post_button - %>
    -
    -
    - -
    -

    - TODO: home -

    -
    -
    -
    - -
    -
    -
    -
    -
    <%= - new_post_button - %>
    - -
    -    -
    - -
    <%= - dropdown( - id: "posts-filter-type", - css: "posts-filter-menu", - - name: "Type", - text: "Filter posts by type.", - - icon: "", - default: "all", - - items: [{ - :id => "all", - :name => "All", - :text => "Show all types.", - }, { - :type => "divider", - }] + %i{blog page project}.map { |id| - name = POST_TYPES[id][:name] - - { - :id => POST_TYPES[id][:id], - :name => name, - :icon => POST_TYPES[id][:icon], - :text => "Show #{name}s.", - } - } - ) - %>
    - -
    <%= - dropdown( - id: "posts-filter-state", - css: "posts-filter-menu", - - name: "State", - text: "Filter by post state.", - - icon: "", - default: "default", - - items: [{ - :id => "default", - :name => "Default", - :text => "Show drafts and posted items.", - }, { - :type => "divider", - }].concat(states_menu_items), - ) - %>
    - -
    <%= - dropdown( - id: "posts-filter-site", - css: "posts-filter-menu", - - name: "Site", - text: "Filter by site.", - - icon: "", - default: "all", - - items: [{ - :id => "all", - :name => "All", - :text => "Show all sites.", - }, { - :type => "divider", - }].concat(sites_menu_items), - ) - %>
    - -
    <%= - dropdown( - id: "posts-filter-user", - css: "posts-filter-menu", - - name: "Author", - text: "Filter by author.", - - icon: "", - default: "all", - - items: [{ - :id => "all", - :name => "All", - :text => "Show all authors.", - }, { - :type => "divider", - }].concat(authors_menu_items), - ) - %>
    - -
    - - - -
    - - -
    -
    - - - - - - - - - - - - - - - - - - -
     NameSiteURL / SlugAuthorCreatedPosted
    -
    -
    - -
    -
    - - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - -
    -

    - TODO: general settings -

    -
    -
    -
    - -
    -
    -
    - -
    - - - -
    - - - Loading... - -
    -
    -
    - -
    -
    -
    -
    - -
    -

    - TODO: themes -

    -
    -
    -
    - -
    -
    -
    -
    - -
    -

    - TODO: sites settings -

    -
    -
    -
    - -
    -
    -
    -
    - -
    -

    - TODO: backups -

    -
    -
    -
    - -
    -
    -
    -
    - -
    -

    - TODO: import -

    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - <%= dialogs %> - - - - - - - - - - - <%= - 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 - } - %> - diff --git a/src/views/admin/page.ecr b/src/views/admin/page.ecr new file mode 100644 index 0000000..c06b5f0 --- /dev/null +++ b/src/views/admin/page.ecr @@ -0,0 +1,1111 @@ + + + + + <%= 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 + assets/css/admin.css + } + %> + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    <%= + new_post_button + %>
    +
    +
    + +
    +

    + TODO: home +

    +
    +
    +
    + +
    +
    +
    +
    +
    <%= + new_post_button + %>
    + +
    +    +
    + +
    <%= + dropdown( + id: "posts-filter-type", + css: "posts-filter-menu", + + name: "Type", + text: "Filter posts by type.", + + icon: "", + default: "all", + + items: [{ + :id => "all", + :name => "All", + :text => "Show all types.", + }, { + :type => "divider", + }] + %i{blog page project}.map { |id| + name = POST_TYPES[id][:name] + + { + :id => POST_TYPES[id][:id], + :name => name, + :icon => POST_TYPES[id][:icon], + :text => "Show #{name}s.", + } + } + ) + %>
    + +
    <%= + dropdown( + id: "posts-filter-state", + css: "posts-filter-menu", + + name: "State", + text: "Filter by post state.", + + icon: "", + default: "default", + + items: [{ + :id => "default", + :name => "Default", + :text => "Show drafts and posted items.", + }, { + :type => "divider", + }].concat(states_menu_items), + ) + %>
    + +
    <%= + dropdown( + id: "posts-filter-site", + css: "posts-filter-menu", + + name: "Site", + text: "Filter by site.", + + icon: "", + default: "all", + + items: [{ + :id => "all", + :name => "All", + :text => "Show all sites.", + }, { + :type => "divider", + }].concat(sites_menu_items), + ) + %>
    + +
    <%= + dropdown( + id: "posts-filter-user", + css: "posts-filter-menu", + + name: "Author", + text: "Filter by author.", + + icon: "", + default: "all", + + items: [{ + :id => "all", + :name => "All", + :text => "Show all authors.", + }, { + :type => "divider", + }].concat(authors_menu_items), + ) + %>
    + +
    + + + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + +
     NameSiteURL / SlugAuthorCreatedPosted
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    +

    + TODO: general settings +

    +
    +
    +
    + +
    +
    +
    + +
    + + + +
    + + + Loading... + +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + TODO: themes +

    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + TODO: sites settings +

    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + TODO: backups +

    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + TODO: import +

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + <%= dialogs %> + + + + + + + + + + + <%= + 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 + } + %> + -- cgit v1.2.3