Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pdxmph/lfl
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hall committed Apr 14, 2013
2 parents 7ea2033 + 14f793a commit 445404f
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 47 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Expand Up @@ -15,7 +15,7 @@ GEM
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.4)
haml (4.0.0)
haml (4.0.1)
tilt
http_router (0.10.2)
rack (>= 1.0.0)
Expand All @@ -26,7 +26,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.21)
multi_json (1.6.1)
multi_json (1.7.2)
padrino (0.10.7)
padrino-admin (= 0.10.7)
padrino-cache (= 0.10.7)
Expand Down Expand Up @@ -56,22 +56,22 @@ GEM
padrino-core (= 0.10.7)
polyglot (0.3.3)
rack (1.5.2)
rack-protection (1.4.0)
rack-protection (1.5.0)
rack
rake (10.0.3)
sinatra (1.3.5)
sinatra (1.3.6)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
sinatra-flash (0.3.0)
sinatra (>= 1.0.0)
sqlite3 (1.3.7)
thor (0.15.4)
tilt (1.3.4)
tilt (1.3.6)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)
tzinfo (0.3.37)
url_mount (0.2.1)
rack

Expand Down
13 changes: 8 additions & 5 deletions admin/views/books/_form.haml
Expand Up @@ -2,33 +2,36 @@
=f.label :library_id
=f.error_message_on :library_id
=f.select(:library_id, :collection => @libraries, :fields => [:street, :id])
%span.description Ex: a simple text

.group
=f.label :title
=f.error_message_on :title
=f.text_field :title, :class => :text_field
%span.description Ex: a simple text
%span.description Ex: Handmaid's Tale, The

.group
=f.label :author
=f.error_message_on :author
=f.text_field :author, :class => :text_field
%span.description Ex: a simple text
%span.description Ex: Atwood, Margaret

.group
=f.label :added
=f.error_message_on :added
=f.text_field :added, :class => :text_field
%span.description Ex: a simple text
%span.description Ex: a 2013-03-10

.group
=f.label :in
=f.error_message_on :in_stock
=f.check_box :in_stock, :class => :check_box
%span.description Ex: a simple text


.group
=f.label :donated
=f.error_message_on :donated
=f.check_box :donated, :class => :check_box

.group.navform.wat-cf
=f.submit pat(:save), :class => :button
=f.submit pat(:cancel), :onclick => "window.location='#{url(:books, :index)}';return false", :class => :button
2 changes: 2 additions & 0 deletions admin/views/books/index.haml
Expand Up @@ -18,6 +18,7 @@
%th=mat(:book, :in_stock)
%th=mat(:book, :created_at)
%th=mat(:book, :updated_at)
%th=mat(:book, :donated)
%th.last=" "
-@books.each do |book|
%tr
Expand All @@ -29,6 +30,7 @@
%td=book.in_stock
%td=book.created_at
%td=book.updated_at
%td=book.donated
%td.last
=button_to pat(:edit), url(:books, :edit, :id => book.id), :method => :get, :class => :button_to
="|"
Expand Down
28 changes: 6 additions & 22 deletions app/views/layouts/application.haml
Expand Up @@ -5,21 +5,16 @@
%title A Little Free Library in Lents
%meta{:content => "", :name => "description"}/
%meta{:content => "", :name => "author"}/
/ Le HTML5 shim, for IE6-8 support of HTML elements
/ HTML5 shim, for IE6-8 support of HTML elements
/[if lt IE 9]
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
/ Le styles
/ Styles
%link{:href => "/stylesheets/bootstrap.css", :rel => "stylesheet"}/
:css
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
%link{:href => "/stylesheets/bootstrap-responsive.css", :rel => "stylesheet"}/
/ Le fav and touch icons
%link{:href => "images/favicon.ico", :rel => "shortcut icon"}/
%link{:href => "images/apple-touch-icon.png", :rel => "apple-touch-icon"}/
%link{:href => "images/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"}/
%link{:href => "images/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"}/
%body
.navbar.navbar-fixed-top
.navbar-inner
Expand Down Expand Up @@ -47,23 +42,12 @@
=yield
/ /container
/
Le javascript
javascript
\==================================================
/ Placed at the end of the document so the pages load faster
%script{:src => "/js/jquery.js"}
%script{:src => "/js/bootstrap-transition.js"}
%script{:src => "/js/bootstrap-alert.js"}
%script{:src => "/js/bootstrap-modal.js"}
%script{:src => "/js/bootstrap-dropdown.js"}
%script{:src => "/js/bootstrap-scrollspy.js"}
%script{:src => "/js/bootstrap-tab.js"}
%script{:src => "/js/bootstrap-tooltip.js"}
%script{:src => "/js/bootstrap-popover.js"}
%script{:src => "/js/bootstrap-button.js"}
%script{:src => "/js/bootstrap-collapse.js"}
%script{:src => "/js/bootstrap-carousel.js"}
%script{:src => "/js/bootstrap-typeahead.js"}

%script{:src => "/javascripts/jquery-1.9.1.min.js"}
%script{:src => "/javascripts/bootstrap.min.js"}
%script{:src => "/javascripts/jquery.tablesorter.min.js"}
:javascript
var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-609327-5']);_gaq.push(['_trackPageview']);
(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
Expand Down
32 changes: 21 additions & 11 deletions app/views/libraries/inventory.haml
@@ -1,19 +1,29 @@
%h2="Library at #{@library.street}"

%table{:class => 'table'}
%p
%strong Current inventory:
#{@library.books.in.count} books
%strong Books ever seen:
#{@library.books.count} books&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
%i{:class => 'icon-plus-sign'}
New this week&nbsp;&nbsp;&nbsp;
%i{:class => 'icon-gift'}
Donated

%table{:class => 'table', :id => 'inventory'}
%thead
%th Title
%th Author
%th Added
%tbody
-@books.each do |book|
-if book.created_at > (Date.today - 7.days)
%tr{:class => "info"}
%td=book.title
%td=book.author
%td=book.created_at.strftime("%B %d, %Y")
-else
%tr
%td=book.title
%td=book.author
%td=book.created_at.strftime("%B %d, %Y")
%tr
%td
#{book.title}
- if book.created_at > (Date.today - 7.days)
%i{:class => 'icon-plus-sign', :title => 'New this week'}
- if book.donated == true
%i{:class => 'icon-gift', :title => "Donated" }
%td=book.author
%td=book.created_at.strftime("%B %d, %Y")

9 changes: 9 additions & 0 deletions db/migrate/005_add_donated_to_books.rb
@@ -0,0 +1,9 @@
class AddDonatedToBooks < ActiveRecord::Migration
def self.up
add_column :books, :donated, :boolean, :default => 0
end

def self.down
remove_column :books, :donated
end
end
7 changes: 4 additions & 3 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 4) do
ActiveRecord::Schema.define(:version => 5) do

create_table "accounts", :force => true do |t|
t.string "name"
Expand All @@ -29,8 +29,9 @@
t.string "author"
t.date "added"
t.boolean "in_stock"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "donated", :default => false
end

create_table "libraries", :force => true do |t|
Expand Down
9 changes: 9 additions & 0 deletions models/book.rb
@@ -1,3 +1,12 @@
class Book < ActiveRecord::Base
belongs_to :library
after_initialize :init

def init
self.in_stock ||= true
self.added ||= Date.today
end

scope :in, where(:in_stock => true)

end
5 changes: 5 additions & 0 deletions public/javascripts/jquery-1.9.1.min.js

Large diffs are not rendered by default.

0 comments on commit 445404f

Please sign in to comment.