Second Commit

This commit is contained in:
2021-04-15 13:06:31 +05:30
parent 7f1d1f54e7
commit 129cd9cbcc
169 changed files with 11137 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<%= form_with model: [:admin, @book] do |f| %>
<div class="form-group">
<label for="title">Title</label>
<%= f.text_field :title, class: 'form-control', id: 'title' %>
</div>
<div class="form-group">
<label for="author">Author</label>
<%= f.text_field :author, class: 'form-control', id: 'author' %>
</div>
<div class="form-group">
<label for="genre">Genre</label>
<%= f.select :genre, Book.genres.keys.map {|genre| [genre.titleize,genre]},{}, class: 'form-control', id: 'genre' %>
</div>
<div class="form-group">
<label for="sub_genre">Sub Genre</label>
<%= f.select :sub_genre, Book.sub_genres.keys.map {|sub_genre| [sub_genre.titleize,sub_genre]},{}, class: 'form-control', id: 'sub_genre' %>
</div>
<div class="form-group">
<label for="pages">Pages</label>
<%= f.number_field :pages, class: 'form-control', id: 'pages' %>
</div>
<div class="form-group">
<label for="copies">Copies</label>
<%= f.number_field :copies, class: 'form-control', id: 'copies' %>
</div>
<div class="form-group">
<%= f.submit 'Save', class: 'btn btn-primary'%>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
<h1 class="my-4">Edit Book details</h1>
<%= render 'form' %>

View File

@@ -0,0 +1,39 @@
<div class="row">
<div class="col-sm-12 ">
<h1 class="my-4">Manage Books</h1>
<%= link_to 'Add New Book', new_admin_book_path, class: 'btn btn-sm btn-primary mb-2'%>
</div>
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col">Genre</th>
<th scope="col">SubGenre</th>
<th scope="col">Author</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<% @books.each_with_index do |book, index| %>
<tr>
<th scope="row"><%= index + 1 %></th>
<td><%= book.title %></td>
<td><%= book.genre %></td>
<td><%= book.sub_genre %></td>
<td><%= book.author %></td>
<td>
<%= link_to 'Edit', edit_admin_book_path(book), class: 'btn btn-sm btn-primary' %>
<%= link_to 'Delete', admin_book_path(book), method: :delete, class: 'btn btn-sm btn-danger', data: { confirm: 'Are you sure?'} %>
<%= link_to 'View', admin_book_path(book), class: 'btn btn-sm btn-secondary' %></td>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @books, theme: 'twitter-bootstrap-4' %>
</div>
</div>

View File

@@ -0,0 +1,2 @@
<h1 class="my-4">New Book details</h1>
<%= render 'form' %>

View File

@@ -0,0 +1,64 @@
<h1 class="my-4">Book Details</h1>
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered">
<tr>
<th scope="col">Title</th>
<td><%= @book.title %></td>
</tr>
<tr>
<th scope="col">Genre</th>
<td><%= @book.genre %></td>
</tr>
<tr>
<th scope="col">Sub Genre</th>
<td><%= @book.sub_genre %></td>
</tr>
<tr>
<th scope="col">Author</th>
<td><%= @book.author %></td>
</tr>
<tr>
<th scope="col">Pages</th>
<td><%= @book.pages %></td>
</tr>
<tr>
<th scope="col">Total Copies</th>
<td><%= @book.copies %></td>
</tr>
<tr>
<th scope="col">Available Copies</th>
<td><%= @book.available_copies %></td>
</tr>
</table>
</div>
</div>
<h3 class="my-4">Check out Status</h3>
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<thead>
<th>#</th>
<th>Book copy code</th>
<th>Status</th>
<th>Email</th>
<th>Borrow date</th>
<th>Expected Return date</th>
<th>Actual Returned Date</th>
</thead>
<tbody>
<% @book.users_books.each_with_index do |user_book, index| %>
<tr>
<td><%= index + 1 %></td>
<td><%= user_book.identifier %></td>
<td><%= user_book.status %></td>
<td><%= user_book.user.email %></td>
<td><%= decorate_date(user_book.created_at) %></td>
<td><%= decorate_date(user_book.due_date) %></td>
<td><%= decorate_date(user_book.returned_at) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -0,0 +1,22 @@
<div class="col-lg-4 mb-4" id="book_<%= book.id%>">
<div class="card h-100 shadow-sm">
<h4 class="card-header"><%= book.title %></h4>
<div class="card-body">
<p class="card-text">
<span> <%= book.description %> </span>
</div>
<% if current_user %>
<div class="card-footer">
<% if book.available_copies > 0 %>
<% unless current_user.books.include?book %>
<%= link_to 'Borrow', borrow_path(book), class: "btn btn-success", remote: true %>
<% else %>
<%= link_to 'Borrowed', 'javascript:;', class: "btn btn-primary", remote: true %>
<% end %>
<% else %>
<a href="javascript:;" class= "btn btn-secondary">Not available</a>
<% end %>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,5 @@
<h1 class="my-4">The complete list of all books</h1>
<div class="row">
<%= render partial: 'books/book', collection: @books%>
</div>
<%= paginate @books, theme: 'twitter-bootstrap-4' %>

