initial commit
This commit is contained in:
41
whatforlunch.com/app/views/recipes/_form.html.erb
Normal file
41
whatforlunch.com/app/views/recipes/_form.html.erb
Normal file
@@ -0,0 +1,41 @@
|
||||
<%= form_for(@recipe) do |f| %>
|
||||
<% if @recipe.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@recipe.errors.count, "error") %> prohibited this recipe from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @recipe.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :name %><br>
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :duration %><br>
|
||||
<%= f.text_field :duration %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :ingredients %><br>
|
||||
<%= f.text_field :ingredients %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :process %><br>
|
||||
<%= f.text_field :process %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :picture_url %><br>
|
||||
<%= f.text_field :picture_url %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :original_url %><br>
|
||||
<%= f.text_field :original_url %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
98
whatforlunch.com/app/views/recipes/edit.html.erb
Normal file
98
whatforlunch.com/app/views/recipes/edit.html.erb
Normal file
@@ -0,0 +1,98 @@
|
||||
<h1>Promjena recepta</h1>
|
||||
|
||||
<%= form_for(@recipe, html: {role: "form"}) do |f| %>
|
||||
|
||||
<div class="form_group row">
|
||||
<%= f.label :name, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-4">
|
||||
<%= f.text_field :name, class: "form-control" %>
|
||||
</div>
|
||||
<% if @recipe.name.to_s.length > 14 %>
|
||||
<div id="name" class="col-md-4 danger" >
|
||||
|
||||
Ime je predugo - skrati do 14 slova!
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="form_group row">
|
||||
<%= f.label :duration, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-4">
|
||||
<%= f.text_field :duration, class: "form-control" %>
|
||||
</div>
|
||||
<% if @recipe.duration.to_s.length > 10 %>
|
||||
<div id="duration" class="col-md-4 danger">
|
||||
|
||||
Dužina je prevelika - skrati do 10 slova!
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="form_group row">
|
||||
<%= f.label :ingredients, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-4">
|
||||
<%= f.text_area :ingredients, class: "form-control", rows: "10" %>
|
||||
</div>
|
||||
<% unless @recipe.ingredients_fit? %>
|
||||
<div id="ingredients" class="col-md-4 danger">
|
||||
Ne smije biti više od 20 sastojaka i svaki sastojak ne smije imati više od 22 znaka (slova, broja, praznine itd.).
|
||||
Skrati ili izbaci neke sastojke.
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form_group row">
|
||||
<%= f.label :process, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-4">
|
||||
<%= f.text_area :process , class: "form-control" , rows: "15" %>
|
||||
|
||||
</div>
|
||||
<% unless @recipe.process_fits? %>
|
||||
<div id="process" class="col-md-4 danger">
|
||||
Priprema mora imati najvise 15 redova a ni jedan red ne smije biti duzi od 44 slova.
|
||||
Skrati malo.
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form_group row ">
|
||||
<div class="col-md-1">
|
||||
Slika
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<%= link_to(@recipe.picture_url, class: "thumbnail") do %>
|
||||
<%= image_tag(@recipe.picture_url) %>
|
||||
<% end %>
|
||||
<%= link_to(" Nađi drugu sliku", @recipe.search_url, target: "_blank" ) %>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form_group row">
|
||||
|
||||
<%= f.label :picture_url, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-4">
|
||||
<%= f.text_field :picture_url, class: "form-control" %>
|
||||
</div>
|
||||
<% unless @recipe.picture_ok? %>
|
||||
<div id="picture" class="col-md-4 danger">
|
||||
Slika mora biti izabrana!
|
||||
Slika ne smije biti sa stranice coolinarika. Nadji drugu.
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form_group row">
|
||||
<%= f.submit class: "btn btn-success" %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
34
whatforlunch.com/app/views/recipes/index.html.erb
Normal file
34
whatforlunch.com/app/views/recipes/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-8">
|
||||
|
||||
<h1>Recepti</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ime</th>
|
||||
<th>Datum</th>
|
||||
<th>Ispravan?</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @recipes.each do |recipe| %>
|
||||
<tr>
|
||||
<td><%= recipe.name %></td>
|
||||
<td><%= recipe.ordinal_date %></td>
|
||||
<td><%= (recipe.is_it_valid?) ? "DA" : "NE" %></td>
|
||||
<td><%= link_to 'Popravi recept', edit_recipe_path(recipe) %></td>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'Napravi novi recept', new_recipe_path %>
|
||||
</div>
|
||||
</div>
|
||||
4
whatforlunch.com/app/views/recipes/index.json.jbuilder
Normal file
4
whatforlunch.com/app/views/recipes/index.json.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.array!(@recipes) do |recipe|
|
||||
json.extract! recipe, :id, :name, :duration, :ingredients, :process, :picture_url, :original_url
|
||||
json.url recipe_url(recipe, format: :json)
|
||||
end
|
||||
16
whatforlunch.com/app/views/recipes/new.html.erb
Normal file
16
whatforlunch.com/app/views/recipes/new.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<h1>Pravljenje Novog Recepta</h1>
|
||||
|
||||
<%= form_for(@recipe, html: {role: "form"}) do |f| %>
|
||||
|
||||
<div class="form_group row">
|
||||
|
||||
<%= f.label :original_url, class: "col-md-1 control-label" %>
|
||||
<div class="col-md-6">
|
||||
<%= f.url_field :original_url, class: "form-control" %>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<%= f.submit class: "btn btn-success" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
34
whatforlunch.com/app/views/recipes/show.html.erb
Normal file
34
whatforlunch.com/app/views/recipes/show.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @recipe.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Duration:</strong>
|
||||
<%= @recipe.duration %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Ingredients:</strong>
|
||||
<%= @recipe.ingredients %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Process:</strong>
|
||||
<%= @recipe.process %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Picture url:</strong>
|
||||
<%= @recipe.picture_url %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Original url:</strong>
|
||||
<%= @recipe.original_url %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_recipe_path(@recipe) %> |
|
||||
<%= link_to 'Back', recipes_path %>
|
||||
1
whatforlunch.com/app/views/recipes/show.json.jbuilder
Normal file
1
whatforlunch.com/app/views/recipes/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.extract! @recipe, :id, :name, :duration, :ingredients, :process, :picture_url, :original_url, :created_at, :updated_at
|
||||
Reference in New Issue
Block a user