Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ gem 'rails', '~> 5.2.2'
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
gem 'devise', '~> 4.6', '>= 4.6.1'

gem 'carrierwave', '~> 0.10.0'
gem 'mini_magick', '~> 4.3'

gem 'bootstrap'
gem 'jquery-rails'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down
48 changes: 48 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ GEM
archive-zip (0.12.0)
io-like (~> 0.3.0)
arel (9.0.0)
autoprefixer-rails (9.4.10.2)
execjs
bcrypt (3.1.12)
bindex (0.5.0)
bootsnap (1.4.1)
msgpack (~> 1.0)
bootstrap (4.3.1)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
builder (3.2.3)
byebug (11.0.0)
capybara (3.14.0)
Expand All @@ -60,13 +67,24 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (2.1.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
concurrent-ruby (1.1.4)
crass (1.0.4)
devise (4.6.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
erubi (1.8.0)
execjs (2.7.0)
ffi (1.10.0)
Expand All @@ -78,6 +96,11 @@ GEM
jbuilder (2.8.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -90,7 +113,11 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.3)
mini_magick (4.9.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
Expand All @@ -99,7 +126,9 @@ GEM
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (1.1.4)
popper_js (1.14.5)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.6)
Expand Down Expand Up @@ -134,6 +163,9 @@ GEM
rb-inotify (0.10.0)
ffi (~> 1.0)
regexp_parser (1.3.0)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sass (3.7.3)
Expand All @@ -147,6 +179,15 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (2.0.1)
ffi (~> 1.9)
rake
sassc-rails (2.1.0)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2, >= 1.2.2)
Expand All @@ -169,6 +210,8 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
warden (1.2.8)
rack (>= 2.0.6)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand All @@ -185,11 +228,16 @@ PLATFORMS

DEPENDENCIES
bootsnap (>= 1.1.0)
bootstrap
byebug
capybara (>= 2.15)
carrierwave (~> 0.10.0)
chromedriver-helper
devise (~> 4.6, >= 4.6.1)
jbuilder (~> 2.5)
jquery-rails
listen (>= 3.0.5, < 3.2)
mini_magick (~> 4.3)
pg (>= 0.18, < 2.0)
puma (~> 3.11)
rails (~> 5.2.2)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/books.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
2 changes: 2 additions & 0 deletions app/assets/javascripts/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
2 changes: 2 additions & 0 deletions app/assets/javascripts/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
*= require_tree .
*= require_self
*/

@import 'bootstrap';
@import 'books.scss';
@import 'home.scss';
36 changes: 36 additions & 0 deletions app/assets/stylesheets/books.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Place all the styles related to the Books controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.header_table{
background-color: rgb(192, 226, 245);
color: black;
font-size: 19px;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

.cell_table{
background-color: rgba(241, 246, 248, 0.651);
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
font-size: 20px;
color: black;
}

.My_book{
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
color: black;
font-size: 45px;
text-decoration: underline;
}
.operation_icon{
background-color: rgb(109, 189, 236);
}
.operation{
background-color: rgba(225, 240, 248, 0.74);

}
.header{
width: 180px;
}
.des{
width: 730px;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/comments.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
84 changes: 84 additions & 0 deletions app/assets/stylesheets/scaffolds.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
body {
background-color: #fff;
color: #333;
margin: 33px;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}

a {
color: #000;

&:visited {
color: #666;
}

&:hover {
color: #fff;
background-color: #000;
}
}

th {
padding-bottom: 5px;
}

td {
padding: 0 5px 7px;
}

div {
&.field, &.actions {
margin-bottom: 10px;
}
}

#notice {
color: green;
}

.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px 7px 0;
margin-bottom: 20px;
background-color: #f0f0f0;

h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px -7px 0;
background-color: #c00;
color: #fff;
}

ul li {
font-size: 12px;
list-style: square;
}
}

label {
display: block;
}
90 changes: 90 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
class BooksController < ApplicationController
before_action :authenticate_user!,except: [:index, :show]
before_action :set_book, only: [:show, :edit, :update, :destroy]
#

# GET /books
# GET /books.json
def index
if current_user
@books = current_user.books
else
redirect_to books_path(@book)
end
end

# GET /books/1
# GET /books/1.json
def show
user_edit
end

# GET /books/new
def new
@book = Book.new
end

# GET /books/1/edit
def edit
user_edit
end

# POST /books
# POST /books.json
def create
@book = current_user.books.build(book_params)
respond_to do |format|
if @book.save
format.html { redirect_to @book, notice: 'Book was successfully created.' }
format.json { render :show, status: :created, location: @book }
else
format.html { render :new }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /books/1
# PATCH/PUT /books/1.json
def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end

# DELETE /books/1
# DELETE /books/1.json
def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_book
@book = Book.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def book_params
params.require(:book).permit(:title, :author, :description, :image, :category)
end

def user_edit
if (user_signed_in? && (current_user.id == @book.user_id))
@can_edit = true
else
@can_edit = false
end
end

end
16 changes: 16 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CommentsController < ApplicationController
def create
@book = Book.find(params[:book_id])
@comment = @book.comments.create(comment_params)
redirect_to books_id_path(@book)
end

def index
end

private
def comment_params
params.require(:comment).permit(:comment, :commenter)
end

end
Loading