populate-me 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rack/golem'
2
3
  require 'json'
3
4
 
@@ -1,23 +1,26 @@
1
+ @import url(http://fonts.googleapis.com/css?family=Lato);
2
+
1
3
  body {
2
- font-family: 'gill sans', verdana, sans-serif;
4
+ font-family: 'Lato', sans-serif;
3
5
  font-size: 12px;
4
- color: #888;
5
- background-color: #444;
6
+ color: #fdf6e3;
7
+ background-color: #002b36;
6
8
  padding: 0px;
7
9
  /* Build column */
8
10
  height: 100%;
9
11
  margin: 0px;
10
12
  text-align: center; /* for IE7 */
13
+ -webkit-font-smoothing: antialiased;
11
14
  }
12
15
 
13
16
  img { border: 0px; }
14
17
  ul { list-style: none; padding: 0px; margin: 0px; }
15
- a { color: #89D8EE; }
18
+ a { color: #dc322f; }
16
19
  a:hover { text-decoration: none; }
17
20
 
18
21
  noscript div {
19
22
  padding: 20px;
20
- background-color: yellow; color: black;
23
+ background-color: #b58900; color: #002b36;
21
24
  }
22
25
 
23
26
  .shadowed {
@@ -30,10 +33,10 @@ noscript div {
30
33
 
31
34
  #trunk { margin: 0px auto; text-align: left; width: 100%; max-width: 500px; min-width: 320px; }
32
35
  #page-title {
33
- background-color: #89D8EE; color: #444; width: 80%; text-align: center;
36
+ background-color: #2aa198; color: #002b36; width: 80%; text-align: center;
34
37
  margin: 0px; padding: 20px 10%;
35
38
  }
36
- #header { background-color: #89D8EE; width: 100%; height: 32px; position: relative; }
39
+ #header { background-color: #2aa198; width: 100%; height: 32px; position: relative; }
37
40
  #search-wrap { position: absolute; top: 0px; bottom: 0px; left: 32px; right: 32px; }
38
41
  #search {
39
42
  width: 80%; height: 22px;
@@ -47,10 +50,10 @@ noscript div {
47
50
  .btn {
48
51
  display: block;
49
52
  width: 32px; height: 32px;
50
- background: transparent url('../img/icons-cms.png') no-repeat left top;
53
+ background: transparent url('../img/icons-cms-solarized.png') no-repeat left top;
51
54
  margin: 0px auto;
52
55
  }
53
- .btn:hover { background-color: #777; }
56
+ .btn:hover { background-color: #586e75; }
54
57
  .back-btn { background-position: 0px -32px; }
55
58
  .plus-btn { background-position: 0px -64px; }
56
59
  .cross-btn {
@@ -59,13 +62,14 @@ noscript div {
59
62
  -moz-border-radius: 5px;
60
63
  -webkit-border-radius: 5px;
61
64
  }
62
- .cross-btn:hover { background-color: #89D8EE;}
65
+ .cross-btn:hover { background-color: #dc322f;}
63
66
  .further-btn { background-position: 0px -128px; }
64
67
 
65
68
  .extra-plus {
66
- border: 1px dashed black;
69
+ /* border: 1px dashed #073642; */
67
70
  margin: 10px;
68
71
  width: auto;
72
+ background-color: #073642;
69
73
  background-position: center -64px;
70
74
  border-radius: 5px;
71
75
  -moz-border-radius: 5px;
@@ -82,11 +86,11 @@ ul.menu-list li {
82
86
 
83
87
  ul.menu-list li a {
84
88
  display: block; padding: 10px;
85
- background-color: white; color: #333;
89
+ background-color: #eee8d5; color: #002b36;
86
90
  text-decoration: none;
87
91
  }
88
92
  ul.menu-list li a:hover {
89
- background-color: #CCC;
93
+ background-color: #93a1a1;
90
94
  }
91
95
 
92
96
  /* ============= */
@@ -106,8 +110,8 @@ ul.nutshell-children li { margin: 0px 10px; }
106
110
  }
107
111
 
108
112
  .nutshell-bar {
109
- background-color: white;
110
- /* background: white url('../img/handle-pattern.png') repeat left top;*/
113
+ background-color: #eee8d5;
114
+ /* background: #fdf6e3 url('../img/grip.png') repeat left top;*/
111
115
  height: 32px;
112
116
  -webkit-border-top-left-radius: 5px;
113
117
  -webkit-border-top-right-radius: 5px;
@@ -118,37 +122,46 @@ ul.nutshell-children li { margin: 0px 10px; }
118
122
  }
119
123
 
120
124
  .sortable-handle {
121
- background: transparent url('../img/handle-pattern.png') repeat left top;
125
+ background: transparent url('../img/grip.png') repeat left top;
122
126
  cursor: move;
127
+ cursor: ns-resize;
128
+ cursor: -webkit-grab;
129
+ cursor: -moz-grab;
123
130
  }
124
131
 
125
- .further-bar { width: auto; background-color: #89D8EE; border-top: 1px dotted black; }
132
+ .further-bar { width: auto; background-color: #2aa198; border-top: 1px dotted black; }
126
133
 
127
134
  .nutshell-edit, .further-bar {
128
135
  display: block; position: relative;
129
136
  padding: 10px 10px 10px 42px;
130
137
  font-size: 12px; line-height: 12px; height: 12px;
131
- color: black; text-decoration: none;
138
+ color: #002b36; text-decoration: none;
132
139
  }
133
- .nutshell-edit:hover, .further-bar:hover { background-color: #CCC; }
140
+ .nutshell-edit:hover, .further-bar:hover { background-color: #586e75; }
134
141
 
135
142
  .nutshell-edit {
136
- background-color: white;
143
+ background-color: #eee8d5;
137
144
  padding: 10px 10px 10px 10px;
145
+ font-size: 14px; line-height: 14px;
138
146
  height: auto;
139
147
  overflow: hidden;
140
148
  white-space: nowrap;
141
149
  text-overflow: ellipsis;
150
+
151
+ -webkit-border-bottom-right-radius: 5px;
152
+ -webkit-border-bottom-left-radius: 5px;
153
+ -moz-border-radius-bottomright: 5px;
154
+ -moz-border-radius-bottomleft: 5px;
155
+ border-bottom-right-radius: 5px;
156
+ border-bottom-left-radius: 5px;
142
157
  }
143
158
  .nutshell-edit:hover {
144
- /* -moz-box-shadow: 0px 0px 20px black;*/
145
- /* -webkit-box-shadow: 0px 0px 20px black;*/
146
- /* box-shadow: 0px 0px 20px black;*/
147
- background-color: aliceblue;
159
+ background-color: #93a1a1;
148
160
  }
149
161
 
162
+ /*
150
163
  .nutshell-bottom {
151
- background-color: white;
164
+ background-color: #fdf6e3;
152
165
  height: 10px;
153
166
  -webkit-border-bottom-right-radius: 5px;
154
167
  -webkit-border-bottom-left-radius: 5px;
@@ -156,25 +169,39 @@ ul.nutshell-children li { margin: 0px 10px; }
156
169
  -moz-border-radius-bottomleft: 5px;
157
170
  border-bottom-right-radius: 5px;
158
171
  border-bottom-left-radius: 5px;
159
- }
172
+ }*/
160
173
 
161
174
  /* ========= */
162
175
  /* = Forms = */
163
176
  /* ========= */
164
177
 
178
+ input:not([type=file]), textarea, select {
179
+ border: 0px;
180
+ background: #eee8d5; color: #002b36;
181
+ }
182
+ input[type=submit] {
183
+ -webkit-border-radius: 3px;
184
+ -moz-border-radius: 3px;
185
+ -o-border-radius: 3px;
186
+ border-radius: 3px;
187
+ background-color: #859900;
188
+ cursor: pointer;
189
+ }
190
+ input[type=submit]:hover { background-color: #586e75; }
165
191
  .backend-form { margin: 10px; padding: 0px; }
166
192
  .crushyfield-error input { background-color: #FCC; }
167
193
  .crushyfield-error-list { color: #F99; }
168
- input[type=text] { width: 50%; }
169
- textarea { width: 70%; height: 150px; }
194
+ input[type=text] { width: 70%; padding: 5px; }
195
+ textarea { width: 70%; height: 150px; padding: 5px; }
196
+ select { padding: 5px; }
170
197
 
171
198
  /* ========== */
172
199
  /* = Footer = */
173
200
  /* ========== */
174
201
 
175
202
  #footer {
176
- border-top: 1px solid #555;
177
- color: #555; font-size: 10px;
203
+ border-top: 1px solid #586e75;
204
+ color: #586e75; font-size: 10px;
178
205
  padding: 10px;
179
206
  }
180
- #footer a { color: #555; }
207
+ #footer a { color: #586e75; }
@@ -111,7 +111,7 @@ $(function() {
111
111
  // Ajax form
112
112
  $('.backend-form').live('submit', function() {
113
113
  var $form = $(this);
114
- $form.find(':submit').after("<img src='"+admin_path+"/_public/img/small-loader.gif' />").remove();
114
+ $form.find(':submit').after("<img src='"+admin_path+"/_public/img/small-loader.gif' alt='Loader' />").remove();
115
115
  $form.ajaxSubmit({
116
116
  success: function(data) {
117
117
  if (data.action=='save' || data.match(/ok/i)) { // Success
@@ -16,7 +16,7 @@
16
16
  </script>
17
17
  <script id='template-nut-tree' type='text/html'>
18
18
  {{#command_plus}}
19
- <a href='<%= config[:path] %>/form/{{class_name}}{{query_string}}' class='btn plus-btn extra-plus pushstack'></a>
19
+ <a href='<%= config[:path] %>/form/{{class_name}}{{query_string}}' class='btn plus-btn extra-plus pushstack' title='Create'></a>
20
20
  {{/command_plus}}
21
21
  <ul class='nut-tree {{#sortable}}sortable{{/sortable}}'>
22
22
  {{#items}}{{>nutshell}}{{/items}}
@@ -27,14 +27,12 @@
27
27
  <div class='nutshell-core'>
28
28
  <div class='nutshell-bar {{#sortable}}sortable-handle{{/sortable}}'>
29
29
 
30
- <a href='<%= config[:path] %>/{{class_name}}/{{id}}' class='btn cross-btn nutshell-delete float-right'></a>
30
+ <a href='<%= config[:path] %>/{{class_name}}/{{id}}' class='btn cross-btn nutshell-delete float-right' title='Delete'></a>
31
31
  </div>
32
- <a href='<%= config[:path] %>/form/{{class_name}}/{{id}}' class='nutshell-edit pushstack'>
33
- {{#thumb}}<img src='{{thumb}}' onerror="this.style.display='none'" />{{/thumb}}
34
- {{^thumb}}<img src='/admin/_public/img/placeholder.png' onerror="this.style.display='none'" />{{/thumb}}
32
+ <a href='<%= config[:path] %>/form/{{class_name}}/{{id}}' class='nutshell-edit pushstack' title='Edit'>
33
+ {{#thumb}}<img src='{{thumb}}' onerror="this.style.display='none'" alt='Thumb' />{{/thumb}}
35
34
  &nbsp;<span class='nutshell-title'>{{title}}</span>
36
35
  </a>
37
- <div class='nutshell-bottom'></div>
38
36
  </div>
39
37
  <ul class='nutshell-children'>
40
38
  {{#children}}
@@ -48,8 +46,8 @@
48
46
  <div id='trunk'>
49
47
  <h1 id='page-title' class='shadowed'><%= config[:page_title] %></h1>
50
48
  <div id='header' class='shadowed'>
51
- <a href='#' class='btn back-btn float-left popstack'></a>
52
- <a href='<%= config[:path] %>' class='btn home-btn float-right'></a>
49
+ <a href='#' class='btn back-btn float-left popstack' title='Back'></a>
50
+ <a href='<%= config[:path] %>' class='btn home-btn float-right' title='Home'></a>
53
51
  <div id='search-wrap'><input type='text' id='search' placeholder='Search' /></div>
54
52
  </div>
55
53
  <noscript><div>In order to have this content management system working, you need to have javascript enabled.</div></noscript>
@@ -1 +1,2 @@
1
- require 'populate_me/mongo/plug'
1
+ # encoding: utf-8
2
+ require 'populate_me/mongo/plug'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module PopulateMe
2
3
  module Mongo
3
4
  module BackendApiPlug
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module PopulateMe
2
3
  module Mongo
3
4
  module Crushyform
@@ -28,6 +29,9 @@ module PopulateMe
28
29
  tag = "<input type='%s' name='%s' value=\"%s\" id='%s' class='%s' %s />%s\n" % [o[:input_type]||'text', o[:input_name], o[:input_value], m.field_id_for(c), o[:input_class], o[:required]&&'required', o[:required]]
29
30
  "#{tag}#{js}"
30
31
  end,
32
+ :slug => proc do |m,c,o|
33
+ crushyform_types[:string].call(m,c,o)
34
+ end,
31
35
  :boolean => proc do |m,c,o|
32
36
  crushid = m.field_id_for(c)
33
37
  s = ['checked', nil]
@@ -210,7 +214,7 @@ module PopulateMe
210
214
  def to_thumb(c)
211
215
  current = @doc[c]
212
216
  if current.respond_to?(:[])
213
- "<img src='/gridfs/#{@doc[c]['stash_thumb_gif']}' width='100' onerror=\"this.style.display='none'\" />\n"
217
+ "<img src='/gridfs/#{@doc[c]['stash_thumb_gif']}' width='100' onerror=\"this.style.display='none'\" alt='Thumb' />\n"
214
218
  end
215
219
  end
216
220
  # Reset dropdowns on hooks
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module PopulateMe
2
3
  module Mongo
3
4
  module Mutation
@@ -14,10 +15,11 @@ module PopulateMe
14
15
 
15
16
  module MutateClass
16
17
  attr_accessor :db, :schema, :relationships
17
- attr_writer :label_column, :sorting_order
18
+ attr_writer :label_column, :slug_column, :sorting_order
18
19
 
19
20
  LABEL_COLUMNS = ['title', 'label', 'fullname', 'full_name', 'surname', 'lastname', 'last_name', 'name', 'firstname', 'first_name', 'login', 'caption', 'reference', 'file_name', 'body', '_id']
20
21
  def label_column; @label_column ||= LABEL_COLUMNS.find{|c| @schema.keys.include?(c)||c=='_id'}; end
22
+ def slug_column; @slug_column ||= (@schema.find{|k,v| v[:type]==:slug}||[])[0]; end
21
23
  def foreign_key_name(plural=false); "id#{'s' if plural}_"+self.name; end
22
24
  def human_name; self.name.gsub(/([A-Z])/, ' \1')[1..-1]; end
23
25
  def human_plural_name; human_name+'s'; end
@@ -100,6 +102,17 @@ module PopulateMe
100
102
  def [](field); @doc[field]; end
101
103
  def []=(field,val); @doc[field] = val; end
102
104
  def to_label; @doc[model.label_column].to_s.tr("\n\r", ' '); end
105
+ ACCENTS_FROM =
106
+ "ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞ"
107
+ ACCENTS_TO =
108
+ "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssT"
109
+ def auto_slug
110
+ s = self.to_label.tr(ACCENTS_FROM,ACCENTS_TO).tr(' .,;:?!/\'"()[]{}<>','-').gsub(/&/, 'and')
111
+ defined?(::Rack::Utils) ? ::Rack::Utils.escape(s) : s
112
+ end
113
+ def to_slug; @doc[model.column_slug]||self.auto_slug; end
114
+ # To param will be deprecated
115
+ # Use a URL like .../<id>/<slug> instead
103
116
  def to_param; "#{@doc['_id']}-#{to_label.scan(/\w+/).join('-')}"; end
104
117
  def field_id_for(col); "%s-%s-%s" % [id||'new',model.name,col]; end
105
118
 
@@ -200,6 +213,7 @@ module PopulateMe
200
213
  def after_validation; end
201
214
  def fix_type_integer(k,v); @doc[k] = v.to_i; end
202
215
  def fix_type_boolean(k,v); @doc[k] = (v=='true'||v==true) ? true : false; end
216
+ def fix_type_slug(k,v); @doc[k] = self.auto_slug if v.to_s==''; end
203
217
  def fix_type_date(k,v)
204
218
  if v.is_a?(String)
205
219
  if v[/\d\d\d\d-\d\d-\d\d/]
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'populate_me/mongo/mutation'
2
4
  require 'populate_me/mongo/stash'
3
5
  require 'populate_me/mongo/crushyform'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module PopulateMe
2
3
  module Mongo
3
4
  module Stash
@@ -12,6 +13,14 @@ module PopulateMe
12
13
 
13
14
  module ClassMethods
14
15
  attr_accessor :gridfs
16
+ def all_after_stash
17
+ self.collection.find.each do |i|
18
+ self.schema.each do |k,v|
19
+ obj = self.new(i)
20
+ obj.after_stash(k) if v[:type]==:attachment&&obj[k].to_s!=''
21
+ end
22
+ end
23
+ end
15
24
  end
16
25
 
17
26
  # Instance Methods
@@ -88,12 +97,16 @@ module PopulateMe
88
97
  end
89
98
  model.gridfs.delete(@doc[col][style]) unless @doc[col][style].nil?
90
99
  ext = style[/[a-zA-Z]+$/].insert(0,'.')
100
+ content_type = Rack::Mime.mime_type(ext)
101
+ unless content_type[/^image\//]
102
+ ext = '.jpg'
103
+ content_type = 'image/jpeg'
104
+ end
91
105
  dest = Tempfile.new(['MongoStash_dest', ext])
92
106
  dest.binmode
93
107
  dest.close
94
108
  system "convert \"#{src.path}\" #{convert_steps} \"#{dest.path}\""
95
109
  filename = "#{model.name}/#{self.id}/#{style}"
96
- content_type = Rack::Mime.mime_type(ext)
97
110
  attachment_id = model.gridfs.put(dest.open, {:filename=>filename, :content_type=>content_type})
98
111
  @doc[col] = @doc[col].update({style=>attachment_id})
99
112
  model.collection.update({'_id'=>@doc['_id']}, @doc)
@@ -107,12 +120,7 @@ module PopulateMe
107
120
 
108
121
  def all_after_stash
109
122
  Stash.classes.each do |m|
110
- m.collection.find.each do |i|
111
- m.schema.each do |k,v|
112
- obj = m.new(i)
113
- obj.after_stash(k) if v[:type]==:attachment&&obj[k].to_s!=''
114
- end
115
- end
123
+ m.all_after_stash
116
124
  end
117
125
  end
118
126
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'populate-me'
3
- s.version = "0.0.6"
3
+ s.version = "0.0.7"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "ALPHA !!! Populate Me is relatively complete but simple CMS"
6
6
  s.description = "ALPHA !!! Populate Me is relatively complete but simple CMS. It includes a Rack middleware for putting in your Rack stack, and a bespoke MongoDB ODM. But Populate Me is not really finished yet."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-golem
@@ -70,7 +70,8 @@ files:
70
70
  - lib/populate_me/control/_public/css/ui-darkness/images/ui-icons_cccccc_256x240.png
71
71
  - lib/populate_me/control/_public/css/ui-darkness/images/ui-icons_ffffff_256x240.png
72
72
  - lib/populate_me/control/_public/css/ui-darkness/jquery-ui-1.8.17.custom.css
73
- - lib/populate_me/control/_public/img/handle-pattern.png
73
+ - lib/populate_me/control/_public/img/grip.png
74
+ - lib/populate_me/control/_public/img/icons-cms-solarized.png
74
75
  - lib/populate_me/control/_public/img/icons-cms.png
75
76
  - lib/populate_me/control/_public/img/placeholder.png
76
77
  - lib/populate_me/control/_public/img/placeholder.stash_thumb.gif