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.
Files changed (95) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/categories.js +2 -0
  5. data/app/assets/javascripts/posts.js +2 -0
  6. data/app/assets/stylesheets/categories.css +4 -0
  7. data/app/assets/stylesheets/scaffold.css +56 -0
  8. data/app/controllers/categories_controller.rb +77 -0
  9. data/app/controllers/posts_controller.rb +94 -0
  10. data/app/controllers/posts_controller.rb~ +92 -0
  11. data/app/helpers/categories_helper.rb +2 -0
  12. data/app/helpers/posts_helper.rb +2 -0
  13. data/app/models/category.rb +4 -0
  14. data/app/models/category.rb~ +3 -0
  15. data/app/models/post.rb +14 -0
  16. data/app/models/post.rb~ +12 -0
  17. data/app/views/categories/_form.html.erb +21 -0
  18. data/app/views/categories/edit.html.erb +6 -0
  19. data/app/views/categories/index.html.erb +14 -0
  20. data/app/views/categories/new.html.erb +5 -0
  21. data/app/views/categories/show.html.erb +7 -0
  22. data/app/views/posts/_categories.html.erb +5 -0
  23. data/app/views/posts/_categories.html.erb~ +5 -0
  24. data/app/views/posts/_form.html.erb +42 -0
  25. data/app/views/posts/_form.html.erb~ +40 -0
  26. data/app/views/posts/edit.html.erb +6 -0
  27. data/app/views/posts/index.html.erb +17 -0
  28. data/app/views/posts/index.html.erb~ +20 -0
  29. data/app/views/posts/new.html.erb +5 -0
  30. data/app/views/posts/show.html.erb +27 -0
  31. data/app/views/posts/show.html.erb~ +30 -0
  32. data/config/routes.rb +6 -0
  33. data/db/migrate/20111231175637_create_categories.rb +13 -0
  34. data/db/migrate/20111231175637_create_categories.rb~ +9 -0
  35. data/db/migrate/20111231181111_create_posts.rb +17 -0
  36. data/db/migrate/20111231181111_create_posts.rb~ +17 -0
  37. data/db/migrate/20111231183528_add_categories_to_post.rb~ +7 -0
  38. data/db/migrate/20111231183528_create_categories_posts.rb +12 -0
  39. data/db/migrate/20111231183528_create_categories_posts.rb~ +7 -0
  40. data/lib/blogmodule.rb +4 -0
  41. data/lib/blogmodule/engine.rb +4 -0
  42. data/lib/blogmodule/version.rb +3 -0
  43. data/lib/tasks/blogmodule_tasks.rake +4 -0
  44. data/test/blogmodule_test.rb +7 -0
  45. data/test/dummy/Rakefile +7 -0
  46. data/test/dummy/app/assets/javascripts/application.js +9 -0
  47. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  48. data/test/dummy/app/controllers/application_controller.rb +3 -0
  49. data/test/dummy/app/helpers/application_helper.rb +2 -0
  50. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/config/application.rb +45 -0
  53. data/test/dummy/config/boot.rb +10 -0
  54. data/test/dummy/config/database.yml +25 -0
  55. data/test/dummy/config/environment.rb +5 -0
  56. data/test/dummy/config/environments/development.rb +30 -0
  57. data/test/dummy/config/environments/production.rb +60 -0
  58. data/test/dummy/config/environments/test.rb +39 -0
  59. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/dummy/config/initializers/inflections.rb +10 -0
  61. data/test/dummy/config/initializers/mime_types.rb +5 -0
  62. data/test/dummy/config/initializers/secret_token.rb +7 -0
  63. data/test/dummy/config/initializers/session_store.rb +8 -0
  64. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/test/dummy/config/locales/en.yml +5 -0
  66. data/test/dummy/config/routes.rb +58 -0
  67. data/test/dummy/db/development.sqlite3 +0 -0
  68. data/test/dummy/db/schema.rb +37 -0
  69. data/test/dummy/log/development.log +10438 -0
  70. data/test/dummy/public/404.html +26 -0
  71. data/test/dummy/public/422.html +26 -0
  72. data/test/dummy/public/500.html +26 -0
  73. data/test/dummy/public/favicon.ico +0 -0
  74. data/test/dummy/script/rails +6 -0
  75. data/test/dummy/tmp/cache/assets/BAD/970/sprockets%2F9a5112306a4228313104b6e694330675 +378 -0
  76. data/test/dummy/tmp/cache/assets/CD1/FE0/sprockets%2Fa933373e0504e8cd28ab26932e144bb1 +9289 -0
  77. data/test/dummy/tmp/cache/assets/CD8/430/sprockets%2F2859ec948a5d3b35fed62400c142008c +0 -0
  78. data/test/dummy/tmp/cache/assets/CD8/710/sprockets%2F4597cff24032334bc3e3542f0754bac8 +395 -0
  79. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +38 -0
  80. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
  81. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9652 -0
  82. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  83. data/test/dummy/tmp/cache/assets/E2C/A10/sprockets%2F9accda57c2c3dd81f1fadc6e19c55c90 +13 -0
  84. data/test/dummy/tmp/cache/assets/E3E/820/sprockets%2F5a1c7de58da1288fd9f29b75aeedf6ea +9272 -0
  85. data/test/fixtures/categories.yml +7 -0
  86. data/test/fixtures/posts.yml +15 -0
  87. data/test/functional/categories_controller_test.rb +49 -0
  88. data/test/functional/posts_controller_test.rb +49 -0
  89. data/test/integration/navigation_test.rb +10 -0
  90. data/test/test_helper.rb +10 -0
  91. data/test/unit/category_test.rb +7 -0
  92. data/test/unit/helpers/categories_helper_test.rb +4 -0
  93. data/test/unit/helpers/posts_helper_test.rb +4 -0
  94. data/test/unit/post_test.rb +7 -0
  95. 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,6 @@
