blogmodule 0.0.1
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/javascripts/categories.js +2 -0
- data/app/assets/javascripts/posts.js +2 -0
- data/app/assets/stylesheets/categories.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/categories_controller.rb +77 -0
- data/app/controllers/posts_controller.rb +94 -0
- data/app/controllers/posts_controller.rb~ +92 -0
- data/app/helpers/categories_helper.rb +2 -0
- data/app/helpers/posts_helper.rb +2 -0
- data/app/models/category.rb +4 -0
- data/app/models/category.rb~ +3 -0
- data/app/models/post.rb +14 -0
- data/app/models/post.rb~ +12 -0
- data/app/views/categories/_form.html.erb +21 -0
- data/app/views/categories/edit.html.erb +6 -0
- data/app/views/categories/index.html.erb +14 -0
- data/app/views/categories/new.html.erb +5 -0
- data/app/views/categories/show.html.erb +7 -0
- data/app/views/posts/_categories.html.erb +5 -0
- data/app/views/posts/_categories.html.erb~ +5 -0
- data/app/views/posts/_form.html.erb +42 -0
- data/app/views/posts/_form.html.erb~ +40 -0
- data/app/views/posts/edit.html.erb +6 -0
- data/app/views/posts/index.html.erb +17 -0
- data/app/views/posts/index.html.erb~ +20 -0
- data/app/views/posts/new.html.erb +5 -0
- data/app/views/posts/show.html.erb +27 -0
- data/app/views/posts/show.html.erb~ +30 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20111231175637_create_categories.rb +13 -0
- data/db/migrate/20111231175637_create_categories.rb~ +9 -0
- data/db/migrate/20111231181111_create_posts.rb +17 -0
- data/db/migrate/20111231181111_create_posts.rb~ +17 -0
- data/db/migrate/20111231183528_add_categories_to_post.rb~ +7 -0
- data/db/migrate/20111231183528_create_categories_posts.rb +12 -0
- data/db/migrate/20111231183528_create_categories_posts.rb~ +7 -0
- data/lib/blogmodule.rb +4 -0
- data/lib/blogmodule/engine.rb +4 -0
- data/lib/blogmodule/version.rb +3 -0
- data/lib/tasks/blogmodule_tasks.rake +4 -0
- data/test/blogmodule_test.rb +7 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +37 -0
- data/test/dummy/log/development.log +10438 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/BAD/970/sprockets%2F9a5112306a4228313104b6e694330675 +378 -0
- data/test/dummy/tmp/cache/assets/CD1/FE0/sprockets%2Fa933373e0504e8cd28ab26932e144bb1 +9289 -0
- data/test/dummy/tmp/cache/assets/CD8/430/sprockets%2F2859ec948a5d3b35fed62400c142008c +0 -0
- data/test/dummy/tmp/cache/assets/CD8/710/sprockets%2F4597cff24032334bc3e3542f0754bac8 +395 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +38 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9652 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E2C/A10/sprockets%2F9accda57c2c3dd81f1fadc6e19c55c90 +13 -0
- data/test/dummy/tmp/cache/assets/E3E/820/sprockets%2F5a1c7de58da1288fd9f29b75aeedf6ea +9272 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/posts.yml +15 -0
- data/test/functional/categories_controller_test.rb +49 -0
- data/test/functional/posts_controller_test.rb +49 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/category_test.rb +7 -0
- data/test/unit/helpers/categories_helper_test.rb +4 -0
- data/test/unit/helpers/posts_helper_test.rb +4 -0
- data/test/unit/post_test.rb +7 -0
- metadata +212 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_for (@category) do |f| %>
|
2
|
+
<% if @category.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @category.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :name %><br />
|
16
|
+
<%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="actions">
|
19
|
+
<%= f.submit %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1>Listing categories</h1>
|
2
|
+
<% @categories.each do |category| %>
|
3
|
+
<ul>
|
4
|
+
<li><%= category.name %></li>
|
5
|
+
<%= link_to 'Destroy', category, confirm: 'Are you sure?', method: :delete %>
|
6
|
+
<%= link_to 'Edit', edit_category_path(category) %>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
|
12
|
+
<br />
|
13
|
+
|
14
|
+
<%= link_to 'New Category', new_category_path %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= form_for(@post) do |f| %>
|
2
|
+
<% if @post.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @post.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
<ul>
|
14
|
+
<% @categories.each do |c| %>
|
15
|
+
<li><%= check_box_tag "post[category_ids][]", c.id, @post.categories.include?(c) %>
|
16
|
+
<%= c.name %></li>
|
17
|
+
<%- end -%>
|
18
|
+
</ul>
|
19
|
+
<div class="field">
|
20
|
+
<%= f.label :published %><br />
|
21
|
+
<%= f.check_box :published %>
|
22
|
+
</div>
|
23
|
+
<div class="field">
|
24
|
+
<%= f.label :title %><br />
|
25
|
+
<%= f.text_field :title %>
|
26
|
+
</div>
|
27
|
+
<div class="field">
|
28
|
+
<%= f.label :date %><br />
|
29
|
+
<%= f.datetime_select :date %>
|
30
|
+
</div>
|
31
|
+
<div class="field">
|
32
|
+
<%= f.label :excerpt %><br />
|
33
|
+
<%= f.text_area :excerpt %>
|
34
|
+
</div>
|
35
|
+
<div class="field">
|
36
|
+
<%= f.label :body %><br />
|
37
|
+
<%= f.text_area :body %>
|
38
|
+
</div>
|
39
|
+
<div class="actions">
|
40
|
+
<%= f.submit %>
|
41
|
+
</div>
|
42
|
+
<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<%= form_for(@post) do |f| %>
|
2
|
+
<% if @post.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @post.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :published %><br />
|
16
|
+
<%= f.check_box :published %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :title %><br />
|
20
|
+
<%= f.text_field :title %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :date %><br />
|
24
|
+
<%= f.datetime_select :date %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :excerpt %><br />
|
28
|
+
<%= f.text_area :excerpt %>
|
29
|
+
</div>
|
30
|
+
<div class="field">
|
31
|
+
<%= f.label :body %><br />
|
32
|
+
<%= f.text_area :body %>
|
33
|
+
</div>
|
34
|
+
<ul class="categories-field">
|
35
|
+
<li><%= f.collection_select :category_ids, @categories.post, :id, :name %></li>
|
36
|
+
</ul>
|
37
|
+
<div class="actions">
|
38
|
+
<%= f.submit %>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h1>Listing posts</h1>
|
2
|
+
|
3
|
+
<%= render :partial => "categories"%>
|
4
|
+
|
5
|
+
<%- if @posts.present? -%>
|
6
|
+
|
7
|
+
<%- @posts.each do |post| -%>
|
8
|
+
<h2><%= link_to post.title.titleize, post %></h2>
|
9
|
+
|
10
|
+
<%= simple_format post.excerpt %>
|
11
|
+
|
12
|
+
<p><%= link_to "continue ...", post %></p>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% else %>
|
16
|
+
<p>We'll start posting soon.</p>
|
17
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h1>Listing posts</h1>
|
2
|
+
|
3
|
+
<%= render :partial => "categories"%>
|
4
|
+
|
5
|
+
<% @posts.each do |post| %>
|
6
|
+
|
7
|
+
<h2><%= post.title %></h2>
|
8
|
+
<p><%= post.date %></p>
|
9
|
+
<p><%= post.body %></p>
|
10
|
+
<td><%= post.category.name %></td>
|
11
|
+
<hr />
|
12
|
+
<td><%= link_to 'Show', post %></td>
|
13
|
+
<td><%= link_to 'Edit', edit_post_path(post) %></td>
|
14
|
+
<td><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></td>
|
15
|
+
<% end %>
|
16
|
+
<hr />
|
17
|
+
|
18
|
+
<br />
|
19
|
+
|
20
|
+
<%= link_to 'New Post', new_post_path %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Indexpage:</b>
|
5
|
+
<%= @post.published %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Title:</b>
|
10
|
+
<%= @post.title %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Date:</b>
|
15
|
+
<%= @post.date %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Content:</b>
|
20
|
+
<%= @post.body %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<%= link_to 'Edit', edit_post_path(@post) %> |
|
27
|
+
<%= link_to 'Back', posts_path %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Indexpage:</b>
|
5
|
+
<%= @post.published %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Title:</b>
|
10
|
+
<%= @post.title %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Date:</b>
|
15
|
+
<%= @post.date %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Content:</b>
|
20
|
+
<%= @post.body %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<b>Category:</b>
|
25
|
+
<%= @post.category %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
|
29
|
+
<%= link_to 'Edit', edit_post_path(@post) %> |
|
30
|
+
<%= link_to 'Back', posts_path %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreatePosts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :posts do |t|
|
4
|
+
t.boolean :published
|
5
|
+
t.datetime :date
|
6
|
+
t.string :title
|
7
|
+
t.string :excerpt
|
8
|
+
t.text :body
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :posts
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreatePosts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :posts do |t|
|
4
|
+
t.boolean :published
|
5
|
+
t.datetime
|
6
|
+
t.string :title
|
7
|
+
t.string :excerpt
|
8
|
+
t.text :body
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :posts
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateCategoriesPosts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "categories_posts", :id => false, :force => true do |t|
|
4
|
+
t.integer "post_id", :null => false
|
5
|
+
t.integer "category_id", :null => false
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
drop_table "categories_posts"
|
11
|
+
end
|
12
|
+
end
|
data/lib/blogmodule.rb
ADDED
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|