flexlayout-rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
- # Add dependencies to develop your gem here.
4
- # Include everything needed to run rake, tests, features, etc.
3
+ gem 'rails'
4
+
5
5
  group :development do
6
6
  gem "rspec", ">= 2.8.0"
7
7
  gem "rdoc", ">= 3.12"
data/Gemfile.lock CHANGED
@@ -1,15 +1,76 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ actionmailer (3.2.8)
5
+ actionpack (= 3.2.8)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.8)
8
+ activemodel (= 3.2.8)
9
+ activesupport (= 3.2.8)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.8)
18
+ activesupport (= 3.2.8)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.8)
21
+ activemodel (= 3.2.8)
22
+ activesupport (= 3.2.8)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.8)
26
+ activemodel (= 3.2.8)
27
+ activesupport (= 3.2.8)
28
+ activesupport (3.2.8)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.0)
4
33
  diff-lcs (1.1.3)
34
+ erubis (2.7.0)
5
35
  git (1.2.5)
36
+ hike (1.2.1)
37
+ i18n (0.6.0)
6
38
  jeweler (1.8.4)
7
39
  bundler (~> 1.0)
8
40
  git (>= 1.2.5)
9
41
  rake
10
42
  rdoc
43
+ journey (1.0.4)
11
44
  json (1.7.5)
45
+ mail (2.4.4)
46
+ i18n (>= 0.4.0)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.19)
12
50
  multi_json (1.3.6)
51
+ polyglot (0.3.3)
52
+ rack (1.4.1)
53
+ rack-cache (1.2)
54
+ rack (>= 0.4)
55
+ rack-ssl (1.3.2)
56
+ rack
57
+ rack-test (0.6.1)
58
+ rack (>= 1.0)
59
+ rails (3.2.8)
60
+ actionmailer (= 3.2.8)
61
+ actionpack (= 3.2.8)
62
+ activerecord (= 3.2.8)
63
+ activeresource (= 3.2.8)
64
+ activesupport (= 3.2.8)
65
+ bundler (~> 1.0)
66
+ railties (= 3.2.8)
67
+ railties (3.2.8)
68
+ actionpack (= 3.2.8)
69
+ activesupport (= 3.2.8)
70
+ rack-ssl (~> 1.3.2)
71
+ rake (>= 0.8.7)
72
+ rdoc (~> 3.4)
73
+ thor (>= 0.14.6, < 2.0)
13
74
  rake (0.9.2.2)
14
75
  rdoc (3.12)
15
76
  json (~> 1.4)
@@ -25,6 +86,16 @@ GEM
25
86
  multi_json (~> 1.0)
26
87
  simplecov-html (~> 0.5.3)
27
88
  simplecov-html (0.5.3)
89
+ sprockets (2.1.3)
90
+ hike (~> 1.2)
91
+ rack (~> 1.0)
92
+ tilt (~> 1.1, != 1.3.0)
93
+ thor (0.16.0)
94
+ tilt (1.3.3)
95
+ treetop (1.4.10)
96
+ polyglot
97
+ polyglot (>= 0.3.1)
98
+ tzinfo (0.3.33)
28
99
 
29
100
  PLATFORMS
30
101
  ruby
@@ -32,6 +103,7 @@ PLATFORMS
32
103
  DEPENDENCIES
33
104
  bundler (>= 1.0.0)
34
105
  jeweler (>= 1.8.3)
106
+ rails
35
107
  rdoc (>= 3.12)
36
108
  rspec (>= 2.8.0)
37
109
  simplecov (>= 0.5)
