creationix-milk 0.1.0 → 0.1.1
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.
- data/VERSION +1 -1
- data/lib/milk/application.rb +35 -6
- data/milk.gemspec +1 -1
- data/site_template/public/js/edit.js +0 -1
- data/site_template/public/js/form_validate.js +1 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/milk/application.rb
CHANGED
@@ -47,8 +47,8 @@ module Milk
|
|
47
47
|
when @req.post?
|
48
48
|
if path == '/login'
|
49
49
|
:login
|
50
|
-
elsif path == '/
|
51
|
-
:
|
50
|
+
elsif path == '/form_submit'
|
51
|
+
:form_submit
|
52
52
|
elsif path =~ PAGE_PATH_REGEX
|
53
53
|
regex = PAGE_PATH_REGEX
|
54
54
|
:preview
|
@@ -101,7 +101,34 @@ module Milk
|
|
101
101
|
Digest::MD5.hexdigest("#{password}")
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
104
|
+
def send_email(from, from_alias, to, to_alias, subject, message)
|
105
|
+
msg = <<END_OF_MESSAGE
|
106
|
+
From: #{from_alias} <#{from}>
|
107
|
+
To: #{to_alias} <#{to}>
|
108
|
+
Subject: #{subject}
|
109
|
+
|
110
|
+
#{message}
|
111
|
+
END_OF_MESSAGE
|
112
|
+
require 'net/smtp'
|
113
|
+
Net::SMTP.start('localhost') do |smtp|
|
114
|
+
smtp.send_message msg, from, to
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def form_submit
|
119
|
+
instr = eval(decode(@req.params['instructions']))
|
120
|
+
p = @req.params.reject { |k,v| k == 'instructions'}
|
121
|
+
print instr.inspect+"\n"
|
122
|
+
print instr[:sendto].inspect+"\n"
|
123
|
+
print instr[:sendto].split(' ').inspect+"\n"
|
124
|
+
instr[:sendto].split(' ').each do |email|
|
125
|
+
continue unless u = USERS[email]
|
126
|
+
send_email("milk@#{@req.host}", "Milk Server at #{@req.host}", email, u[:name], "Someone messaged you from #{@req.referer}", YAML.dump(p))
|
127
|
+
end
|
128
|
+
@resp.redirect(instr[:dest])
|
129
|
+
end
|
130
|
+
|
131
|
+
def logout
|
105
132
|
@resp.delete_cookie('auth', :path => "/")
|
106
133
|
@resp.redirect(@req.params['dest'])
|
107
134
|
end
|
@@ -112,7 +139,7 @@ module Milk
|
|
112
139
|
@req.cookies['flash']
|
113
140
|
end
|
114
141
|
|
115
|
-
def login
|
142
|
+
def login
|
116
143
|
email = @req.params['email']
|
117
144
|
if email.length > 0
|
118
145
|
user = USERS[email]
|
@@ -153,6 +180,7 @@ module Milk
|
|
153
180
|
end
|
154
181
|
|
155
182
|
def load_deps(list, target)
|
183
|
+
return list unless DEPENDENCY_TREE[target]
|
156
184
|
DEPENDENCY_TREE[target].each do |more|
|
157
185
|
if more.class == Symbol
|
158
186
|
load_deps(list, more)
|
@@ -186,6 +214,7 @@ module Milk
|
|
186
214
|
@resp.status = 404
|
187
215
|
page = Milk::Page.find('NotFound')
|
188
216
|
Milk::Application.join_tree(page, self)
|
217
|
+
@action = :view
|
189
218
|
@resp.write page.view
|
190
219
|
when :view
|
191
220
|
Milk::Application.join_tree(@page, self)
|
@@ -213,8 +242,8 @@ module Milk
|
|
213
242
|
login
|
214
243
|
when :logout
|
215
244
|
logout
|
216
|
-
when :
|
217
|
-
|
245
|
+
when :form_submit
|
246
|
+
form_submit
|
218
247
|
when :access_denied
|
219
248
|
@resp.staus = 403
|
220
249
|
@resp.write "Access Denied"
|
data/milk.gemspec
CHANGED
@@ -3,7 +3,6 @@ function form_validate(form)
|
|
3
3
|
var good = true;
|
4
4
|
$(".form_field", form).each(function(i,tr){
|
5
5
|
var field = $("input,textarea,select", tr);
|
6
|
-
console.log(field);
|
7
6
|
var required = $(tr).hasClass('required');
|
8
7
|
var message = "";
|
9
8
|
var value = field[0].value;
|
@@ -11,7 +10,6 @@ function form_validate(form)
|
|
11
10
|
{
|
12
11
|
if (field.hasClass("email_field"))
|
13
12
|
{
|
14
|
-
console.log("Validating email");
|
15
13
|
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
16
14
|
if (!filter.test(value))
|
17
15
|
{
|
@@ -20,7 +18,6 @@ function form_validate(form)
|
|
20
18
|
}
|
21
19
|
else if (field.hasClass("phone_field"))
|
22
20
|
{
|
23
|
-
console.log("Validating phone");
|
24
21
|
var stripped = value.replace(/[\s()+\-]|ext\.?/gi, "");
|
25
22
|
// 10 is the minimum number of numbers required
|
26
23
|
if (!(/\d{10,}/i).test(stripped))
|
@@ -45,7 +42,6 @@ function form_validate(form)
|
|
45
42
|
message_area.show();
|
46
43
|
}
|
47
44
|
});
|
48
|
-
|
49
|
-
return false;
|
45
|
+
return good;
|
50
46
|
|
51
47
|
}
|