Commit cdad6671005cfbd3d87af0bcd5f78c7aa0cf46bd

Authored by David Silva
1 parent 7c861d61

Inprove block code.

- change lambda to proc in block's content method.
  - remove unnecessary code.
  - add block's css

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes@gmail.com>
app/controllers/my_profile/profile_editor_controller.rb
@@ -18,6 +18,7 @@ class ProfileEditorController &lt; MyProfileController @@ -18,6 +18,7 @@ class ProfileEditorController &lt; MyProfileController
18 @profile_data = profile 18 @profile_data = profile
19 @possible_domains = profile.possible_domains 19 @possible_domains = profile.possible_domains
20 if request.post? 20 if request.post?
  21 + puts "$"*80, params[:profile_data]
21 params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) 22 params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
22 Profile.transaction do 23 Profile.transaction do
23 Image.transaction do 24 Image.transaction do
plugins/profile_description_block/lib/profile_description_block.rb 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +class ProfileDescriptionBlock < Block
  2 + settings_items :show_name, :type => :boolean,
  3 + :default => false
  4 +
  5 + attr_accessor :show_name
  6 +
  7 + def self.description
  8 + _('Profile Description')
  9 + end
  10 +
  11 + def help
  12 + _('this block displays the description field of the profile')
  13 + end
  14 +
  15 + def default_title
  16 + _('PROFILE DESCRIPTION')
  17 + end
  18 +
  19 + def content(args={})
  20 + description = if self.owner.description.blank?
  21 + "Description field is empty or
  22 + not enabled on enviroment"
  23 + else
  24 + self.owner.description
  25 + end
  26 + block = self
  27 + s = show_name
  28 + proc do
  29 + render(
  30 + :file => 'blocks/profile_description',
  31 + :locals => { :block => block, :show_name => s ,
  32 + :description => description}
  33 + )
  34 + end
  35 + end
  36 +
  37 + def cacheable?
  38 + false
  39 + end
  40 +
  41 +end
plugins/profile_description_block/lib/profile_description_block_plugin.rb 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +class ProfileDescriptionBlockPlugin < Noosfero::Plugin
  2 +
  3 + def self.plugin_name
  4 + # FIXME
  5 + "Profile Description Block"
  6 + end
  7 +
  8 + def self.extra_blocks
  9 + {
  10 + ProfileDescriptionBlock => { :type => [Community, Person] }
  11 + }
  12 + end
  13 +
  14 +
  15 + def self.plugin_description
  16 + # FIXME
  17 + _("A plugin that adds a block that show the profile description")
  18 + end
  19 +
  20 + def stylesheet?
  21 + true
  22 + end
  23 +
  24 +end
plugins/profile_description_block/public/style.css 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +#content .box-1 .profile-description-block {
  2 + display: table;
  3 + width: 100%;
  4 +}
  5 +
  6 +#content .profile-description-block-title {
  7 + font-family: arial;
  8 + font-size: 15px;
  9 + text-align: left;
  10 +}
plugins/profile_description_block/views/blocks/profile_description.html.erb 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<div class = 'profile-description-block'>
  2 +<div class = "block-title">
  3 + <%= block.title %>
  4 +</div>
  5 +<div class = "profile-description-block-title">
  6 + <%= description %>
  7 +</div>
  8 +</div>