data/README.md CHANGED
@@ -23,6 +23,29 @@ In addition a stylesheet called `flexlayout.css` is included, which wraps the Fl
23
23
  * [Wookmark-jQuery](https://github.com/GBKS/Wookmark-jQuery)
24
24
  * [FT-column-flow](https://github.com/ftlabs/ftcolumnflow)
25
25
 
26
+ ### Bonus view helpers
27
+
28
+ `html5_script folder = nil`
29
+
30
+ ```html
31
+ <!--[if lte IE 8]><script src=\"html5-forms/html5.min.js\" type=\"text/javascript\"><![endif]-->
32
+ ```
33
+
34
+ No args:
35
+
36
+ ```html
37
+ "<!--[if lte IE 8]><script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\" type=\"text/javascript\"><![endif]-->"
38
+ ```
39
+
40
+
41
+ `script_src_tag src`
42
+
43
+ Renders fx:
44
+
45
+ ```html
46
+ <script src=\"html5-forms/html5.min.js\" type=\"text/javascript\">
47
+ ```
48
+
26
49
  ## Install
27
50
 
28
51
  `gem 'flexlayout-rails'`
@@ -62,15 +85,72 @@ DEFAULTS = {
62
85
  }
63
86
  ```
64
87
 
88
+ Note:
89
+ Flexbox comes in different syntaxes as described [here](http://css-tricks.com/old-flexbox-and-new-flexbox/). The latest `flex-` syntax is only supported by Chrome 21+ as shown [here](http://caniuse.com/flexbox). Hence you need fallback in your CSS:
90
+
91
+ ```css
92
+ selector
93
+ { display: flex }
94
+
95
+ .no-flexbox selector
96
+ { display: box }
97
+ ```
98
+
99
+ ### View helpers
100
+
101
+ ```haml
102
+ = flexie_script
103
+ ```
104
+
105
+ Renders:
106
+
107
+ <!--[if lte IE 8]><script src="js/flexie.js"></script><![endif]-->
108
+
109
+ ### Flex box helpers
110
+
111
+ The following stylesheets with CSS helper classes are included.
112
+
113
+ * `flexlayout.css`
114
+ * `flex-box-helpers.css`
115
+
116
+ Better yet to use [Compass box mixins](http://compass-style.org/examples/compass/css3/box/)
117
+
118
+ ```scss
119
+ @import "compass/css3"
120
+
121
+ .example {
122
+ @include display-box;
123
+ @include box-orient(horizontal);
124
+ @include box-align(stretch);
125
+
126
+ ...
127
+ .content {
128
+ @include box-flex(1);
129
+ }
130
+ }
131
+ ```
132
+
133
+ Or fx [Preboot](https://github.com/markdotto/Preboot.less) if using LESS.
134
+
135
+ ```less
136
+ .content {
137
+ .box-flex(1);
138
+ }
139
+ ```
140
+
65
141
  *Flexbox Articles*
66
142
 
67
143
  * [Flexbox quick guide](http://www.html5rocks.com/en/tutorials/flexbox/quick/)
144
+ * [Flexible box layout explained](http://coding.smashingmagazine.com/2011/09/19/css3-flexible-box-layout-explained/)
145
+ * [Understanding flexbox](http://benfrain.com/understanding-the-css3-flexbox-flexible-box-layout-module/)
68
146
 
69
147
  _Critiques:_
70
148
 
71
149
  * [Why Flexboxes Aren't Good for Page Layout](http://www.xanthir.com/blog/b4580)
72
150
  * [Flexbox vs Princess Bride](http://oli.jp/2011/css3-flexbox/)
73
151
 
152
+ Conclusion: As is almost always the case, they are good only if used in the right context to solve the right problem ;)
153
+
74
154
  ### Regions.js
75
155
 
76
156
  If you find [this](http://labs.adobe.com/technologies/cssregions/) interesting, just try this script!
@@ -178,7 +258,7 @@ See [Wookmark-jQuery](https://github.com/GBKS/Wookmark-jQuery) for examples and
178
258
 
179
259
  See [FT-column-flow](https://github.com/ftlabs/ftcolumnflow) for examples, demos and usage guide etc.
180
260
 
181
- See fx [BAsic usage example](http://ftlabs.github.com/ftcolumnflow/1.html)
261
+ See fx [Basic usage example](http://ftlabs.github.com/ftcolumnflow/1.html)
182
262
 
183
263
  ## Contributing to flexlayout-rails
184
264
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "flexlayout-rails"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-08-28"
12
+ s.date = "2012-08-31"
13
13
  s.description = "Use CSS Flex, Regions, Multi-column and Template layout models in your Rails apps"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -27,14 +27,17 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "flexlayout-rails.gemspec",
29
29
  "lib/flexlayout-rails.rb",
30
+ "lib/flexlayout/view_helper.rb",
30
31
  "spec/flexlayout/center.html",
31
32
  "spec/flexlayout/form.html",
33
+ "spec/flexlayout/view_helper_spec.rb",
32
34
  "spec/regions/img/lorem-ipsum-logo.jpeg",
33
35
  "spec/regions/index.html",
34
36
  "spec/regions/js/detection.js",
35
37
  "spec/regions/js/layout.js",
36
38
  "spec/regions/js/setup.js",
37
39
  "spec/spec_helper.rb",
40
+ "spec/view_helper.rb",
38
41
  "vendor/assets/javascripts/FT-colum-flow.min.js",
39
42
  "vendor/assets/javascripts/FT-column-flow.js",
40
43
  "vendor/assets/javascripts/feature-detects/cssregions.js",
@@ -52,6 +55,7 @@ Gem::Specification.new do |s|
52
55
  "vendor/assets/javascripts/template_layout/templateLayout.compiler.js",
53
56
  "vendor/assets/javascripts/template_layout/templateLayout.generator.js",
54
57
  "vendor/assets/javascripts/template_layout/templateLayout.js",
58
+ "vendor/assets/stylesheets/flex-box-helpers.css",
55
59
  "vendor/assets/stylesheets/flexlayout.css",
56
60
  "vendor/assets/stylesheets/multi-column.css"
57
61
  ]
@@ -65,12 +69,14 @@ Gem::Specification.new do |s|
65
69
  s.specification_version = 3
66
70
 
67
71
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
68
73
  s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
69
74
  s.add_development_dependency(%q<rdoc>, [">= 3.12"])
70
75
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
71
76
  s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
72
77
  s.add_development_dependency(%q<simplecov>, [">= 0.5"])
73
78
  else
79
+ s.add_dependency(%q<rails>, [">= 0"])
74
80
  s.add_dependency(%q<rspec>, [">= 2.8.0"])
75
81
  s.add_dependency(%q<rdoc>, [">= 3.12"])
76
82
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -78,6 +84,7 @@ Gem::Specification.new do |s|
78
84
  s.add_dependency(%q<simplecov>, [">= 0.5"])
79
85
  end
80
86
  else
87
+ s.add_dependency(%q<rails>, [">= 0"])
81
88
  s.add_dependency(%q<rspec>, [">= 2.8.0"])
82
89
  s.add_dependency(%q<rdoc>, [">= 3.12"])
83
90
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -0,0 +1,27 @@
1
+ module FlexLayout
2
+ module ViewHelper
3
+ def ie_script_tag version, operator = :lt, &block
4
+ raise ArgumentError, "must take a block" unless block_given?
5
+ raw("<!--[if #{operator} IE #{version}]>#{capture(&block)}<![endif]-->").html_safe
6
+ end
7
+
8
+ def flexie_script
9
+ # content = capture(script_tag "flexie.min.js")
10
+ ie_script_tag 8, :lte do
11
+ script_src_tag "flexie.min.js"
12
+ end
13
+ end
14
+
15
+ # Le HTML5 shim, for IE6-8 support of HTML elements
16
+ # if :local option, the option must point to the relative asset folder!
17
+ def html5_script folder = nil
18
+ ie_script_tag 8, :lte do
19
+ script_src_tag folder ? File.join(folder, "html5.min.js") : "http://html5shim.googlecode.com/svn/trunk/html5.js"
20
+ end
21
+ end
22
+
23
+ def script_src_tag src
24
+ raw("<script src=\"#{src}\" type=\"text/javascript\">").html_safe
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,11 @@
1
+ require 'flexlayout/view_helper'
2
+
1
3
  module FlexLayout
2
4
  module Rails
3
5
  class Engine < ::Rails::Engine
6
+ initializer 'flexlayout config' do
7
+ ActionView::Base.send :include, FlexLayout::ViewHelper
8
+ end
4
9
  end
5
10
  end
6
11
  end
@@ -0,0 +1,54 @@
1
+ require 'view_helper'
2
+
3
+ describe FlexLayout::ViewHelper do
4
+ include ControllerTestHelpers,
5
+ FlexLayout::ViewHelper
6
+
7
+ describe '#ie_script_tag' do
8
+ context 'no arguments' do
9
+ specify do
10
+ expect { ie_script_tag }.to raise_error(ArgumentError)
11
+ end
12
+ end
13
+
14
+ context '8' do
15
+ specify do
16
+ expect { ie_script_tag(8) }.to raise_error(ArgumentError)
17
+ end
18
+ end
19
+
20
+ context '8, hello' do
21
+ specify do
22
+ ie_script_tag(8) { 'hello'}.should == "<!--[if lt IE 8]>hello<![endif]-->"
23
+ end
24
+ end
25
+
26
+ context '8, :lte, hello' do
27
+ specify do
28
+ ie_script_tag(8, :lte) { 'hello'}.should == "<!--[if lte IE 8]>hello<![endif]-->"
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '#flexie_script' do
34
+ context 'no arguments' do
35
+ specify do
36
+ flexie_script.should == "<!--[if lte IE 8]><script src=\"flexie.min.js\" type=\"text/javascript\"><![endif]-->"
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#html5_script' do
42
+ context 'no arguments' do
43
+ specify do
44
+ html5_script.should == "<!--[if lte IE 8]><script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\" type=\"text/javascript\"><![endif]-->"
45
+ end
46
+ end
47
+
48
+ context "'html5-forms'" do
49
+ specify do
50
+ html5_script('html5-forms').should == "<!--[if lte IE 8]><script src=\"html5-forms/html5.min.js\" type=\"text/javascript\"><![endif]-->"
51
+ end
52
+ end
53
+ end
54
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,5 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
1
  require 'rspec'
4
- require 'flexie-rails'
2
+ require 'flexlayout-rails'
5
3
 
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
4
+ RSpec.configure do |config|
12
5
  end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ require 'rubygems'
3
+ require 'rails'
4
+ require 'json'
5
+ require 'active_support'
6
+ require 'action_pack'
7
+ require 'action_view'
8
+ require 'action_controller'
9
+ require 'action_view/template'
10
+
11
+ require 'spec_helper'
12
+
13
+ module ControllerTestHelpers
14
+
15
+ def self.included(base)
16
+ base.class_eval do
17
+
18
+ include ActionView::Helpers,
19
+ ActionView::Helpers::CaptureHelper,
20
+ ActionView::Helpers::JavaScriptHelper,
21
+ ActionView::Helpers::AssetTagHelper
22
+
23
+ # allow tabs.create to run by stubbing an output_buffer
24
+ attr_accessor :output_buffer
25
+ @output_buffer = ""
26
+
27
+ # stub content_for for testing
28
+ def content_for(name, content = nil, &block)
29
+ # this doesn't exist, and causes errors
30
+ @_content_for = {} unless defined? @_content_for
31
+ # we've got to initialize this, so we can concat to it
32
+ @_content_for[name] = '' if @_content_for[name].nil?
33
+ # now the rest is the same as in rails
34
+ content = capture(&block) if block_given?
35
+ @_content_for[name] << content if content
36
+ @_content_for[name] unless content
37
+ end
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,85 @@
1
+ /* Flexbox-Helpers.css
2
+ * Helper classes to use with CSS3 Flexible Boxes
3
+ *
4
+ * http://richardshepherd.com
5
+ * @richardshepherd
6
+ *
7
+ * Keep your eye on the spec because these
8
+ * properties and values WILL change :)
9
+ * http://dev.w3.org/csswg/css3-flexbox/
10
+ * -------------------------------------------- */
11
+
12
+ .boxHorizontal {
13
+ display: -webkit-box;
14
+ display: -moz-box;
15
+ display: box;
16
+
17
+ -webkit-box-orient: horizontal;
18
+ -moz-box-orient: horizontal;
19
+ box-orient: horizontal;
20
+ }
21
+
22
+ .boxVertical {
23
+ display: -webkit-box;
24
+ display: -moz-box;
25
+ display: box;
26
+
27
+ -webkit-box-orient: vertical;
28
+ -moz-box-orient: vertical;
29
+ box-orient: vertical;
30
+ }
31
+
32
+ .boxFlex,
33
+ .boxFlex1 { -webkit-box-flex: 1; -moz-box-flex: 1; box-flex: 1; }
34
+ .boxFlex2 { -webkit-box-flex: 2; -moz-box-flex: 2; box-flex: 2; }
35
+ .boxFlex3 { -webkit-box-flex: 3; -moz-box-flex: 3; box-flex: 3; }
36
+ .boxFlex4 { -webkit-box-flex: 4; -moz-box-flex: 4; box-flex: 4; }
37
+
38
+ .boxStart {
39
+ -webkit-box-pack: start;
40
+ -moz-box-pack: start;
41
+ box-pack: start;
42
+ }
43
+
44
+ .boxEnd {
45
+ -webkit-box-pack: end;
46
+ -moz-box-pack: end;
47
+ box-pack: end;
48
+ }
49
+
50
+ .boxCentered {
51
+ -webkit-box-pack: center;
52
+ -moz-box-pack: center;
53
+ box-pack: center;
54
+ }
55
+
56
+
57
+ /* Additional Classes written by/adapted from Alex Russell's great work
58
+ * http://infrequently.org/2009/08/css-3-progress/
59
+ * -----------------------------------------------*/
60
+
61
+ .boxHorizontal > *,
62
+ .boxVertical > * {
63
+ -webkit-box-flex: 0;
64
+ -moz-box-flex: 0;
65
+ box-flex: 0;
66
+ display: block;
67
+ }
68
+
69
+ .spacer {
70
+ -webkit-box-flex: 1;
71
+ -moz-box-flex: 1;
72
+ box-flex: 1;
73
+ }
74
+
75
+ .boxGroup1 {
76
+ -webkit-box-flex-group: 1;
77
+ -moz-box-flex-group: 1;
78
+ box-flex-group: 1;
79
+ }
80
+
81
+ .boxGroup2 {
82
+ -webkit-box-flex-group: 2;
83
+ -moz-box-flex-group: 2;
84
+ box-flex-group: 2;
85
+ }
@@ -1,6 +1,6 @@
1
- /* From: http://infrequently.org/2009/08/css-3-progress/ */
1
+ /* From: http://infrequently.org/2009/08/css-3-progress/
2
2
 
3
- /* hbox and vbox classes */
3
+ hbox and vbox classes */
4
4
 
5
5
  .hbox {
6
6
  display: -webkit-box;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexlayout-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-28 00:00:00.000000000 Z
12
+ date: 2012-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rspec
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -110,14 +126,17 @@ files:
110
126
  - VERSION
111
127
  - flexlayout-rails.gemspec
112
128
  - lib/flexlayout-rails.rb
129
+ - lib/flexlayout/view_helper.rb
113
130
  - spec/flexlayout/center.html
114
131
  - spec/flexlayout/form.html
132
+ - spec/flexlayout/view_helper_spec.rb
115
133
  - spec/regions/img/lorem-ipsum-logo.jpeg
116
134
  - spec/regions/index.html
117
135
  - spec/regions/js/detection.js
118
136
  - spec/regions/js/layout.js
119
137
  - spec/regions/js/setup.js
120
138
  - spec/spec_helper.rb
139
+ - spec/view_helper.rb
121
140
  - vendor/assets/javascripts/FT-colum-flow.min.js
122
141
  - vendor/assets/javascripts/FT-column-flow.js
123
142
  - vendor/assets/javascripts/feature-detects/cssregions.js
@@ -135,6 +154,7 @@ files:
135
154
  - vendor/assets/javascripts/template_layout/templateLayout.compiler.js
136
155
  - vendor/assets/javascripts/template_layout/templateLayout.generator.js
137
156
  - vendor/assets/javascripts/template_layout/templateLayout.js
157
+ - vendor/assets/stylesheets/flex-box-helpers.css
138
158
  - vendor/assets/stylesheets/flexlayout.css
139
159
  - vendor/assets/stylesheets/multi-column.css
140
160
  homepage: http://github.com/kristianmandrup/flexlayout-rails
@@ -152,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
172
  version: '0'
153
173
  segments:
154
174
  - 0
155
- hash: 3858388048093815556
175
+ hash: 2728143054712158305
156
176
  required_rubygems_version: !ruby/object:Gem::Requirement
157
177
  none: false
158
178
  requirements: