mirror of
https://github.com/wahyd4/Libr.git
synced 2026-08-09 21:05:51 +10:00
list books
This commit is contained in:
@@ -13,4 +13,52 @@ body {
|
||||
background-color: whiteSmoke;
|
||||
height: 60px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
display: inline-block;
|
||||
width:100%;
|
||||
text-align: right;
|
||||
}
|
||||
p.title{
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
div.span2{
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
.cover
|
||||
{
|
||||
position:relative;
|
||||
-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
|
||||
-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
|
||||
box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
|
||||
}
|
||||
.cover:before, .cover:after
|
||||
{
|
||||
content:"";
|
||||
position:absolute;
|
||||
z-index:-1;
|
||||
-webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);
|
||||
-moz-box-shadow:0 0 20px rgba(0,0,0,0.8);
|
||||
box-shadow:0 0 20px rgba(0,0,0,0.8);
|
||||
top:10px;
|
||||
bottom:10px;
|
||||
left:0;
|
||||
right:0;
|
||||
-moz-border-radius:100px / 10px;
|
||||
border-radius:100px / 10px;
|
||||
}
|
||||
.cover:after
|
||||
{
|
||||
right:10px;
|
||||
left:auto;
|
||||
-webkit-transform:skew(8deg) rotate(3deg);
|
||||
-moz-transform:skew(8deg) rotate(3deg);
|
||||
-ms-transform:skew(8deg) rotate(3deg);
|
||||
-o-transform:skew(8deg) rotate(3deg);
|
||||
transform:skew(8deg) rotate(3deg);
|
||||
}
|
||||
|
||||
.cover:hover{
|
||||
box-shadow: 3px 3px 12px #999;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,10 @@
|
||||
class BookController < ApplicationController
|
||||
|
||||
def view
|
||||
|
||||
end
|
||||
|
||||
def search
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class HomeController < ApplicationController
|
||||
|
||||
def index
|
||||
|
||||
@books = Book.order 'id DESC'
|
||||
end
|
||||
end
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
class Book < ActiveRecord::Base
|
||||
attr_accessible :author, :image, :isbn, :name, :users
|
||||
|
||||
has_many :users
|
||||
has_many :user_to_books
|
||||
has_many :users, through: :user_to_books
|
||||
|
||||
end
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
class User < ActiveRecord::Base
|
||||
attr_accessible :email, :name, :books
|
||||
has_many :books
|
||||
has_many :user_to_books
|
||||
has_many :books, through: :user_to_books
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class UserToBook < ActiveRecord::Base
|
||||
|
||||
attr_accessible :user, :book
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :book
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
- content_for :javascript_includes do
|
||||
= javascript_include_tag 'book'
|
||||
@@ -1 +1,8 @@
|
||||
p Hello
|
||||
h3 New Arrival:
|
||||
div.row-fluid
|
||||
- @books.each do |book|
|
||||
div.span2
|
||||
div
|
||||
a href="/books/#{book.id}"
|
||||
img.cover src="#{book.image}"
|
||||
p.title =book.name
|
||||
@@ -1,7 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ocelots
|
||||
title Libr
|
||||
link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"
|
||||
= stylesheet_link_tag '/bootstrap/css/bootstrap.min.css'
|
||||
= stylesheet_link_tag '/bootstrap/css/bootstrap-responsive.min.css'
|
||||
|
||||
@@ -64,4 +64,8 @@ Libr::Application.configure do
|
||||
# Log the query plan for queries taking more than this (works
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
config.assets.precompile << '*.js'
|
||||
config.assets.precompile << '*.css'
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Libr::Application.routes.draw do
|
||||
|
||||
root to:'home#index'
|
||||
match 'books/:id' => 'book#view'
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
# first created -> highest priority.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class AddSomeBooks
|
||||
User.create email:'test@test.com', name:'Test'
|
||||
User.first.books.create name:'看见', image:'http:\/\/img3.douban.com\/mpic\/s24514758.jpg',isbn:'9787549529322'
|
||||
end
|
||||
Reference in New Issue
Block a user