guilded 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ = 1.0.5 2010-01-21
2
+
3
+ * Gave css inclusion a :position option allowing for positioning before or after the component(s) css.
4
+
5
+
1
6
  = 1.0.4 2010-01-04
2
7
 
3
8
  * Fixed a bug with a file include to make guilded work with the bundler gem.
data/README.rdoc CHANGED
@@ -119,7 +119,7 @@ have decided to include support for it in Guilded as of release 0.3.0.
119
119
 
120
120
  Add to environment file:
121
121
 
122
- config.gem "guilded", :version => '1.0.0', :source => 'http://gemcutter.org'
122
+ config.gem "guilded", :version => '1.0.5', :source => 'http://gemcutter.org'
123
123
 
124
124
  Run:
125
125
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
data/guilded.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{guilded}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2010-01-04}
12
+ s.date = %q{2010-01-21}
13
13
  s.description = %q{Guilded intends to provide a toolset for creating and consuming reusable web components. Currently, this problem domain is filled with JavaScript frameworks. These frameworks are wonderful and work very well. However, they do not degrade gracefully and are not accessible (in most cases). Guilded seeks to provide the same level of "componentization" and ease of use without sacrificing degradability and accessibility. Guilded will achieve these goals by applying each technology at our disposal (HTML, CSS and JavaScript) to do as it was intended.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
data/lib/guilded.rb CHANGED
@@ -73,7 +73,7 @@ require 'guilded/rails/inactive_record/human_attribute_hint'
73
73
  # <%= g_load_alerter :skin => 'blueish', :id => 'load_alerter' %>
74
74
  #
75
75
  module Guilded
76
- VERSION = '1.0.4'
76
+ VERSION = '1.0.5'
77
77
  end
78
78
 
79
79
  ActionView::Base.send( :include, Guilded::Rails::ViewHelpers ) if defined?( ActionView )
@@ -35,11 +35,12 @@ module Guilded
35
35
  end
36
36
  configure_guilded
37
37
  @initialized_at = Time.now
38
- @g_elements = Hash.new
39
- @g_data_elements = Hash.new
40
- @combined_js_srcs = Array.new
41
- @combined_css_srcs = Array.new
42
- @assets_combined = false
38
+ @g_elements = {}
39
+ @g_data_elements = {}
40
+ @combined_js_srcs = []
41
+ @combined_css_srcs = []
42
+ @css_temp_hold = { :pre => [], :post => [], :components => [], :reset => [] }
43
+ @valid_css_positions = @css_temp_hold.keys
43
44
  # Make sure that the css reset file is first so that other files can override the reset,
44
45
  # unless the user specified no reset to be included.
45
46
  init_sources
@@ -71,6 +72,10 @@ module Guilded
71
72
  def add_js_sources( *sources )
72
73
  resolve_js_libs( *sources )
73
74
  end
75
+
76
+ def add_css_source( src, position=:post )
77
+ @css_temp_hold[position.to_sym] << src unless @css_temp_hold[position.to_sym].include?( src )
78
+ end
74
79
 
75
80
  def count #:nodoc:
76
81
  @g_elements.size
@@ -103,14 +108,16 @@ module Guilded
103
108
  # The collection of JavaScript assets for the current Guilded component set.
104
109
  #
105
110
  def combined_js_srcs
106
- #generate_asset_lists unless @assets_combined
107
111
  @combined_js_srcs
108
112
  end
109
113
 
110
114
  # The collection of CSS assets for the current Guilded component set.
111
115
  #
112
116
  def combined_css_srcs
113
- #generate_asset_lists unless @assets_combined
117
+ @css_temp_hold[:reset].each { |src| @combined_css_srcs << src }
118
+ @css_temp_hold[:pre].each { |src| @combined_css_srcs << src }
119
+ @css_temp_hold[:components].each { |src| @combined_css_srcs << src }
120
+ @css_temp_hold[:post].each { |src| @combined_css_srcs << src }
114
121
  @combined_css_srcs
115
122
  end
116
123
 
@@ -120,7 +127,8 @@ module Guilded
120
127
  @combined_css_srcs.clear
121
128
  @combined_js_srcs.clear
122
129
  @g_elements.clear
123
- @assets_combined = false
130
+ @css_temp_hold = { :pre => [], :post => [], :components => [], :reset => [] }
131
+ @valid_css_positions = @css_temp_hold.keys
124
132
  init_sources
125
133
  @default_css_count = @combined_css_srcs.size
126
134
  @default_js_count = @combined_js_srcs.size
@@ -139,7 +147,7 @@ module Guilded
139
147
  #
140
148
  def apply #:nodoc:
141
149
  to_init = ""
142
- generate_asset_lists unless @assets_combined
150
+ generate_asset_lists #unless @assets_combined
143
151
  @combined_css_srcs.each { |css| to_init << "<link href=\"/stylesheets/#{css}\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />" }
144
152
  @combined_js_srcs.each { |js| to_init << "<script type=\"text/javascript\" src=\"/javascripts/#{js}\"></script>" }
145
153
  to_init << generate_javascript_init
@@ -174,12 +182,11 @@ module Guilded
174
182
  # and shorter string.
175
183
  #
176
184
  def css_cache_name
177
- generate_css_cache_name( @combined_css_srcs )
185
+ name = generate_css_cache_name( @combined_css_srcs )
186
+ name
178
187
  end
179
188
 
180
189
  def generate_js_cache_name( sources ) #:nodoc:
181
- generate_asset_lists unless @assets_combined
182
- #return"#{controller.class.to_s.underscore}_#{controller.action_name}" if development?
183
190
  sorted_srcs = sources.sort
184
191
  stripped_srcs = sorted_srcs.map { |src| src.gsub( /.js/, '' ).gsub( /\//, '_') }
185
192
  joined = stripped_srcs.join( "+" )
@@ -187,13 +194,25 @@ module Guilded
187
194
  end
188
195
 
189
196
  def generate_css_cache_name( sources ) #:nodoc:
190
- generate_asset_lists unless @assets_combined
191
- #return "#{controller.class.to_s.underscore}_#{controller.action_name}" if development?
192
197
  sorted_srcs = sources.sort
193
198
  stripped_srcs = sorted_srcs.map { |src| src.gsub( /.css/, '' ).gsub( /\//, '_') }
194
199
  joined = stripped_srcs.join( "+" )
195
200
  "#{Digest::MD5.hexdigest( joined )}"
196
201
  end
202
+
203
+ # Combines all JavaScript and CSS files into lists to include based on what Guilded components are on
204
+ # the current page.
205
+ #
206
+ def generate_asset_lists #:nodoc:
207
+ @g_elements.each_value do |defi|
208
+ #TODO get stylesheet (skin) stuff using rails caching
209
+ combine_css_sources( defi.kind, defi.options[:skin], defi.styles ) unless defi.exclude_css?
210
+
211
+ # Combine all JavaScript sources so that the caching option can be used on
212
+ # the javascript_incldue_tag helper.
213
+ combine_js_sources( defi.kind, defi.libs ) unless defi.exclude_js?
214
+ end
215
+ end
197
216
 
198
217
  protected
199
218
 
@@ -209,7 +228,6 @@ module Guilded
209
228
  @css_path = @config[:css_path]
210
229
  @css_folder = @config[:css_folder]
211
230
  @reset_css = @config[:reset_css]
212
- #@do_reset_css = @config[:do_reset_css]
213
231
  @env = @config[:environment]
214
232
  @env ||= :production
215
233
  @js_path.freeze
@@ -224,7 +242,6 @@ module Guilded
224
242
  @guilded_js.freeze
225
243
  @css_folder.freeze
226
244
  @reset_css.freeze
227
- #@do_reset_css.freeze
228
245
  @env.freeze
229
246
  end
230
247
 
@@ -232,24 +249,8 @@ module Guilded
232
249
  # collections.
233
250
  #
234
251
  def init_sources #:nodoc:
235
- @combined_css_srcs << "#{@reset_css}" unless @reset_css.nil? || @reset_css.empty?
252
+ @css_temp_hold[:reset] << "#{@reset_css}" unless @reset_css.nil? || @reset_css.empty?
236
253
  resolve_js_libs( "#{@jquery_js}", "#{@jquery_folder}#{@url_js}", "#{@js_folder}#{@guilded_js}" )
237
- #TODO include the jQuery lib from Google server in production
238
- end
239
-
240
- # Combines all JavaScript and CSS files into lists to include based on what Guilded components are on
241
- # the current page.
242
- #
243
- def generate_asset_lists #:nodoc:
244
- @assets_combined = true
245
- @g_elements.each_value do |defi|
246
- #TODO get stylesheet (skin) stuff using rails caching
247
- combine_css_sources( defi.kind, defi.options[:skin], defi.styles ) unless defi.exclude_css?
248
-
249
- # Combine all JavaScript sources so that the caching option can be used on
250
- # the javascript_incldue_tag helper.
251
- combine_js_sources( defi.kind, defi.libs ) unless defi.exclude_js?
252
- end
253
254
  end
254
255
 
255
256
  # Helper method that takes the libs and component specific js files and puts them
@@ -324,16 +325,16 @@ module Guilded
324
325
  def combine_css_sources( component, skin, styles=[] ) #:nodoc:
325
326
  # Get all of this components defined external styles
326
327
  styles.each do |style|
327
- @combined_css_srcs.push( style ) unless @combined_css_srcs.include?( style )
328
+ @css_temp_hold[:components].push( style ) unless @css_temp_hold[:components].include?( style )
328
329
  end
329
330
 
330
331
  #Get the default or guilded skin styles for this component
331
332
  comp_src = add_guilded_css_path( component, skin )
332
- @combined_css_srcs.push( comp_src ) unless @combined_css_srcs.include?( comp_src ) || comp_src.empty?
333
+ @css_temp_hold[:components].push( comp_src ) unless @css_temp_hold[:components].include?( comp_src ) || comp_src.empty?
333
334
  user_src = add_guilded_css_path( component, "user" )
334
- @combined_css_srcs.push( user_src ) unless @combined_css_srcs.include?( user_src ) || user_src.empty?
335
+ @css_temp_hold[:components].push( user_src ) unless @css_temp_hold[:components].include?( user_src ) || user_src.empty?
335
336
  skin_user_src = add_guilded_css_path( component, "#{skin || 'default'}_user" )
336
- @combined_css_srcs.push( skin_user_src ) unless @combined_css_srcs.include?( skin_user_src ) || skin_user_src.empty?
337
+ @css_temp_hold[:components].push( skin_user_src ) unless @css_temp_hold[:components].include?( skin_user_src ) || skin_user_src.empty?
337
338
  end
338
339
 
339
340
  def add_guilded_css_path( source, skin ) #:nodoc:
@@ -11,9 +11,11 @@ module Guilded
11
11
  # call to g_apply_behavior will not output anything.
12
12
  #
13
13
  def g_apply_behavior
14
- self.output_buffer.sub!( /<!-- guilded.styles -->/, stylesheet_link_tag( Guilded::Guilder.instance.combined_css_srcs, :cache => "cache/#{Guilded::Guilder.instance.css_cache_name}" ) )
15
- html = javascript_include_tag( Guilded::Guilder.instance.combined_js_srcs, :cache => "cache/#{Guilded::Guilder.instance.js_cache_name}" )
16
- html << Guilded::Guilder.instance.generate_javascript_init
14
+ g = Guilded::Guilder.instance
15
+ g.generate_asset_lists
16
+ self.output_buffer.sub!( /<!-- guilded.styles -->/, stylesheet_link_tag( g.combined_css_srcs, :cache => "cache/#{g.css_cache_name}" ) )
17
+ html = javascript_include_tag( g.combined_js_srcs, :cache => "cache/#{g.js_cache_name}" )
18
+ html << g.generate_javascript_init
17
19
  html
18
20
  end
19
21
 
@@ -24,11 +26,11 @@ module Guilded
24
26
  # Generates the base javascript includes, if they have not alreay been included.
25
27
  #
26
28
  # def g_includes
27
- # return "" if @base_included
28
- # @base_included = true
29
- # javascript_include_tag( 'jquery/jquery-1.2.6.min.js' ) +
30
- # "<script type=\"text/javascript\">$j = jQuery.noConflict(); g={};</script>"
31
- # end
29
+ # return "" if @base_included
30
+ # @base_included = true
31
+ # javascript_include_tag( 'jquery/jquery-1.2.6.min.js' ) +
32
+ # "<script type=\"text/javascript\">$j = jQuery.noConflict(); g={};</script>"
33
+ # end
32
34
 
33
35
  # Creates a javascript include tag for a Guilded specific file. The only difference
34
36
  # being that it adds the file to a sources array to be concatenated and included at the
@@ -66,8 +68,8 @@ module Guilded
66
68
  ''
67
69
  end
68
70
 
69
- # Written to replace the Rails stylesheet_link_tag helper. Although the syntax
70
- # is exactly the same, the method works a little differently.
71
+ # Replaces the Rails stylesheet_link_tag helper if you wnat Guilded to manage CSS for you.
72
+ # Although the syntax is exactly the same, the method works a little differently.
71
73
  #
72
74
  # This helper adds the stylesheet(s) to a collection to be renderred out together
73
75
  # with all the guilded componenets stylesheets. This allows the stylesheets passed
@@ -76,16 +78,15 @@ module Guilded
76
78
  # The helper will ensure that these stylesheets are included after Guilded's reset
77
79
  # stylesheet and before guilded's component's stylesheets so that they can override any
78
80
  # resets, etc and not override any guilded components styles.
81
+
82
+ # *options*
83
+ # :position The place to position the css. pre for before the component's css or post for after.
84
+ # Defaults to post.
79
85
  #
80
86
  def g_stylesheet_link_tag( *sources )
81
- options = sources.extract_options!
82
- g = Guilded::Guilder.instance
83
-
84
- if options[:ensure_primary]
85
- g.inject_css( *sources )
86
- else
87
- g.combined_css_srcs.push( *sources )
88
- end
87
+ options = sources.extract_options! || {}
88
+ options[:position] ||= :post
89
+ sources.each { |src| Guilded::Guilder.instance.add_css_source( src, options[:position] ) }
89
90
  ''
90
91
  end
91
92
 
@@ -5,8 +5,6 @@ GUILDED_CONFIG = {
5
5
  :js_path => "#{RAILS_ROOT}/public/javascripts/",
6
6
  :js_folder => "", # from the js_path
7
7
  :jquery_js => "jquery/jquery-1.3.2.min.js", # from the js_path
8
- :use_remote_jquery => false,
9
- :remote_jquery_url => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
10
8
  :mootools_js => "mootools/mootools-1.2.3.min.js", # from the js_path
11
9
  :css_path => "#{RAILS_ROOT}/public/stylesheets/",
12
10
  :css_folder => "guilded/", # from the css_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guilded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson (midas)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-04 00:00:00 -06:00
12
+ date: 2010-01-21 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency