manifest-rails 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.rdoc +3 -0
  3. data/app/assets/javascripts/manifest/main.js +17 -0
  4. data/app/assets/stylesheets/manifest/_forms.css.scss +42 -21
  5. data/app/assets/stylesheets/manifest/_tables.css.scss +24 -20
  6. data/app/assets/stylesheets/manifest/main.css.scss +72 -0
  7. data/app/assets/stylesheets/manifest/sessions.css.scss +9 -0
  8. data/app/controllers/manifest/content_blocks_controller.rb +14 -11
  9. data/app/controllers/manifest/manifest_controller.rb +3 -8
  10. data/app/controllers/manifest/pages_controller.rb +2 -5
  11. data/app/controllers/manifest/sessions_controller.rb +1 -1
  12. data/app/controllers/pages_controller.rb +1 -8
  13. data/app/form_builders/manifest/labelled_form_builder.rb +23 -0
  14. data/app/models/content_block.rb +6 -2
  15. data/app/models/page.rb +18 -13
  16. data/app/views/layouts/manifest/manifest.html.erb +19 -18
  17. data/app/views/layouts/manifest/sessions.html.erb +10 -7
  18. data/app/views/manifest/content_blocks/_form.html.erb +24 -26
  19. data/app/views/manifest/content_blocks/edit.html.erb +1 -9
  20. data/app/views/manifest/content_blocks/index.html.erb +14 -14
  21. data/app/views/manifest/content_blocks/new.html.erb +1 -1
  22. data/app/views/manifest/pages/_form.html.erb +9 -10
  23. data/app/views/manifest/pages/edit.html.erb +1 -9
  24. data/app/views/manifest/pages/index.html.erb +5 -3
  25. data/app/views/manifest/pages/new.html.erb +1 -1
  26. data/app/views/manifest/pages/show.html.erb +29 -6
  27. data/config/initializers/manifest.rb +1 -1
  28. data/config/routes.rb +1 -1
  29. data/db/migrate/20120303200114_create_pages.rb +10 -0
  30. data/db/migrate/20120304152605_create_content_blocks.rb +13 -0
  31. data/db/migrate/20120304155055_add_index_to_pages.rb +5 -0
  32. data/db/migrate/20120304155130_add_index_to_content_blocks.rb +5 -0
  33. data/db/migrate/20120305164036_create_editors.rb +11 -0
  34. data/lib/active_record/base/data_type_for_manifest.rb +11 -0
  35. data/lib/generators/manifest/data_type/data_type_generator.rb +13 -2
  36. data/lib/generators/manifest/data_type/templates/_form.html.erb +19 -0
  37. data/lib/generators/manifest/data_type/templates/controller.rb +41 -4
  38. data/lib/generators/manifest/data_type/templates/edit.html.erb +3 -0
  39. data/lib/generators/manifest/data_type/templates/index.html.erb +4 -0
  40. data/lib/generators/manifest/data_type/templates/model.rb +1 -1
  41. data/lib/generators/manifest/data_type/templates/new.html.erb +3 -0
  42. data/lib/generators/manifest/install/USAGE +1 -3
  43. data/lib/generators/manifest/install/install_generator.rb +13 -4
  44. data/lib/generators/manifest/install/templates/create_content_blocks.rb +1 -1
  45. data/lib/generators/manifest/install/templates/create_pages.rb +1 -1
  46. data/lib/manifest.rb +4 -9
  47. data/lib/manifest/engine.rb +0 -3
  48. data/lib/manifest/version.rb +1 -1
  49. metadata +54 -115
  50. data/README.md +0 -37
  51. data/app/assets/images/manifest/grid.png +0 -0
  52. data/app/assets/images/manifest/sketch.png +0 -0
  53. data/app/assets/javascripts/manifest/manifest.js +0 -7
  54. data/app/assets/stylesheets/manifest/_mixins.css.scss +0 -41
  55. data/app/assets/stylesheets/manifest/manifest.css.scss +0 -137
  56. data/app/controllers/manifest/editors_controller.rb +0 -3
  57. data/app/models/user.rb +0 -8
  58. data/lib/active_record/base/acts_as_manifest.rb +0 -8
@@ -2,35 +2,36 @@
2
2
 
3
3
  <html>
4
4
  <head>