View File

@@ -0,0 +1 @@
$("#book_<%= @book.id %>").replaceWith("<%= escape_javascript render(partial: 'books/book', :locals => { book: @book }) %>")

View File

@@ -0,0 +1,33 @@
<h1 class="my-4">My Books</h1>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col">Borrow date</th>
<th scope="col">Expected Return date</th>
<th scope="col">Actual Return date</th>
<th scope="col">Status</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<% @books.each_with_index do |book, index| %>
<% user_book = book.users_books.first %>
<tr>
<th scope="row"><%= index + 1 %></th>
<td><%= book.title %></td>
<td><%= decorate_date(user_book.created_at) %></td>
<td><%= decorate_date(user_book.due_date) %></td>
<td><%= decorate_date(user_book.returned_at) %></td>
<td><%= user_book.status.titleize %></td>
<% if user_book.returned? %>
<td></td>
<% else %>
<td td><%= link_to 'Return', returns_path(book), class: 'btn btn-primary btn-sm', data: { confirm: 'Are you sure?'} %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @books, theme: 'twitter-bootstrap-4' %>

View File

@@ -0,0 +1,16 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,5 @@
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>

View File

@@ -0,0 +1,7 @@
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>

View File

@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>

View File

@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>

View File

@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>

View File

@@ -0,0 +1,25 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,16 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,43 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "new-password" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<% end %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "current-password" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View File

@@ -0,0 +1,50 @@
<div id="layoutAuthentication">
<div id="layoutAuthentication_content">
<main>
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card shadow-lg border-0 rounded-lg mt-5">
<div class="card-header">
<h3 class="text-center font-weight-light my-4">Create Account</h3>
</div>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="form-group">
<label class="small mb-1" for="inputEmailAddress">Email</label>
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control py-4", id: "inputEmailAddress" %>
</div>
<div class="form-row">
<div class="col-md-6">
<div class="form-group">
<label class="small mb-1" for="inputPassword">Password</label>
<% if @minimum_password_length %>
<em><small>(<%= @minimum_password_length %> characters minimum)</small></em>
<% end %><br />
<%= f.password_field :password, autocomplete: "new-password", id: 'inputPassword', class: "form-control py-4" %>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="small mb-1" for="inputConfirmPassword">Confirm Password</label>
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: "form-control py-4", id: "inputConfirmPassword" %>
</div>
</div>
</div>
<div class="form-group mt-4 mb-0">
<%= f.submit "Create Account", class: "btn btn-primary btn-block"%>
</div>
<% end %>
</div>
<div class="card-footer text-center">
<div class="small">
<%= link_to 'Have an account? Go to login', new_user_session_path%></div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>

View File

