add recipe lookup by title
This commit is contained in:
parent
989e8747e4
commit
41344fe84c
10
parse.scm
10
parse.scm
|
@ -65,3 +65,13 @@
|
|||
(lambda (recipes search-ingredients)
|
||||
(filter (lambda (x) (contains-ingredients? x search-ingredients))
|
||||
recipes)))
|
||||
|
||||
(define recipe-by-name
|
||||
(lambda (recipes name)
|
||||
(if (null? recipes)
|
||||
#f
|
||||
(let ((recipe (car recipes)))
|
||||
(if (equal? (title recipe)
|
||||
name)
|
||||
recipe
|
||||
(recipe-by-name (cdr recipes) name))))))
|
||||
|
|
|
@ -6,8 +6,12 @@ get '/' do
|
|||
`cd ..; echo "(display (html-wrap (cookbook-as-html cookbook)))" | petite -q "batch.scm"`
|
||||
end
|
||||
|
||||
get '/:ingredient' do
|
||||
get '/ingredient/:ingredient' do
|
||||
ingredient = HTMLEntities.new.decode params['ingredient']
|
||||
puts ingredient
|
||||
`cd ..; echo "(display (html-wrap (cookbook-as-html (recipes-by-ingredients cookbook '(\\"#{ingredient}\\")))))" | petite -q "batch.scm"`
|
||||
end
|
||||
|
||||
get '/recipe/:title' do
|
||||
title = HTMLEntities.new.decode params['title']
|
||||
`cd ..; echo "(display (html-wrap (recipe-as-html (recipe-by-name cookbook \\"#{title}\\"))))" | petite -q "batch.scm"`
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user