blog_engine 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dd17072f39005939d348e926cb79b92f8c326de8f9bf261e17181b47f8fb1a0a
4
+ data.tar.gz: 562a21d71c50de722b41f6b0577cced6b3ba32b0736b76e7b8a9f41afb1ea441
5
+ SHA512:
6
+ metadata.gz: 1e7a084e6eebf2b2cc9053eadcefb0ef9636b05717e0269c8f43e1090972f61c992c46c1b2a193602f24cc96a0ab93f14de55f1b21d9de0afdc653be2b25340f
7
+ data.tar.gz: 17be66af84a93b052a31c8c0109e7ceeca94def741b0db213486611e639c4ebd9e91bf18ba2ddc5d2a545d29f97defc1dd69046b6210aab0023ddc8c4fcdb94b
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2024 kashiftariq1997
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
+ # BlogEngine
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_engine"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install blog_engine
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](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/blog_engine .css
@@ -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
+ module BlogEngine
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,60 @@
1
+ module BlogEngine
2
+ class PostsController < ApplicationController
3
+ before_action :set_post, only: %i[ show edit update destroy ]
4
+
5
+ # GET /posts
6
+ def index
7
+ @posts = Post.all
8
+ end
9
+
10
+ # GET /posts/1
11
+ def show
12
+ end
13
+
14
+ # GET /posts/new
15
+ def new
16
+ @post = Post.new
17
+ end
18
+
19
+ # GET /posts/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /posts
24
+ def create
25
+ @post = Post.new(post_params)
26
+
27
+ if @post.save
28
+ redirect_to @post, notice: "Post was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /posts/1
35
+ def update
36
+ if @post.update(post_params)
37
+ redirect_to @post, notice: "Post was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /posts/1
44
+ def destroy
45
+ @post.destroy
46
+ redirect_to posts_url, notice: "Post was successfully destroyed.", status: :see_other
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_post
52
+ @post = Post.find(params[:id])
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def post_params
57
+ params.require(:post).permit(:title, :content)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,4 @@
1
+ module BlogEngine
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BlogEngine
2
+ module PostsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BlogEngine
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module BlogEngine
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module BlogEngine
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module BlogEngine
2
+ class Post < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: post) do |form| %>
2
+ <% if post.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
+
6
+ <ul>
7
+ <% post.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.label :title, style: "display: block" %>
16
+ <%= form.text_field :title %>
17
+ </div>
18
+
19
+ <div>
20
+ <%= form.label :content, style: "display: block" %>
21
+ <%= form.text_area :content %>
22
+ </div>
23
+
24
+ <div>
25
+ <%= form.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <div id="<%= dom_id post %>">
2
+ <p>
3
+ <strong>Title:</strong>
4
+ <%= post.title %>
5
+ </p>
6
+
7
+ <p>
8
+ <strong>Content:</strong>
9
+ <%= post.content %>
10
+ </p>
11
+
12
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Editing post</h1>
2
+
3
+ <%= render "form", post: @post %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this post", @post %> |
9
+ <%= link_to "Back to posts", posts_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Posts</h1>
4
+
5
+ <div id="posts">
6
+ <% @posts.each do |post| %>
7
+ <%= render post %>
8
+ <p>
9
+ <%= link_to "Show this post", post %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New post", new_post_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New post</h1>
2
+
3
+ <%= render "form", post: @post %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to posts", posts_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @post %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this post", edit_post_path(@post) %> |
7
+ <%= link_to "Back to posts", posts_path %>
8
+
9
+ <%= button_to "Destroy this post", @post, method: :delete %>
10
+ </div>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Blog engine</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "blog_engine/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ BlogEngine::Engine.routes.draw do
2
+ resources :posts
3
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBlogEnginePosts < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :blog_engine_posts do |t|
4
+ t.string :title
5
+ t.text :content
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module BlogEngine
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace BlogEngine
4
+ initializer :append_migrations do |app|
5
+ app.config.assets.precompile += %w( blog_engine/application.css )
6
+ unless app.root.to_s.match?(root.to_s)
7
+ config.paths["db/migrate"].expanded.each do |expanded_path|
8
+ app.config.paths["db/migrate"] << expanded_path
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module BlogEngine
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "blog_engine/version"
2
+ require "blog_engine/engine"
3
+
4
+ module BlogEngine
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,14 @@
1
+ # lib/generators/blog_engine/install_generator.rb
2
+ require 'rails/generators'
3
+
4
+ module BlogEngine
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ source_root File.expand_path('templates', __dir__)
8
+
9
+ def add_my_engine_routes
10
+ route "mount BlogEngine::Engine => '/blog'"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :blog_engine do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blog_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - HussnainYounas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-03-28 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: 7.0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.0.8.1
27
+ description: A Blog Post Engine.
28
+ email:
29
+ - findhussnain@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/assets/config/blog_engine_manifest.js
38
+ - app/assets/stylesheets/blog_engine/application.css
39
+ - app/controllers/blog_engine/application_controller.rb
40
+ - app/controllers/blog_engine/posts_controller.rb
41
+ - app/helpers/blog_engine/application_helper.rb
42
+ - app/helpers/blog_engine/posts_helper.rb
43
+ - app/jobs/blog_engine/application_job.rb
44
+ - app/mailers/blog_engine/application_mailer.rb
45
+ - app/models/blog_engine/application_record.rb
46
+ - app/models/blog_engine/post.rb
47
+ - app/views/blog_engine/posts/_form.html.erb
48
+ - app/views/blog_engine/posts/_post.html.erb
49
+ - app/views/blog_engine/posts/edit.html.erb
50
+ - app/views/blog_engine/posts/index.html.erb
51
+ - app/views/blog_engine/posts/new.html.erb
52
+ - app/views/blog_engine/posts/show.html.erb
53
+ - app/views/layouts/blog_engine/application.html.erb
54
+ - config/routes.rb
55
+ - db/migrate/20240328003433_create_blog_engine_posts.rb
56
+ - lib/blog_engine.rb
57
+ - lib/blog_engine/engine.rb
58
+ - lib/blog_engine/version.rb
59
+ - lib/generators/blog_engine/install_generator.rb
60
+ - lib/tasks/blog_engine_tasks.rake
61
+ homepage:
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.4.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Blog Post Engine.
84
+ test_files: []