rails_blogger_engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/rails_blogger_engine/application.js +13 -0
- data/app/assets/javascripts/rails_blogger_engine/articles.js +2 -0
- data/app/assets/javascripts/rails_blogger_engine/comments.js +2 -0
- data/app/assets/stylesheets/rails_blogger_engine/application.css +15 -0
- data/app/assets/stylesheets/rails_blogger_engine/articles.css +4 -0
- data/app/assets/stylesheets/rails_blogger_engine/comments.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/rails_blogger_engine/application_controller.rb +4 -0
- data/app/controllers/rails_blogger_engine/articles_controller.rb +62 -0
- data/app/controllers/rails_blogger_engine/comments_controller.rb +17 -0
- data/app/helpers/rails_blogger_engine/application_helper.rb +4 -0
- data/app/helpers/rails_blogger_engine/articles_helper.rb +4 -0
- data/app/helpers/rails_blogger_engine/comments_helper.rb +4 -0
- data/app/models/rails_blogger_engine/article.rb +15 -0
- data/app/models/rails_blogger_engine/comment.rb +4 -0
- data/app/views/layouts/rails_blogger_engine/application.html.erb +15 -0
- data/app/views/rails_blogger_engine/articles/_form.html.erb +29 -0
- data/app/views/rails_blogger_engine/articles/edit.html.erb +6 -0
- data/app/views/rails_blogger_engine/articles/index.html.erb +29 -0
- data/app/views/rails_blogger_engine/articles/new.html.erb +5 -0
- data/app/views/rails_blogger_engine/articles/show.html.erb +21 -0
- data/app/views/rails_blogger_engine/comments/_comment.html.erb +1 -0
- data/app/views/rails_blogger_engine/comments/_form.html.erb +8 -0
- data/config/initializers/assets.rb +1 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20150325015547_create_rails_blogger_engine_articles.rb +10 -0
- data/db/migrate/20150325015849_create_rails_blogger_engine_comments.rb +10 -0
- data/db/migrate/20150325022747_add_author_id_to_rails_blogger_engine_articles.rb +5 -0
- data/lib/rails_blogger_engine/engine.rb +5 -0
- data/lib/rails_blogger_engine/version.rb +3 -0
- data/lib/rails_blogger_engine.rb +9 -0
- data/lib/tasks/rails_blogger_engine_tasks.rake +4 -0
- data/test/controllers/rails_blogger_engine/articles_controller_test.rb +51 -0
- data/test/controllers/rails_blogger_engine/comments_controller_test.rb +9 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -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/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +31 -0
- data/test/dummy/log/development.log +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/rails_blogger_engine/articles.yml +9 -0
- data/test/fixtures/rails_blogger_engine/comments.yml +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/rails_blogger_engine/article_test.rb +9 -0
- data/test/models/rails_blogger_engine/comment_test.rb +9 -0
- data/test/rails_blogger_engine_test.rb +7 -0
- data/test/test_helper.rb +20 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52c68e067a356b95ea8707f58c789ae0a641fb52
|
4
|
+
data.tar.gz: c01e29b06c89669d55259795b51d450cdd9dd225
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06fd6d2914b7f350bbb11d41e9274e9a2dc480c875dcc6dc83202f99e0eef00db8cb176995d0e880310501ebca53503f2930133ab61276aa3a3d773a76d75d52
|
7
|
+
data.tar.gz: 9db11d2fdd334a8927df9991f7e14f66eeb87ad08d97896570cc5cbb4848129d4991aa3745d7fc4609372e1a2569775a613b91120a9d07cf4f61e554cb66a389
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Eric Kuhn
|
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,13 @@
|
|
1
|
+
= RailsBloggerEngine
|
2
|
+
|
3
|
+
This project rocks and uses MIT-LICENSE.
|
4
|
+
|
5
|
+
1. Add gem ‘rails_blogger_migration' to your gem file
|
6
|
+
|
7
|
+
2. Run Bundle Install
|
8
|
+
|
9
|
+
3. Add mount RailsBloggerEngine::Engine, at: "/blog” to your routes files
|
10
|
+
|
11
|
+
4. Run rake rails_blogger_engine:install:migrations
|
12
|
+
|
13
|
+
5. Run rake db:migrate
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsBloggerEngine'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
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 any plugin's vendor/assets/javascripts directory 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
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -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,62 @@
|
|
1
|
+
require_dependency "rails_blogger_engine/application_controller"
|
2
|
+
|
3
|
+
module RailsBloggerEngine
|
4
|
+
class ArticlesController < ApplicationController
|
5
|
+
before_action :set_article, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /articles
|
8
|
+
def index
|
9
|
+
@articles = Article.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /articles/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /articles/new
|
17
|
+
def new
|
18
|
+
@article = Article.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /articles/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /articles
|
26
|
+
def create
|
27
|
+
@article = Article.new(article_params)
|
28
|
+
|
29
|
+
if @article.save
|
30
|
+
redirect_to @article, notice: 'Article was successfully created.'
|
31
|
+
else
|
32
|
+
render :new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# PATCH/PUT /articles/1
|
37
|
+
def update
|
38
|
+
if @article.update(article_params)
|
39
|
+
redirect_to @article, notice: 'Article was successfully updated.'
|
40
|
+
else
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# DELETE /articles/1
|
46
|
+
def destroy
|
47
|
+
@article.destroy
|
48
|
+
redirect_to articles_url, notice: 'Article was successfully destroyed.'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_article
|
54
|
+
@article = Article.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
58
|
+
def article_params
|
59
|
+
params.require(:article).permit(:title, :text, :author_name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_dependency "rails_blogger_engine/application_controller"
|
2
|
+
|
3
|
+
module RailsBloggerEngine
|
4
|
+
class CommentsController < ApplicationController
|
5
|
+
def create
|
6
|
+
@article = Article.find(params[:article_id])
|
7
|
+
@comment = @article.comments.create(comment_params)
|
8
|
+
flash[:notice] = "Comment has been created!"
|
9
|
+
redirect_to articles_path
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def comment_params
|
14
|
+
params.require(:comment).permit(:text)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RailsBloggerEngine
|
2
|
+
class Article < ActiveRecord::Base
|
3
|
+
has_many :comments
|
4
|
+
|
5
|
+
attr_accessor :author_name
|
6
|
+
belongs_to :author, class_name: RailsBloggerEngine.author_class.to_s
|
7
|
+
|
8
|
+
before_save :set_author
|
9
|
+
|
10
|
+
private
|
11
|
+
def set_author
|
12
|
+
self.author = RailsBloggerEngine.author_class.find_or_create_by(name: author_name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RailsBloggerEngine</title>
|
5
|
+
<%= stylesheet_link_tag "rails_blogger_engine/application", media: "all" %>
|
6
|
+
<%= stylesheet_link_tag "scaffold" %>
|
7
|
+
<%= javascript_include_tag "rails_blogger_engine/application" %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%= form_for(@article) do |f| %>
|
2
|
+
<% if @article.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @article.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></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="field">
|
23
|
+
<%= f.label :author_name %><br>
|
24
|
+
<%= f.text_field :author_name %>
|
25
|
+
</div>
|
26
|
+
<div class="actions">
|
27
|
+
<%= f.submit %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Listing Articles</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Title</th>
|
9
|
+
<th>Text</th>
|
10
|
+
<th colspan="3"></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
|
14
|
+
<tbody>
|
15
|
+
<% @articles.each do |article| %>
|
16
|
+
<tr>
|
17
|
+
<td><%= article.title %></td>
|
18
|
+
<td><%= article.text %></td>
|
19
|
+
<td><%= link_to 'Show', article %></td>
|
20
|
+
<td><%= link_to 'Edit', edit_article_path(article) %></td>
|
21
|
+
<td><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<br>
|
28
|
+
|
29
|
+
<%= link_to 'New Article', new_article_path %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
<p>
|
3
|
+
<b>Author:</b>
|
4
|
+
<%= @article.author %>
|
5
|
+
</p>
|
6
|
+
<p>
|
7
|
+
<strong>Title:</strong>
|
8
|
+
<%= @article.title %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<strong>Text:</strong>
|
13
|
+
<%= @article.text %>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<h3>Comments</h3>
|
17
|
+
<%= render @article.comments %>
|
18
|
+
<%= render "rails_blogger_engine/comments/form" %>
|
19
|
+
|
20
|
+
<%= link_to 'Edit', edit_article_path(@article) %> |
|
21
|
+
<%= link_to 'Back', articles_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= comment_counter + 1 %>. <%= comment.text %>
|