5
- <title><%= Manifest.configuration.app_name %></title>
6
- <%= stylesheet_link_tag 'manifest/manifest' %>
7
- <%= javascript_include_tag 'manifest/manifest' %>
5
+ <title>Manifest</title>
6
+
7
+ <%= stylesheet_link_tag 'manifest/main' %>
8
+ <%= javascript_include_tag 'manifest/main' %>
8
9
  <%= csrf_meta_tags %>
9
10
 
10
- <!-- Google Webfonts -->
11
- <link href='http://fonts.googleapis.com/css?family=Droid+Sans:700,400' rel='stylesheet' type='text/css'>
11
+ <!-- Google Web Fonts -->
12
+ <link href='http://fonts.googleapis.com/css?family=Oswald|PT+Sans:400,700' rel='stylesheet' type='text/css'>
12
13
  </head>
13
-
14
14
  <body>
15
- <header>
16
- <h1><%= link_to Manifest.configuration.app_name, manifest_path %></h1>
15
+ <div class='app-nav'>
16
+ <h1>Manifest</h1>
17
+
17
18
  <nav>
18
19
  <ul>
19
- <% Manifest::DATA_TYPES.each do |d| %>
20
+ <li><%= link_to 'Pages', manifest_pages_path %></li>
21
+ <li><%= link_to 'Content Blocks', manifest_content_blocks_path %></li>
22
+
23
+ <% Manifest.configuration.data_types.each do |d| %>
20
24
  <li><%= link_to d[:nav_name], eval("#{d[:route]}") %></li>
21
25
  <% end %>
26
+
27
+ <li><%= link_to 'Visit Site', '/', target: '_blank' %></li>
28
+ <li><%= link_to 'Log Out', manifest_logout_path %></li>
22
29
  </ul>
23
30
  </nav>
31
+ </div><!-- app-nav -->
24
32
 
25
- <%= link_to('Log Out', manifest_logout_path, class: 'pretty-button', id: 'log-out') if current_editor %>
26
- </header>
27
-
28
- <div id='manifest_content'>
29
- <% flash.each do |name, msg| %>
30
- <%= content_tag :div, msg, id: "flash_#{name}" %>
31
- <% end %>
32
-
33
+ <div class='app-content'>
33
34
  <%= yield %>
34
- </div>
35
+ </div><!-- app-content -->
35
36
  </body>
36
37
  </html>
@@ -2,24 +2,27 @@
2
2
 
3
3
  <html>
4
4
  <head>
5
- <title><%= Manifest.configuration.app_name %></title>
6
- <%= stylesheet_link_tag 'manifest/manifest' %>
7
- <%= javascript_include_tag 'manifest/manifest' %>
5
+ <title>Manifest</title>
6
+
7
+ <%= stylesheet_link_tag 'manifest/sessions' %>
8
+ <%= stylesheet_link_tag 'manifest/main' %>
8
9
  <%= csrf_meta_tags %>
9
10
 
10
11
  <!-- Google Webfonts -->
11
- <link href='http://fonts.googleapis.com/css?family=Droid+Sans:700,400' rel='stylesheet' type='text/css'>
12
+ <link href='http://fonts.googleapis.com/css?family=Oswald|PT+Sans:400,700' rel='stylesheet' type='text/css'>
12
13
  </head>
13
14
 
14
15
  <body>
15
- <h1 class='logged-out-header'><%= Manifest.configuration.app_name %></h1>
16
+ <div class='app-nav'>
17
+ <h1>Manifest</h1>
18
+ </div><!-- app-nav -->
16
19
 
17
- <div id='manifest_content'>
20
+ <div class='app-content'>
18
21
  <% flash.each do |name, msg| %>
19
22
  <%= content_tag :div, msg, id: "flash_#{name}" %>
20
23
  <% end %>
21
24
 
22
25
  <%= yield %>
23
- </div>
26
+ </div><!-- app-content -->
24
27
  </body>
25
28
  </html>
@@ -1,40 +1,38 @@
1
1
  <% if @content_block.errors.any? %>
2
- <div class='errors'>
3
- <h6>This from could not be submitted:</h6>
2
+ <div class='form-errors'>
3
+ <h3>Whoops!</h3>
4
+
5
+ <p>Please correct the following errors:</p>
6
+
4
7
  <ul>
5
8
  <% @content_block.errors.full_messages.each do |msg| %>
6
9
  <li><%= msg %></li>
7
10
  <% end %>
8
11
  </ul>
9
- </div>
12
+ </div><!-- form-errors -->
10
13
  <% end %>
11
14
 
