bread 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +17 -2
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +34 -1
- data/bread.gemspec +0 -0
- data/lib/bread/commands/config_command.rb +15 -0
- data/lib/bread/commands/controller_layout_command.rb +44 -0
- data/lib/bread/commands/crumb_to_command.rb +23 -0
- data/lib/bread/commands/ivars_command.rb +16 -0
- data/lib/bread/config.rb +30 -0
- data/lib/bread/controller.rb +4 -9
- data/lib/bread/crumb.rb +24 -0
- data/lib/bread/helper.rb +12 -19
- data/lib/bread/version.rb +1 -1
- data/lib/bread.rb +8 -1
- data/lib/generators/bread/USAGE +2 -0
- data/lib/generators/bread/install_generator.rb +12 -0
- data/lib/generators/bread/templates/skeleton.rb +15 -0
- data/test/bread_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/products.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/products.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/products_controller.rb +79 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/products_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/product.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +22 -0
- data/test/dummy/app/views/products/_form.html.erb +25 -0
- data/test/dummy/app/views/products/edit.html.erb +6 -0
- data/test/dummy/app/views/products/index.html.erb +29 -0
- data/test/dummy/app/views/products/new.html.erb +5 -0
- data/test/dummy/app/views/products/show.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +9 -0
- data/test/dummy/config/breadcrumbs.rb +18 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +27 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +12 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140203163238_create_products.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/log/development.log +886 -0
- data/test/dummy/log/test.log +14262 -0
- data/test/dummy/public/404.html +27 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/products_controller_test.rb +50 -0
- data/test/dummy/test/fixtures/products.yml +9 -0
- data/test/dummy/test/helpers/products_helper_test.rb +4 -0
- data/test/dummy/test/models/product_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +137 -5
- data/lib/bread/command.rb +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e8027cf13f5a7e44e18d3f34c45603caf4bf29e
|
|
4
|
+
data.tar.gz: c2683c97974e9b483bf1ad3e6cef4a941cf16a7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe0369dcd7ccb742df886727440cb5d2713cd6addcce04b40cec45278d9e1f9e9c0c57e179fe0015396fead0ac242efa16b223af3e9043b03970717cd4adeeb0
|
|
7
|
+
data.tar.gz: 048f1ef5da222f6be35be27b4a44677f1005bd3910d5d3da382db0921567868102d8a815e4ef4ed143225fb0bb320180588afa1b0ea5ebbe3b6c6472e3bb6712
|
data/.gitignore
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
source '
|
|
1
|
+
# source 'http://gems.dev.helloinnovation.com'
|
|
2
|
+
source "https://rubygems.org"
|
|
2
3
|
|
|
3
|
-
#
|
|
4
|
+
# Declare your gem's dependencies in permissions.gemspec.
|
|
5
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
6
|
+
# development dependencies will be added by default to the :development group.
|
|
4
7
|
gemspec
|
|
8
|
+
|
|
9
|
+
# Declare any dependencies that are still in development here instead of in
|
|
10
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
11
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
12
|
+
# your gem to rubygems.org.
|
|
13
|
+
|
|
14
|
+
# To use debugger
|
|
15
|
+
# gem 'debugger'
|
|
16
|
+
gem 'rails', '4.0.0' # June 25, 2013
|
|
17
|
+
gem 'sqlite3'
|
|
18
|
+
gem 'turn'
|
|
19
|
+
gem 'colorize'
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Permissions'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'lib'
|
|
28
|
+
t.libs << 'test'
|
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
|
30
|
+
t.verbose = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task default: :test
|
data/bread.gemspec
CHANGED
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Bread
|
|
2
|
+
class ControllerLayoutCommand
|
|
3
|
+
|
|
4
|
+
attr_reader :keys
|
|
5
|
+
|
|
6
|
+
def initialize(controller)
|
|
7
|
+
IvarsCommand.new(controller).ivars.each do |key, ivar|
|
|
8
|
+
self.instance_variable_set(key, ivar)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
@controller = controller
|
|
12
|
+
@actions = {}
|
|
13
|
+
@keys = []
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def actions(*action_names, &block)
|
|
17
|
+
action_names.each do |action_name|
|
|
18
|
+
@actions[action_name] = block
|
|
19
|
+
is_current_action = action_name.to_s == @controller.action_name
|
|
20
|
+
|
|
21
|
+
if is_current_action
|
|
22
|
+
self.instance_eval(&block)
|
|
23
|
+
# teria que ter um break aqui, que tambem pare todos os registros de proximas actions =D
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def crumbs(*keys)
|
|
29
|
+
parent = nil
|
|
30
|
+
if keys.last.is_a? Hash
|
|
31
|
+
options = keys.last
|
|
32
|
+
keys.delete(options)
|
|
33
|
+
#raise "Unexpected options: #{}"
|
|
34
|
+
parent = options[:parent]
|
|
35
|
+
end
|
|
36
|
+
@keys = keys + @keys
|
|
37
|
+
if parent
|
|
38
|
+
blk = @actions[parent]
|
|
39
|
+
instance_eval(&blk)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Bread
|
|
2
|
+
class CrumbToCommand
|
|
3
|
+
|
|
4
|
+
include ActionDispatch::Routing::UrlFor
|
|
5
|
+
|
|
6
|
+
attr_reader :crumb
|
|
7
|
+
|
|
8
|
+
def initialize(controller, key, &block)
|
|
9
|
+
@key = key
|
|
10
|
+
|
|
11
|
+
IvarsCommand.new(controller).ivars.each do |key, ivar|
|
|
12
|
+
instance_variable_set(key, ivar)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
instance_eval(&block)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def crumb_to(title, path, options={})
|
|
19
|
+
@crumb = Crumb.new(options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Bread
|
|
2
|
+
class IvarsCommand
|
|
3
|
+
|
|
4
|
+
attr_reader :ivars
|
|
5
|
+
|
|
6
|
+
def initialize(target)
|
|
7
|
+
@ivars = {}
|
|
8
|
+
|
|
9
|
+
ivars_keys = target.instance_variables.select { |key| not key.to_s.starts_with?('@_') }
|
|
10
|
+
ivars_keys.each do |key|
|
|
11
|
+
@ivars[key] = target.instance_variable_get(key)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/bread/config.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Bread
|
|
2
|
+
class Config
|
|
3
|
+
include Singleton
|
|
4
|
+
|
|
5
|
+
attr_reader :crumb_definitions
|
|
6
|
+
|
|
7
|
+
def reload!
|
|
8
|
+
config_file = Rails.root.join "config/breadcrumbs.rb"
|
|
9
|
+
if File.exists? config_file
|
|
10
|
+
load config_file
|
|
11
|
+
else
|
|
12
|
+
puts "ACHEI NAO".on_red
|
|
13
|
+
# `rails g bread:install`
|
|
14
|
+
# self.reload!
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def config(&block)
|
|
19
|
+
cmd = ConfigCommand.new
|
|
20
|
+
cmd.instance_eval(&block)
|
|
21
|
+
@crumb_definitions = cmd.crumb_definitions
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/bread/controller.rb
CHANGED
|
@@ -6,18 +6,13 @@ module Bread
|
|
|
6
6
|
attr_reader :bread_block
|
|
7
7
|
def bread(&block)
|
|
8
8
|
@bread_block = block
|
|
9
|
-
before_filter :execute_bread_command
|
|
10
9
|
end
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def execute_bread_command
|
|
20
|
-
Command.new(self).instance_eval(&self.class.bread_block)
|
|
12
|
+
def bread_keys
|
|
13
|
+
cmd = ControllerLayoutCommand.new(self)
|
|
14
|
+
cmd.instance_eval(&self.class.bread_block)
|
|
15
|
+
cmd.keys
|
|
21
16
|
end
|
|
22
17
|
|
|
23
18
|
end
|
data/lib/bread/crumb.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Bread
|
|
2
|
+
class Crumb < Hash
|
|
3
|
+
|
|
4
|
+
def initialize(context, title, path, options)
|
|
5
|
+
@context = context
|
|
6
|
+
options.merge(title: title, path: path).each do |k, v|
|
|
7
|
+
self[k] = v
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def title
|
|
12
|
+
self[:title]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def path
|
|
16
|
+
self[:path]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def current?
|
|
20
|
+
@context.current_page? path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/bread/helper.rb
CHANGED
|
@@ -2,28 +2,21 @@ module Bread
|
|
|
2
2
|
module Helper
|
|
3
3
|
|
|
4
4
|
def bread
|
|
5
|
-
|
|
5
|
+
Config.instance.reload! # if should_reload?
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
controller.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
crumb_definitions = Config.instance.crumb_definitions
|
|
8
|
+
keys_for_current_action = controller.bread_keys
|
|
9
|
+
|
|
10
|
+
@crumbs = []
|
|
11
|
+
keys_for_current_action.map do |key|
|
|
12
|
+
crumbs_to_block = crumb_definitions[key] || :crumb_definitions_not_found
|
|
13
|
+
self.instance_eval(&crumbs_to_block)
|
|
13
14
|
end
|
|
15
|
+
@crumbs
|
|
16
|
+
end
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[]
|
|
18
|
-
else
|
|
19
|
-
list = []
|
|
20
|
-
while tmp
|
|
21
|
-
arr = controller.instance_eval(&tmp[:block])
|
|
22
|
-
list << {title: arr.first, path: arr.second} if arr
|
|
23
|
-
tmp = tmp[:parent]
|
|
24
|
-
end
|
|
25
|
-
list.reverse
|
|
26
|
-
end
|
|
18
|
+
def crumb_to(title, path, options={})
|
|
19
|
+
@crumbs << Crumb.new(self, title, path, options)
|
|
27
20
|
end
|
|
28
21
|
|
|
29
22
|
end
|
data/lib/bread/version.rb
CHANGED
data/lib/bread.rb
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
require "bread/version"
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require "bread/commands/controller_layout_command"
|
|
4
|
+
require "bread/commands/config_command"
|
|
5
|
+
require "bread/commands/ivars_command"
|
|
6
|
+
require "bread/commands/crumb_to_command"
|
|
7
|
+
|
|
3
8
|
require "bread/controller"
|
|
4
9
|
require "bread/helper"
|
|
10
|
+
require "bread/crumb"
|
|
11
|
+
require "bread/config"
|
|
5
12
|
|
|
6
13
|
|
|
7
14
|
module Bread
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Bread.config do
|
|
2
|
+
|
|
3
|
+
# # products
|
|
4
|
+
# key(:all_products) { bread_to("Contacts", :products, icon: 'list') }
|
|
5
|
+
# key(:make_product) { bread_to("Add", [:products, :new], icon: 'plus', target: '_blank') }
|
|
6
|
+
# key(:products_by_category) { bread_to(@category.name, [:products, :by_category, @category], icon: 'filter') }
|
|
7
|
+
# key(:view_product) { bread_to(@product.name, @product) }
|
|
8
|
+
# key(:change_product) { bread_to("Edit", [@product, :edit]) }
|
|
9
|
+
# key(:product_timeline) { bread_to("Timeline", [@product, :timeline]) }
|
|
10
|
+
# key(:product_year) { bread_to(@year, [@product, :timeline, @year]) }
|
|
11
|
+
# key(:product_month) { bread_to(@month, [@product, :timeline, @year, @month]) }
|
|
12
|
+
# key(:product_day) { bread_to(@day, [@product, :timeline, @year, @month, @day]) }
|
|
13
|
+
# key(:product_time) { bread_to(@time, [@product, :timeline, @year, @month, @day, @time]) }
|
|
14
|
+
|
|
15
|
+
end
|
data/test/bread_test.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
div.field, div.actions {
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#notice {
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.field_with_errors {
|
|
28
|
+
padding: 2px;
|
|
29
|
+
background-color: red;
|
|
30
|
+
display: table;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#error_explanation {
|
|
34
|
+
width: 450px;
|
|
35
|
+
border: 2px solid red;
|
|
36
|
+
padding: 7px;
|
|
37
|
+
padding-bottom: 0;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
background-color: #f0f0f0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#error_explanation h2 {
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
padding: 5px 5px 5px 15px;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
margin: -7px;
|
|
48
|
+
margin-bottom: 0px;
|
|
49
|
+
background-color: #c00;
|
|
50
|
+
color: #fff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#error_explanation ul li {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
list-style: square;
|
|
56
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
class ProductsController < ApplicationController
|
|
2
|
+
before_action :set_product, only: [:show, :edit, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
bread do
|
|
7
|
+
# alias_actions :new, :create
|
|
8
|
+
# alias_actions :edit, :update, :destroy
|
|
9
|
+
|
|
10
|
+
actions(:index) { crumbs :root, :all_products, parent: nil }
|
|
11
|
+
actions(:new, :create) { crumbs :make_product, parent: :index, lala: 1, lele: 2, lili: 3434 }
|
|
12
|
+
actions(:by_category) { crumbs :products_by_category, parent: :index }
|
|
13
|
+
actions(:show) do
|
|
14
|
+
parent = @category.present? ? :by_category : :index
|
|
15
|
+
crumbs(:view_product, parent: parent)
|
|
16
|
+
end
|
|
17
|
+
actions(:edit) { crumbs :change_product, parent: :show }
|
|
18
|
+
actions(:timeline) { crumbs :product_timeline, parent: :show }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# GET /products
|
|
25
|
+
def index
|
|
26
|
+
@products = Product.all
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# GET /products/1
|
|
30
|
+
def show
|
|
31
|
+
@category = "lalala"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# GET /products/new
|
|
35
|
+
def new
|
|
36
|
+
@product = Product.new
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# GET /products/1/edit
|
|
40
|
+
def edit
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# POST /products
|
|
44
|
+
def create
|
|
45
|
+
@product = Product.new(product_params)
|
|
46
|
+
|
|
47
|
+
if @product.save
|
|
48
|
+
redirect_to @product, notice: 'Product was successfully created.'
|
|
49
|
+
else
|
|
50
|
+
render action: 'new'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# PATCH/PUT /products/1
|
|
55
|
+
def update
|
|
56
|
+
if @product.update(product_params)
|
|
57
|
+
redirect_to @product, notice: 'Product was successfully updated.'
|
|
58
|
+
else
|
|
59
|
+
render action: 'edit'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# DELETE /products/1
|
|
64
|
+
def destroy
|
|
65
|
+
@product.destroy
|
|
66
|
+
redirect_to products_url, notice: 'Product was successfully destroyed.'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
71
|
+
def set_product
|
|
72
|
+
@product = Product.find(params[:id])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Only allow a trusted parameter "white list" through.
|
|
76
|
+
def product_params
|
|
77
|
+
params.require(:product).permit(:name, :category)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%#= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
|
6
|
+
<%#= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<ul id="breadcrumbs">
|
|
12
|
+
<% bread.each do |crumb| %>
|
|
13
|
+
<li class="<%= 'active' if crumb.current? %>">
|
|
14
|
+
<%= link_to crumb.title, crumb.path, class: "icon icon-#{crumb[:icon]}" %>
|
|
15
|
+
</li>
|
|
16
|
+
<% end %>
|
|
17
|
+
</ul>
|
|
18
|
+
|
|
19
|
+
<%= yield %>
|
|
20
|
+
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%= form_for(@product) do |f| %>
|
|
2
|
+
<% if @product.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @product.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :name %><br>
|
|
16
|
+
<%= f.text_field :name %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :category %><br>
|
|
20
|
+
<%= f.text_field :category %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="actions">
|
|
23
|
+
<%= f.submit %>
|
|
24
|
+
</div>
|
|
25
|
+
<% end %>
|