diff options
Diffstat (limited to 'src/guff.cr')
-rw-r--r-- | src/guff.cr | 159 |
1 files changed, 117 insertions, 42 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 = "<option value='%s'>%s</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: " + <option value='%s'>%s</option> + ", + + new_post_button: " + <a + href='#' + class='btn btn-primary' + title='Create new blog post.' + data-toggle='modal' + data-target='#blog-edit-dialog' + > + <i class='fa fa-plus-circle'></i> + New Post + </a><!-- btn --> + + <a + href='#' + class='btn btn-primary' + title='Show additonal options.' + data-toggle='dropdown' + > + <span class='hidden'> + <i class='fa fa-plus-circle'></i> + New + </span> + + <i class='fa fa-caret-down'></i> + </a> + + <ul class='dropdown-menu'> + <li class='hidden'> + <a + href='#' + title='Create new blog post.' + data-toggle='modal' + data-target='#blog-edit-dialog' + > + <i class='fa fa-fw fa-bullhorn'></i> + New Post + </a> + </li> + + <li> + <a + href='#' + title='Create new page.' + data-toggle='modal' + data-target='#page-edit-dialog' + > + <i class='fa fa-fw fa-bookmark-o'></i> + New Page + </a> + </li> + + <li> + <a + href='#' + title='Create new project.' + data-toggle='modal' + data-target='#project-edit-dialog' + > + <i class='fa fa-fw fa-cube'></i> + New Project + </a> + </li> + </ul> + ", + } + + 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 |