12
- <%= form_for [:manifest, @content_block] do |f| %>
15
+ <%= form_for [:manifest, @content_block], builder: Manifest::LabelledFormBuilder do |f| %>
13
16
  <% if current_editor.admin? %>
14
- <div class='field'>
15
- <%= f.label :title %>
16
- <%= f.text_field :title %>
17
- </div>
18
-
19
- <div class='field inline-label'>
20
- <%= f.label :page_id %>
21
- <%= f.select :page_id, Page.all.collect { |p| [p.title, p.id] }, :include_blank => true %>
22
- </div>
17
+ <%= f.text_field :title %>
18
+ <% else %>
19
+ <p><strong>Title:</strong> <%= @content_block.title %></p>
20
+ <% end %>
23
21
 
24
- <div class='field inline-label'>
25
- <%= f.label :allow_html, 'Allow HTML' %>
26
- <%= f.check_box :allow_html %>
27
- </div>
22
+ <% if current_editor.admin? %>
23
+ <%= f.collection_select :page_id, Page.all, :id, :title %>
24
+ <% else %>
25
+ <p><strong>Page:</strong> <%= @content_block.page ? @content_block.page.title : 'No page' %></p>
28
26
  <% end %>
29
27
 
30
- <div class='field'>
31
- <%= f.label :content %>
32
- <% if @content_block.allow_html %>
33
- <%= f.text_area :content, :class => 'tinymce' %>
34
- <% else %>
35
- <%= f.text_area :content %>
36
- <% end %>
37
- </div>
28
+ <% if current_editor.admin? %>
29
+ <%= f.check_box :allow_html %>
30
+ <% end %>
38
31
 
39
- <div class='actions'><%= f.submit %></div>
32
+ <% if @content_block.allow_html? %>
33
+ <%= f.text_area :content, class: 'tinymce' %>
34
+ <% else %>
35
+ <%= f.text_area :content %>
36
+ <% end %>
37
+ <%= f.submit %>
40
38
  <% end %>
@@ -1,11 +1,3 @@
1
- <h2>Edit Content Block: <%= @content_block.title %></h2>
1
+ <h2>Content Blocks: Edit &ldquo;<%= @content_block.title %>&rdquo;</h2>
2
2
 
3
3
  <%= render 'form' %>
4
-
5
- <p class='model_actions'>
6
- <%= link_to 'Delete Content Block', manifest_content_block_path(@content_block),
7
- method: :delete,
8
- confirm: "Are you sure you want to delete this content block (#{@content_block.title})?",
9
- class: 'delete'
10
- %>
11
- </p>
@@ -1,23 +1,21 @@
1
1
  <h2>Content Blocks</h2>
2
2
 
3
- <% if @content_blocks %>
4
- <table id='content_blocks' class='resource_table'>
3
+ <% if @content_blocks.count > 0 %>
4
+ <table>
5
5
  <thead>
6
- <tr>
7
- <th>Name</th>
8
- <th>Page Name</th>
9
- </tr>
6
+ <th>Title</th>
7
+ <th>Page</th>
8
+ <th>Created</th>
9
+ <th>Updated</th>
10
10
  </thead>
11
-
11
+
12
12
  <tbody>
13
13
  <% @content_blocks.each do |c| %>
14
- <tr id='event_<%= c.id %>'>
14
+ <tr>
15
15
  <td><%= link_to c.title, edit_manifest_content_block_path(c) %></td>
16
- <% if c.page %>
17
- <td><%= c.page.title %></td>
18
- <% else %>
19
- <td>No page (sitewide)</td>
20
- <% end %>
16
+ <td><%= link_to c.page.title, manifest_page_path(c.page) %></td>
17
+ <td><%= c.created_at.to_s(:short) %></td>
18
+ <td><%= c.updated_at.to_s(:short) %></td>
21
19
  </tr>
22
20
  <% end %>
23
21
  </tbody>
@@ -25,5 +23,7 @@
25
23
  <% end %>
26
24
 
27
25
  <% if current_editor.admin? %>
28
- <p class='model_actions'><%= link_to 'New Content Block', new_manifest_content_block_path %></p>
26
+ <div class='model-actions'>
27
+ <%= link_to 'New Content Block', new_manifest_content_block_path %>
28
+ </div><!-- model-actions -->
29
29
  <% end %>
@@ -1,3 +1,3 @@
1
- <h2>New Content Block</h2>
1
+ <h2>Content Blocks: New</h2>
2
2
 
3
3
  <%= render 'form' %>
@@ -1,19 +1,18 @@
1
1
  <% if @page.errors.any? %>
