facades 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gitignore +1 -0
  2. data/.rbenv-gemsets +1 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +19 -0
  7. data/README.md +115 -101
  8. data/Rakefile +8 -0
  9. data/app/assets/javascripts/facades/debug/grid.js +0 -0
  10. data/app/helpers/facades_helper.rb +1 -0
  11. data/config.ru +7 -0
  12. data/facades.gemspec +9 -2
  13. data/lib/facades/helpers/layout.rb +36 -73
  14. data/lib/facades/helpers/navigation.rb +182 -110
  15. data/lib/facades/helpers/{elements.rb → notifications.rb} +9 -36
  16. data/lib/facades/helpers.rb +6 -17
  17. data/lib/facades/patterns/tabs.rb +75 -0
  18. data/lib/facades/patterns.rb +7 -0
  19. data/lib/facades/{sass_ext → sass_extensions}/color.rb +5 -13
  20. data/lib/facades/sass_extensions/conversions.rb +27 -0
  21. data/lib/facades/sass_extensions/functions.rb +84 -0
  22. data/lib/facades/sass_extensions/icons.rb +66 -0
  23. data/lib/facades/sass_extensions.rb +21 -0
  24. data/lib/facades/support/compass/project/MIT-LICENSE.txt +20 -0
  25. data/lib/facades/support/compass/project/humans.txt +8 -0
  26. data/lib/facades/support/compass/project/index.html +45 -0
  27. data/lib/facades/support/compass/project/manifest.rb +18 -0
  28. data/lib/facades/support/compass/project/robots.txt +4 -0
  29. data/lib/facades/support/compass.rb +9 -0
  30. data/lib/facades/support/rails.rb +12 -15
  31. data/lib/facades/support/simple_form.rb +32 -0
  32. data/lib/facades/version.rb +1 -1
  33. data/lib/facades.rb +21 -44
  34. data/spec/internal/app/helpers/application_helper.rb +3 -0
  35. data/spec/internal/app/views/navigation/_multi_list.html.erb +11 -0
  36. data/spec/internal/app/views/navigation/_multi_option_list.html.erb +14 -0
  37. data/spec/internal/app/views/navigation/_single_list.html.erb +9 -0
  38. data/spec/internal/config/database.yml +3 -0
  39. data/spec/internal/config/routes.rb +3 -0
  40. data/spec/internal/db/schema.rb +3 -0
  41. data/spec/internal/log/.gitignore +1 -0
  42. data/spec/internal/public/favicon.ico +0 -0
  43. data/spec/spec_helper.rb +16 -6
  44. data/spec/unit/helpers/layout_spec.rb +4 -0
  45. data/spec/unit/helpers/navigation_spec.rb +384 -0
  46. data/spec/unit/helpers/notifications_spec.rb +4 -0
  47. data/spec/unit/patterns/tabs_spec.rb +58 -0
  48. data/src/icons/facades.yml +105 -0
  49. data/src/icons/font-awesome.yml +210 -0
  50. data/src/scss/facades/_buttons.scss +10 -0
  51. data/src/scss/facades/_config.scss +99 -0
  52. data/src/scss/facades/_debug.scss +8 -0
  53. data/src/scss/facades/_forms.scss +228 -0
  54. data/src/scss/facades/_global.scss +104 -0
  55. data/src/scss/facades/_icons.scss +61 -0
  56. data/src/scss/facades/_mixins.scss +115 -0
  57. data/src/scss/facades/_mobile.scss +3 -0
  58. data/src/scss/facades/_setup.scss +191 -0
  59. data/src/scss/facades/_typography.scss +220 -0
  60. data/src/scss/facades/buttons/_glossy.scss +29 -0
  61. data/src/scss/facades/buttons/_gradient.scss +36 -0
  62. data/src/scss/facades/buttons/_shared.scss +33 -0
  63. data/src/scss/facades/buttons/_simple.scss +28 -0
  64. data/src/scss/facades/icons/_classes.scss +37 -0
  65. data/src/scss/facades/icons/_legacy.scss +27 -0
  66. data/src/scss/facades/layout/_lists.scss +43 -0
  67. data/src/scss/facades/mixins/_gradients.scss +30 -0
  68. data/src/scss/facades/mixins/_rhythm.scss +37 -0
  69. data/src/scss/facades/mobile/_buttons.scss +97 -0
  70. data/src/scss/facades/mobile/_config.scss +30 -0
  71. data/src/scss/facades/mobile/_global.scss +81 -0
  72. data/src/scss/facades/mobile/_mixins.scss +49 -0
  73. data/src/scss/facades/mobile/_setup.scss +50 -0
  74. data/src/scss/facades/mobile/patterns/_navbar.scss +21 -0
  75. data/src/scss/facades/mobile/patterns/_panel.scss +37 -0
  76. data/src/scss/facades/mobile/patterns/_stage.scss +20 -0
  77. data/src/scss/facades/mobile/patterns/_toolbar.scss +25 -0
  78. data/src/scss/facades/mobile/themes/_apple.scss +17 -0
  79. data/src/scss/facades/patterns/_labels.scss +50 -0
  80. data/src/scss/facades/patterns/_navbar.scss +4 -0
  81. data/src/scss/facades/patterns/_notifications.scss +82 -0
  82. data/src/scss/facades/patterns/_pagination.scss +4 -0
  83. data/src/scss/facades/patterns/_pills.scss +50 -0
  84. data/src/scss/facades/patterns/_tabs.scss +83 -0
  85. data/src/scss/facades/patterns/_twipsy.scss +84 -0
  86. data/src/scss/facades/typography/_tables.scss +95 -0
  87. metadata +201 -58
  88. data/app/views/facades/_pagination.html.erb +0 -20
  89. data/lib/facades/builders/form/base.rb +0 -212
  90. data/lib/facades/builders/form/elements.rb +0 -112
  91. data/lib/facades/builders/form/helper.rb +0 -29
  92. data/lib/facades/builders/form.rb +0 -22
  93. data/lib/facades/builders/sprite.rb +0 -50
  94. data/lib/facades/builders/table.rb +0 -76
  95. data/lib/facades/debug/html.rb +0 -6
  96. data/lib/facades/helpers/builders.rb +0 -24
  97. data/lib/facades/helpers/mobile.rb +0 -57
  98. data/lib/facades/helpers/pagination.rb +0 -83
  99. data/lib/facades/helpers/utility.rb +0 -31
  100. data/lib/facades/sass_ext/form_elements.rb +0 -52
  101. data/lib/facades/sass_ext/funcs.rb +0 -33
  102. data/lib/facades/sass_ext.rb +0 -14
  103. data/lib/facades/stylesheets/facades/_common.scss +0 -7
  104. data/lib/facades/stylesheets/facades/_css3.scss +0 -93
  105. data/lib/facades/stylesheets/facades/_layout.scss +0 -5
  106. data/lib/facades/stylesheets/facades/_normalize.scss +0 -5
  107. data/lib/facades/stylesheets/facades/_setup.scss +0 -104
  108. data/lib/facades/stylesheets/facades/_typography.scss +0 -2
  109. data/lib/facades/stylesheets/facades/_ui.scss +0 -3
  110. data/lib/facades/stylesheets/facades/_utilities.scss +0 -32
  111. data/lib/facades/stylesheets/facades/layout/_dropdown-list.scss +0 -7
  112. data/lib/facades/stylesheets/facades/layout/_forms.scss +0 -53
  113. data/lib/facades/stylesheets/facades/layout/_grid.scss +0 -49
  114. data/lib/facades/stylesheets/facades/layout/_responsive_grid.scss +0 -164
  115. data/lib/facades/stylesheets/facades/setup/_forms.scss +0 -284
  116. data/lib/facades/stylesheets/facades/setup/_ie.scss +0 -12
  117. data/lib/facades/stylesheets/facades/setup/_reset.scss +0 -255
  118. data/lib/facades/stylesheets/facades/typography/_baseline.scss +0 -91
  119. data/lib/facades/stylesheets/facades/typography/_lists.scss +0 -34
  120. data/lib/facades/stylesheets/facades/typography/_shadow.scss +0 -8
  121. data/lib/facades/stylesheets/facades/ui/_buttons.scss +0 -34
  122. data/lib/facades/stylesheets/facades/ui/_flash-messages.scss +0 -29
  123. data/lib/facades/stylesheets/facades/ui/_tabbed.scss +0 -5
  124. data/lib/facades/stylesheets/facades/ui/_tool-tip.scss +0 -44
  125. data/lib/facades/stylesheets/facades/utilities/_clearfix.scss +0 -20
  126. data/lib/facades/stylesheets/facades/utilities/_color.scss +0 -7
  127. data/lib/facades/stylesheets/facades/utilities/_cursors.scss +0 -4
  128. data/lib/facades/support/serve.rb +0 -17
  129. data/lib/facades/support/tipsy.rb +0 -17
  130. data/spec/facades/helpers/elements_spec.rb +0 -86
  131. data/spec/facades/helpers/layout_helpers_spec.rb +0 -5
  132. data/spec/facades/helpers/navigation_spec.rb +0 -107
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .DS_Store
6
+ vendor/bundle
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ global
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@facades --create
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ notifications:
6
+ email: false
data/Gemfile CHANGED
@@ -1,4 +1,16 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ group :development do
4
+ gem 'combustion', '~> 0.3.1'
5
+ end
6
+
7
+ group :test do
8
+ gem 'guard-coffeescript'
9
+ gem 'rake'
10
+ gem 'growl'
11
+ gem 'guard', '0.8.8'
12
+ gem "guard-rspec"
13
+ end
14
+
3
15
  # Specify your gem's dependencies in facades.gemspec
