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 +3 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/blogger/application.js +13 -0
- data/app/assets/javascripts/blogger/articles.js +2 -0
- data/app/assets/javascripts/blogger/comments.js +2 -0
- data/app/assets/stylesheets/blogger/application.css +15 -0
- data/app/assets/stylesheets/blogger/articles.css +4 -0
- data/app/assets/stylesheets/blogger/comments.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/blogger/application_controller.rb +4 -0
- data/app/controllers/blogger/articles_controller.rb +62 -0
- data/app/controllers/blogger/comments_controller.rb +17 -0
- data/app/helpers/blogger/application_helper.rb +4 -0
- data/app/helpers/blogger/articles_helper.rb +4 -0
- data/app/helpers/blogger/comments_helper.rb +4 -0
- data/app/models/blogger/article.rb +15 -0
- data/app/models/blogger/comment.rb +4 -0
- data/app/views/blogger/articles/_form.html.erb +29 -0
- data/app/views/blogger/articles/edit.html.erb +6 -0
- data/app/views/blogger/articles/index.html.erb +29 -0
- data/app/views/blogger/articles/new.html.erb +5 -0
- data/app/views/blogger/articles/show.html.erb +22 -0
- data/app/views/blogger/comments/_comment.html.erb +1 -0
- data/app/views/blogger/comments/_form.html.erb +8 -0
- data/app/views/layouts/blogger/application.html.erb +15 -0
- data/config/initializers/assets.rb +1 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20150322200045_create_blogger_articles.rb +10 -0
- data/db/migrate/20150322202121_create_blogger_comments.rb +10 -0
- data/db/migrate/20150323010458_add_author_id_to_blogger_articles.rb +5 -0
- data/lib/blogger.rb +9 -0
- data/lib/blogger/engine.rb +5 -0
- data/lib/blogger/version.rb +3 -0
- data/lib/tasks/blogger_tasks.rake +4 -0
- data/test/blogger_test.rb +7 -0
- data/test/controllers/blogger/articles_controller_test.rb +51 -0
- data/test/controllers/blogger/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.ru +4 -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/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +30 -0
- data/test/dummy/log/development.log +277 -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/dummy/tmp/cache/assets/development/sprockets/18620df37479ef239dbca82e4e2c88b9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2380a1312c92daad5bbec7d681785f83 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/275b79e00400843a0561d69d30516a10 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2c8d9e436990782275148b1a4e1a9b06 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/320d097947296b8a25ada62c537d836b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/46a9e4ecc26e6906cc43870865ff3846 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/601848f617752da354dfbd77e3d22528 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6571f700c96faf44a3c1729a8f83cb48 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9e7f240b6f9cade86eb65f6f703dbf74 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab18bc4ea73e5f6dd2553905d42f6402 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab2a0a8fab8751a75bc8586201320848 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bbae4a2e8593a0acf281af3a0d3b419e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d1750b2d96bc1de41d8d0a5d6d55337f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d1f5fc9f3d2a953feefbfa98b132597c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e7b551f0ca3eb6df84585d207b6d3f2c +0 -0
- data/test/fixtures/blogger/articles.yml +9 -0
- data/test/fixtures/blogger/comments.yml +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/blogger/article_test.rb +9 -0
- data/test/models/blogger/comment_test.rb +9 -0
- data/test/test_helper.rb +20 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e86af8cee212756253dc007023fa2e6114dd75e
|
4
|
+
data.tar.gz: 3d987572071c142c6ee12a44805b01380e55f79c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cdfb32bd5de10fda35813cf3d1b062e766e585d1b8bace6049d73396f5f2171fa1e7a703f8ff89ed34e1ca362b69cec326753f99723e965588248c94e01326a0
|
7
|
+
data.tar.gz: 253463b1b80db428697f186fd52624250e44706e34372baa926197bb92e9cd93655ddf2b721f862c6a017e683b5e796db0a8a2829577c45c45f0e6f91c6a9cec
|
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
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 = 'Blogger'
|
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 "blogger/application_controller"
|
2
|
+
|
3
|
+
module Blogger
|
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 "blogger/application_controller"
|
2
|
+
|
3
|
+
module Blogger
|
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 Blogger
|
2
|
+
class Article < ActiveRecord::Base
|
3
|
+
has_many :comments
|
4
|
+
|
5
|
+
attr_accessor :author_name
|
6
|
+
belongs_to :author, class_name: Blogger.author_class.to_s
|
7
|
+
|
8
|
+
before_save :set_author
|
9
|
+
|
10
|
+
private
|
11
|
+
def set_author
|
12
|
+
self.author = Blogger.author_class.find_or_create_by(name: author_name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -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,22 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Author:</b>
|
5
|
+
<%= @article.author %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Title:</strong>
|
10
|
+
<%= @article.title %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Text:</strong>
|
15
|
+
<%= @article.text %>
|
16
|
+
</p>
|
17
|
+
<h3>Comments</h3>
|
18
|
+
<%= render @article.comments %>
|
19
|
+
<%= render "blogger/comments/form" %>
|
20
|
+
|
21
|
+
<%= link_to 'Edit', edit_article_path(@article) %> |
|
22
|
+
<%= link_to 'Back', articles_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= comment_counter + 1 %>. <%= comment.text %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Blogger</title>
|
5
|
+
<%= stylesheet_link_tag "blogger/application", media: "all" %>
|
6
|
+
<%= stylesheet_link_tag "scaffold" %>
|
7
|
+
<%= javascript_include_tag "blogger/application" %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|