ujifgc
ujifgc

Reputation: 2255

Custom template for padrino admin page

How can I make padrino-admin page generator produce beautiful custom pages?

By default padrino-admin generates pretty ugly admin pages, totally unmaintainable:

.group
  =f.label :title
  =f.error_message_on :title
  =f.text_field :title, :class => :text_field
  %span.description Ex: a simple text

.group
  =f.label :name
  =f.error_message_on :name
  =f.text_field :name, :class => :text_field
  %span.description Ex: a simple text

--- more annoyingly redundant frak

.group.navform.wat-cf
  =f.submit pat(:save), :class => :button
  =f.submit pat(:cancel), :onclick => "window.location='#{url(:pages, :index)}';return false", :class => :button

I wrote a nice AdminFormBuilder < AbstractFormBuilder, connected it with set :default_builder, 'AdminFormBuilder', it generates same admin pages from very short code:

= f.inputs :name, :surname, :email
= f.inputs :password, :password_confirmation, :as => :password
= f.input :role, :as => :select, :options => access_control.roles, :descr => 'a simple text'
= f.submits

Now I want padrino g admin_page to generate more of such pages. What should I do?

Upvotes: 0

Views: 1082

Answers (2)

ujifgc
ujifgc

Reputation: 2255

Here is one-line patch for padrino-admin gem: https://github.com/ujifgc/padrino-framework/commit/b07399bdfbc15d05682237c64580e77558ac9fce

Now I can place copy of original templates folder from padrino-admin-0.10.5/lib/padrino-admin/generators to vendor/padrino-admin/generators and enjoy my own admin page templates.

Upvotes: 0

DAddYE
DAddYE

Reputation: 1729

There are two ways:

1) Make your custom admin gem copying as base the actual padrino-admin 2) Fork the project (where now we support a new admin based on bootstrap) apply your changes and submit a pull request.

Btw the most interesting file for this job is this: https://github.com/padrino/padrino-framework/blob/master/padrino-admin/lib/padrino-admin/generators/admin_page.rb

Upvotes: 1

Related Questions