Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba5b896
commit 207ce05
Showing
17 changed files
with
113 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
require 'mustache/sinatra' | |||
require 'black_book/views/layout' | |||
require 'black_book/views/index' | |||
require 'black_book/views/person' | |||
require 'black_book/views/edit' | |||
require 'black_book/views/show' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
module BlackBook | |||
module Views | |||
class Edit < Person | |||
def action | |||
page ? "/#{page}" : '/' | |||
end | |||
|
|||
def new? | |||
!!@person['_id'] | |||
end | |||
|
|||
def new_or_edit | |||
new? ? 'Editing' : 'New' | |||
end | |||
|
|||
def button_text | |||
new? ? "Update" : "Create" | |||
end | |||
|
|||
def title | |||
new? ? "Editing #{super}" : "New#{super}" | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
module BlackBook | |||
module Views | |||
class Index < Layout | |||
def addresses | |||
@addresses | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
module BlackBook | |||
module Views | |||
class Layout < ::Mustache | |||
self.template_extension = 'html' | |||
|
|||
def title | |||
'Addresses!' | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
module BlackBook | |||
module Views | |||
class Person < Layout | |||
def title | |||
"#{name} - Addresses" | |||
end | |||
|
|||
def name | |||
@person['name'] | |||
end | |||
|
|||
def page | |||
@person['page'] | |||
end | |||
|
|||
def emails | |||
@person['emails'] | |||
end | |||
|
|||
def addresses | |||
@person['addresses'] | |||
end | |||
|
|||
def numbers | |||
@person['numbers'] | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
#!/usr/bin/ruby | |||
# Jonathan D. Stott <jonathan.stott@gmail.com> | |||
module BlackBook | |||
module Views | |||
class Show < Person | |||
def addresses | |||
if addresses = super | |||
addresses.map! { |a| a['lines'] = a['address'].split(/\r?\n/).map! { |l| { :line => l } }; a } | |||
addresses | |||
else | |||
addresses | |||
end | |||
end | |||
end | |||
end | |||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.