plugins/profile_fields_block/lib/profile_fields_block.rb
@@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
1 -class ProfileFieldsBlock < Block  
2 -  
3 - settings_items :profile_description, :type => :string, :default => ""  
4 - settings_items :show_name, :type => :boolean, :default => false  
5 - attr_accessor :show_name  
6 -  
7 -  
8 - def self.description  
9 - _('Profile Fields ')  
10 - end  
11 -  
12 - def profile_description  
13 - self.settings[:profile_description]  
14 - end  
15 -  
16 - def help  
17 - _('This block display the description of the community')  
18 - end  
19 -  
20 - def content(args={})  
21 - self.profile_description = retrive_description_profile_field  
22 - block_content = self.profile_description  
23 - block = self  
24 - s = show_name  
25 - lambda do |object|  
26 - render(  
27 - :file => 'blocks/profile_fields',  
28 - :locals => { :block => block, :show_name => s ,  
29 - :description => block_content}  
30 - )  
31 - end  
32 - end  
33 -  
34 - def cacheable?  
35 - false  
36 - end  
37 -  
38 -  
39 - private  
40 -  
41 - def retrive_description_profile_field  
42 - box_id = self.box_id  
43 - owner_id = Box.find(box_id).owner_id  
44 - description = Profile.find(owner_id).description  
45 - if description.blank?  
46 - "Description field are empty or  
47 - not enabled in enviroment"  
48 - else  
49 - description  
50 - end  
51 - end  
52 -  
53 -end  
plugins/profile_fields_block/lib/profile_fields_block_plugin.rb
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -class ProfileFieldsBlockPlugin < Noosfero::Plugin  
2 -  
3 - def self.plugin_name  
4 - # FIXME  
5 - "ProfileFieldsBlockPlugin"  
6 - end  
7 -  
8 - def self.extra_blocks  
9 - {  
10 - ProfileFieldsBlock => { :type => [Community] }  
11 - }  
12 - end  
13 -  
14 -  
15 - def self.plugin_description  
16 - # FIXME  
17 - _("A plugin that include a generic block")  
18 - end  
19 -  
20 - def stylesheet?  
21 - true  
22 - end  
23 -  
24 -end  
plugins/profile_fields_block/public/style.css
@@ -1,270 +0,0 @@ @@ -1,270 +0,0 @@
1 -.mpog_hidden_field {  
2 - display: none;  
3 -}  
4 -  
5 -#signup-form small#secondary-email-balloon ,  
6 -#signup-form small#area-interest-balloon {  
7 - display: none;  
8 - width: 142px;  
9 - height: 69px;  
10 - color: #FFFFFF;  
11 - font-weight: bold;  
12 - font-size: 11px;  
13 - padding: 5px 10px 45px 10px;  
14 - margin: 0;  
15 - line-height: 1.5em;  
16 - background: transparent url(/images/gray-balloon.png) bottom center no-repeat;  
17 - position: absolute;  
18 - z-index: 2;  
19 - right: -150px;  
20 -}  
21 -  
22 -#signup-form #signup-secondary-email,  
23 -#signup-form #signup-area-interest {  
24 - position: relative;  
25 -}  
26 -  
27 -#signup-form small#secondary-email-balloon,  
28 -#signup-form small#area-interest-balloon {  
29 - top: -80px;  
30 -}  
31 -  
32 -.dynamic-table {  
33 - border: solid 1px #000;  
34 - margin-top: 5px;  
35 - margin-bottom: 15px;  
36 -}  
37 -.dynamic-table td, .dynamic-table tr {  
38 - border: none;  
39 -}  
40 -.dynamic-table input {  
41 - width: 220px;  
42 -}  
43 -  
44 -.mpog-incomplete-percentage img {  
45 - margin-left: 5px;  
46 -}  
47 -  
48 -.mpog-incomplete-percentage img:hover {  
49 - cursor: pointer;  
50 -}  
51 -  
52 -#institution_dialog {  
53 - display: none;  
54 -}  
55 -  
56 -.errorExplanation {  
57 - color: red;  
58 - margin-left: 10px;  
59 -}  
60 -  
61 -.hide-field {  
62 - display: none !important;  
63 -}  
64 -  
65 -.show-field {  
66 - display: block !important;  
67 -}  
68 -  
69 -#user_filter_content {  
70 - display: block;  
71 - width: 100%;  
72 - height: auto;  
73 -}  
74 -  
75 -.mpog_search_form_fields {  
76 - margin-top: 10px;  
77 - width: 80%;  
78 - height: auto;  
79 - position: relative;  
80 - float: left;  
81 -}  
82 -  
83 -.mpog_search_form_button {  
84 - margin-top: 10px;  
85 -}  
86 -  
87 -.mpog_search_form_fields input[type='text'] {  
88 - width: 90%;  
89 -  
90 -}  
91 -  
92 -.mpog_search_form_table tr td:first-child {  
93 - width: 22%;  
94 -}  
95 -  
96 -.formfieldline {  
97 - margin-top: 10px;  
98 -}  
99 -.formfieldline input[type="text"] {  
100 - width: 180px;  
101 -}  
102 -  
103 -#complete_registration {  
104 - padding: 5px;  
105 - width: 100%;  
106 - background-color: #fff;  
107 -}  
108 -  
109 -#complete_registration a {  
110 - text-decoration: none;  
111 -}  
112 -  
113 -#complete_registration a:hover {  
114 - font-weight: bold;  
115 -}  
116 -  
117 -#complete_registration_percentage {  
118 - width: 100%;  
119 - height: 20px;  
120 - background: #fff;  
121 - border: solid 1px #000;  
122 -}  
123 -  
124 -#profile-data .invalid {  
125 - border-color: rgb(127, 0, 0);  
126 - box-shadow: 0px 0px 7px red;  
127 -}  
128 -  
129 -#profile-data .validated {  
130 - box-shadow: 0px 0px 7px green;  
131 - border-color: rgb(0, 80, 0)  
132 -}  
133 -  
134 -#software-name-field  
135 -{  
136 - padding-bottom: 10px;  
137 -}  
138 -  
139 -#software-hostname  
140 -{  
141 - float: left;  
142 - display: inline-block;  
143 - vertical-align: middle;  
144 -  
145 - background: #EEE;  
146 - border: 1px solid #CFCFCF;  
147 -  
148 - line-height: 22px;  
149 - padding: 0px 7px;  
150 - color: #4A4A4A;  
151 - font-size: 20px;  
152 - text-transform: lowercase;  
153 - min-width: 190px;  
154 - border-spacing: 20px;  
155 -}  
156 -  
157 -.mandatory::after  
158 -{  
159 - color: red;  
160 - content: ' (*)'  
161 -}  
162 -  
163 -.autocomplete_validation_message {  
164 - color: red;  
165 -}  
166 -  
167 -  
168 -#content .institutions-block ul,  
169 -#content .softwares-block ul {  
170 - min-width: 196px;  
171 - width: 192px;  
172 - margin: 0px 0px 0px -3px;  
173 - padding: 0px;  
174 -}  
175 -  
176 -#content .box-1 .institutions-block ul,  
177 -#content .box-1 .softwares-block ul {  
178 - width: auto;  
179 - display: block;  
180 -}  
181 -  
182 -#content .institutions-block .block-footer-content a,  
183 -#content .softwares-block .block-footer-content a {  
184 - position: absolute;  
185 - top: 2px;  
186 - right: 0px;  
187 - font-size: 11px;  
188 - color: #000;  
189 - text-decoration: none;  
190 - padding-right: 15px;  
191 -}  
192 -  
193 -#content .institutions-block .block-footer-content a,  
194 -#content .lock-footer-content a {  
195 - background: url(../../../designs/themes/base/imgs/arrow-right-p.png) 100% 50% no-repeat;  
196 -}  
197 -  
198 -.improve_input_size {  
199 - width: 315px !important;  
200 -}  
201 -  
202 -.search-community-content-block span {  
203 - width: auto;  
204 -}  
205 -  
206 -#catalog-list ul li {  
207 - display: inline;  
208 - margin-right: 5px;  
209 - font-size: 14px;  
210 - padding: 5px;  
211 - }  
212 -  
213 -#catalog-list ul li span {  
214 - cursor: pointer;  
215 - margin-left: 5px;  
216 -}  
217 -  
218 -.catalog-remove-item {  
219 - padding: 3px;  
220 - border: solid 1px #999;  
221 - border-radius: 3px;  
222 -}  
223 -  
224 -.category_box {  
225 - font-size: 11px;  
226 - border:1px solid #e9e8ed;  
227 - border-radius:8px;  
228 - background-color:#e9e8ed;  
229 - padding:3px 6px;  
230 - margin: 10px 3px;  
231 - color: blue;  
232 -}  
233 -  
234 -.search-results-type-software_info li {  
235 - width: 100% !important;  
236 - display: block !important;  
237 -}  
238 -  
239 -/* Start software block main area definitions */  
240 -.software-block {  
241 - position: relative;  
242 - float: left;  
243 - margin: 0px 10px 10px 0px;  
244 - width: 30%;  
245 - height: 200px;  
246 - word-wrap: break-word;  
247 - overflow: hidden;  
248 -}  
249 -  
250 -.software-block-logo {  
251 - width: 150px;  
252 - height: 150px;  
253 - margin: 0px auto;  
254 -}  
255 -  
256 -.software-block-content, .software-block-finality {  
257 - width: 100%;  
258 - height: 100%;  
259 - position: absolute;  
260 - top: 0px;  
261 - left: 0px;  
262 -}  
263 -  
264 -.software-block-finality {  
265 - background-color: #fff;  
266 - top: 100%;  
267 - display: block;  
268 - background-color:rgba(255, 255, 255, 0.9);  
269 -}  
270 -/* End software block main area definitions */  
plugins/profile_fields_block/views/blocks/profile_fields.html.erb
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -<div class = "profile_description_block">  
2 -<%= block.title %>  
3 -</div>  
4 -<div class = "block-footer-content">  
5 -<h1> <%= description %> <h1>  
6 -</div>