2
- <div class='errors'>
3
- <h6>This from could not be submitted:</h6>
2
+ <div class='form-errors'>
3
+ <h3>Whoops!</h3>
4
+
5
+ <p>Please correct the following errors:</p>
6
+
4
7
  <ul>
5
8
  <% @page.errors.full_messages.each do |msg| %>
6
9
  <li><%= msg %></li>
7
10
  <% end %>
8
11
  </ul>
9
- </div>
12
+ </div><!-- form-errors -->
10
13
  <% end %>
11
14
 
12
- <%= form_for [:manifest, @page] do |f| %>
13
- <div class='field'>
14
- <%= f.label :title %>
15
- <%= f.text_field :title %>
16
- </div>
17
-
18
- <div class='actions'><%= f.submit %></div>
15
+ <%= form_for [:manifest, @page], builder: Manifest::LabelledFormBuilder do |f| %>
16
+ <%= f.text_field :title %>
17
+ <%= f.submit %>
19
18
  <% end %>
@@ -1,11 +1,3 @@
1
- <h2>Edit Page: <%= @page.title %></h2>
1
+ <h2>Pages: Edit &ldquo;<%= @page.title %>&rdquo;</h2>
2
2
 
3
3
  <%= render 'form' %>
4
-
5
- <p class='model_actions'>
6
- <%= link_to 'Delete Page', manifest_page_path(@page), {
7
- method: :delete,
8
- confirm: "Are you sure you want to delete this page (#{@page.title})?",
9
- class: 'delete'
10
- }%>
11
- </p>
@@ -1,13 +1,15 @@
1
1
  <h2>Pages</h2>
2
2
 
3
- <% if @pages %>
3
+ <% if @pages.count > 0 %>
4
4
  <ul>
5
5
  <% @pages.each do |p| %>
6
- <li><%= link_to p.title, current_editor.admin? ? edit_manifest_page_path(p) : manifest_page_path(p) %> <%= link_to('(show)', manifest_page_path(p)) if current_editor.admin? %></li>
6
+ <li><%= link_to p.title, manifest_page_path(p) %></li>
7
7
  <% end %>
8
8
  </ul>
9
9
  <% end %>
10
10
 
11
11
  <% if current_editor.admin? %>
12
- <p class='model_actions'><%= link_to 'New Page', new_manifest_page_path %></p>
12
+ <div class='model-actions'>
13
+ <%= link_to 'New Page', new_manifest_page_path %>
14
+ </div><!-- model-actions -->
13
15
  <% end %>
@@ -1,3 +1,3 @@
1
- <h2>New Page</h2>
1
+ <h2>Pages: New</h2>
2
2
 
3
3
  <%= render 'form' %>
@@ -1,7 +1,30 @@
1
- <h2>Page: <%= @page.title %></h2>
1
+ <h2>Pages: &ldquo;<%= @page.title %>&rdquo;</h2>
2
2
 
3
- <ul>
4
- <% @page.content_blocks.each do |c| %>
5
- <li><%= link_to c.title, edit_manifest_content_block_path(c) %></li>
6
- <% end %>
7
- </ul>
3
+ <h3>Content Blocks</h3>
4
+
5
+ <% if @page.content_blocks.count > 0 %>
6
+ <table>
7
+ <thead>
8
+ <th>Title</th>
9
+ <th>Created</th>
10
+ <th>Updated</th>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @page.content_blocks.each do |c| %>
15
+ <tr>
16
+ <td><%= link_to c.title, edit_manifest_content_block_path(c) %></td>
17
+ <td><%= c.created_at.to_s(:short) %></td>
18
+ <td><%= c.updated_at.to_s(:short) %></td>
19
+ </tr>
20
+ <% end %>
21
+ </tbody>
22
+ </table>
23
+ <% else %>
24
+ <p>This page has no content blocks of its own. <%= link_to('Add one!', new_manifest_content_block_path(content_block: { page_id: @page.id })) if current_editor.admin? %></p>
25
+ <% end %>
26
+
27
+ <% if current_editor.admin? %>
28
+ <%= link_to 'Edit Page', edit_manifest_page_path(@page) %>
29
+ <%= link_to 'Delete Page', manifest_page_path(@page), method: :delete, confirm: "Are you sure you want to delete page \"#{@page.title}\"?" %>
30
+ <% end %>
@@ -7,7 +7,7 @@ module Manifest
7
7
  acts_as_manifest = false
8
8
 
9
9
  File.open(m, 'r') do |f|