4
16
  gemspec
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ require 'growl'
4
+
5
+ guard 'rspec', {
6
+ cli: '--colour --format documentation --fail-fast',
7
+ version: 2,
8
+ all_after_pass: false,
9
+ all_on_start: false,
10
+ notify: true } do
11
+
12
+ watch(%r{^spec/.+_spec\.rb$})
13
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
+ watch('spec/spec_helper.rb') { "spec" }
15
+ watch(%r{/lib/facades/helpers/(.+)\.rb$}) { |m| "spec/unit/helpers/#{m[1]}_spec.rb" }
16
+ watch(%r{/lib/facades/patterns/(.+)\.rb$}) { |m| "spec/unit/patterns/#{m[1]}_spec.rb" }
17
+ end
18
+
19
+ guard 'coffeescript', :input => 'src/javascript', :output => 'app/assets/javascripts/', :all_on_start => true
data/README.md CHANGED
@@ -1,83 +1,72 @@
1
- #Facades
2
- Facades is a gem designed to assist with front-end development and misc design. It includes a compass plugin / mixins, and various Rails view helpers to help with common development tasks.
1
+ ==================================================================================================================
2
+ Facades
3
+ ==================================================================================================================
3
4
 
4
- **Note** With version 1.0 there are a number of changes in functionality setup. Check [here](https://github.com/kurbmedia/facades/tree/1.0) for more info. Currently master
5
- tracks the released version.
5
+ Facades is a framework, written in SASS (.scss) designed to assist with front-end development rapid prototyping. It includes a number of base classes, patterns and mixins,
6
+ focused on semantic html, and styled around a consistent vertical rhythm.
6
7
 
7
- ##CSS / SASS
8
- Facades includes several mixins and includes for setting up a few defaults within your css.
8
+ **Another one? Come on**
9
+ Theres tons of css / rapid dev frameworks around, and some pretty awesome ones including [Twitter's Bootstrap](http://bootstrap.io) and [foundation](http://foundation.zurb.com). We took inspiration from
10
+ each of these to create a more standards based solution writtenfor HTML5 and designed around a clean baseline rhythm.
9
11
 
10
- ###Reset
11
- A HTML5-friendly reset is included to ensure elements like `aside`, `section` etc are setup properly. It also sets up a few typography defaults using Compass' vertical-rhythm format.
12
- To configure, assign the variables to `$font-size` and `$line-height`. These will default to 12px / 24px. Vertical-rhythm is defaulted to relative font sizes.
12
+ **Why not just use one of the existing frameworks then?**
13
+ We wanted something that was more standards friendly where at all possible, and felt as though a lot of what was out there missed the mark. We've
14
+ utilized the concepts that worked, and scrapped a few that didn't. Keeping a clean vertical rhythm was also important, which
15
+ wasn't available with anything existing at the time.
13
16
 
14
- $font-size:12px;
15
- $line-height:24px;
16
-
17
- @import 'facades/reset'; // Will automatically setup the vertical rhythm
17
+ Facades also utilizes the fantastic [Compass](https://github.com/chriseppstein/compass) library to add additional function and flexiblity.
18
+ This helps increase the functionality and reliability of the framework as a whole.
18
19
 
19
- ###Layout
20
- Mixins are provided for a fixed grid, forms, and grid debugging.
20
+ Most of the patterns included here are written using sass mixins, with configuration options for fonts, sizes, and colors.
21
+ For instance, the notifications pattern (alerts/flash messages) is implemented as a mixin, allowing the developer to decide their own node and class
22
+ scheme to use. This makes facades easier to implement in existing projects, without having to change existing classes or html format.
21
23
 
22
- **Grid Setup**
23
-
24
- $grid-width: 960px; // Full width of the container
25
- $grid-columns: 24; // Total number of columns
26
- $grid-gutter-width: 10px; // Spacing between each column
27
-
28
- @import 'facades/layout/grid'; /( or include 'facades/layout')
29
- #wrapper{ @include container; }
24
+ When implementing patterns color schemes are provided as an option, for those instances where you'd prefer your own class names and design.
30
25
 
31
- To debug grid alignment, a shortcut to the Compass' grid background is provided.
26
+ For those who just want to import and go, theres also a `_globals.scss` which creates all of the defaults, with classes and all. To utilize, import it into your main css file.
32
27
 
33
- #wrapper{ @include debug-grid; }
28
+ ``` scss
29
+ @import 'facades/global';
30
+ ```
34
31
 
35
- ### Mixins
36
- Below is a list of available mixins
37
-
38
- Interface
39
- -----------------------
40
- tool-tip
41
- flash-message
42
- flash-message-colors
43
-
44
- Forms
45
- ----------------------
46
- form-field-list
47
- form-split-field-list
48
- form-field
49
- form-input
50
- form-select
51
- form-textarea
52
- form-errors
53
- form-error-message
54
- form-field-hint
55
-
56
- Grid (based off of the blueprint grid)
57
- ---------------------
58
- column
59
- push
60
- pull
61
- append
62
- prepend
63
- span (function) // width:span(2);
64
-
65
- Text
66
- ----------------------
67
- leading (shortcut to Compass adjust-leading-to)
68
- font-size (shortcut to Compass adjust-font-size-to)
69
- inset-text (text-shadow text insetting)
70
-
71
- Utility
72
- ----------------------
73
- position (shorthand position relative/fixed/absolute)
74
- luminance ( return a colors lightness in terms of 'light' or 'dark' )
75
- tint (tint a color with white)
76
- shade (darken a color with black)
77
-
78
- ##Helpers
32
+ If you'd like to configure any particular variables such as sizes or line heights, do so before importing the global file.
33
+
34
+ Reset and Configuration
35
+ ------------------------------
36
+
37
+ Facades implements the awesome [HTML5 Boilerplate](https://github.com/h5bp/html5-boilerplate) reset/normalize stylesheet to establish a
38
+ grounds for which to expand upon. Common colors, sizes and line-heights are fully configurable using the variables found in `_config.scss`.
39
+ The more common options you probably want to configure are:
40
+
41
+ `$font-color`: The body/default font color.
42
+
43
+ `$font-size`: The base font size, also used when calculating vertical rhythm
44
+
45
+ `$line-height`: The base line-height, combined with `$font-size` establishes a baseline and sets up the vertical-rhythm
46
+
47
+ `$font-family`: The base font-family
48
+
49
+ `$notice-color`: The color used for .notice alerts labels, blue by default
50
+
51
+ `$success-color`: The color used for .success labels and alerts, green by default
52
+
53
+ `$error-color`: The color used for :invalid fields, .error labels and alerts, red by default
54
+
55
+ `$warning-color`: The color used for .warning labels and alerts, yellow by default
56
+
57
+ `$input-border-color`: The default color used for form elements, grey by default.
58
+
59
+ `$input-focus-color`: The font color used when an input is focused, defaults to `$font-color`
60
+
61
+ `$input-focus-border-color`: The border color used for inputs when in a :focus state. Defaults to `$notice-color`
79
62
 
80
- ###Layout Helpers
63
+ `$input-error-color`: The font color used for inputs in an :invalid or .error state. Defaults to red.
64
+
65
+ `$input-error-border-color`: The border color used for inputs in an :invalid or .error state. Defaults to `$error-color`.
66
+
67
+
68
+ Layout Helpers
69
+ ------------------------------
81
70
 
82
71
  **Variables**
83
72
  Setup variables via templates to be used within your layout.
@@ -90,7 +79,7 @@ Setup variables via templates to be used within your layout.
90
79
  To assign variables, pass their value to the method. To display, use the method without any arguments
91
80
 
92
81
  # index.html.erb
93
- <%= page_id('home') %>
82
+ <% page_id('home') %>
94
83
 
95
84
  # In your layout
96
85
  body id="<%= page_id %>"
@@ -109,53 +98,78 @@ To assign variables, pass their value to the method. To display, use the method
109
98
  # In production
110
99
  <%= robot_meta_tag %> #=> <meta name="robots" content="index, follow" />
111
100
 
112
- `button_link` Shortcut for creating a link class="button" with an optional icon
101
+ `browser_name` Returns the name of the user's browser (ie webkit, mozilla, ie8, ie9, etc)
113
102
 
114
- <%= button_link 'Link Text', some_path, icon: 'image.png' %> #=> <a href='#' class='button'><img src='image.png' /></a>
115
-
116
- ###Pagination Helper
117
-
118
- Any model which responds to current_page and total_pages can utilize the pagination helper.
103
+ Navigation Helpers
104
+ ------------------------------
119
105
 
120
- <%= paginate(collection) %>
121
-
122
- Will render a link based list with the current collection pagination. If `Facades.enable_html5` is set to `true` items will be wrapped in a HTMl5 `<nav>` tag, otherwise a div will be used. The class 'pagination' is added to that top level element.
123
- By default the included partial facades/pagination is rendered. To customize output simply override this in your application. See app/views/facades/_pagination.html.erb for more info.
106
+ Facades provides a navigation helper for creating nested navigation lists. Syntax is similar to other Rails helpers such as `form_for`
124
107
 
125
- ###Navigation Helper
126
-
127
- Facades provides a navigation helper for creating nested navigation lists.
128
-
129
- <%= nav do %>
130
- <%= nav_link 'About Me', about_path %>
131
- <%= nav_link 'Top Level', some_path do %>
132
- <%= nav_link 'Sub Item', some_sub_path %>
108
+ <%= nav do |n| %>
109
+ <%= n.link 'About Me', about_path %>
110
+ <%= n.link 'Top Level', some_path do |s| %>
111
+ <%= s.link 'Sub Item', some_sub_path %>
133
112
  <% end %>
134
113
  <% end %>
135
114
 
136
115
  Will output
137
116
 
138
117
  <nav>
139
- <ol>
118
+ <ul>
140
119
  <li><a href='/about-path'>About Me</a></li>
141
120
  <li><a href='/some-path'>Top Level</a>
142
- <ol>
121
+ <ul>
143
122
  <li><a href="/some-sub-path">Sub Item</a></li>
144
- </ol>
123
+ </ul>
145
124
  </li>
146
- </ol>
125
+ </ul>
147
126
  </nav>
148
127
 
149
128
  Note: The `<nav>` tag is only included if `Facades.enable_html5` is set to true.
150
-
151
- As a convenience, the class `on` will be added to a link when the current url matches that link. This can be overridden by using the `matcher` or `proc` attributes when calling `nav_link`.
152
- When using a proc/lambda, returning true will set the `on` class.
129
+
130
+ As a convenience, the class `active` will be added to a link when the current url matches that link. This can be overridden by using one of three ways:
131
+ 1. Assigning a `:proc` attribute. When using a proc/lambda, returning true will set the `active` class.
153
132
 
154
133
  # Current path /home
155
- <%= nav_link 'Path', some_path, proc: lambda{ |current_path| true } %> #=> <a href='/anything' class='on'>Path</a>
156
-
157
- When using `:matcher`, pass a string or regular expression in which the request.path should match to be `on`.
134
+ <%= n.link 'Path', some_path, proc: lambda{ |current_path| true } %> #=> <a href='/anything' class='active'>Path</a>
158
135
 
159
- # Current path /somewhere
160
- <%= nav_link 'Path', '/something-else', matcher: /somewhere/ %> #=> <a href='/something-else' class='on'>Path</a>
136
+ 2. Passing a `:match` attribute as one of `:exact`, `:after`, or `:before` will match all urls based on that formula. `:exact` matches only the exact
137
+ url defined in the link's href attribute. `:before` matches any path matching a "parent" url, while `:after` matches any url starting with the specified path.
138
+ The latter is useful for when you'd like to match sub-pages or paths in nested navigations.
139
+
140
+ 3. Assigning a `:matcher` attribute, containing a regular expression in which the request.path should match to be `active`.
161
141
 
142
+ <%= n.link 'Path', '/something-else', matcher: /something/ %> #=> <a href='/something-else' class='active'>Path</a>
143
+
144
+ In addition to the `nav` helper, a `nav_link` helper is also provided, for use when creating single links, which should also track 'active' state.
145
+
146
+
147
+ Contributing
148
+ ------------------------------
149
+
150
+ Fork and create. When coding styles or ruby libs, adhere to a 2 space indention. Patterns should be written as mixins, with a
151
+ default class construction in `_global.scss`. Colors should be configurable, either by using one of the colors included in `_config.scss`
152
+ (preferred) or by 'namespaced' variable (ie: $patternname-border-color).
153
+
154
+ Pre-built classes / styles should be as lightweight as possible and avoid css hacks. We encourage support of Paul Irish's class conventions
155
+ found [here](http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/). CSS overrides for IE should utilize this technique.
156
+ Styles should confirm to a vertical-rhythm as much as possible (some things seem to always be off a hair in IE (who would have thought)).
157
+
158
+ Document patterns with html examples, which should utilize HTML5 elements, in an intended/semantic manner.
159
+
160
+ Thanks
161
+ ------------------------------
162
+
163
+ Thanks to the fine folks who work on the HTML5 Boilerplate, the Compass library and contributors, and the hundreds of
164
+ random people who've blogged the tons and tons of google search results we've read in creating this library.
165
+
166
+ License
167
+ ------------------------------
168
+
169
+ Copyright 2012 kurb media llc.
170
+ MIT/GPL ( do whatever you want, but check the licenses below )
171
+
172
+ **Components:**
173
+
174
+ Compass: MIT (modified)
175
+ HTML5 Boilerplate reset.css: Public Domain
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
+ require "rspec"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new("spec") do |spec|
6
+ spec.pattern = "spec/**/*_spec.rb"
7
+ end
8
+
9
+ task :default => :spec
File without changes
@@ -1,3 +1,4 @@
1
1
  module FacadesHelper
2
2
  include Facades::Helpers
3
+ include Facades::Patterns
3
4
  end
data/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize!
7
+ run Combustion::Application
data/facades.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Brent Kirby"]
9
9
  s.email = ["brent@kurbmedia.com"]
10
10
  s.homepage = "https://github.com/kurbmedia/facades"
11
- s.summary = %q{Front-end development awesome-ness}
12
- s.description = %q{Facades is a front-end development framework which supplies a few helpers, stylesheets and sass extensions for easier front-end development.}
11
+ s.summary = %q{Front-end development awesome-ness with Compass and Sass.}
12
+ s.description = %q{Facades is a collection of front-end patterns and libraries designed to speed up development of web sites and applications.}
13
13
 
14
14
  s.rubyforge_project = "facades"
15
15
 
@@ -19,5 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency('sass', ['~> 3.1'])
22
+ s.add_dependency('compass', ['>= 0.11.7'])
23
+
24
+ s.add_development_dependency('combustion', '~> 0.3.1')
25
+ s.add_development_dependency("rspec", ">= 2.7.0")
26
+ s.add_development_dependency("sass-rails", "~> 3.1")
27
+ s.add_development_dependency("webrat", "~> 0.7")
28
+ s.add_development_dependency("rspec-rails", ">= 2.11.0")
22
29
 
23
30
  end
@@ -1,11 +1,9 @@
1
1
  module Facades
2
2
  module Helpers
3
3
  ##
4
- #
5
- # # Convenience helpers generally used in layout files
6
- #
4
+ # Convenience helpers generally used in layout files
5
+ #
7
6
  module Layout
8
-
9
7
  ##
10
8
  # Returns a short-hand string identifying the current browser
11
9
  #
@@ -28,37 +26,28 @@ module Facades
28
26
  # @param [String] content The content to be used in the meta tag
29
27
  # @return [String] A html meta tag with the name and content attributes set
30
28
  #
31
- def meta_tag(name, content = nil)
32
- return _retrieve_variable(:"__#{name}") if content.nil?
33
- content = tag(:meta, :name => name, :content => content)
34
- _create_variable(:"__#{name}", content, false)
35
- content
29
+ def meta_tag(name, content)
30
+ tag(:meta, :name => name, :content => content)
36
31
  end
37
-
32
+
38
33
  ##
39
34
  # Create a script tag for activating google analytics
40
35
  # @param [String] site_id The site ID provided by google analytics
41
36
  # @return [String] script tag
42
37
  #
43
38
  def google_analytics(site_id, &block)
44
- return "" if defined?(Rails) && Rails.env != "production"
45
- additional = capture(&block) if block_given?
46
- additional ||= ""
39
+ return "" if defined?(Rails) && Rails.env != "production"
47
40
  content_tag(:script) do
48
41
  %Q{
49
- var _gaq = _gaq || [];
50
- _gaq.push(['_setAccount', #{site_id}]);
51
- _gaq.push(['_trackPageview']);
52
- #{additional}
53
- (function() {
54
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
55
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
56
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
57
- })();
42
+ var _gaq=[['_setAccount','#{site_id}'],['_trackPageview']];
43
+ (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
44
+ g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
45
+ s.parentNode.insertBefore(g,s)}(document,'script'));
46
+ #{(block_given? ? capture(&block) : "")}
58
47
  }
59
48
  end.html_safe
60
49
  end
61
-
50
+
62
51
  ##
63
52
  #
64
53
  # Creates a page id to be used for identifying a page for CSS/design purposes. If a variable
@@ -77,21 +66,13 @@ module Facades
77
66
  #
78
67
  #
79
68
  def page_id(content = nil)
80
- _create_variable(:__page_id, content, false) and return if content
81
- return _retrieve_variable(:__page_id) if content_for?(:__page_id)
82
- result = if defined?(controller)
83
- cname = controller.class.to_s.gsub(/controller$/i,'').underscore.split("/").join('_')
84
- aname = controller.action_name
85
- "#{cname}_#{aname}"
86
- elsif defined?(request) && request.respond_to?(:path_info)
87
- ::File.basename(request.path_info).to_s
88
- end
89
- result
69
+ return (@view_flow.get(:page_id) || default_page_title_for_view) unless content
70
+ provide(:page_id, content) if content
90
71
  end
91
72
 
92
73
  ##
93
74
  #
94
- # Convenienve method to create a page title for the <title></title> tag.
75
+ # Convenience method to create a page title for the <title></title> tag.
95
76
  #
96
77
  # @param [String] content The text for the page title
97
78
  # @return [String] The provided content
@@ -102,29 +83,11 @@ module Facades
102
83
  # <title><%= page_title %></title> #=> <title>This is my page title</title>
103
84
  #
104
85
  def page_title(content = nil)
105
- _create_variable(:__page_title, content, false) and return if content
106
- return _retrieve_variable(:__page_title) if content_for?(:__page_title)
107
- return ""
86
+ provide(:page_title, content) and return if content
87
+ return @view_flow.get(:page_title) unless content
88
+ ""
108
89
  end
109
-
110
- ##
111
- #
112
- # Convenience method for content_for allowing for single-line variable creation. Also defines a method that can be
113
- # re-used within a template.
114
- #
115
- # @param [Symbol] var_name The name of the variable to create
116
- # @param [String] content The content that variable defines
117
- # @return [String] An empty string. Use the newly created method from +var_name+ to return the value
118
- #
119
- # @example Setting a "page_class" variable
120
- # <% set_var(:page_class, 'cool') %>
121
- # <%= page_class %> #=> 'cool'
122
- #
123
- #
124
- def set_var(var_name, content)
125
- _create_variable("#{var_name}", content) and return ''
126
- end
127
-
90
+
128
91
  ##
129
92
  #
130
93
  # Configures a "robots" meta tag based on the rails environment. In environments other than 'production'
@@ -136,26 +99,26 @@ module Facades
136
99
  def robot_meta_tag
137
100
  tag(:meta, :name => 'robots', :content => (Rails.env.eql?('production') ? 'index, follow' : 'noindex, nofollow'))
138
101
  end
102
+
139
103
 
140
104
  private
141
105
 
142
- def _create_variable(var, content, create_method = true) #:nodoc:
143
- content_for(var.to_sym, content)
144
- return '' unless create_method
145
- class_eval <<-MAKE_VAR, __FILE__, __LINE__ + 1
146
- def #{var}
147
- content_for(:#{var})
148
- end
149
- public :#{var}
150
- MAKE_VAR
151
- end
152
-
153
- def _retrieve_variable(var) #:nodoc:
154
- (content_for?(var.to_sym) ? content_for(var.to_sym) : "")
106
+ ##
107
+ # Constructs a default page title from the current
108
+ # controller and action
109
+ #
110
+ def default_page_title_for_view
111
+ if defined?(controller)
112
+ cname = controller.class.to_s.gsub(/controller$/i,'').underscore.split("/").join('_')
113
+ aname = controller.action_name
114
+ "#{cname}_#{aname}"
115
+ elsif defined?(request) && request.respond_to?(:path_info)
116
+ ::File.basename(request.path_info).to_s
117
+ end
118
+ ""
155
119
  end
156
120
 
157
- end
158
-
121
+ end # Layout
159
122
 
160
- end
161
- end
123
+ end # Helpers
124
+ end # Facades