forked from skruse/PLATIN
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
171 lines (153 loc) · 4.61 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Rakefile - create single combined nd compressed javascript file
COMPRESS="java -jar lib/yuicompressor-2.4.2.jar"
COMPRESSED_OUTPUT_FILE='platin-min.js'
OUTPUT_FILE='platin.js'
CSS_FILE='css/platin.css'
task :default => :all
task :all => [COMPRESSED_OUTPUT_FILE, OUTPUT_FILE, CSS_FILE, :copyJqueryUIImageDirectory]
# javascript sources
Files = %w(js/Build/Minifier/basic.js
lib/excanvas/excanvas.js
lib/slider/js/range.js
lib/slider/js/slider.js
lib/slider/js/timer.js
lib/openlayers/OpenLayers.js
lib/stamen/tile.stamen.js
lib/jquery/jquery-deparam.min.js
lib/jquery/jquery.remember.js
lib/jquery/purl.min.js
lib/jquery-ui/jquery-ui-1.10.3.custom.js
lib/jszip/jszip.min.js
lib/sheetjs/shim.js
lib/sheetjs/xls.min.js
lib/sheetjs/xlsx.js
lib/momentjs/moment.js
lib/ucsv/ucsv-1.1.0-min.js
lib/flot/jquery.flot.js
lib/flot/jquery.flot.pie.js
lib/flot/jquery.flot.resize.js
lib/flot/jquery.flot.selection.js
lib/flot/jquery.flot.time.js
lib/flot/jquery.flot.tooltip.js
lib/SimileRemnants.js
js/Util/Tooltips.js
js/GeoTemConfig.js
js/Map/MapControl.js
js/Map/CircleObject.js
js/Util/FilterBar.js
js/Util/Selection.js
js/Map/PlacenameTags.js
js/Map/MapConfig.js
js/Map/MapGui.js
js/Map/MapWidget.js
js/Time/TimeConfig.js
js/Time/TimeGui.js
js/Time/TimeWidget.js
js/Table/TableConfig.js
js/Table/TableGui.js
js/Table/TableWidget.js
js/Table/Table.js
js/Dataloader/Dataloader.js
js/Dataloader/DataloaderConfig.js
js/Dataloader/DataloaderGui.js
js/Dataloader/DataloaderWidget.js
js/FuzzyTimeline/FuzzyTimelineConfig.js
js/FuzzyTimeline/FuzzyTimelineDensity.js
js/FuzzyTimeline/FuzzyTimelineGui.js
js/FuzzyTimeline/FuzzyTimelineRangeBars.js
js/FuzzyTimeline/FuzzyTimelineRangePiechart.js
js/FuzzyTimeline/FuzzyTimelineRangeSlider.js
js/FuzzyTimeline/FuzzyTimelineWidget.js
js/Overlayloader/Overlayloader.js
js/Overlayloader/OverlayloaderConfig.js
js/Overlayloader/OverlayloaderGui.js
js/Overlayloader/OverlayloaderWidget.js
js/PieChart/PieChart.js
js/PieChart/PieChartCategoryChooser.js
js/PieChart/PieChartConfig.js
js/PieChart/PieChartGui.js
js/PieChart/PieChartHashFunctions.js
js/PieChart/PieChartWidget.js
js/Storytelling/Storytelling.js
js/Storytelling/StorytellingConfig.js
js/Storytelling/StorytellingGui.js
js/Storytelling/StorytellingWidget.js
js/LineOverlay/LineOverlay.js
js/LineOverlay/LineOverlayConfig.js
js/LineOverlay/LineOverlayWidget.js
js/Util/DataObject.js
js/Util/Dataset.js
js/Time/TimeDataSource.js
js/Map/Binning.js
js/Map/MapDataSource.js
js/Map/Clustering.js
js/Util/Dropdown.js
js/Map/MapZoomSlider.js
js/Map/MapPopup.js
js/Map/PlacenamePopup.js
js/Util/Publisher.js
js/Util/WidgetWrapper.js
js/Build/Minifier/final.js)
# css sources
Cssfiles = %w(lib/openlayers/theme/default/style.css
lib/jquery-ui/jquery-ui-1.10.3.custom.css
css/style.css)
def cat_files(outputfile, basename)
File.open(outputfile, 'a') do |x|
Files.each do |f|
x.puts(File.open(f).read.gsub('REPLACEME-REPLACEME', basename))
end
end
end
file CSS_FILE => Cssfiles do
File.open(CSS_FILE, 'w') do |x|
Cssfiles.each do |f|
x.puts(File.open(f).read)
end
end
end
# Just one big JS file, no compression.
file OUTPUT_FILE => Files do
basename = File.basename(OUTPUT_FILE, ".js")
File.open(OUTPUT_FILE, 'w') do |x|
x.puts("(function($){\n\nvar jQuery = $;");
end
cat_files(OUTPUT_FILE, basename)
File.open(OUTPUT_FILE, 'a') do |x|
x.puts("})(jQuery);");
end
end
task :copyJqueryUIImageDirectory do
@source = "./lib/jquery-ui/images"
@target = "./css/images"
@includePattern = "/**/*"
FileUtils.rm_rf(@target) #remove target directory (if exists)
FileUtils.mkdir_p(@target) #create the target directory
files = FileList.new().include("#{@source}#{@includePattern}");
files.each do |file|
#create target location file string (replace source with target in path)
targetLocation = file.sub(@source, @target)
#ensure directory exists
FileUtils.mkdir_p(File.dirname(targetLocation));
#copy the file
FileUtils.cp_r(file, targetLocation)
end
end
# Compress it.
file COMPRESSED_OUTPUT_FILE => Files do
basename = File.basename(COMPRESSED_OUTPUT_FILE, ".js")
File.open(OUTPUT_FILE, 'w') do |x|
x.puts("(function($){\n\nvar jQuery = $;");
end
cat_files(OUTPUT_FILE, basename)
File.open(OUTPUT_FILE, 'a') do |x|
x.puts("})(jQuery);");
end
system "#{COMPRESS} #{OUTPUT_FILE} >> #{COMPRESSED_OUTPUT_FILE}"
end
# Clean up the whole thing.
task :clean do
rm OUTPUT_FILE
rm COMPRESSED_OUTPUT_FILE
rm CSS_FILE
end