diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 373df8b..095f5d7 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -21,20 +21,14 @@ module ApplicationHelper
nav = [
nav_item('Recipes', recipes_path, 'recipes'),
nav_item('Ingredients', ingredients_path, 'ingredients'),
- nav_item('Logs', logs_path, 'logs'),
+ nav_item('Logs', logs_path, 'logs', current_user?),
nav_item('Calculator', calculator_path, 'calculator'),
- nav_item('About', about_path, 'home')
+ nav_item('About', about_path, 'home'),
+ nav_item('Notes', notes_path, 'notes', current_user?),
+ nav_item('Admin', admin_users_path, 'admin/users', current_user? && current_user.admin?)
]
- if current_user
- nav << nav_item('Notes', notes_path, 'notes')
- end
-
- if current_user && current_user.admin?
- nav << nav_item('Admin', admin_users_path, 'admin/users')
- end
-
- nav
+ nav.compact
end
def profile_nav_items
@@ -57,8 +51,8 @@ module ApplicationHelper
end
end
- def nav_item(name, url, controller = nil)
- content_tag('li', link_to(name, url), class: active_for_controller(controller))
+ def nav_item(name, url, controller = nil, visible = true)
+ !visible ? nil : content_tag('li', link_to(name, url), class: active_for_controller(controller))
end
def active_for_controller(controller)
diff --git a/app/views/ingredients/index.html.erb b/app/views/ingredients/index.html.erb
index cc34471..1639e4c 100644
--- a/app/views/ingredients/index.html.erb
+++ b/app/views/ingredients/index.html.erb
@@ -8,7 +8,9 @@
No Ingredients
<% else %>
- <%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
+ <% if current_user? %>
+ <%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
+ <% end %>
@@ -19,22 +21,26 @@
USDA |
KCal per 100g |
Density (oz/cup) |
- |
+ <% if current_user? %>
+ |
+ <% end %>
<% decorate(@ingredients, IngredientDecorator).each do |ingredient| %>
- <%= link_to ingredient.name, edit_ingredient_path(ingredient) %> |
+ <%= link_to_if current_user?, ingredient.name, edit_ingredient_path(ingredient) %> |
<%= ingredient.ndbn_check %> |
<%= ingredient.kcal %> |
<%= ingredient.density %> |
-
- <%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
-
- <% end %>
- |
+ <% if current_user? %>
+
+ <%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
+
+ <% end %>
+ |
+ <% end %>
<% end %>
@@ -43,7 +49,9 @@
- <%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
+ <% if current_user? %>
+ <%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
+ <% end %>
diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb
new file mode 100644
index 0000000..bf23ff0
--- /dev/null
+++ b/app/views/kaminari/_first_page.html.erb
@@ -0,0 +1,3 @@
+
+ <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
+
diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb
new file mode 100644
index 0000000..6d3a149
--- /dev/null
+++ b/app/views/kaminari/_gap.html.erb
@@ -0,0 +1,3 @@
+
+ <%= content_tag :a, raw(t 'views.pagination.truncate') %>
+
diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb
new file mode 100644
index 0000000..fb619ea
--- /dev/null
+++ b/app/views/kaminari/_last_page.html.erb
@@ -0,0 +1,3 @@
+
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
+
diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb
new file mode 100644
index 0000000..15e10e4
--- /dev/null
+++ b/app/views/kaminari/_next_page.html.erb
@@ -0,0 +1,3 @@
+
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
+
diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb
new file mode 100644
index 0000000..8028b45
--- /dev/null
+++ b/app/views/kaminari/_page.html.erb
@@ -0,0 +1,9 @@
+<% if page.current? %>
+
+ <%= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
+
+<% else %>
+
+ <%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
+
+<% end %>
diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb
new file mode 100644
index 0000000..2c8757b
--- /dev/null
+++ b/app/views/kaminari/_paginator.html.erb
@@ -0,0 +1,15 @@
+<%= paginator.render do -%>
+
+<% end -%>
diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb
new file mode 100644
index 0000000..d94a50a
--- /dev/null
+++ b/app/views/kaminari/_prev_page.html.erb
@@ -0,0 +1,3 @@
+
+ <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
+
diff --git a/app/views/recipes/index.html.erb b/app/views/recipes/index.html.erb
index b6d1148..b946bc6 100644
--- a/app/views/recipes/index.html.erb
+++ b/app/views/recipes/index.html.erb
@@ -9,7 +9,9 @@
No Recipes
<% else %>
- <%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
+ <% if current_user? %>
+ <%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
+ <% end %>
<%= paginate @recipes %>
@@ -69,7 +71,9 @@
- <%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
+ <% if current_user? %>
+ <%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
+ <% end %>
\ No newline at end of file