ymdp 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/ymdp/application.rb +22 -0
- data/lib/ymdp/application_view.rb +312 -0
- data/lib/ymdp/base.rb +119 -0
- data/lib/ymdp/commands/build.rb +0 -6
- data/lib/ymdp/compiler/base.rb +12 -10
- data/lib/ymdp/compiler/domains.rb +8 -34
- data/lib/ymdp/compiler/template.rb +58 -85
- data/lib/ymdp/configuration/config.rb +70 -28
- data/lib/ymdp/configuration/constants.rb +17 -3
- data/lib/ymdp/processor/form_post.rb +5 -1
- data/lib/ymdp/support/file.rb +29 -11
- data/lib/ymdp/tasks/keys.rake +13 -13
- data/lib/ymdp/tasks/ymdp.rake +4 -4
- data/spec/application_spec.rb +29 -0
- data/spec/application_view_spec.rb +5 -0
- data/spec/compiler_spec.rb +3 -3
- data/spec/compiler_template_spec.rb +26 -54
- data/spec/data/app/views/layouts/application.html.haml +2 -0
- data/spec/data/config/config.yml +1 -0
- data/spec/data/config/constants.rb +3 -7
- data/spec/data/script/destroy +2 -2
- data/spec/data/script/langs +1 -3
- data/spec/default_settings.rb +42 -0
- data/spec/domains_spec.rb +3 -22
- data/spec/spec_helper.rb +3 -0
- data/spec/stubs.rb +11 -0
- data/spec/ymdp_base_spec.rb +125 -0
- data/test.rb +46 -0
- data/ymdp.gemspec +15 -65
- metadata +14 -64
- data/lib/new_application/.base +0 -11
- data/lib/new_application/Gemfile +0 -13
- data/lib/new_application/Rakefile +0 -3
- data/lib/new_application/app/.gitignore +0 -1
- data/lib/new_application/app/assets/images/lightbox/lightbox_bg.png +0 -0
- data/lib/new_application/app/assets/javascripts/OpenMailIntl.js +0 -291
- data/lib/new_application/app/assets/javascripts/controls.js +0 -965
- data/lib/new_application/app/assets/javascripts/date.js +0 -104
- data/lib/new_application/app/assets/javascripts/dragdrop.js +0 -974
- data/lib/new_application/app/assets/javascripts/effects.js +0 -1123
- data/lib/new_application/app/assets/javascripts/lowpro.js +0 -320
- data/lib/new_application/app/assets/javascripts/prototype.js +0 -4874
- data/lib/new_application/app/assets/javascripts/scriptaculous.js +0 -68
- data/lib/new_application/app/assets/yrb/en-US/application_en-US.pres +0 -7
- data/lib/new_application/app/helpers/application_helper.rb +0 -3
- data/lib/new_application/app/javascripts/application.js +0 -580
- data/lib/new_application/app/javascripts/debug.js +0 -138
- data/lib/new_application/app/javascripts/flash.js +0 -96
- data/lib/new_application/app/javascripts/header.js +0 -13
- data/lib/new_application/app/javascripts/help.js +0 -76
- data/lib/new_application/app/javascripts/i18n.js +0 -235
- data/lib/new_application/app/javascripts/launcher.js +0 -159
- data/lib/new_application/app/javascripts/logger.js +0 -61
- data/lib/new_application/app/javascripts/tag_helper.js +0 -178
- data/lib/new_application/app/stylesheets/application.css +0 -0
- data/lib/new_application/app/stylesheets/ie.css +0 -0
- data/lib/new_application/app/stylesheets/ie6.css +0 -0
- data/lib/new_application/app/stylesheets/ie7.css +0 -0
- data/lib/new_application/app/stylesheets/ie8.css +0 -0
- data/lib/new_application/app/stylesheets/lightbox.css +0 -30
- data/lib/new_application/app/stylesheets/non_ie.css +0 -0
- data/lib/new_application/app/views/layouts/application.html.haml +0 -35
- data/lib/new_application/app/views/shared/_error.html.haml +0 -8
- data/lib/new_application/app/views/shared/_flash.html.haml +0 -2
- data/lib/new_application/app/views/shared/_javascripts.html.haml +0 -22
- data/lib/new_application/app/views/shared/_loading.html.haml +0 -13
- data/lib/new_application/app/views/shared/_stylesheets.html.haml +0 -23
- data/lib/new_application/config/categories.yml +0 -6
- data/lib/new_application/config/config.yml.example +0 -30
- data/lib/new_application/config/constants.rb +0 -54
- data/lib/new_application/config/servers.yml.example +0 -9
- data/lib/new_application/lib/init.rb +0 -13
- data/lib/new_application/lib/tasks/environment.rake +0 -4
- data/lib/new_application/lib/tasks/keys.rake +0 -3
- data/lib/new_application/lib/tasks/setup.rake +0 -13
- data/lib/new_application/lib/tasks/ymdp.rake +0 -4
- data/lib/new_application/script/build +0 -9
- data/lib/new_application/script/config +0 -13
- data/lib/new_application/script/destroy +0 -18
- data/lib/new_application/script/generate +0 -4
- data/lib/new_application/script/gitrm +0 -17
- data/lib/new_application/script/growl +0 -6
- data/lib/new_application/script/images +0 -48
- data/lib/new_application/script/jslint.js +0 -5072
- data/lib/new_application/script/langs +0 -31
- data/lib/new_application/script/translate +0 -5
- data/lib/new_application/script/ymdt +0 -1895
- data/lib/new_application/script/ymdt.old +0 -1890
- data/lib/new_application/script/yuicompressor-2.4.2.jar +0 -0
- data/lib/new_application/ymdp +0 -8
- data/lib/ymdp/processor/processor.rb +0 -132
- data/lib/ymdp/ymdp.rb +0 -208
Binary file
|
data/lib/new_application/ymdp
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
require 'support/file'
|
2
|
-
require 'haml'
|
3
|
-
|
4
|
-
module YMDP
|
5
|
-
module Renderer
|
6
|
-
class Base
|
7
|
-
end
|
8
|
-
|
9
|
-
class Haml < Base
|
10
|
-
def self.scope
|
11
|
-
YMDP::ViewHelpers
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.render(filename)
|
15
|
-
options = {}
|
16
|
-
::Haml::Engine.new(filename, options).render(scope)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class ERB < Base
|
21
|
-
def self.scope
|
22
|
-
YMDP::ViewHelpers.get_binding
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.render(filename)
|
26
|
-
::ERB.new(filename, 0, "%<>").result(scope)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module Processor
|
32
|
-
class Base
|
33
|
-
extend YMDP::Config
|
34
|
-
extend YMDP::FileSupport
|
35
|
-
|
36
|
-
def self.render(params)
|
37
|
-
output = []
|
38
|
-
tags = true
|
39
|
-
if params[:tags] == false
|
40
|
-
tags = false
|
41
|
-
end
|
42
|
-
if params[:partial]
|
43
|
-
# params[:partial].to_a.each do |partial|
|
44
|
-
# output << render_partial(params)
|
45
|
-
output << Partial.render(params)
|
46
|
-
# end
|
47
|
-
end
|
48
|
-
# if params[:javascript]
|
49
|
-
# output << "<script type='text/javascript'>" if tags
|
50
|
-
# output << render_javascripts(params)
|
51
|
-
# output << "</script>" if tags
|
52
|
-
# end
|
53
|
-
# if params[:stylesheet]
|
54
|
-
# # params[:stylesheet].to_a.each do |stylesheet|
|
55
|
-
# output << render_stylesheet(params)
|
56
|
-
# # end
|
57
|
-
# end
|
58
|
-
output.join("\n")
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.render_partial(params)
|
62
|
-
Partial.render(params)
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.render_javascripts(params)
|
66
|
-
JavaScript.render(params)
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.render_stylesheet(params)
|
70
|
-
Stylesheet.render(params)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class Partial < Base
|
75
|
-
def self.render(params)
|
76
|
-
filename = params[:partial]
|
77
|
-
output = ''
|
78
|
-
path = nil
|
79
|
-
|
80
|
-
path = find_partial(filename)
|
81
|
-
|
82
|
-
if path
|
83
|
-
output = process(path)
|
84
|
-
else
|
85
|
-
raise "Could not find partial: #{filename}"
|
86
|
-
end
|
87
|
-
output
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.process(path)
|
91
|
-
output = ""
|
92
|
-
|
93
|
-
File.open(path) do |f|
|
94
|
-
template = f.read
|
95
|
-
if path =~ /haml$/
|
96
|
-
output = YMDP::Processor::Haml.render(template, path)
|
97
|
-
else
|
98
|
-
output = YMDP::Processor::ERB.render(template)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
output
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.find_partial(partial)
|
106
|
-
path = nil
|
107
|
-
["views", "views/shared"].each do |dir|
|
108
|
-
basic_path = "#{BASE_PATH}/app/#{dir}/_#{partial}.html"
|
109
|
-
|
110
|
-
["", ".haml", ".erb"].each do |extension|
|
111
|
-
if File.exists?(basic_path + extension)
|
112
|
-
path ||= basic_path + extension
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
path
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
class JavaScript < Base
|
121
|
-
def self.render(params)
|
122
|
-
puts "Rendering partial"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class Stylesheet < Base
|
127
|
-
def self.render(params)
|
128
|
-
puts "Rendering partial"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
data/lib/ymdp/ymdp.rb
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
require 'processor/compressor'
|
2
|
-
require 'processor/validator'
|
3
|
-
|
4
|
-
class Application
|
5
|
-
def self.current_view?(view)
|
6
|
-
current_view.downcase == view.downcase
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.current_view
|
10
|
-
@@current_view
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.current_view= view
|
14
|
-
@@current_view = view
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module YMDP
|
19
|
-
module Base
|
20
|
-
# include YMDP::Config
|
21
|
-
include YMDP::FileSupport
|
22
|
-
include YMDP::Compressor
|
23
|
-
|
24
|
-
extend self
|
25
|
-
|
26
|
-
def supported_languages
|
27
|
-
dirs = Dir["#{BASE_PATH}/app/assets/yrb/*"].map do |path|
|
28
|
-
filename = path.split("/").last
|
29
|
-
|
30
|
-
filename
|
31
|
-
end
|
32
|
-
|
33
|
-
dirs.unshift(dirs.delete("en-US"))
|
34
|
-
|
35
|
-
raise "Default YRB key en-US not found" unless dirs.include?("en-US")
|
36
|
-
|
37
|
-
dirs
|
38
|
-
end
|
39
|
-
|
40
|
-
def english_languages
|
41
|
-
supported_languages.select do |lang|
|
42
|
-
lang =~ /^en/
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def javascript_include(filename)
|
47
|
-
unless filename =~ /^http/
|
48
|
-
filename = "#{@assets_directory}/javascripts/#{filename}"
|
49
|
-
end
|
50
|
-
"<script src='#{filename}' type='text/javascript' charset='utf-8'></script>"
|
51
|
-
end
|
52
|
-
|
53
|
-
def include_firebug_lite
|
54
|
-
javascript_include "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" if @domain != "my"
|
55
|
-
end
|
56
|
-
|
57
|
-
def render(params)
|
58
|
-
output = []
|
59
|
-
tags = true
|
60
|
-
if params[:tags] == false
|
61
|
-
tags = false
|
62
|
-
end
|
63
|
-
if params[:partial]
|
64
|
-
params[:partial].to_a.each do |partial|
|
65
|
-
output << render_partial(partial)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
if params[:javascript]
|
69
|
-
output << "<script type='text/javascript'>" if tags
|
70
|
-
output << render_javascripts(params[:javascript].to_a, params[:filename])
|
71
|
-
output << "</script>" if tags
|
72
|
-
end
|
73
|
-
if params[:stylesheet]
|
74
|
-
params[:stylesheet].to_a.each do |stylesheet|
|
75
|
-
output << render_stylesheet(stylesheet, tags)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
output.join("\n")
|
79
|
-
end
|
80
|
-
|
81
|
-
def render_partial(filename)
|
82
|
-
output = ''
|
83
|
-
path = nil
|
84
|
-
|
85
|
-
["views", "views/shared"].each do |dir|
|
86
|
-
basic_path = "#{BASE_PATH}/app/#{dir}/_#{filename}.html"
|
87
|
-
|
88
|
-
["", ".haml", ".erb"].each do |extension|
|
89
|
-
if File.exists?(basic_path + extension)
|
90
|
-
path ||= basic_path + extension
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
if path
|
96
|
-
|
97
|
-
File.open(path) do |f|
|
98
|
-
template = f.read
|
99
|
-
if path =~ /haml$/
|
100
|
-
output = process_haml(template, path)
|
101
|
-
else
|
102
|
-
output = process_template(template)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
else
|
106
|
-
raise "Could not find partial: #{filename}"
|
107
|
-
end
|
108
|
-
output
|
109
|
-
end
|
110
|
-
|
111
|
-
def render_stylesheet(filename, tags=false)
|
112
|
-
unless filename =~ /\.css$/
|
113
|
-
filename = "#{filename}.css"
|
114
|
-
end
|
115
|
-
path = "#{BASE_PATH}/app/stylesheets/#{filename}"
|
116
|
-
|
117
|
-
output = ''
|
118
|
-
if File.exists?(path)
|
119
|
-
tmp_filename = save_processed_template(path)
|
120
|
-
if CONFIG.compress_css?
|
121
|
-
output = YMDP::Compressor::Stylesheet.compress(tmp_filename)
|
122
|
-
else
|
123
|
-
File.open(path) do |f|
|
124
|
-
template = f.read
|
125
|
-
output = process_template(template)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
if tags
|
130
|
-
"<style type='text/css'>\n" + output + "\n</style>"
|
131
|
-
else
|
132
|
-
output
|
133
|
-
end
|
134
|
-
else
|
135
|
-
""
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def render_javascripts(filenames, combined_filename=nil)
|
140
|
-
output = []
|
141
|
-
|
142
|
-
# concatenate all javascript files into one long string
|
143
|
-
#
|
144
|
-
filenames.each do |filename|
|
145
|
-
output << render_without_compression(filename, false)
|
146
|
-
end
|
147
|
-
output = output.join("\n")
|
148
|
-
|
149
|
-
filenames_str = combined_filename || filenames.join()
|
150
|
-
tmp_filename = "./tmp/#{filenames_str}.js"
|
151
|
-
|
152
|
-
# use the saved file if it already exists
|
153
|
-
unless File.exists?(tmp_filename)
|
154
|
-
save_to_file(output, tmp_filename)
|
155
|
-
validate_filename = tmp_filename
|
156
|
-
end
|
157
|
-
|
158
|
-
# return compressed javascript or else don't
|
159
|
-
output = YMDP::Compressor::JavaScript.compress(tmp_filename) || output
|
160
|
-
|
161
|
-
YMDP::Validator::JavaScript.validate(validate_filename) if validate_filename
|
162
|
-
|
163
|
-
output
|
164
|
-
end
|
165
|
-
|
166
|
-
def render_without_compression(filename, tags=true)
|
167
|
-
unless filename =~ /\.js$/
|
168
|
-
filename = "#{filename}.js"
|
169
|
-
end
|
170
|
-
path = "#{YMDP_ROOT}/app/javascripts/#{filename}"
|
171
|
-
|
172
|
-
output = ''
|
173
|
-
|
174
|
-
if File.exists?(path)
|
175
|
-
File.open(path) do |f|
|
176
|
-
template = f.read
|
177
|
-
output = process_template(template)
|
178
|
-
end
|
179
|
-
|
180
|
-
if tags
|
181
|
-
"<script type='text/javascript'>\n" + output + "\n</script>"
|
182
|
-
else
|
183
|
-
output
|
184
|
-
end
|
185
|
-
else
|
186
|
-
""
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
# processes the template (with HAML or ERB) and saves it to the tmp folder
|
191
|
-
#
|
192
|
-
def save_processed_template(path)
|
193
|
-
filename = path.split("/").last
|
194
|
-
tmp_filename = "#{TMP_PATH}/#{filename}"
|
195
|
-
|
196
|
-
unless File.exists?(tmp_filename)
|
197
|
-
File.open(path) do |f|
|
198
|
-
template = f.read
|
199
|
-
output = process_template(template)
|
200
|
-
|
201
|
-
save_to_file(output, tmp_filename)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
tmp_filename
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|