aerogel-core 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34096608560195b108c8293d58d750ecd2c71e55
4
- data.tar.gz: aef77ff72c91c44dcc31773ab1db82898fdf18af
3
+ metadata.gz: 03745769b429a1a9f37d4cc55d91c33b134d18f3
4
+ data.tar.gz: f1e55f86299fe31ff72c98fdce5ea959c9981bdc
5
5
  SHA512:
6
- metadata.gz: 6110c5fd235c225219491bf76f2050fd8a4230870302f246dffcb32aa70e0054ac14efcd380275789060e9789658a777c234393c1795f42282b005028d0ae7e2
7
- data.tar.gz: 9a54b53fe15a2d57c841fc056bbaf04168125c606ade574e2a0f333545ce3e605296a3920b9f07c22e4062f29d5b3b1137585e524bebf28702c99172aca872d5
6
+ metadata.gz: 38b100edb2a525b7f56351964d612e4f5a10655328d996fe7be1e938de34cd40a807c5864888ab0839dadfdd06ed48ba0f61ebd436c4ae1c27610e762be91dff
7
+ data.tar.gz: ce62b0f6e225916d387226dd3d9c0edf484c73800d84bbb03c40a70d167c7488668329250f4aa6ec4bcf6fa96ba32c8ca69d66e87cbf9257fe263b09fa2a2d24
data/aerogel-core.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'sinatra'
22
22
  spec.add_dependency 'sinatra-contrib'
23
23
  spec.add_dependency 'sinatra-asset-pipeline'
24
+ spec.add_dependency 'rack-flash3'
24
25
  spec.add_dependency 'sass'
25
26
  spec.add_dependency 'coffee-script'
26
27
  spec.add_dependency 'uglifier'
@@ -0,0 +1,19 @@
1
+ module Aerogel::Helpers
2
+
3
+ def csrf_field_name
4
+ 'authenticity_token'
5
+ end
6
+
7
+ def csrf_token
8
+ session[:csrf] ||= SecureRandom.hex(32) if defined?(session)
9
+ end
10
+
11
+ def csrf_token_field
12
+ input_hidden_tag csrf_field_name, csrf_token
13
+ end
14
+
15
+ def csrf_protected?
16
+ true
17
+ end
18
+
19
+ end # module Aerogel::Helpers
@@ -3,8 +3,8 @@ module Aerogel::Helpers
3
3
  def output_concat( text )
4
4
  if self.respond_to?(:is_haml?) && is_haml?
5
5
  haml_concat(text)
6
- elsif !OutputBuffer.buffer.nil? # has_erb_buffer?
7
- OutputBuffer.buffer.concat text
6
+ elsif !Aerogel::Render::OutputBuffer.buffer.nil? # has_erb_buffer?
7
+ Aerogel::Render::OutputBuffer.buffer.concat text
8
8
  else # theres no template to concat, return the text directly
9
9
  text
10
10
  end
@@ -15,9 +15,9 @@ module Aerogel::Helpers
15
15
  if self.respond_to?(:is_haml?) && is_haml? && (block_is_haml?(inner_block) rescue false)
16
16
  # haml
17
17
  capture_haml(nil, &block)
18
- elsif OutputBuffer.block_is_erb? block
18
+ elsif Aerogel::Render::OutputBuffer.block_is_erb? block
19
19
  # erb
20
- OutputBuffer.capture( &block )
20
+ Aerogel::Render::OutputBuffer.capture( &block )
21
21
  else
22
22
  block.call
23
23
  end
@@ -0,0 +1,28 @@
1
+ module Aerogel::Helpers
2
+
3
+ # Creates tag.
4
+ #
5
+ def tag( name, *args, &block )
6
+ if block_given?
7
+ content = output_capture(&block)
8
+ elsif args.first.is_a? String
9
+ content = args.shift
10
+ end
11
+ attrs = args.shift || {}
12
+ # t_attrs = attrs.map{|k,v| v.nil? ? " #{k}" : " #{k}=\"#{h(v)}\""}
13
+ t_attrs = attrs.map{|k,v| v.nil? ? " #{k}" : " #{k}=\"#{(v)}\""}
14
+ if content
15
+ output = "<#{name}#{t_attrs.join}>"+content+"</#{name}>"
16
+ else
17
+ output = "<#{name}#{t_attrs.join}/>"
18
+ end
19
+ if Aerogel::Render::OutputBuffer.block_is_template?(block)
20
+ output_concat(output)
21
+ return nil
22
+ else
23
+ return output
24
+ end
25
+ end
26
+
27
+
28
+ end # module Aerogel::Helpers
@@ -1,4 +1,5 @@
1
1
  require 'aerogel/configurator'
2
+ require 'rack-flash'
2
3
 
3
4
  module Aerogel::Config
4
5
 
@@ -20,6 +21,14 @@ module Aerogel::Config
20
21
  app.config.load config_filename
21
22
  end
22
23
 
24
+ # set :protection, true
25
+ # set :protect_from_csrf, true
26
+ app.set :sessions, true
27
+ # TODO: demand to configure session secret on application level
28
+ # set :session_secret, '$aer0G31'
29
+ app.use Rack::Protection::AuthenticityToken
30
+ app.use Rack::Flash
31
+
23
32
  end
24
33
  end # module Aerogel::Config
25
34
 
@@ -1,3 +1,3 @@
1
1
  module Aerogel
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aerogel-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-flash3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: sass
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -180,8 +194,10 @@ files:
180
194
  - app/helpers/assets.rb
181
195
  - app/helpers/config.rb
182
196
  - app/helpers/core.rb
197
+ - app/helpers/csrf.rb
183
198
  - app/helpers/output_buffer.rb
184
199
  - app/helpers/render.rb
200
+ - app/helpers/tags.rb
185
201
  - app/routes/core.rb
186
202
  - app/routes/static.rb
187
203
  - assets/javascripts/application.js