Skip to content

Commit

Permalink
basic themed generator
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Sep 27, 2010
1 parent 0f8a22f commit ed4c323
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 63 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -56,7 +56,7 @@ Start creating your controllers manually or with a scaffold, and then use the `t

If you have a controller named like the plural of the used model you can specify just the first parameter:

script/generate themed posts # you have a model named Post and a controller named PostsController
rails g web_app_theme:themed posts # you have a model named Post and a controller named PostsController

script/generate themed admin/gallery_pictures # you have a model named GalleryPicture and a controller named Admin::GalleryPicturesController

Expand Down Expand Up @@ -93,6 +93,7 @@ If you want to show form error messages inside the generated forms, use the foll
end

If you want to have translated pages, simple create in your locale.yml the keys just like config/locales/en_us.yml example.

en_us:
web-app-theme:
save: Save
Expand Down
45 changes: 0 additions & 45 deletions lib/generators/web_app_theme/templates/layout_admin.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions lib/generators/web_app_theme/templates/layout_sign.html.erb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/generators/web_app_theme/theme/theme_generator.rb
@@ -1,6 +1,6 @@
module WebAppTheme
class ThemeGenerator < Rails::Generators::Base
source_root File.expand_path('../../templates', __FILE__)
source_root File.expand_path('../templates', __FILE__)

argument :layout_name, :type => :string, :default => 'application'

Expand Down Expand Up @@ -33,7 +33,7 @@ def copy_theme_stylesheets
protected

def stylesheets_path
"../../../../stylesheets"
"../../../../../stylesheets"
end

def generate_haml_layout(admin_layout_name)
Expand Down
19 changes: 19 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_edit.html.erb
@@ -0,0 +1,19 @@
<div class="block">
<div class="secondary-navigation">
<ul class="wat-cf">
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
<li class="active"><%%= link_to "#{t("web-app-theme.edit", :default => "Edit")}", edit_<%= singular_controller_routing_path %>_path %></li>
</ul>
</div>
<div class="content">
<h2 class="title"><%%= t("web-app-theme.edit", :default => "Edit") %> <%= model_name %></h2>
<div class="inner">
<%% form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => :form } do |f| -%>
<%%= render :partial => "form", :locals => {:f => f} %>
<%% end -%>
</div>
</div>
</div>

<%% content_for :sidebar, render(:partial => 'sidebar') -%>
13 changes: 13 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_form.html.erb
@@ -0,0 +1,13 @@
<% columns.each do |column| %>
<div class="group">
<%%= f.label :<%= column.name %>, t("activerecord.attributes.<%= model_name.underscore %>.<%= column.name %>", :default => "<%= column.name.humanize %>"), :class => :label %>
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
<span class="description">Ex: a simple text</span>
</div>
<%- end -%>
<div class="group navform wat-cf">
<button class="button" type="submit">
<%%= image_tag("web-app-theme/tick.png", :alt => "#{t("web-app-theme.save", :default => "Save")}") %> <%%= t("web-app-theme.save", :default => "Save") %>
</button>
<%%= link_to "#{image_tag("web-app-theme/cross.png", :alt => "#{t("web-app-theme.cancel", :default => "Cancel")}")} #{t("web-app-theme.cancel", :default => "Cancel")}", <%= controller_routing_path %>_path, :class => "button" %>
</div>
18 changes: 18 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_new.html.erb
@@ -0,0 +1,18 @@
<div class="block">
<div class="secondary-navigation">
<ul class="wat-cf">
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
<li class="active"><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
</ul>
</div>
<div class="content">
<h2 class="title"><%%= t("web-app-theme.new", :default => "New")%> <%= model_name %></h2>
<div class="inner">
<%% form_for :<%= model_name.underscore %>, :url => <%= controller_routing_path %>_path, :html => { :class => :form } do |f| -%>
<%%= render :partial => "form", :locals => {:f => f} %>
<%% end -%>
</div>
</div>
</div>

<%% content_for :sidebar, render(:partial => 'sidebar') -%>
25 changes: 25 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_show.html.erb
@@ -0,0 +1,25 @@
<div class="block">
<div class="secondary-navigation">
<ul class="wat-cf">
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
<li class="active"><%%= link_to "#{t("web-app-theme.show", :default => "Show")}", <%= singular_controller_routing_path %>_path %></li>
</ul>
</div>
<div class="content">
<div class="inner">
<% columns.each do |column| %>
<p>
<b><%%= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= column.name %>", :default => t("activerecord.labels.<%= column.name %>", :default => "<%= column.name.humanize %>")) %>:</b>
<%%= @<%= resource_name %>.<%= column.name %> %>
</p>
<%- end -%>
<div class="wat-cf">
<%%= link_to "#{image_tag("web-app-theme/application_edit.png", :alt => "#{t("web-app-theme.edit", :default=> "Edit")}")} #{t("web-app-theme.edit", :default=> "Edit")}", edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => "button" %>
<%%= link_to "#{image_tag("web-app-theme/cross.png", :alt => "#{t("web-app-theme.delete", :default=> "Delete")}")} #{t("web-app-theme.delete", :default => "Delete")}", <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :class => "button", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
</div>
</div>
</div>
</div>

<%% content_for :sidebar, render(:partial => 'sidebar') -%>
@@ -0,0 +1,13 @@
<div class="block">
<h3>Simple Block</h3>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="block">
<h3>Links</h3>
<ul class="navigation">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</div>
36 changes: 36 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_signin.html.erb
@@ -0,0 +1,36 @@
<h1><%= options[:app_name] %></h1>
<div class="block" id="block-login">
<h2>Login Box</h2>
<div class="content login">
<div class="flash">
<%% flash.each do |type, message| -%>
<div class="message <%%= type %>">
<p><%%= message %></p>
</div>
<%% end -%>
</div>
<%% form_tag({:action => :create}, :class => 'form login') do -%>
<div class="group wat-cf">
<div class="left">
<label class="label right">Login</label>
</div>
<div class="right">
<%%= text_field_tag :login, @login, :class => 'text_field' %>
</div>
</div>
<div class="group wat-cf">
<div class="left">
<label class="label right">Password</label>
</div>
<div class="right">
<%%= password_field_tag :password, nil, :class => 'text_field' %>
</div>
</div>
<div class="group navform wat-cf">
<div class="right">
<input type="submit" class="button" value="Sign in" />
</div>
</div>
<%% end -%>
</div>
</div>
52 changes: 52 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_signup.html.erb
@@ -0,0 +1,52 @@
<h1><%= options[:app_name] %></h1>
<div class="block" id="block-signup">
<h2>Sign up</h2>
<div class="content">
<div class="flash">
<%% flash.each do |type, message| -%>
<div class="message <%%= type %>">
<p><%%= message %></p>
</div>
<%% end -%>
</div>
<%% form_for :<%= resource_name %>, :url => <%= controller_routing_path %>_path, :html => { :class => 'form' } do |f| -%>
<div class="group wat-cf">
<div class="left">
<label class="label">Login</label>
</div>
<div class="right">
<%%= f.text_field :login, :class => 'text_field' %>
</div>
</div>
<div class="group wat-cf">
<div class="left">
<label class="label">Email</label>
</div>
<div class="right">
<%%= f.text_field :email, :class => 'text_field' %>
</div>
</div>
<div class="group wat-cf">
<div class="left">
<label class="label">Password</label>
</div>
<div class="right">
<%%= f.password_field :password, :class => 'text_field' %>
</div>
</div>

<div class="group">
<div class="left wat-cf">
<label class="label">Password</label>
</div>
<div class="right">
<%%= f.password_field :password_confirmation, :class => 'text_field' %>
</div>
</div>

<div class="group navform">
<input type="submit" class="button" value="Sign up" />
</div>
<%% end -%>
</div>
</div>
54 changes: 54 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_tables.html.erb
@@ -0,0 +1,54 @@
<div class="block">
<div class="secondary-navigation">
<ul class="wat-cf">
<li class="first active"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
</ul>
</div>
<div class="content">
<h2 class="title"><%%= t("web-app-theme.all", :default => "All") %> <%= plural_model_name %></h2>
<div class="inner">
<table class="table">
<tr>
<th class="first">ID</th>
<% unless columns.empty? -%>
<th>
<%%= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= columns.first.name %>", :default => t("activerecord.labels.<%= columns.first.name %>", :default => "<%= columns.first.name.capitalize %>")) %>
</th>
<% end -%>
<th><%%= t("web-app-theme.created_at", :default => "Created at") %></th>
<th class="last">&nbsp;</th>
</tr>
<%% @<%= plural_resource_name %>.each do |<%= resource_name %>| -%>
<tr class="<%%= cycle("odd", "even") %>">
<td>
<%%= <%= resource_name %>.id %>
</td>
<% unless columns.empty? -%>
<td>
<%%= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %>
</td>
<% end -%>
<td>
<%%= <%= resource_name %>.created_at %>
</td>
<td class="last">
<%%= link_to "#{t("web-app-theme.show", :default => "Show")}", <%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to "#{t("web-app-theme.edit", :default => "Edit")}", edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to "#{t("web-app-theme.delete", :default => "Delete")}", <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
</td>
</tr>
<%% end -%>
</table>
<div class="actions-bar wat-cf">
<div class="actions">
</div>
<% if options[:will_paginate] %>
<%%= will_paginate @<%= plural_resource_name %> %>
<% end %>
</div>
</div>
</div>
</div>

<%% content_for :sidebar, render(:partial => 'sidebar') -%>
18 changes: 18 additions & 0 deletions lib/generators/web_app_theme/themed/templates/view_text.html.erb
@@ -0,0 +1,18 @@
<div class="block" id="block-text">
<div class="content">
<h2 class="title"><%= resource_name.capitalize %></h2>
<div class="inner">
<p class="first">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span class="hightlight">Excepteur sint occaecat cupidatat non proident</span>, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p> <span class="small">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</span></p>
<p> <span class="gray">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</span></p>
<hr />
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span class="hightlight">Excepteur sint occaecat cupidatat non proident</span>, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</div>
</div>

<%% content_for :sidebar, render(:partial => 'sidebar') -%>

0 comments on commit ed4c323

Please sign in to comment.