myengine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/myengine/application.js +15 -0
  6. data/app/assets/javascripts/myengine/comments.js +2 -0
  7. data/app/assets/javascripts/myengine/posts.js +2 -0
  8. data/app/assets/stylesheets/myengine/application.css +13 -0
  9. data/app/assets/stylesheets/myengine/comments.css +4 -0
  10. data/app/assets/stylesheets/myengine/posts.css +4 -0
  11. data/app/assets/stylesheets/scaffold.css +56 -0
  12. data/app/controllers/myengine/application_controller.rb +4 -0
  13. data/app/controllers/myengine/comments_controller.rb +12 -0
  14. data/app/controllers/myengine/posts_controller.rb +87 -0
  15. data/app/helpers/myengine/application_helper.rb +4 -0
  16. data/app/helpers/myengine/comments_helper.rb +4 -0
  17. data/app/helpers/myengine/posts_helper.rb +4 -0
  18. data/app/models/myengine/comment.rb +5 -0
  19. data/app/models/myengine/post.rb +6 -0
  20. data/app/views/layouts/myengine/application.html.erb +14 -0
  21. data/app/views/myengine/comments/_comment.html.erb +1 -0
  22. data/app/views/myengine/comments/_form.html.erb +8 -0
  23. data/app/views/myengine/posts/_form.html.erb +25 -0
  24. data/app/views/myengine/posts/edit.html.erb +6 -0
  25. data/app/views/myengine/posts/index.html.erb +25 -0
  26. data/app/views/myengine/posts/new.html.erb +5 -0
  27. data/app/views/myengine/posts/show.html.erb +18 -0
  28. data/config/routes.rb +7 -0
  29. data/db/migrate/20130529033013_create_myengine_posts.rb +10 -0
  30. data/db/migrate/20130529033206_create_myengine_comments.rb +10 -0
  31. data/lib/myengine.rb +4 -0
  32. data/lib/myengine/engine.rb +5 -0
  33. data/lib/myengine/version.rb +3 -0
  34. data/lib/tasks/myengine_tasks.rake +4 -0
  35. data/test/dummy/README.rdoc +261 -0
  36. data/test/dummy/Rakefile +7 -0
  37. data/test/dummy/app/assets/javascripts/application.js +15 -0
  38. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  39. data/test/dummy/app/controllers/application_controller.rb +3 -0
  40. data/test/dummy/app/helpers/application_helper.rb +2 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/test/dummy/config.ru +4 -0
  43. data/test/dummy/config/application.rb +59 -0
  44. data/test/dummy/config/boot.rb +10 -0
  45. data/test/dummy/config/database.yml +25 -0
  46. data/test/dummy/config/environment.rb +5 -0
  47. data/test/dummy/config/environments/development.rb +37 -0
  48. data/test/dummy/config/environments/production.rb +67 -0
  49. data/test/dummy/config/environments/test.rb +37 -0
  50. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  51. data/test/dummy/config/initializers/inflections.rb +15 -0
  52. data/test/dummy/config/initializers/mime_types.rb +5 -0
  53. data/test/dummy/config/initializers/secret_token.rb +7 -0
  54. data/test/dummy/config/initializers/session_store.rb +8 -0
  55. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/test/dummy/config/locales/en.yml +5 -0
  57. data/test/dummy/config/routes.rb +4 -0
  58. data/test/dummy/public/404.html +26 -0
  59. data/test/dummy/public/422.html +26 -0
  60. data/test/dummy/public/500.html +25 -0
  61. data/test/dummy/public/favicon.ico +0 -0
  62. data/test/dummy/script/rails +6 -0
  63. data/test/fixtures/myengine/comments.yml +9 -0
  64. data/test/fixtures/myengine/posts.yml +9 -0
  65. data/test/functional/myengine/comments_controller_test.rb +9 -0
  66. data/test/functional/myengine/posts_controller_test.rb +51 -0
  67. data/test/integration/navigation_test.rb +10 -0
  68. data/test/myengine_test.rb +7 -0
  69. data/test/test_helper.rb +15 -0
  70. data/test/unit/helpers/myengine/comments_helper_test.rb +6 -0
  71. data/test/unit/helpers/myengine/posts_helper_test.rb +6 -0
  72. data/test/unit/myengine/comment_test.rb +9 -0
  73. data/test/unit/myengine/post_test.rb +9 -0
  74. metadata +182 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 909ebaaec23495dec82681f6c2fe5fa3687d4549