10
- if f.lines.to_a.select { |l| l =~ /acts_as_manifest/ }.count > 0
10
+ if f.lines.to_a.select { |l| l =~ /data_type_for_manifest/ }.count > 0
11
11
  f.rewind
12
12
  f.lines.each do |l|
13
13
  if l =~ /ActiveRecord::Base/
data/config/routes.rb CHANGED
@@ -10,5 +10,5 @@ Rails.application.routes.draw do
10
10
  resources :content_blocks
11
11
  end
12
12
 
13
- get ':slug' => 'pages#show', as: 'page'
13
+ get '/:id' => 'pages#show', as: 'page'
14
14
  end
@@ -0,0 +1,10 @@
1
+ class CreatePages < ActiveRecord::Migration
2
+ def change
3
+ create_table :pages do |t|
4
+ t.string :title
5
+ t.string :slug
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateContentBlocks < ActiveRecord::Migration
2
+ def change
3
+ create_table :content_blocks do |t|
4
+ t.string :title
5
+ t.string :slug
6
+ t.text :content
7
+ t.integer :page_id
8
+ t.boolean :allow_html, default: false
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexToPages < ActiveRecord::Migration
2
+ def change
3
+ add_index :pages, :slug, unique: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexToContentBlocks < ActiveRecord::Migration
2
+ def change
3
+ add_index :content_blocks, :slug, unique: true
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class CreateEditors < ActiveRecord::Migration
2
+ def change
3
+ create_table :editors do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+ t.boolean :admin, default: false
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class ActiveRecord::Base
2
+ def self.data_type_for_manifest
3
+ nav_name = ActiveSupport::Inflector.pluralize(self.to_s)
4
+ route = "manifest_#{nav_name.underscore}_path"
5
+
6
+ Manifest.configure do |config|
7
+ config.data_types << { nav_name: ActiveSupport::Inflector.pluralize(self.to_s), route: route }
8
+ config.data_types.uniq!
9
+ end
10
+ end
11
+ end
@@ -8,9 +8,20 @@ class Manifest::DataTypeGenerator < ActiveRecord::Generators::Base
8
8
  migration_template 'migration.rb', "#{Rails.root}/db/migrate/create_#{table_name}.rb"
9
9
  end
10
10
 
11
+ def generate_data_type_form_partial
12
+ template '_form.html.erb', "#{Rails.root}/app/views/manifest/#{table_name}/_form.html.erb"
13
+ end
14
+
15
+ def generate_data_type_new_view
16
+ template 'new.html.erb', "#{Rails.root}/app/views/manifest/#{table_name}/new.html.erb"
17
+ end
18
+
19
+ def generate_data_type_edit_view
20
+ template 'edit.html.erb', "#{Rails.root}/app/views/manifest/#{table_name}/edit.html.erb"
21
+ end
22
+
11
23
  def create_index_view
12
- plural_name = ActiveSupport::Inflector.pluralize(name)
13
- template 'index.html.erb', "#{Rails.root}/app/views/manifest/#{plural_name.underscore}/index.html.erb"
24
+ template 'index.html.erb', "#{Rails.root}/app/views/manifest/#{table_name}/index.html.erb"
14
25
  end
15
26
 
16
27
  def create_manifest_namespace_in_routes_if_it_does_not_exist
@@ -0,0 +1,19 @@
1
+ <%%= form_for [:manifest, @<%= name.underscore %>], builder: Manifest::LabelledFormBuilder do |f| %>
2
+ <% attributes.each do |attribute| %>
3
+ <% if [:integer, :decimal, :float, :string].include?(attribute.type) %>
4
+ <%%= f.text_field :<%= attribute.name %> %>
5
+ <% elsif [:boolean].include?(attribute.type) %>
6
+ <%%= f.check_box :<%= attribute.name %> %>
7
+ <% elsif [:text].include?(attribute.type) %>
8
+ <%%= f.text_area :<%= attribute.name %> %>
9
+ <% elsif [:date].include?(attribute.type) %>
10
+ <%%= f.date_select :<%= attribute.name %> %>
11
+ <% elsif [:datetime].include?(attribute.type) %>
12
+ <%%= f.datetime_select :<%= attribute.name %> %>
13
+ <% elsif [:time].include?(attribute.type) %>
14
+ <%%= f.time_select :<%= attribute.name %> %>
15
+ <% end %>
16
+ <% end %>
17
+
18
+ <%%= f.submit %>
19
+ <%% end %>