populate-me 0.0.2 → 0.0.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.
@@ -210,7 +210,7 @@ module PopulateMe
|
|
210
210
|
def to_thumb(c)
|
211
211
|
current = @doc[c]
|
212
212
|
if current.respond_to?(:[])
|
213
|
-
"<img src='/gridfs/#{@doc[c]['
|
213
|
+
"<img src='/gridfs/#{@doc[c]['stash_thumb_gif']}' width='100' onerror=\"this.style.display='none'\" />\n"
|
214
214
|
end
|
215
215
|
end
|
216
216
|
# Reset dropdowns on hooks
|
@@ -42,7 +42,7 @@ module PopulateMe
|
|
42
42
|
# def minilist_view
|
43
43
|
# o = "<ul class='minilist'>\n"
|
44
44
|
# self.collection.find.each_mutant do |m|
|
45
|
-
# thumb = m.respond_to?(:to_populate_thumb) ? m.to_populate_thumb('
|
45
|
+
# thumb = m.respond_to?(:to_populate_thumb) ? m.to_populate_thumb('stash_thumb_gif') : m.placeholder_thumb('stash_thumb_gif')
|
46
46
|
# o << "<li title='#{m.to_label}' id='mini-#{m.id}'>#{thumb}<div>#{m.to_label}</div></li>\n"
|
47
47
|
# end
|
48
48
|
# o << "</ul>\n"
|
@@ -65,10 +65,10 @@ module PopulateMe
|
|
65
65
|
module InstanceMethods
|
66
66
|
|
67
67
|
def after_stash(col)
|
68
|
-
convert(col, "-resize '100x75^' -gravity center -extent 100x75", '
|
68
|
+
convert(col, "-resize '100x75^' -gravity center -extent 100x75", 'stash_thumb_gif')
|
69
69
|
end
|
70
70
|
|
71
|
-
def generic_thumb(img , size='
|
71
|
+
def generic_thumb(img , size='stash_thumb_gif', obj=self)
|
72
72
|
return placeholder_thumb(size) if obj.nil?
|
73
73
|
current = obj.doc[img]
|
74
74
|
if !current.nil? && !current[size].nil?
|
@@ -79,7 +79,7 @@ module PopulateMe
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def placeholder_thumb(size)
|
82
|
-
"/_public/img/placeholder.#{size}"
|
82
|
+
"/_public/img/placeholder.#{size.gsub(/^(.*)_([a-zA-Z]+)$/, '\1.\2')}"
|
83
83
|
end
|
84
84
|
|
85
85
|
def to_nutshell
|
@@ -88,7 +88,7 @@ module PopulateMe
|
|
88
88
|
'id'=>@doc['_id'].to_s,
|
89
89
|
'foreign_key_name'=>model.foreign_key_name,
|
90
90
|
'title'=>self.to_label,
|
91
|
-
'thumb'=>self.respond_to?(:to_populate_thumb) ? self.to_populate_thumb('
|
91
|
+
'thumb'=>self.respond_to?(:to_populate_thumb) ? self.to_populate_thumb('stash_thumb_gif') : nil,
|
92
92
|
'children'=>nutshell_children,
|
93
93
|
}
|
94
94
|
end
|
@@ -96,7 +96,7 @@ module PopulateMe
|
|
96
96
|
def in_nutshell
|
97
97
|
o = model.list_options
|
98
98
|
out = "<div class='in-nutshell'>\n"
|
99
|
-
out << self.to_populate_thumb('
|
99
|
+
out << self.to_populate_thumb('nutshell_jpg') if self.respond_to?(:to_populate_thumb)
|
100
100
|
cols = model.populate_config[:quick_update_fields] || nutshell_backend_columns.select{|col|
|
101
101
|
[:boolean,:select].include?(model.schema[col][:type]) && !model.schema[col][:multiple] && !model.schema[col][:no_quick_update]
|
102
102
|
}
|
@@ -71,7 +71,7 @@ module PopulateMe
|
|
71
71
|
def convert(col, convert_steps, style)
|
72
72
|
return if @doc[col].nil?
|
73
73
|
if @temp_attachments.nil? || @temp_attachments[col].nil?
|
74
|
-
f =
|
74
|
+
f = model.gridfs.get(@doc[col]['original'])
|
75
75
|
return unless f.content_type[/^image\//]
|
76
76
|
src = Tempfile.new('MongoStash_src')
|
77
77
|
src.binmode
|
@@ -86,7 +86,7 @@ module PopulateMe
|
|
86
86
|
src = @temp_attachments[col][:tempfile]
|
87
87
|
end
|
88
88
|
model.gridfs.delete(@doc[col][style]) unless @doc[col][style].nil?
|
89
|
-
ext = style[
|
89
|
+
ext = style[/[a-zA-Z]+$/].insert(0,'.')
|
90
90
|
dest = Tempfile.new(['MongoStash_dest', ext])
|
91
91
|
dest.binmode
|
92
92
|
dest.close
|
@@ -103,6 +103,7 @@ module PopulateMe
|
|
103
103
|
class << self
|
104
104
|
attr_accessor :classes
|
105
105
|
Stash.classes = []
|
106
|
+
|
106
107
|
def all_after_stash
|
107
108
|
Stash.classes.each do |m|
|
108
109
|
m.collection.find.each do |i|
|
@@ -112,6 +113,36 @@ module PopulateMe
|
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
116
|
+
|
117
|
+
def fix_dots_in_keys(c, for_real=false)
|
118
|
+
puts "\n#{c}" unless for_real
|
119
|
+
img_keys = c.schema.select{|k,v| v[:type]==:attachment }.keys
|
120
|
+
c.find({}, {:fields=>img_keys}).each do |e|
|
121
|
+
old_hash = e.doc.select{|k,v| img_keys.include?(k) }
|
122
|
+
fixed_hash = Marshal.load(Marshal.dump(old_hash))
|
123
|
+
img_keys.each do |k|
|
124
|
+
(fixed_hash[k]||{}).keys.each do |style|
|
125
|
+
fixed_hash[k][style.tr('.','_')] = fixed_hash[k].delete(style)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
next if old_hash==fixed_hash
|
129
|
+
|
130
|
+
if for_real
|
131
|
+
c.collection.update({'_id'=>e.id}, {'$set'=>fixed_hash})
|
132
|
+
else
|
133
|
+
puts old_hash.inspect
|
134
|
+
puts fixed_hash.inspect
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def all_fix_dots_in_keys(for_real=false)
|
141
|
+
Stash.classes.each do |c|
|
142
|
+
Stash.fix_dots_in_keys(c, for_real)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
115
146
|
end
|
116
147
|
|
117
148
|
end
|
data/populate-me.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'populate-me'
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.3"
|
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.
|
4
|
+
version: 0.0.3
|
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: 2012-
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-golem
|