4
+ data.tar.gz: 192e4184f7894d18bc7885726924afd5afa24c85
5
+ SHA512:
6
+ metadata.gz: 93222a175176cdb411105b293298dd9df3bf220b71e5fc4f8dd04b2910e538abe793a61e866ead0bafda1800a10d47863f1a846efc4616162ca315d1986f05e2
7
+ data.tar.gz: 71968a52cd6bcc717bdd7bd4ca49956de4b3c90d524cfca3c763cfac22ee2fbe61c15d7b6cf1766f92614a951ae890fd1d0c28d04d1db256861dc89be2a0b7a3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Myengine
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Myengine'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ module Myengine
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ require_dependency "myengine/application_controller"
2
+
3
+ module Myengine
4
+ class CommentsController < ApplicationController
5
+ def create
6
+ @post = Post.find(params[:post_id])
7
+ @comment = @post.comments.create(params[:comment])
8
+ flash[:notice] = "Comment has been created!"
9
+ redirect_to posts_path
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "myengine/application_controller"
2
+
3
+ module Myengine
4
+ class PostsController < ApplicationController
5
+ # GET /posts
6
+ # GET /posts.json
7
+ def index
8
+ @posts = Post.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render json: @posts }
13
+ end
14
+ end
15
+
16
+ # GET /posts/1
17
+ # GET /posts/1.json
18
+ def show
19
+ @post = Post.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @post }
24
+ end
25
+ end
26
+
27
+ # GET /posts/new
28
+ # GET /posts/new.json
29
+ def new
30
+ @post = Post.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render json: @post }
35
+ end
36
+ end
37
+
38
+ # GET /posts/1/edit
39
+ def edit
40
+ @post = Post.find(params[:id])
41
+ end
42
+
43
+ # POST /posts
44
+ # POST /posts.json
45
+ def create
46
+ @post = Post.new(params[:post])
47
+
48
+ respond_to do |format|
49
+ if @post.save
50
+ format.html { redirect_to @post, notice: 'Post was successfully created.' }
51
+ format.json { render json: @post, status: :created, location: @post }
52
+ else
53
+ format.html { render action: "new" }
54
+ format.json { render json: @post.errors, status: :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /posts/1
60
+ # PUT /posts/1.json
61
+ def update
62
+ @post = Post.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @post.update_attributes(params[:post])
66
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render action: "edit" }
70
+ format.json { render json: @post.errors, status: :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /posts/1
76
+ # DELETE /posts/1.json
77
+ def destroy
78
+ @post = Post.find(params[:id])
79
+ @post.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to posts_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,4 @@
1
+ module Myengine
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Myengine
2
+ module CommentsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Myengine
2
+ module PostsHelper
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module Myengine
2
+ class Comment < ActiveRecord::Base
3
+ attr_accessible :post_id, :text
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Myengine
2
+ class Post < ActiveRecord::Base
3
+ attr_accessible :text, :title
4
+ has_many :comments
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Myengine</title>
5
+ <%= stylesheet_link_tag "myengine/application", :media => "all" %>
6
+ <%= javascript_include_tag "myengine/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ <%= comment_counter + 1 %>. <%= comment.text %>
@@ -0,0 +1,8 @@
1
+ <h3>New comment</h3>
2
+ <%= form_for [@post, @post.comments.build] do |f| %>
3
+ <p>
4
+ <%= f.label :text %><br />
5
+ <%= f.text_area :text %>
6
+ </p>
7
+ <%= f.submit %>
8
+ <% end %>
@@ -0,0 +1,25 @@
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 :title %><br />
16
+ <%= f.text_field :title %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :text %><br />
20
+ <%= f.text_area :text %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% 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,25 @@
1
+ <h1>Listing posts</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Text</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @posts.each do |post| %>
13
+ <tr>
14
+ <td><%= post.title %></td>
15
+ <td><%= post.text %></td>
16
+ <td><%= link_to 'Show', post %></td>
17
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
18
+ <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= 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,18 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Title:</b>
5
+ <%= @post.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Text:</b>
10
+ <%= @post.text %>
11
+ </p>
12
+
13
+
14
+ <%= link_to 'Edit', edit_post_path(@post) %> |
15
+ <%= link_to 'Back', posts_path %>
16
+ <h3>Comments</h3>
17
+ <%= render @post.comments %>
18
+ <%= render "myengine/comments/form" %>