@@ -0,0 +1,35 @@
<div id="layoutAuthentication">
<div id="layoutAuthentication_content">
<main>
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card shadow-lg border-0 rounded-lg mt-5">
<div class="card-header">
<h3 class="text-center font-weight-light my-4">Login</h3>
</div>
<div class="card-body">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-group">
<label class="small mb-1" for="inputEmailAddress">Email</label>
<%= f.email_field :email, autofocus: true, autocomplete: "email", id: 'inputEmailAddress', class: "form-control py-4" %>
</div>
<div class="form-group">
<label class="small mb-1" for="inputPassword">Password</label>
<%= f.password_field :password, autocomplete: "current-password", class: "form-control py-4", id: "inputPassword"%>
</div>
<div class="form-group d-flex align-items-center justify-content-between mt-4 mb-0">
<%= f.submit "Login", class: "btn btn-primary" %>
</div>
<% end %>
</div>
<div class="card-footer text-center">
<div class="small"><%= link_to "Need an account? Sign up!", new_user_registration_path %></div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>

View File

@@ -0,0 +1,15 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

View File

@@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end %>
<% end %>

View File

@@ -0,0 +1,16 @@
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,28 @@
<header>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active" style="background-image: url(<%= asset_url('img1.jpg')%>)">
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url(<%= asset_url('img2.jpg')%>)">
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url(<%= asset_url('img3.jpg')%>)">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>

View File

@@ -0,0 +1,40 @@
<h1 class="my-4">Welcome to Modern Library</h1>
<!-- Marketing Icons Section -->
<div class="row">
<%= render partial: 'books/book', collection: @books%>
</div>
<!-- Features Section -->
<div class="row">
<div class="col-lg-6">
<h2>Modern Library Features</h2>
<p>The Modern Library includes:</p>
<ul>
<li>
<strong>Easy Borrow</strong>
</li>
<li>1000000+ books</li>
<li>Premium service</li>
<li>Unlimited membership</li>
<li>One stop for all you need</li>
</ul>
<p>The modern library is a one stop solution for all the book lovers to borrow books with ease. This is world's first online library system haing millions of books at one place. So register tody and get its benifits</p>
</div>
<div class="col-lg-6">
<%= image_tag "img4.jpg", class: 'img-fluid rounded', alt: '' %>
</div>
</div>
<!-- /.row -->
<hr>
<!-- Call to Action Section -->
<div class="row mb-4">
<div class="col-md-8">
<p>Excited to see the full list of all available images? Click here and view millions of books available in our system.</p>
</div>
<div class="col-md-4">
<%= link_to 'View full list', books_path , class: 'btn btn-lg btn-primary btn-block' %>
</div>
</div>

View File

@@ -0,0 +1,8 @@
<% if notice || alert %>
<% if notice %>
<p class="alert alert-success"><%= notice %></p>
<% end %>
<% if alert %>
<p class="alert alert-danger"><%= alert %></p>
<% end %>
<% end %>

View File

@@ -0,0 +1,5 @@
<footer class="footer py-3 bg-dark">
<div class="container">
<p class="m-0 text-center text-white">Copyright &copy; The Modern Library 2021</p>
</div>
</footer>

View File

@@ -0,0 +1,38 @@
<!-- Navigation -->
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<%= link_to 'THE MODERN LIBRARY', root_path, class: 'navbar-brand' %>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<%= link_to 'All Books', books_path, class: 'nav-link' %>
</li>
<% if current_user %>
<% if current_user.admin? %>
<li class="nav-item">
<%= link_to 'Admin panel', admin_books_path, class: 'nav-link' %>
</li>
<% else %>
<li class="nav-item">
<%= link_to 'Dashboard', dashboard_index_path, class: 'nav-link' %>
</li>
<% end %>
<li class="nav-item">
<%= link_to 'Signout', destroy_user_session_path, method: :delete, class: 'nav-link' %>
</li>
<% else %>
<li class="nav-item">
<%= link_to 'Login', new_user_session_path, class: 'nav-link' %>
</li>
<li class="nav-item">
<%= link_to 'Join us now!', new_user_registration_path, class: 'nav-link' %>
</li>
<% end %>
</ul>
</div>
</div>
</nav>

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>LibraryMgmtSys</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/header' %>
<% if params[:controller] == 'home' && params[:action] == 'index' %>
<%= render 'home/slider' %>
<% end %>
<%= render 'layouts/flash' %>
<div class="container" style="padding-bottom: 50px">
<%= yield %>
</div>
<%= render 'layouts/footer' %>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1 @@
<%= yield %>