compass-jquery-plugin 0.2.2.4 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,76 @@
1
+ require 'fileutils'
2
+ require 'lib/handle_js_files'
3
+
4
+ CALENDAR_SRC = File.join(GEM_ROOT, 'src', 'calendar')
5
+ CALENDAR_SRC_TRANSLATIONS = File.join(CALENDAR_SRC, 'js', 'i18n') + "/*.js"
6
+
7
+ CALENDAR_DEST_TEMPLATES = File.join(GEM_ROOT, 'templates', 'calendar')
8
+ CALENDAR_DEST_STYLESHEETS = File.join(CALENDAR_DEST_TEMPLATES, 'jquery.ui')
9
+ CALENDAR_DEST_TRANSLATIONS = File.join(CALENDAR_DEST_TEMPLATES, 'i18n', 'calendar')
10
+
11
+ CALENDAR_MESSAGE1 = "# Generated by compass-jquery-plugin/gem-tasks/calendar.rake\n# Install with: compass -f jquery -p calendar\n\n"
12
+ CALENDAR_MESSAGE2 = "// Generated by compass-jquery-plugin/gem-tasks/calendar.rake\n\n"
13
+
14
+ all_scripts = [
15
+ 'js/jquery.weekcalendar.js',
16
+ 'js/jMonthCalendar.js'
17
+ ].collect {|filename| File.read(File.join(CALENDAR_SRC, filename))}.join "\n\n"
18
+
19
+ all_stylesheets = [
20
+ 'jquery.weekcalendar.css',
21
+ 'jMonthCalendar.css'
22
+ ].collect {|filename| File.read(File.join(CALENDAR_SRC, 'css', filename))}.join "\n\n"
23
+
24
+ namespace :calendar do
25
+ desc 'Build the stylesheets and templates for calendar.'
26
+ task :build do
27
+
28
+ FileUtils.remove_dir CALENDAR_DEST_TEMPLATES if File.exists? CALENDAR_DEST_TEMPLATES
29
+ FileUtils.mkdir_p(File.join(CALENDAR_DEST_TEMPLATES, 'config', 'initializers'))
30
+
31
+ open File.join(CALENDAR_DEST_TEMPLATES, 'manifest.rb'), 'w' do |manifest|
32
+ manifest.print CALENDAR_MESSAGE1
33
+
34
+ open File.join(CALENDAR_DEST_TEMPLATES, 'config', 'initializers', 'calendar.rb'), 'w' do |f|
35
+ f.print(File.read(File.join(CALENDAR_SRC, 'config', 'initializers', 'calendar.rb')))
36
+ end
37
+ manifest.print "file 'config/initializers/calendar.rb'\n"
38
+
39
+ open File.join(CALENDAR_DEST_TEMPLATES, 'jquery.calendar.js'), 'w' do |f|
40
+ f.print concat_files(all_scripts)
41
+ end
42
+ manifest.print "javascript 'jquery.calendar.js'\n"
43
+
44
+ open File.join(CALENDAR_DEST_TEMPLATES, 'jquery.calendar.min.js'), 'w' do |f|
45
+ f.print compress_js(all_scripts)
46
+ end
47
+ manifest.print "javascript 'jquery.calendar.min.js'\n"
48
+
49
+ # ['i18n'].each do |path|
50
+ # FileUtils.mkdir_p File.join(CALENDAR_DEST_TRANSLATIONS)
51
+ # Dir.foreach File.join(CALENDAR_SRC, 'js', path) do |file|
52
+ # next unless /\.js$/ =~ file
53
+ # js = File.read File.join(CALENDAR_SRC, 'js', path, file)
54
+ # file.gsub!(/^grid\./,'')
55
+ # manifest.print "javascript '#{File.join(path, 'calendar', file)}'\n"
56
+ # open File.join(CALENDAR_DEST_TRANSLATIONS, file), 'w' do |f|
57
+ # f.write js
58
+ # end
59
+ # file.gsub!(/\.js$/, '.min.js')
60
+ # manifest.print "javascript '#{File.join(path, 'calendar', file)}'\n"
61
+ # open File.join(CALENDAR_DEST_TRANSLATIONS, file), 'w' do |f|
62
+ # f.write compress_js(js)
63
+ # end
64
+ # end
65
+ # end
66
+
67
+ FileUtils.mkdir_p File.join(CALENDAR_DEST_STYLESHEETS)
68
+ open File.join(CALENDAR_DEST_STYLESHEETS, 'calendar.sass'), 'w' do |f|
69
+ sass = CALENDAR_MESSAGE2
70
+ IO.popen("css2sass", 'r+') { |ff| ff.print(all_stylesheets); ff.close_write; sass += ff.read }
71
+ f.print sass
72
+ end
73
+ manifest.print "stylesheet 'jquery.ui/calendar.sass'\n"
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,77 @@
1
+ require 'fileutils'
2
+ require 'lib/handle_js_files'
3
+
4
+ # Compass generator for dynatree 3.5+
5
+ DYNATREE_SRC = File.join(GEM_ROOT, 'src', 'dynatree')
6
+ DYNATREE_SRC_SKINS = File.join(DYNATREE_SRC, 'skins')
7
+
8
+ DYNATREE_DEST_TEMPLATES = File.join(GEM_ROOT, 'templates', 'dynatree')
9
+ DYNATREE_DEST_SKINS = File.join(DYNATREE_DEST_TEMPLATES, 'jquery.ui')
10
+ DYNATREE_DEST_IMAGES = File.join(DYNATREE_DEST_TEMPLATES, 'jquery.ui')
11
+
12
+ DYNATREE_MESSAGE1 = "# Generated by compass-jquery-plugin/gem-tasks/dynatree.rake\n# Install with: compass -f jquery -p dynatree\n\n"
13
+ DYNATREE_MESSAGE2 = "// Generated by compass-jquery-plugin/gem-tasks/dynatree.rake\n\n"
14
+
15
+ all_scripts = [
16
+ 'js/jquery.dynatree.js'
17
+ ].collect {|filename| File.read(File.join(DYNATREE_SRC, filename))}.join "\n\n"
18
+
19
+ namespace :dynatree do
20
+ desc 'Build the stylesheets and templates for dynatree.'
21
+ task :build do
22
+
23
+ FileUtils.remove_dir DYNATREE_DEST_TEMPLATES if File.exists? DYNATREE_DEST_TEMPLATES
24
+ FileUtils.mkdir_p(File.join(DYNATREE_DEST_TEMPLATES, 'config', 'initializers'))
25
+
26
+ open File.join(DYNATREE_DEST_TEMPLATES, 'manifest.rb'), 'w' do |manifest|
27
+ manifest.print DYNATREE_MESSAGE1
28
+
29
+ open File.join(DYNATREE_DEST_TEMPLATES, 'config', 'initializers', 'dynatree.rb'), 'w' do |f|
30
+ f.print(File.read(File.join(DYNATREE_SRC, 'config', 'initializers', 'dynatree.rb')))
31
+ end
32
+ manifest.print "file 'config/initializers/dynatree.rb'\n"
33
+
34
+ open File.join(DYNATREE_DEST_TEMPLATES, 'jquery.dynatree.js'), 'w' do |f|
35
+ f.print concat_files(all_scripts)
36
+ end
37
+ manifest.print "javascript 'jquery.dynatree.js'\n"
38
+
39
+ open File.join(DYNATREE_DEST_TEMPLATES, 'jquery.dynatree.min.js'), 'w' do |f|
40
+ f.print compress_js(all_scripts)
41
+ end
42
+ manifest.print "javascript 'jquery.dynatree.min.js'\n"
43
+
44
+ # jQuery DynaTreee Skins
45
+
46
+ FileUtils.mkdir_p(File.join(DYNATREE_DEST_SKINS))
47
+
48
+ Dir.foreach DYNATREE_SRC_SKINS do |skin|
49
+ next if /^\./ =~ skin
50
+
51
+ # Convert the stylesheet
52
+
53
+ Dir.foreach File.join(DYNATREE_SRC_SKINS, "#{skin}") do |file|
54
+ next unless /\.css$/ =~ file
55
+ css = File.read File.join(DYNATREE_SRC_SKINS, "#{skin}", file)
56
+ sass = ''
57
+ IO.popen("css2sass", 'r+') { |f| f.print(css); f.close_write; sass = f.read }
58
+ open File.join(DYNATREE_DEST_SKINS, "dynatree.#{skin}.sass"), 'w' do |f|
59
+ f.write DYNATREE_MESSAGE2 + sass
60
+ end
61
+ manifest.print "stylesheet 'jquery.ui/dynatree.#{skin}.sass', :media => 'screen, projection'\n"
62
+ end
63
+
64
+ # Copy the skin images directory
65
+ src_dir = File.join(DYNATREE_SRC_SKINS, skin, 'images')
66
+ dest_dir = File.join(DYNATREE_DEST_IMAGES, "dynatree.#{skin}")
67
+ FileUtils.mkdir_p dest_dir
68
+
69
+ Dir.foreach(src_dir) do |image|
70
+ next if /^\./ =~ image
71
+ FileUtils.cp(File.join(src_dir, image), dest_dir)
72
+ manifest.print "image 'jquery.ui/dynatree.#{skin}/#{image}'\n"
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,109 @@
1
+ require 'fileutils'
2
+ require 'lib/handle_js_files'
3
+
4
+ # Compass generator for jqGrid 3.5+
5
+ JQGRID_SRC = File.join(GEM_ROOT, 'src', 'jqgrid')
6
+ JQGRID_SRC_LOCALES = File.join(JQGRID_SRC, 'config', 'locales')
7
+ JQGRID_SRC_TRANSLATIONS = File.join(JQGRID_SRC, 'js', 'i18n') + "/*.js"
8
+
9
+ JQGRID_DEST_TEMPLATES = File.join(GEM_ROOT, 'templates', 'jqgrid')
10
+ JQGRID_DEST_LOCALES = File.join(JQGRID_DEST_TEMPLATES, 'config', 'locales', 'jquery', 'jqgrid')
11
+ JQGRID_DEST_STYLESHEETS = File.join(JQGRID_DEST_TEMPLATES, 'jquery.ui')
12
+ JQGRID_DEST_TRANSLATIONS = File.join(JQGRID_DEST_TEMPLATES, 'i18n', 'jqgrid')
13
+
14
+ JQGRID_MESSAGE1 = "# Generated by compass-jquery-plugin/gem-tasks/jqgrid.rake\n# Install with: compass -f jquery -p jqgrid\n\n"
15
+ JQGRID_MESSAGE2 = "// Generated by compass-jquery-plugin/gem-tasks/jqgrid.rake\n\n"
16
+
17
+ all_scripts = [
18
+ 'js/grid.base.js',
19
+ 'js/grid.celledit.js',
20
+ 'js/grid.common.js',
21
+ 'js/grid.custom.js',
22
+ 'js/grid.formedit.js',
23
+ 'js/grid.import.js',
24
+ 'js/grid.inlinedit.js',
25
+ 'js/grid.jqueryui.js',
26
+ 'js/grid.postext.js',
27
+ 'js/grid.setcolumns.js',
28
+ 'js/grid.subgrid.js',
29
+ 'js/grid.tbltogrid.js',
30
+ 'js/grid.treegrid.js',
31
+ 'js/jqDnR.js',
32
+ 'js/jqModal.js',
33
+ 'js/jquery.fmatter.js',
34
+ 'js/jquery.searchFilter.js',
35
+ 'js/JsonXml.js',
36
+ 'plugins/jquery.contextmenu.js',
37
+ 'plugins/jquery.tablednd.js'
38
+ ].collect {|filename| File.read(File.join(JQGRID_SRC, filename))}.join "\n\n"
39
+
40
+ all_stylesheets = [
41
+ 'ui.jqgrid.css',
42
+ 'jquery.searchFilter.css'
43
+ ].collect {|filename| File.read(File.join(JQGRID_SRC, 'css', filename))}.join "\n\n"
44
+
45
+ namespace :jqgrid do
46
+ desc 'Build the stylesheets and templates for jqGrid.'
47
+ task :build do
48
+
49
+ FileUtils.remove_dir JQGRID_DEST_TEMPLATES if File.exists? JQGRID_DEST_TEMPLATES
50
+ FileUtils.mkdir_p(File.join(JQGRID_DEST_TEMPLATES, 'config', 'initializers'))
51
+
52
+ open File.join(JQGRID_DEST_TEMPLATES, 'manifest.rb'), 'w' do |manifest|
53
+ manifest.print JQGRID_MESSAGE1
54
+
55
+ open File.join(JQGRID_DEST_TEMPLATES, 'config', 'initializers', 'jqgrid.rb'), 'w' do |f|
56
+ f.print(File.read(File.join(JQGRID_SRC, 'config', 'initializers', 'jqgrid.rb')))
57
+ end
58
+ manifest.print "file 'config/initializers/jqgrid.rb'\n"
59
+
60
+ ['jqgrid'].each do |path|
61
+ FileUtils.mkdir_p(JQGRID_DEST_LOCALES)
62
+ Dir.foreach File.join(JQGRID_SRC_LOCALES, 'jquery', path) do |file|
63
+ next unless /\.yml$/ =~ file
64
+ yaml = File.read File.join(JQGRID_SRC_LOCALES, 'jquery', path, file)
65
+ manifest.print "file 'config/locales/jquery/jqgrid/#{file}'\n"
66
+ open File.join(JQGRID_DEST_LOCALES, file), 'w' do |f|
67
+ f.write yaml
68
+ end
69
+ end
70
+ end
71
+
72
+ open File.join(JQGRID_DEST_TEMPLATES, 'jquery.jqGrid.js'), 'w' do |f|
73
+ f.print concat_files(all_scripts)
74
+ end
75
+ manifest.print "javascript 'jquery.jqGrid.js'\n"
76
+
77
+ open File.join(JQGRID_DEST_TEMPLATES, 'jquery.jqGrid.min.js'), 'w' do |f|
78
+ f.print compress_js(all_scripts)
79
+ end
80
+ manifest.print "javascript 'jquery.jqGrid.min.js'\n"
81
+
82
+ ['i18n'].each do |path|
83
+ FileUtils.mkdir_p File.join(JQGRID_DEST_TRANSLATIONS)
84
+ Dir.foreach File.join(JQGRID_SRC, 'js', path) do |file|
85
+ next unless /\.js$/ =~ file
86
+ js = File.read File.join(JQGRID_SRC, 'js', path, file)
87
+ file.gsub!(/^grid\./,'')
88
+ manifest.print "javascript '#{File.join(path, 'jqgrid', file)}'\n"
89
+ open File.join(JQGRID_DEST_TRANSLATIONS, file), 'w' do |f|
90
+ f.write js
91
+ end
92
+ file.gsub!(/\.js$/, '.min.js')
93
+ manifest.print "javascript '#{File.join(path, 'jqgrid', file)}'\n"
94
+ open File.join(JQGRID_DEST_TRANSLATIONS, file), 'w' do |f|
95
+ f.write compress_js(js)
96
+ end
97
+ end
98
+ end
99
+
100
+ FileUtils.mkdir_p File.join(JQGRID_DEST_STYLESHEETS)
101
+ open File.join(JQGRID_DEST_STYLESHEETS, 'jqGrid.sass'), 'w' do |f|
102
+ sass = JQGRID_MESSAGE2
103
+ IO.popen("css2sass", 'r+') { |ff| ff.print(all_stylesheets); ff.close_write; sass += ff.read }
104
+ f.print sass
105
+ end
106
+ manifest.print "stylesheet 'jquery.ui/jqGrid.sass'\n"
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,336 @@
1
+ require 'fileutils'
2
+ require 'lib/handle_js_files'
3
+
4
+ # Compass generator for jrails 0.1+
5
+ JRAILS_SRC = File.join(GEM_ROOT, 'src', 'jrails')
6
+ JRAILS_SRC_SCRIPTS = JRAILS_SRC + "/*.js"
7
+
8
+ JQUERY_SRC = File.join(GEM_ROOT, 'src', 'jquery-1.3.2')
9
+ JQUERY_SRC_SCRIPTS = JQUERY_SRC + "/*.js"
10
+
11
+ JQUERY_UI_SRC = File.join(GEM_ROOT, 'src', 'jquery.ui-1.7.2')
12
+ JQUERY_UI_SRC_SCRIPTS = File.join(JQUERY_UI_SRC, 'js') + "/*.js"
13
+ JQUERY_UI_SRC_THEMES = File.join(JQUERY_UI_SRC, 'themes')
14
+ JQUERY_UI_SRC_TRANSLATIONS = File.join(JQUERY_UI_SRC, 'js', 'i18n') #+ "/*.js"
15
+
16
+ JRAILS_DEST_TEMPLATES = File.join(GEM_ROOT, 'templates', 'jrails')
17
+ JRAILS_DEST_TRANSLATIONS = File.join(JRAILS_DEST_TEMPLATES, 'i18n', 'jquery.ui')
18
+ JRAILS_DEST_THEMES = File.join(JRAILS_DEST_TEMPLATES, 'jquery.ui')
19
+ JRAILS_DEST_IMAGES = File.join(JRAILS_DEST_TEMPLATES, 'jquery.ui')
20
+
21
+ JRAILS_MESSAGE1 = "# Generated by compass-jquery-plugin/gem-tasks/jrails.rake\n# Install with: compass -f jquery -p jrails\n\n"
22
+ JRAILS_MESSAGE2 = "// Generated by compass-jquery-plugin/gem-tasks/jrails.rake\n\n"
23
+
24
+ namespace :jrails do
25
+ desc 'Build the stylesheets and templates for jRails.'
26
+ task :build do
27
+
28
+ FileUtils.remove_dir JRAILS_DEST_TEMPLATES if File.exists? JRAILS_DEST_TEMPLATES
29
+ FileUtils.mkdir_p(File.join(JRAILS_DEST_TEMPLATES, 'config', 'initializers'))
30
+
31
+ open File.join(JRAILS_DEST_TEMPLATES, 'manifest.rb'), 'w' do |manifest|
32
+
33
+ # jRails
34
+
35
+ manifest.print JRAILS_MESSAGE1
36
+
37
+ open File.join(JRAILS_DEST_TEMPLATES, 'config', 'initializers', 'jrails.rb'), 'w' do |f|
38
+ f.print(File.read(File.join(JRAILS_SRC, 'config', 'initializers', 'jrails.rb')))
39
+ end
40
+ manifest.print "file 'config/initializers/jrails.rb'\n"
41
+
42
+ open File.join(JRAILS_DEST_TEMPLATES, 'jrails.js'), 'w' do |f|
43
+ f.print concat_files(all_files(JRAILS_SRC_SCRIPTS))
44
+ end
45
+ manifest.print "javascript 'jrails.js'\n"
46
+
47
+ open File.join(JRAILS_DEST_TEMPLATES, 'jrails.min.js'), 'w' do |f|
48
+ f.print compress_js(all_files(JRAILS_SRC_SCRIPTS))
49
+ end
50
+ manifest.print "javascript 'jrails.min.js'\n"
51
+
52
+ # jQuery
53
+
54
+ open File.join(JRAILS_DEST_TEMPLATES, 'jquery.js'), 'w' do |f|
55
+ f.print concat_files(all_files(JQUERY_SRC_SCRIPTS))
56
+ end
57
+ manifest.print "javascript 'jquery.js'\n"
58
+
59
+ open File.join(JRAILS_DEST_TEMPLATES, 'jquery.min.js'), 'w' do |f|
60
+ f.print compress_js(all_files(JQUERY_SRC_SCRIPTS))
61
+ end
62
+ manifest.print "javascript 'jquery.min.js'\n"
63
+
64
+ # jQuery Plugins
65
+
66
+ ['plugins'].each do |path|
67
+ Dir.foreach File.join(JQUERY_SRC, path) do |file|
68
+ next unless /\.js$/ =~ file
69
+ js = File.read File.join(JQUERY_SRC, path, file)
70
+ manifest.print "javascript '#{file}'\n"
71
+ open File.join(JRAILS_DEST_TEMPLATES, file), 'w' do |f|
72
+ f.write js
73
+ end
74
+ file.gsub!(/\.js$/, '.min.js')
75
+ manifest.print "javascript '#{file}'\n"
76
+ open File.join(JRAILS_DEST_TEMPLATES, file), 'w' do |f|
77
+ f.write compress_js(js)
78
+ end
79
+ end
80
+ end
81
+
82
+ # jQuery.UI
83
+
84
+ # Scripts
85
+
86
+ all_jquery_ui_scripts = [
87
+ 'jquery-ui-1.7.2.custom.js',
88
+ 'effects.blind.js',
89
+ 'effects.bounce.js',
90
+ 'effects.clip.js',
91
+ 'effects.core.js',
92
+ 'effects.drop.js',
93
+ 'effects.explode.js',
94
+ 'effects.fold.js',
95
+ 'effects.highlight.js',
96
+ 'effects.pulsate.js',
97
+ 'effects.scale.js',
98
+ 'effects.shake.js',
99
+ 'effects.slide.js',
100
+ 'effects.transfer.js',
101
+ 'effects.blind.js',
102
+ 'ui.accordion.js',
103
+ 'ui.core.js',
104
+ 'ui.datepicker.js',
105
+ 'ui.dialog.js',
106
+ 'ui.draggable.js',
107
+ 'ui.droppable.js',
108
+ 'ui.progressbar.js',
109
+ 'ui.resizable.js',
110
+ 'ui.selectable.js',
111
+ 'ui.slider.js',
112
+ 'ui.sortable.js',
113
+ 'ui.tabs.js'
114
+ ].collect {|filename| File.read(File.join(JQUERY_UI_SRC, 'js', filename))}.join "\n\n"
115
+
116
+ open File.join(JRAILS_DEST_TEMPLATES, 'jquery-ui.js'), 'w' do |f|
117
+ f.print concat_files(all_jquery_ui_scripts)
118
+ end
119
+ manifest.print "javascript 'jquery-ui.js'\n"
120
+
121
+ open File.join(JRAILS_DEST_TEMPLATES, 'jquery-ui.min.js'), 'w' do |f|
122
+ f.print compress_js(all_jquery_ui_scripts)
123
+ end
124
+ manifest.print "javascript 'jquery-ui.min.js'\n"
125
+
126
+ # jQuery UI locales
127
+
128
+ # FileUtils.mkdir_p File.join(JRAILS_DEST_TEMPLATES, 'i18n')
129
+ # open File.join(JRAILS_DEST_TEMPLATES, 'i18n', 'jquery.ui.locale.js'), 'w' do |f|
130
+ # f.print concat_files(all_files(JQUERY_UI_SRC_TRANSLATIONS))
131
+ # end
132
+ # manifest.print "javascript 'i18n/jquery.ui.locale.js'\n"
133
+ #
134
+ # open File.join(JRAILS_DEST_TEMPLATES, 'i18n', 'jquery.ui.locale.min.js'), 'w' do |f|
135
+ # f.print compress_js(all_files(JQUERY_UI_SRC_TRANSLATIONS))
136
+ # end
137
+ # manifest.print "javascript 'i18n/jquery.ui.locale.min.js'\n"
138
+
139
+ ['i18n'].each do |path|
140
+ FileUtils.mkdir_p File.join(JRAILS_DEST_TRANSLATIONS)
141
+ Dir.foreach JQUERY_UI_SRC_TRANSLATIONS do |file|
142
+ next unless /^ui\.datepicker-(.+)\.js$/ =~ file
143
+ lang = file
144
+ #lang.gsub!(/^ui\.datepicker-(.+)\.js$/, '')
145
+ #puts lang
146
+ js = File.read File.join(JQUERY_UI_SRC_TRANSLATIONS, file)
147
+ file.gsub!(/^ui\./,'')
148
+ manifest.print "javascript '#{File.join(path, 'jquery.ui', file)}'\n"
149
+ open File.join(JRAILS_DEST_TRANSLATIONS, file), 'w' do |f|
150
+ f.write js
151
+ end
152
+ file.gsub!(/\.js$/, '.min.js')
153
+ manifest.print "javascript '#{File.join(path, 'jquery.ui', file)}'\n"
154
+ open File.join(JRAILS_DEST_TRANSLATIONS, file), 'w' do |f|
155
+ f.write compress_js(js)
156
+ end
157
+ end
158
+ end
159
+
160
+ # jQuery UI Themes
161
+
162
+ FileUtils.mkdir_p(File.join(JRAILS_DEST_THEMES))
163
+
164
+ ui = JqueryUiTheme.new(File.join(JQUERY_UI_SRC_THEMES, 'base'))
165
+ ui.convert_css(File.join(JRAILS_DEST_THEMES, '_partials'))
166
+
167
+ all_jquery_ui_stylesheets = [
168
+ '_core.sass',
169
+ '_accordion.sass',
170
+ '_datepicker.sass',
171
+ '_dialog.sass',
172
+ '_progressbar.sass',
173
+ '_resizable.sass',
174
+ '_slider.sass',
175
+ '_tabs.sass',
176
+ '_theme.sass'
177
+ ].collect {|filename| File.read(File.join(JRAILS_DEST_THEMES, '_partials', filename))}.join "\n\n"
178
+
179
+ open File.join(JRAILS_DEST_THEMES, '_theme.sass'), 'w' do |f|
180
+ sass = JRAILS_MESSAGE2
181
+ f.print(all_jquery_ui_stylesheets)
182
+ f.print sass
183
+ FileUtils.rm_r(File.join(JRAILS_DEST_THEMES, '_partials'))
184
+ end
185
+ manifest.print "stylesheet 'jquery.ui/_theme.sass', :media => 'screen, projection'\n"
186
+
187
+ Dir.foreach JQUERY_UI_SRC_THEMES do |theme|
188
+ next if /^\./ =~ theme
189
+
190
+ # Convert the stylesheet
191
+ manifest.print "stylesheet 'jquery.ui/#{theme}.sass', :media => 'screen, projection'\n"
192
+ ui.convert_theme(theme, File.join(JQUERY_UI_SRC_THEMES, theme), File.join(JRAILS_DEST_THEMES))
193
+
194
+ # Copy the theme images directory
195
+ src_dir = File.join(JQUERY_UI_SRC_THEMES, theme, 'images')
196
+ dest_dir = File.join(JRAILS_DEST_IMAGES, theme)
197
+ FileUtils.mkdir_p dest_dir
198
+
199
+ Dir.foreach(src_dir) do |image|
200
+ next if /^\./ =~ image
201
+ FileUtils.cp(File.join(src_dir, image), dest_dir)
202
+ manifest.print "image 'jquery.ui/#{theme}/#{image}'\n"
203
+ end
204
+ end
205
+ end
206
+ end
207
+
208
+ desc 'Remove the prototype / script.aculo.us javascript files'
209
+ task :scrub_default_js do
210
+ files = %W[controls.js dragdrop.js effects.js prototype.js]
211
+ project_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
212
+ files.each do |fname|
213
+ FileUtils.rm File.join(project_dir, fname)
214
+ end
215
+ end
216
+ end
217
+
218
+ class JqueryUiTheme
219
+
220
+ VARIABLE_NAME_BASE = 'ui_'
221
+ VARIABLE_MATCHER = /(\S*)\/\*\{(\w*)\}\*\//
222
+ THEME_FILENAME = 'ui.theme.css'
223
+
224
+ attr_accessor :base_theme
225
+
226
+ # Initialize with the base theme
227
+ def initialize(base_theme_directory)
228
+ @base_theme_directory = base_theme_directory
229
+ @base_theme = File.read(File.join(@base_theme_directory, THEME_FILENAME))
230
+ if @base_theme[3775..3794] == "#363636/*{fcError}*/"
231
+ print "Fixing up bug in 1.7.1 template\n"
232
+ @base_theme[3775..3794] == "#cd0a0a/*{fcError}*/"
233
+ end
234
+ if @base_theme[416,16] == ".ui-widget input"
235
+ print "Fixing up bug in 1.7.2 template\n"
236
+ @base_theme[416,0] = ".ui-widget .ui-widget { font-size: 1em; }\n"
237
+ end
238
+ end
239
+
240
+ # This sets up the Regexp that will extract the variables from a theme
241
+ def regexp
242
+ return @regexp if @regexp
243
+ placeholder = '___PLACEHOLDER___'
244
+ @regexp = @base_theme.dup
245
+ # Install placeholders for the variable data
246
+ @regexp.gsub!(VARIABLE_MATCHER) {placeholder}
247
+ # Strip the header comments
248
+ @regexp.gsub! /.*^\*\/\s*/m, ''
249
+ # Collapse all whitespace
250
+ @regexp.gsub! /\s+/, ' '
251
+ # Escape the literal strings
252
+ @regexp = Regexp.escape(@regexp)
253
+ # Whitespace means nothing
254
+ @regexp.gsub! /\\\ /, '\s+'
255
+ # Fast variable finder
256
+ @regexp.gsub! placeholder, '([^;]*|\S*)'
257
+ # Get 'er done
258
+ @regexp = Regexp.new(@regexp)
259
+ end
260
+
261
+ # You can zip this with the regexp captures to create a variable hash
262
+ def regexp_variables
263
+ return @regexp_variables if @regexp_variables
264
+ @regexp_variables = Array.new
265
+ @base_theme.scan(VARIABLE_MATCHER) {@regexp_variables << $2}
266
+ @regexp_variables
267
+ end
268
+
269
+ # Convert all the ui.*.css files into sass goodness
270
+ def convert_css(stylesheets)
271
+ FileUtils.mkdir_p(File.join(stylesheets))
272
+ Dir.foreach @base_theme_directory do |file|
273
+ next unless /^ui\..*\.css$/ =~ file
274
+ next if %w{ui.all.css ui.base.css}.include? file
275
+ css = File.read(File.join(@base_theme_directory, file))
276
+ open File.join(stylesheets, '_' + file.gsub(/\.css$/,'.sass').gsub(/^ui\./,'')), 'w' do |f|
277
+ if file == THEME_FILENAME
278
+ f.print(self.class.theme_css2sass(@base_theme))
279
+ else
280
+ f.print(self.class.css2sass(css))
281
+ end
282
+ f.close
283
+ end
284
+ end
285
+ end
286
+
287
+ # Create a sass file of variables names and copy the images
288
+ def convert_theme(name, dir, stylesheets)
289
+ if name == 'base'
290
+ theme = @base_theme
291
+ else
292
+ theme = File.read(File.join(dir, THEME_FILENAME))
293
+ end
294
+ FileUtils.mkdir_p stylesheets
295
+ # Figure out the variables with the regexp
296
+ vars = Hash.new
297
+ regexp.match(theme).captures.each_with_index do |capture, index|
298
+ # Remove variable comments
299
+ capture.gsub! /\/\*\{\w*\}\*\/$/, ''
300
+ # Update url
301
+ capture.gsub! /^url\(images(.*)\)/, "image_url(\"jquery.ui/#{name}\\1\")"
302
+ # Quote most things
303
+ capture = "\"#{capture}\"" if capture =~ /[^#%0-9a-fptxm\-]/ and !(capture =~ /^image_url/)
304
+ vars[VARIABLE_NAME_BASE + regexp_variables[index]] ||= capture
305
+ end
306
+ # Write out the theme sass
307
+ open File.join(stylesheets, "#{name}.sass"), 'w' do |f|
308
+ f.print JRAILS_MESSAGE2
309
+ # Preserve header comment (css2sass currently doesn't convert comments)
310
+ theme =~ /\/\*\s*(.*)^\*\//m
311
+ $1.each {|line| f.print line.gsub(/^(\s*\*\s*)/,'// ')}
312
+ f.print "\n"
313
+ vars.each do |variable_name, value|
314
+ f.print "!#{variable_name} ||= #{value}\n"
315
+ end
316
+ f.print "\n@import jquery.ui/_theme.sass\n"
317
+ end
318
+ end
319
+
320
+ # Converter for ui.theme.css which has the variable names
321
+ def self.theme_css2sass(theme_css)
322
+ # Install variable names and convert to sass
323
+ sass = css2sass(theme_css.gsub(VARIABLE_MATCHER){"!#{VARIABLE_NAME_BASE}#{$2}"})
324
+ # Convert select lines from literal to programatic syntax
325
+ sass.gsub!(/.*/){|x| /\!/=~x ? x.gsub(/:/,'=').gsub(/ solid /, ' "solid" ') : x}
326
+ sass
327
+ end
328
+
329
+ # Sass is simply awesome
330
+ def self.css2sass(css)
331
+ sass = ''
332
+ IO.popen("css2sass", 'r+') { |f| f.print(css); f.close_write; sass = f.read }
333
+ return sass
334
+ end
335
+ end
336
+