manifest-rails 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.rdoc +3 -0
- data/app/assets/javascripts/manifest/main.js +17 -0
- data/app/assets/stylesheets/manifest/_forms.css.scss +42 -21
- data/app/assets/stylesheets/manifest/_tables.css.scss +24 -20
- data/app/assets/stylesheets/manifest/main.css.scss +72 -0
- data/app/assets/stylesheets/manifest/sessions.css.scss +9 -0
- data/app/controllers/manifest/content_blocks_controller.rb +14 -11
- data/app/controllers/manifest/manifest_controller.rb +3 -8
- data/app/controllers/manifest/pages_controller.rb +2 -5
- data/app/controllers/manifest/sessions_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +1 -8
- data/app/form_builders/manifest/labelled_form_builder.rb +23 -0
- data/app/models/content_block.rb +6 -2
- data/app/models/page.rb +18 -13
- data/app/views/layouts/manifest/manifest.html.erb +19 -18
- data/app/views/layouts/manifest/sessions.html.erb +10 -7
- data/app/views/manifest/content_blocks/_form.html.erb +24 -26
- data/app/views/manifest/content_blocks/edit.html.erb +1 -9
- data/app/views/manifest/content_blocks/index.html.erb +14 -14
- data/app/views/manifest/content_blocks/new.html.erb +1 -1
- data/app/views/manifest/pages/_form.html.erb +9 -10
- data/app/views/manifest/pages/edit.html.erb +1 -9
- data/app/views/manifest/pages/index.html.erb +5 -3
- data/app/views/manifest/pages/new.html.erb +1 -1
- data/app/views/manifest/pages/show.html.erb +29 -6
- data/config/initializers/manifest.rb +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20120303200114_create_pages.rb +10 -0
- data/db/migrate/20120304152605_create_content_blocks.rb +13 -0
- data/db/migrate/20120304155055_add_index_to_pages.rb +5 -0
- data/db/migrate/20120304155130_add_index_to_content_blocks.rb +5 -0
- data/db/migrate/20120305164036_create_editors.rb +11 -0
- data/lib/active_record/base/data_type_for_manifest.rb +11 -0
- data/lib/generators/manifest/data_type/data_type_generator.rb +13 -2
- data/lib/generators/manifest/data_type/templates/_form.html.erb +19 -0
- data/lib/generators/manifest/data_type/templates/controller.rb +41 -4
- data/lib/generators/manifest/data_type/templates/edit.html.erb +3 -0
- data/lib/generators/manifest/data_type/templates/index.html.erb +4 -0
- data/lib/generators/manifest/data_type/templates/model.rb +1 -1
- data/lib/generators/manifest/data_type/templates/new.html.erb +3 -0
- data/lib/generators/manifest/install/USAGE +1 -3
- data/lib/generators/manifest/install/install_generator.rb +13 -4
- data/lib/generators/manifest/install/templates/create_content_blocks.rb +1 -1
- data/lib/generators/manifest/install/templates/create_pages.rb +1 -1
- data/lib/manifest.rb +4 -9
- data/lib/manifest/engine.rb +0 -3
- data/lib/manifest/version.rb +1 -1
- metadata +54 -115
- data/README.md +0 -37
- data/app/assets/images/manifest/grid.png +0 -0
- data/app/assets/images/manifest/sketch.png +0 -0
- data/app/assets/javascripts/manifest/manifest.js +0 -7
- data/app/assets/stylesheets/manifest/_mixins.css.scss +0 -41
- data/app/assets/stylesheets/manifest/manifest.css.scss +0 -137
- data/app/controllers/manifest/editors_controller.rb +0 -3
- data/app/models/user.rb +0 -8
- 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
|
6
|
-
|
7
|
-
<%=
|
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
|
11
|
-
<link href='http://fonts.googleapis.com/css?family=
|
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
|
-
<
|
16
|
-
<h1
|
15
|
+
<div class='app-nav'>
|
16
|
+
<h1>Manifest</h1>
|
17
|
+
|
17
18
|
<nav>
|
18
19
|
<ul>
|
19
|
-
|
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
|
-
|
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
|
6
|
-
|
7
|
-
<%=
|
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=
|
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
|
-
<
|
16
|
+
<div class='app-nav'>
|
17
|
+
<h1>Manifest</h1>
|
18
|
+
</div><!-- app-nav -->
|
16
19
|
|
17
|
-
<div
|
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
|
-
<
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
31
|
-
<%= f.
|
32
|
-
|
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
|
-
|
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>
|
1
|
+
<h2>Content Blocks: Edit “<%= @content_block.title %>”</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
|
3
|
+
<% if @content_blocks.count > 0 %>
|
4
|
+
<table>
|
5
5
|
<thead>
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
</
|
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
|
14
|
+
<tr>
|
15
15
|
<td><%= link_to c.title, edit_manifest_content_block_path(c) %></td>
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
<
|
26
|
+
<div class='model-actions'>
|
27
|
+
<%= link_to 'New Content Block', new_manifest_content_block_path %>
|
28
|
+
</div><!-- model-actions -->
|
29
29
|
<% end %>
|
@@ -1,19 +1,18 @@
|
|
1
1
|
<% if @page.errors.any? %>
|
2
|
-
<div class='errors'>
|
3
|
-
<
|
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
|
-
|
14
|
-
|
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
|
1
|
+
<h2>Pages: Edit “<%= @page.title %>”</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,
|
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
|
-
<
|
12
|
+
<div class='model-actions'>
|
13
|
+
<%= link_to 'New Page', new_manifest_page_path %>
|
14
|
+
</div><!-- model-actions -->
|
13
15
|
<% end %>
|
@@ -1,7 +1,30 @@
|
|
1
|
-
<h2>
|
1
|
+
<h2>Pages: “<%= @page.title %>”</h2>
|
2
2
|
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 =~ /
|
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
@@ -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,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
|
-
|
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 %>
|