pilot_blog 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/blog_manifest.js +2 -0
  6. data/app/assets/javascripts/blog/application.js +13 -0
  7. data/app/assets/javascripts/blog/articles.js +2 -0
  8. data/app/assets/javascripts/blog/comments.js +2 -0
  9. data/app/assets/stylesheets/blog/application.css +15 -0
  10. data/app/assets/stylesheets/blog/articles.css +4 -0
  11. data/app/assets/stylesheets/blog/comments.css +4 -0
  12. data/app/controllers/blog/application_controller.rb +5 -0
  13. data/app/controllers/blog/articles_controller.rb +62 -0
  14. data/app/controllers/blog/comments_controller.rb +17 -0
  15. data/app/helpers/blog/application_helper.rb +4 -0
  16. data/app/helpers/blog/articles_helper.rb +4 -0
  17. data/app/helpers/blog/comments_helper.rb +4 -0
  18. data/app/jobs/blog/application_job.rb +4 -0
  19. data/app/mailers/blog/application_mailer.rb +6 -0
  20. data/app/models/blog/application_record.rb +5 -0
  21. data/app/models/blog/article.rb +5 -0
  22. data/app/models/blog/comment.rb +4 -0
  23. data/app/views/blog/articles/_form.html.erb +27 -0
  24. data/app/views/blog/articles/edit.html.erb +6 -0
  25. data/app/views/blog/articles/index.html.erb +29 -0
  26. data/app/views/blog/articles/new.html.erb +5 -0
  27. data/app/views/blog/articles/show.html.erb +17 -0
  28. data/app/views/blog/comments/_comment.html.erb +1 -0
  29. data/app/views/blog/comments/_form.html.erb +8 -0
  30. data/app/views/layouts/blog/application.html.erb +14 -0
  31. data/config/routes.rb +6 -0
  32. data/db/migrate/20161118150630_create_blog_articles.rb +10 -0
  33. data/db/migrate/20161118152732_create_blog_comments.rb +10 -0
  34. data/lib/blog/engine.rb +5 -0
  35. data/lib/blog/version.rb +3 -0
  36. data/lib/blog.rb +5 -0
  37. data/lib/tasks/blog_tasks.rake +4 -0
  38. metadata +114 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d13718fb59aea76339f4288ea907ac22572e6c95
4
+ data.tar.gz: 6636b9676f172632e7a2bd45cd68f784f06a5bc1
5
+ SHA512:
6
+ metadata.gz: 53cda1e83e5f529e2c3236e2cf9710579f590241ec98f895c56a61fa602f8cd2981299ce0e64747d78a2caaf521bf4b0bdc7f7b315a0cdc2d288b94be20a2226
7
+ data.tar.gz: bb30decc357042d539c2c79fab9a1c7efa306cf1cd1224fdf42cca8392687c72cda4c74c6b2ddbd383f01285bd04e241cbd76e770bb4bce4ac836ae9af23cd55
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 naemcivic
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.md ADDED
@@ -0,0 +1,28 @@
1
+ # Blog
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'blog'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install blog
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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 = 'Blog'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
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
+ require 'bundler/gem_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,2 @@
1
+ //= link_directory ../javascripts/blog .js
2
+ //= link_directory ../stylesheets/blog .css
@@ -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. JavaScript code in this file should be added after the last require_* statement.
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,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,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 other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -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,5 @@
1
+ module Blog
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "blog/application_controller"
2
+
3
+ module Blog
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)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ require_dependency "blog/application_controller"
2
+
3
+ module Blog
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,4 @@
1
+ module Blog
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Blog
2
+ module ArticlesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Blog
2
+ module CommentsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Blog
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Blog
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Blog
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Blog
2
+ class Article < ApplicationRecord
3
+ has_many :comments
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Blog
2
+ class Comment < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,27 @@
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 %>
16
+ <%= f.text_field :title %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= f.label :text %>
21
+ <%= f.text_area :text %>
22
+ </div>
23
+
24
+ <div class="actions">
25
+ <%= f.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Article</h1>
2
+
3
+ <%= render 'form', article: @article %>
4
+
5
+ <%= link_to 'Show', @article %> |
6
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1,29 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>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,5 @@
1
+ <h1>New Article</h1>
2
+
3
+ <%= render 'form', article: @article %>
4
+
5
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1,17 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Title:</strong>
5
+ <%= @article.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Text:</strong>
10
+ <%= @article.text %>
11
+ </p>
12
+ <h3>Comments</h3>
13
+ <%= render @article.comments %>
14
+ <%= render "blog/comments/form" %>
15
+
16
+ <%= link_to 'Edit', edit_article_path(@article) %> |
17
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1 @@
1
+ <%= comment_counter + 1 %>. <%= comment.text %>
@@ -0,0 +1,8 @@
1
+ <h3>New comment</h3>
2
+ <%= form_for [@article, @article.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,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Blog</title>
5
+ <%= stylesheet_link_tag "blog/application", media: "all" %>
6
+ <%= javascript_include_tag "blog/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Blog::Engine.routes.draw do
2
+ root to: "articles#index"
3
+ resources :articles do
4
+ resources :comments
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBlogArticles < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :blog_articles do |t|
4
+ t.string :title
5
+ t.text :text
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBlogComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :blog_comments do |t|
4
+ t.integer :article_id
5
+ t.text :text
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Blog
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Blog
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Blog
2
+ VERSION = '0.1.0'
3
+ end
data/lib/blog.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "blog/engine"
2
+
3
+ module Blog
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :blog do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pilot_blog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - naemcivic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: sqlite3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: Build a blog engine and mount in on an existing project.
48
+ email:
49
+ - naemcivic@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - app/assets/config/blog_manifest.js
58
+ - app/assets/javascripts/blog/application.js
59
+ - app/assets/javascripts/blog/articles.js
60
+ - app/assets/javascripts/blog/comments.js
61
+ - app/assets/stylesheets/blog/application.css
62
+ - app/assets/stylesheets/blog/articles.css
63
+ - app/assets/stylesheets/blog/comments.css
64
+ - app/controllers/blog/application_controller.rb
65
+ - app/controllers/blog/articles_controller.rb
66
+ - app/controllers/blog/comments_controller.rb
67
+ - app/helpers/blog/application_helper.rb
68
+ - app/helpers/blog/articles_helper.rb
69
+ - app/helpers/blog/comments_helper.rb
70
+ - app/jobs/blog/application_job.rb
71
+ - app/mailers/blog/application_mailer.rb
72
+ - app/models/blog/application_record.rb
73
+ - app/models/blog/article.rb
74
+ - app/models/blog/comment.rb
75
+ - app/views/blog/articles/_form.html.erb
76
+ - app/views/blog/articles/edit.html.erb
77
+ - app/views/blog/articles/index.html.erb
78
+ - app/views/blog/articles/new.html.erb
79
+ - app/views/blog/articles/show.html.erb
80
+ - app/views/blog/comments/_comment.html.erb
81
+ - app/views/blog/comments/_form.html.erb
82
+ - app/views/layouts/blog/application.html.erb
83
+ - config/routes.rb
84
+ - db/migrate/20161118150630_create_blog_articles.rb
85
+ - db/migrate/20161118152732_create_blog_comments.rb
86
+ - lib/blog.rb
87
+ - lib/blog/engine.rb
88
+ - lib/blog/version.rb
89
+ - lib/tasks/blog_tasks.rake
90
+ homepage: https://github.com/naemcivic/RailsBlogEngine
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.4
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A pilot project to test buidling a blog engine for future production purposes
114
+ test_files: []