From 525f19116d763b1de16b2a4b84f5b5c9beac3132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Hermansen?= Date: Sun, 23 May 2010 17:34:41 +0800 Subject: [PATCH] Updated all scaffold related views so it uses I18n. --- README.markdown | 11 ++++++++--- scaffold/templates/edit.html.haml | 8 ++++---- scaffold/templates/index.html.haml | 14 ++++++-------- scaffold/templates/new.html.haml | 6 ++---- scaffold/templates/show.html.haml | 13 ++++++++----- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.markdown b/README.markdown index f0ad9ec..b563913 100644 --- a/README.markdown +++ b/README.markdown @@ -1,10 +1,15 @@ -# Rails 3 HAML Scaffold Generator +# Information about this fork + +This for is no longer following the normal scaffolding layout of Rails. +It uses I18n backend for headings, model attributes names etc in it's views. + +## Rails 3 HAML Scaffold Generator Essentially just a copy of the Rails 3 ERB generator with HAML replacements for the templates. Original idea from [Paul Barry's article on custom genrators][OriginalIdea] -## Installation +### Installation 1. Generate your new rails application: @@ -55,4 +60,4 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] * Gemify (?) -[OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3 \ No newline at end of file +[OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3 diff --git a/scaffold/templates/edit.html.haml b/scaffold/templates/edit.html.haml index 2ffa70b..2256e55 100644 --- a/scaffold/templates/edit.html.haml +++ b/scaffold/templates/edit.html.haml @@ -1,5 +1,5 @@ -%h1 Editing <%= singular_name %> - +%h1= t '.title' +%p + = link_to t('back'), <%= plural_name %>_path + = link_to t('show'), @<%= singular_name %> = render 'form' - -== #{ link_to 'Show', @<%= singular_name %> } | #{ link_to 'Back', <%= plural_name %>_path } diff --git a/scaffold/templates/index.html.haml b/scaffold/templates/index.html.haml index e035225..7c0aa9b 100644 --- a/scaffold/templates/index.html.haml +++ b/scaffold/templates/index.html.haml @@ -1,10 +1,11 @@ -%h1 Listing <%= plural_name %> +%h1= t('.title') +%p= link_to t('.new_<%= singular_name %>'), new_<%= singular_name %>_path %table %thead %tr <% for attribute in attributes -%> - %th <%= attribute.human_name %> + %th= <%= class_name %>.human_attribute_name :<%= attribute %> <% end -%> %th{ :colspan => 3 } @@ -14,9 +15,6 @@ <% for attribute in attributes -%> %td= <%= singular_name %>.<%= attribute.name %> <% end -%> - %td= link_to 'Show', <%= singular_name %> - %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) - %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete - -%br -= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path + %td.action= link_to t('show'), <%= singular_name %> + %td.action= link_to t('edit'), edit_<%= singular_name %>_path(<%= singular_name %>) + %td.action= link_to t('destroy'), <%= singular_name %>, :confirm => t('are_you_sure'), :method => :delete diff --git a/scaffold/templates/new.html.haml b/scaffold/templates/new.html.haml index a18eb0e..6fe0b13 100644 --- a/scaffold/templates/new.html.haml +++ b/scaffold/templates/new.html.haml @@ -1,5 +1,3 @@ -%h1 New <%= singular_name %> - +%h1= t '.title' +%p= link_to t('back'), <%= plural_name %>_path = render 'form' - -= link_to 'Back', <%= plural_name %>_path diff --git a/scaffold/templates/show.html.haml b/scaffold/templates/show.html.haml index e04a831..132e83a 100644 --- a/scaffold/templates/show.html.haml +++ b/scaffold/templates/show.html.haml @@ -1,7 +1,10 @@ -<% for attribute in attributes -%> +%h1= t '.title' %p - %strong <%= attribute.human_name %>: - = @<%= singular_name %>.<%= attribute.name %> -<% end -%> + = link_to t('back'), <%= plural_name %>_path + = link_to t('edit'), edit_<%= singular_name %>_path(@<%= singular_name %>) -== #{ link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) } | #{ link_to 'Back', <%= plural_name %>_path } +%dl +<% for attribute in attributes -%> + %dt= <%= class_name %>.human_attribute_name :<%= attribute %> + %dd= @<%= singular_name %>.<%= attribute.name %> +<% end -%>