Update
This commit is contained in:
parent
22cc927a85
commit
414d1c3ac5
71
brunch.md
71
brunch.md
|
@ -14,33 +14,52 @@ category: JavaScript libraries
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
files:
|
```js
|
||||||
javascripts: # or 'stylesheets' or 'templates'
|
module.exports = {
|
||||||
order:
|
files: {
|
||||||
before: [ 'normalize.css' ]
|
javascripts: { # or 'stylesheets' or 'templates'
|
||||||
after: [ 'helpers.css' ]
|
order: {
|
||||||
|
before: [ 'normalize.css' ],
|
||||||
|
after: [ 'helpers.css' ],
|
||||||
|
|
||||||
joinTo: 'app.js'
|
joinTo: 'app.js',
|
||||||
joinTo:
|
joinTo: {
|
||||||
'js/app.js': /^app/
|
'js/app.js': /^app/,
|
||||||
'js/vendor.js': /^vendor/
|
'js/vendor.js': /^vendor/
|
||||||
pluginHelpers: 'js/vendor.js'
|
},
|
||||||
|
pluginHelpers: 'js/vendor.js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paths:
|
paths: {
|
||||||
public: 'public' # where to compile
|
public: 'public', # where to compile
|
||||||
watched: ['app','test','vendor'] # what to monitor
|
watched: ['app','test','vendor'], # what to monitor
|
||||||
|
}
|
||||||
|
|
||||||
modules:
|
modules: {
|
||||||
wrapper: 'amd'
|
wrapper: 'amd',
|
||||||
definition: 'amd'
|
definition: 'amd',
|
||||||
nameCleaner: (path) -> path.replace /^app\//, ''
|
nameCleaner: (path) => path.replace(/^app\//, '')
|
||||||
|
}
|
||||||
|
|
||||||
# brunch b --apply production
|
npm: { styles, globals }
|
||||||
overrides:
|
|
||||||
production:
|
plugins: {
|
||||||
optimize: true
|
sass: { ... }
|
||||||
sourceMaps: false
|
}
|
||||||
plugins: autoReload: enabled: false
|
|
||||||
|
// brunch w --apply testing
|
||||||
|
// BRUNCH_ENV=testing brunch build
|
||||||
|
overrides: {
|
||||||
|
production: {
|
||||||
|
optimize: true,
|
||||||
|
sourceMaps: false,
|
||||||
|
plugins: { autoReload: { enabled: false } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCompile: (files, assets) => { ... }
|
||||||
|
```
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
|
@ -53,11 +72,11 @@ category: JavaScript libraries
|
||||||
|
|
||||||
## Extensions
|
## Extensions
|
||||||
|
|
||||||
Compile to JS/CSS
|
Compile to CSS
|
||||||
|
|
||||||
* stylus-brunch
|
* stylus-brunch
|
||||||
* coffee-script-brunch
|
|
||||||
* less-brunch
|
* less-brunch
|
||||||
|
* sass-brunch
|
||||||
|
|
||||||
Compile to HTML
|
Compile to HTML
|
||||||
|
|
||||||
|
@ -75,4 +94,4 @@ Etc
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* https://github.com/brunch/brunch/blob/master/docs/config.md
|
* <https://github.com/brunch/brunch/blob/master/docs/config.md>
|
||||||
|
|
|
@ -19,4 +19,3 @@ Use `{{ contents }}` to bring it out
|
||||||
Engines:
|
Engines:
|
||||||
|
|
||||||
* swig (like liquid)
|
* swig (like liquid)
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,11 @@ category: Rails
|
||||||
add_index :accounts, [:branch_id, :party_id, :surname],
|
add_index :accounts, [:branch_id, :party_id, :surname],
|
||||||
:order => {:branch_id => :desc, :part_id => :asc}
|
:order => {:branch_id => :desc, :part_id => :asc}
|
||||||
|
|
||||||
|
### In console
|
||||||
|
Use `ActiveRecord::Migration`.
|
||||||
|
|
||||||
|
ActiveRecord::Migration.add_index :posts, :slug
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
* http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index
|
* http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index
|
||||||
|
|
|
@ -3,9 +3,10 @@ title: Routes
|
||||||
category: Rails
|
category: Rails
|
||||||
---
|
---
|
||||||
|
|
||||||
### Multiple resources
|
## Multiple resources (`resources`)
|
||||||
|
|
||||||
resources :books
|
resources :books
|
||||||
|
|
||||||
# PhotosController:
|
# PhotosController:
|
||||||
# index => GET /photos
|
# index => GET /photos
|
||||||
# new => GET /photos/new
|
# new => GET /photos/new
|
||||||
|
@ -19,15 +20,31 @@ category: Rails
|
||||||
# new_book_path
|
# new_book_path
|
||||||
# book_path(id)
|
# book_path(id)
|
||||||
# edit_book_path(id)
|
# edit_book_path(id)
|
||||||
#
|
|
||||||
|
### Custom actions
|
||||||
|
|
||||||
resources :photos do
|
resources :photos do
|
||||||
member { get 'preview' } # /photo/1/preview
|
member { get 'preview' } # /photo/1/preview
|
||||||
get 'preview', on: :member # (..same as the first)
|
|
||||||
collection { get 'search' } # /photos/search
|
collection { get 'search' } # /photos/search
|
||||||
|
|
||||||
|
get 'preview', on: :member # (..same as the first)
|
||||||
end
|
end
|
||||||
|
|
||||||
### Single resource
|
### Options
|
||||||
|
|
||||||
|
resources :photos,
|
||||||
|
path_names: { new: 'brand_new' } # /photos/1/brand_new
|
||||||
|
path: 'postings' # /postings
|
||||||
|
only: :index
|
||||||
|
only: [:index, :show]
|
||||||
|
except: :show
|
||||||
|
except: [:index, :show]
|
||||||
|
|
||||||
|
shallow: true # also generate shallow routes
|
||||||
|
shalow_path: 'secret'
|
||||||
|
shallow_prefix: 'secret'
|
||||||
|
|
||||||
|
## Single resource (`resource`)
|
||||||
|
|
||||||
resource :coder
|
resource :coder
|
||||||
|
|
||||||
|
@ -39,7 +56,7 @@ category: Rails
|
||||||
# update => PUT /coder
|
# update => PUT /coder
|
||||||
# delete => DELETE /coder
|
# delete => DELETE /coder
|
||||||
|
|
||||||
### Matching
|
## Matching (`match`)
|
||||||
|
|
||||||
match 'photo/:id' => 'photos#show' # /photo/what-is-it
|
match 'photo/:id' => 'photos#show' # /photo/what-is-it
|
||||||
match 'photo/:id', id: /[0-9]+/ # /photo/0192
|
match 'photo/:id', id: /[0-9]+/ # /photo/0192
|
||||||
|
|
|
@ -56,22 +56,14 @@ end
|
||||||
# spec/requests/*.rb
|
# spec/requests/*.rb
|
||||||
describe "home page" do
|
describe "home page" do
|
||||||
it "displays the user's username after successful login" do
|
it "displays the user's username after successful login" do
|
||||||
user = User.create!(:username => "jdoe", :password => "secret")
|
|
||||||
|
|
||||||
get "/login"
|
get "/login"
|
||||||
|
|
||||||
assert_select "form.login" do
|
|
||||||
assert_select "input[name=?]", "username"
|
|
||||||
assert_select "input[name=?]", "password"
|
|
||||||
assert_select "input[type=?]", "submit"
|
|
||||||
end
|
|
||||||
|
|
||||||
post "/login", username: "jdoe", password: "secret"
|
post "/login", username: "jdoe", password: "secret"
|
||||||
|
|
||||||
expect(response.status).to eql 200
|
expect(response.status).to eql 200
|
||||||
|
expect(response).to redirect_to(...)
|
||||||
# capybara
|
expect(response).to render_template(:show)
|
||||||
expect(page).to have_selector(".header .username", :text => "jdoe")
|
expect(response.body).to include 'hello'
|
||||||
|
follow_redirect!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue