diff options
-rw-r--r-- | src/guff.cr | 41 | ||||
-rw-r--r-- | src/views/admin-page.ecr | 95 |
2 files changed, 51 insertions, 85 deletions
diff --git a/src/guff.cr b/src/guff.cr index 8228e88..01e0cb4 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -1447,6 +1447,17 @@ module Guff </li> </ul> ", + + state_button: " + <a + href='#' + class='btn %s post-state' + title='Mark as %s.' + > + <i class='fa %s'></i> + %s + </a> + ", } def tabs(id : String) @@ -1465,6 +1476,36 @@ module Guff end end + STATES = [{ + id: "draft", + name: "Draft", + icon: "fa-wrench", + css: "btn-primary", + }, { + id: "posted", + name: "Posted", + icon: "fa-bullhorn", + css: "btn-default", + }, { + id: "deleted", + name: "Deleted", + icon: "fa-trash", + css: "btn-default", + }] + + private def state_buttons + @state_buttons ||= String.build do |io| + STATES.each do |row| + io << TEMPLATES[:state_button] % [ + h(row[:css]), + h(row[:name]), + h(row[:icon]), + h(row[:name]) + ] + end + 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 index f1b8b01..a77ddf6 100644 --- a/src/views/admin-page.ecr +++ b/src/views/admin-page.ecr @@ -528,37 +528,12 @@ State </label> - <div class='btn-group btn-group-justified'> - <a - href='#' - class='btn btn-primary post-state' - title='Mark this page as a draft.' - > - <i class='fa fa-wrench'></i> - Draft - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this page as published.' - > - <i class='fa fa-bullhorn'></i> - Published - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this page as deleted.' - > - <i class='fa fa-trash'></i> - Deleted - </a> - </div><!-- btn-group --> + <div class='btn-group btn-group-justified'><%= + state_buttons + %></div><!-- btn-group --> <p class='help-block'> - Visibility state of this page. + Visibility of this blog post. </p> </div><!-- col-md-6 --> </div><!-- row --> @@ -724,34 +699,9 @@ State </label> - <div class='btn-group btn-group-justified'> - <a - href='#' - class='btn btn-primary post-state' - title='Mark this page as a draft.' - > - <i class='fa fa-wrench'></i> - Draft - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this page as published.' - > - <i class='fa fa-bullhorn'></i> - Published - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this page as deleted.' - > - <i class='fa fa-trash'></i> - Deleted - </a> - </div><!-- btn-group --> + <div class='btn-group btn-group-justified'><%= + state_buttons + %></div><!-- btn-group --> <p class='help-block'> Visibility state of this page. @@ -911,34 +861,9 @@ State </label> - <div class='btn-group btn-group-justified'> - <a - href='#' - class='btn btn-primary post-state' - title='Mark this project as a draft.' - > - <i class='fa fa-wrench'></i> - Draft - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this project as published.' - > - <i class='fa fa-bullhorn'></i> - Published - </a> - - <a - href='#' - class='btn btn-default post-state' - title='Mark this project as deleted.' - > - <i class='fa fa-trash'></i> - Deleted - </a> - </div><!-- btn-group --> + <div class='btn-group btn-group-justified'><%= + state_buttons + %></div><!-- btn-group --> <p class='help-block'> Visibility state of this project. |