1
+ <h1>Editing category</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @category %> |
6
+ <%= link_to 'Back', categories_path %>
@@ -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,5 @@
1
+ <h1>New category</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,7 @@
1
+ <p>
2
+ <b>Name:</b>
3
+ <%= @category.name %>
4
+ </p>
5
+
6
+ <%= link_to 'Edit', edit_category_path(@category) %> |
7
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,5 @@
1
+ <ul class="squared">
2
+ <% @categories.each do |category| %>
3
+ <li><%= link_to_unless_current category.name, posts_path(:category_id => category.id) %></li>
4
+ <% end %>
5
+ </ul>
@@ -0,0 +1,5 @@
1
+ <% @categories.each do |category| %>
2
+ <ul>
3
+ <li><%= link_to_unless_current category.name, posts_path(:category) %>
4
+ </ul>
5
+ <% end %>
@@ -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,6 @@
1
+ <h1>Editing post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @post %> |
6
+ <%= link_to 'Back', posts_path %>
@@ -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,5 @@
1
+ <h1>New post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', posts_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,6 @@
1
+ Rails.application.routes.draw do
2
+ resources :posts
3
+
4
+ resources :categories
5
+
6
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCategories < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :categories
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class CreateCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ 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 :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,7 @@
1
+ class AddCategoriesToPost < ActiveRecord::Migration
2
+ def change
3
+ create_table "categories_posts" do |t|
4
+ t.integer :post_id
5
+ END
6
+ end
7
+ 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
@@ -0,0 +1,7 @@
1
+ class AddCategoriesToPost < ActiveRecord::Migration
2
+ def change
3
+ create_table "categories_posts" do |t|
4
+ t.integer :post_id
5
+ end
6
+ end
7
+ end
data/lib/blogmodule.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "blogmodule/engine"
2
+
3
+ module Blogmodule
4
+ end
@@ -0,0 +1,4 @@
1
+ module Blogmodule
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Blogmodule
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :blogmodule do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BlogmoduleTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Blogmodule
6
+ end
7
+ end
@@ -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
+ */