infopark_rails_connector 6.8.0.beta.200.621.4c8e1b0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +59 -0
- data/app/assets/images/admin/minus.gif +0 -0
- data/app/assets/images/bg80.png +0 -0
- data/app/assets/images/edit.png +0 -0
- data/app/assets/images/icons/mm_generic.png +0 -0
- data/app/assets/images/icons/mm_menu.png +0 -0
- data/app/assets/images/ratings/star.gif +0 -0
- data/app/assets/images/time_machine/calendar-menuarrow.gif +0 -0
- data/app/assets/images/time_machine/calendar_bg.png +0 -0
- data/app/assets/images/time_machine/icon.png +0 -0
- data/app/assets/images/time_machine/slider_bg.png +0 -0
- data/app/assets/images/time_machine/slider_handle.png +0 -0
- data/app/assets/images/time_machine/timemachine_bg.png +0 -0
- data/app/assets/javascripts/comments.js +29 -0
- data/app/assets/javascripts/editmarker.js +240 -0
- data/app/assets/javascripts/infopark_rails_connector.js.erb +3 -0
- data/app/assets/javascripts/initializer.js +9 -0
- data/app/assets/javascripts/ratings.js +26 -0
- data/app/assets/javascripts/time_machine/calendar-setup.js +200 -0
- data/app/assets/javascripts/time_machine/calendar.js +1806 -0
- data/app/assets/javascripts/time_machine/lang/calendar-de.js +127 -0
- data/app/assets/javascripts/time_machine/lang/calendar-en.js +127 -0
- data/app/assets/javascripts/time_machine/lang/calendar-es.js +129 -0
- data/app/assets/javascripts/time_machine/lang/calendar-fr.js +125 -0
- data/app/assets/javascripts/time_machine/lang/calendar-it.js +124 -0
- data/app/assets/javascripts/time_machine/slider.js +278 -0
- data/app/assets/javascripts/time_machine.js +8 -0
- data/app/assets/stylesheets/editmarker.css +70 -0
- data/app/assets/stylesheets/infopark_rails_connector.css.erb +4 -0
- data/app/assets/stylesheets/ratings.css +97 -0
- data/app/assets/stylesheets/time_machine/time_machine.css +292 -0
- data/app/assets/stylesheets/time_machine.css +6 -0
- data/app/controllers/cms_controller.rb +6 -0
- data/app/controllers/comments_controller.rb +6 -0
- data/app/controllers/crm_form_controller.rb +2 -0
- data/app/controllers/pdf_controller.rb +6 -0
- data/app/controllers/rails_connector/default_cms_controller.rb +40 -0
- data/app/controllers/rails_connector/default_comments_controller.rb +71 -0
- data/app/controllers/rails_connector/default_crm_form_controller.rb +167 -0
- data/app/controllers/rails_connector/default_pdf_controller.rb +136 -0
- data/app/controllers/rails_connector/default_ratings_controller.rb +84 -0
- data/app/controllers/rails_connector/default_rss_controller.rb +29 -0
- data/app/controllers/rails_connector/default_search_controller.rb +60 -0
- data/app/controllers/rails_connector/default_user_controller.rb +267 -0
- data/app/controllers/rails_connector/pdf_external_controller.rb +54 -0
- data/app/controllers/rails_connector/time_machine_controller.rb +48 -0
- data/app/controllers/ratings_controller.rb +6 -0
- data/app/controllers/rss_controller.rb +6 -0
- data/app/controllers/search_controller.rb +2 -0
- data/app/controllers/seo_sitemap_controller.rb +12 -0
- data/app/controllers/user_controller.rb +2 -0
- data/app/helpers/cms_helper.rb +6 -0
- data/app/helpers/cms_routing_helper.rb +6 -0
- data/app/helpers/crm_form_helper.rb +3 -0
- data/app/helpers/rails_connector/cms_asset_helper.rb +51 -0
- data/app/helpers/rails_connector/default_cms_helper.rb +27 -0
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +93 -0
- data/app/helpers/rails_connector/default_crm_form_helper.rb +58 -0
- data/app/helpers/rails_connector/default_ratings_helper.rb +38 -0
- data/app/helpers/rails_connector/default_user_helper.rb +90 -0
- data/app/helpers/rails_connector/display_helper.rb +117 -0
- data/app/helpers/rails_connector/error_messages_helper.rb +23 -0
- data/app/helpers/rails_connector/layout_helper.rb +30 -0
- data/app/helpers/rails_connector/link_helper.rb +88 -0
- data/app/helpers/rails_connector/mandatory_label_helper.rb +10 -0
- data/app/helpers/rails_connector/marker_helper.rb +363 -0
- data/app/helpers/rails_connector/menu_helper.rb +72 -0
- data/app/helpers/rails_connector/micronav_helper.rb +107 -0
- data/app/helpers/rails_connector/seo_helper.rb +44 -0
- data/app/helpers/rails_connector/table_of_contents_helper.rb +20 -0
- data/app/helpers/rails_connector/time_machine_helper.rb +24 -0
- data/app/helpers/rails_connector/tracking_helper.rb +32 -0
- data/app/helpers/ratings_helper.rb +4 -0
- data/app/helpers/user_helper.rb +3 -0
- data/app/mailers/confirmation_mailer.rb +13 -0
- data/app/models/crm_form.rb +2 -0
- data/app/models/named_link.rb +2 -0
- data/app/models/obj.rb +9 -0
- data/app/models/rails_connector/default_comment.rb +28 -0
- data/app/models/rails_connector/default_rating.rb +20 -0
- data/app/models/rails_connector/link_list.rb +30 -0
- data/app/views/cms/_comments.html.erb +44 -0
- data/app/views/cms/_index.html.erb +7 -0
- data/app/views/cms/_rating.html.erb +31 -0
- data/app/views/cms/index.html.erb +3 -0
- data/app/views/comments/_comment.html.erb +28 -0
- data/app/views/confirmation_mailer/register_confirmation.erb +5 -0
- data/app/views/confirmation_mailer/reset_password.erb +5 -0
- data/app/views/crm_form/_flash_messages.html.erb +11 -0
- data/app/views/crm_form/_form.html.erb +17 -0
- data/app/views/crm_form/confirmation.html.erb +3 -0
- data/app/views/crm_form/index.html.erb +5 -0
- data/app/views/crm_form/not_logged_in.html.erb +1 -0
- data/app/views/errors/403_forbidden.html.erb +3 -0
- data/app/views/errors/410_gone.html.erb +7 -0
- data/app/views/layouts/rails_connector/time_machine.html.erb +12 -0
- data/app/views/pdf/index.html.erb +7 -0
- data/app/views/pdf/index.xsl +1240 -0
- data/app/views/rails_connector/time_machine/index.html.erb +88 -0
- data/app/views/rss/_item.rss.builder +11 -0
- data/app/views/rss/index.rss.builder +11 -0
- data/app/views/search/_hit.html.erb +12 -0
- data/app/views/search/_hits.html.erb +11 -0
- data/app/views/search/_mini_panel.html.erb +4 -0
- data/app/views/search/_pagination.html.erb +5 -0
- data/app/views/search/_panel.html.erb +4 -0
- data/app/views/search/search.html.erb +12 -0
- data/app/views/seo_sitemap/show.xml.builder +16 -0
- data/app/views/user/_flash_messages.html.erb +11 -0
- data/app/views/user/edit.html.erb +6 -0
- data/app/views/user/edit_password.html.erb +11 -0
- data/app/views/user/forgot_password.html.erb +7 -0
- data/app/views/user/login.html.erb +15 -0
- data/app/views/user/new.html.erb +11 -0
- data/app/views/user/profile.html.erb +8 -0
- data/app/views/user/register_pending.html.erb +1 -0
- data/app/views/user/set_password.html.erb +14 -0
- data/config/cms_routes.rb +13 -0
- data/config/locales/de.rails_connector.controllers.yml +30 -0
- data/config/locales/de.rails_connector.errors.yml +11 -0
- data/config/locales/de.rails_connector.helpers.yml +9 -0
- data/config/locales/de.rails_connector.lib.yml +6 -0
- data/config/locales/de.rails_connector.models.yml +8 -0
- data/config/locales/de.rails_connector.views.yml +87 -0
- data/config/locales/en.rails_connector.controllers.yml +30 -0
- data/config/locales/en.rails_connector.errors.yml +10 -0
- data/config/locales/en.rails_connector.helpers.yml +9 -0
- data/config/locales/en.rails_connector.lib.yml +6 -0
- data/config/locales/en.rails_connector.models.yml +8 -0
- data/config/locales/en.rails_connector.views.yml +87 -0
- data/config/routes.rb +37 -0
- data/lib/generators/rails_connector/comments/comments_generator.rb +21 -0
- data/lib/generators/rails_connector/comments/templates/migration.rb +17 -0
- data/lib/generators/rails_connector/install/install_generator.rb +38 -0
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +58 -0
- data/lib/generators/rails_connector/install/templates/local/configuration.rb +2 -0
- data/lib/generators/rails_connector/install/templates/obj_extensions.rb +25 -0
- data/lib/generators/rails_connector/ratings/ratings_generator.rb +21 -0
- data/lib/generators/rails_connector/ratings/templates/migration.rb +15 -0
- data/lib/infopark_rails_connector.rb +31 -0
- data/lib/obj_extensions.rb +6 -0
- data/lib/rails_connector/authenticable.rb +30 -0
- data/lib/rails_connector/cms_accessible.rb +114 -0
- data/lib/rails_connector/cms_dispatch_controller.rb +47 -0
- data/lib/rails_connector/cms_env.rb +55 -0
- data/lib/rails_connector/cms_test_request.rb +23 -0
- data/lib/rails_connector/commentable.rb +23 -0
- data/lib/rails_connector/configuration/google_analytics.rb +29 -0
- data/lib/rails_connector/configuration/pdf_generator.rb +15 -0
- data/lib/rails_connector/configuration/rss.rb +46 -0
- data/lib/rails_connector/configuration.rb +235 -0
- data/lib/rails_connector/core_extensions/time.rb +18 -0
- data/lib/rails_connector/core_extensions.rb +1 -0
- data/lib/rails_connector/crm.rb +282 -0
- data/lib/rails_connector/engine.rb +78 -0
- data/lib/rails_connector/fop.rb +18 -0
- data/lib/rails_connector/fop_on_rails/document/dom_tree.rb +42 -0
- data/lib/rails_connector/fop_on_rails/document/images.rb +34 -0
- data/lib/rails_connector/fop_on_rails/document/tables.rb +67 -0
- data/lib/rails_connector/fop_on_rails/document.rb +25 -0
- data/lib/rails_connector/fop_on_rails.rb +92 -0
- data/lib/rails_connector/googlebot_checker.rb +47 -0
- data/lib/rails_connector/html_string.rb +19 -0
- data/lib/rails_connector/infopark_base.rb +2 -0
- data/lib/rails_connector/link_resolvable.rb +9 -0
- data/lib/rails_connector/liquid_support/action_marker.rb +69 -0
- data/lib/rails_connector/liquid_support/field_value_drop.rb +22 -0
- data/lib/rails_connector/liquid_support/general_helper_tag.rb +44 -0
- data/lib/rails_connector/liquid_support/link_drop.rb +22 -0
- data/lib/rails_connector/liquid_support/liquid_template_handler.rb +162 -0
- data/lib/rails_connector/liquid_support/named_object_drop.rb +14 -0
- data/lib/rails_connector/liquid_support/obj_drop.rb +43 -0
- data/lib/rails_connector/liquid_support/obj_filters.rb +77 -0
- data/lib/rails_connector/liquid_support.rb +23 -0
- data/lib/rails_connector/markdown_string.rb +19 -0
- data/lib/rails_connector/rateable.rb +57 -0
- data/lib/rails_connector/seo.rb +52 -0
- data/lib/rails_connector/ses.rb +72 -0
- data/lib/rails_connector/string_tagging.rb +29 -0
- data/lib/rails_connector/syndicateable.rb +11 -0
- data/lib/search_request.rb +2 -0
- data/lib/tasks/check.rake +25 -0
- data/lib/tasks/cms_license_check.rake +17 -0
- metadata +489 -0
@@ -0,0 +1,292 @@
|
|
1
|
+
body {
|
2
|
+
color:#fff;
|
3
|
+
font-size:11px;
|
4
|
+
font-family:'Lucida Grande', Helvetica, Verdana, Arial, sans-serif;
|
5
|
+
background-color:#333;
|
6
|
+
}
|
7
|
+
|
8
|
+
#time-machine {
|
9
|
+
width:425px;
|
10
|
+
height:300px;
|
11
|
+
margin:auto;
|
12
|
+
margin-top:20px;
|
13
|
+
padding:0;
|
14
|
+
background:transparent url(../time_machine/timemachine_bg.png) no-repeat;
|
15
|
+
}
|
16
|
+
|
17
|
+
#slider {
|
18
|
+
width:375px;
|
19
|
+
height:50px;
|
20
|
+
margin-left:25px;
|
21
|
+
margin-top:15px;
|
22
|
+
}
|
23
|
+
|
24
|
+
#track {
|
25
|
+
width:375px;
|
26
|
+
height:23px;
|
27
|
+
background:transparent url(../time_machine/slider_bg.png) no-repeat;
|
28
|
+
}
|
29
|
+
|
30
|
+
#handle {
|
31
|
+
height:21px;
|
32
|
+
width:50px;
|
33
|
+
margin:2px;
|
34
|
+
padding-right:2px;
|
35
|
+
background:transparent url(../time_machine/slider_handle.png) no-repeat 0 2px;
|
36
|
+
cursor:move;
|
37
|
+
}
|
38
|
+
|
39
|
+
#display {
|
40
|
+
padding-top:5px;
|
41
|
+
width:375px;
|
42
|
+
text-align:center;
|
43
|
+
}
|
44
|
+
|
45
|
+
#calendar {
|
46
|
+
width:250px;
|
47
|
+
height:200px;
|
48
|
+
padding-top:20px;
|
49
|
+
margin-left:87px;
|
50
|
+
}
|
51
|
+
|
52
|
+
/* The main calendar widget. DIV containing a table. */
|
53
|
+
|
54
|
+
.calendar {
|
55
|
+
height:200px;
|
56
|
+
position:relative;
|
57
|
+
display: none;
|
58
|
+
font-size: 11px;
|
59
|
+
color: #fff;
|
60
|
+
cursor: default;
|
61
|
+
background:transparent url(../time_machine/calendar_bg.png) no-repeat;
|
62
|
+
font-family: tahoma,verdana,sans-serif;
|
63
|
+
}
|
64
|
+
|
65
|
+
.calendar table {
|
66
|
+
margin:10px;
|
67
|
+
font-size: 11px;
|
68
|
+
color: #fff;
|
69
|
+
cursor: default;
|
70
|
+
background:none;
|
71
|
+
font-family: tahoma,verdana,sans-serif;
|
72
|
+
}
|
73
|
+
|
74
|
+
/* Header part -- contains navigation buttons and day names. */
|
75
|
+
|
76
|
+
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
|
77
|
+
text-align: center;
|
78
|
+
padding: 1px;
|
79
|
+
border-bottom: 1px solid #666;
|
80
|
+
}
|
81
|
+
|
82
|
+
.calendar .nav {
|
83
|
+
background: transparent url(../time_machine/calendar-menuarrow.gif) no-repeat 100% 100%;
|
84
|
+
}
|
85
|
+
|
86
|
+
.calendar thead .title { /* This holds the current "month, year" */
|
87
|
+
font-weight: bold;
|
88
|
+
padding: 1px;
|
89
|
+
border: 1px solid #000;
|
90
|
+
background:none;
|
91
|
+
color: #fff;
|
92
|
+
text-align: center;
|
93
|
+
border-bottom: 1px solid #666;
|
94
|
+
}
|
95
|
+
|
96
|
+
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
|
97
|
+
}
|
98
|
+
|
99
|
+
.calendar thead .daynames { /* Row <TR> containing the day names */
|
100
|
+
}
|
101
|
+
|
102
|
+
.calendar thead .name { /* Cells <TD> containing the day names */
|
103
|
+
border-bottom:1px solid #666;
|
104
|
+
padding:2px;
|
105
|
+
text-align:center;
|
106
|
+
background:none;
|
107
|
+
}
|
108
|
+
|
109
|
+
.calendar thead .weekend { /* How a weekend day name shows in header */
|
110
|
+
color: #fff;
|
111
|
+
}
|
112
|
+
|
113
|
+
.calendar thead .hilite { /* How do the buttons in header appear when hover */
|
114
|
+
padding: 0px;
|
115
|
+
background-color: #999;
|
116
|
+
}
|
117
|
+
|
118
|
+
.calendar thead .active { /* Active (pressed) buttons in header */
|
119
|
+
padding: 2px 0px 0px 2px;
|
120
|
+
background-color: #fff;
|
121
|
+
color:#333;
|
122
|
+
}
|
123
|
+
|
124
|
+
/* The body part -- contains all the days in month. */
|
125
|
+
|
126
|
+
.calendar tbody .day { /* Cells <TD> containing month days dates */
|
127
|
+
width: 2em;
|
128
|
+
text-align: right;
|
129
|
+
padding: 2px 4px 2px 2px;
|
130
|
+
}
|
131
|
+
.calendar tbody .day.othermonth {
|
132
|
+
font-size: 80%;
|
133
|
+
color: #aaa;
|
134
|
+
}
|
135
|
+
.calendar tbody .day.othermonth.oweekend {
|
136
|
+
color: #faa;
|
137
|
+
}
|
138
|
+
|
139
|
+
.calendar table .wn {
|
140
|
+
padding: 2px 3px 2px 2px;
|
141
|
+
border-right: 1px solid #666;
|
142
|
+
background:none;
|
143
|
+
}
|
144
|
+
|
145
|
+
.calendar tbody .rowhilite td {
|
146
|
+
background: #999;
|
147
|
+
}
|
148
|
+
|
149
|
+
.calendar tbody .rowhilite td.wn {
|
150
|
+
background: #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.calendar tbody td.hilite { /* Hovered cells <TD> */
|
154
|
+
background:#666
|
155
|
+
}
|
156
|
+
|
157
|
+
.calendar tbody td.active { /* Active (pressed) cells <TD> */
|
158
|
+
padding: 2px 2px 0px 2px;
|
159
|
+
border: 1px solid;
|
160
|
+
border-color:#000;
|
161
|
+
}
|
162
|
+
|
163
|
+
.calendar tbody td.selected { /* Cell showing selected date */
|
164
|
+
font-weight: bold;
|
165
|
+
padding: 2px 2px 0px 2px;
|
166
|
+
border: 1px solid;
|
167
|
+
border-color: #000;
|
168
|
+
background:#aaa;
|
169
|
+
color:#fff;
|
170
|
+
}
|
171
|
+
|
172
|
+
.calendar tbody td.weekend { /* Cells showing weekend days */
|
173
|
+
color: #f00;
|
174
|
+
}
|
175
|
+
|
176
|
+
.calendar tbody td.today { /* Cell showing today date */
|
177
|
+
font-weight: bold;
|
178
|
+
color: #3366ff;
|
179
|
+
}
|
180
|
+
|
181
|
+
.calendar tbody .disabled { color: #999; }
|
182
|
+
|
183
|
+
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
|
184
|
+
visibility: hidden;
|
185
|
+
}
|
186
|
+
|
187
|
+
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
|
188
|
+
display: none;
|
189
|
+
}
|
190
|
+
|
191
|
+
/* The footer part -- status bar and "Close" button */
|
192
|
+
|
193
|
+
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
|
194
|
+
}
|
195
|
+
|
196
|
+
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
|
197
|
+
background: #e8f0f4;
|
198
|
+
padding: 2px;
|
199
|
+
border: 1px solid #000;
|
200
|
+
background: #666;
|
201
|
+
color: #fff;
|
202
|
+
text-align: center;
|
203
|
+
}
|
204
|
+
|
205
|
+
.calendar tfoot .hilite { /* Hover style for buttons in footer */
|
206
|
+
border-top: 1px solid #fff;
|
207
|
+
border-right: 1px solid #000;
|
208
|
+
border-bottom: 1px solid #000;
|
209
|
+
border-left: 1px solid #fff;
|
210
|
+
padding: 1px;
|
211
|
+
background: #d8e0e4;
|
212
|
+
}
|
213
|
+
|
214
|
+
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
|
215
|
+
padding: 2px 0px 0px 2px;
|
216
|
+
border-top: 1px solid #000;
|
217
|
+
border-right: 1px solid #fff;
|
218
|
+
border-bottom: 1px solid #fff;
|
219
|
+
border-left: 1px solid #000;
|
220
|
+
}
|
221
|
+
|
222
|
+
/* Combo boxes (menus that display months/years for direct selection) */
|
223
|
+
|
224
|
+
.calendar .combo {
|
225
|
+
position: absolute;
|
226
|
+
display: none;
|
227
|
+
width: 4em;
|
228
|
+
top: 0px;
|
229
|
+
left: 0px;
|
230
|
+
cursor: default;
|
231
|
+
background: #999;
|
232
|
+
font-size: 90%;
|
233
|
+
padding: 1px;
|
234
|
+
z-index: 100;
|
235
|
+
}
|
236
|
+
|
237
|
+
.calendar .combo .label,
|
238
|
+
.calendar .combo .label-IEfix {
|
239
|
+
text-align: center;
|
240
|
+
padding: 1px;
|
241
|
+
}
|
242
|
+
|
243
|
+
.calendar .combo .label-IEfix {
|
244
|
+
width: 4em;
|
245
|
+
}
|
246
|
+
|
247
|
+
.calendar .combo .active {
|
248
|
+
background: #c8d0d4;
|
249
|
+
padding: 0px;
|
250
|
+
}
|
251
|
+
|
252
|
+
.calendar .combo .hilite {
|
253
|
+
background: #333;
|
254
|
+
color: #fff;
|
255
|
+
}
|
256
|
+
|
257
|
+
.calendar td.time {
|
258
|
+
border-top: 1px solid #000;
|
259
|
+
padding: 1px 0px;
|
260
|
+
text-align: center;
|
261
|
+
background-color: #e8f0f4;
|
262
|
+
}
|
263
|
+
|
264
|
+
.calendar td.time .hour,
|
265
|
+
.calendar td.time .minute,
|
266
|
+
.calendar td.time .ampm {
|
267
|
+
padding: 0px 3px 0px 4px;
|
268
|
+
border: 1px solid #889;
|
269
|
+
font-weight: bold;
|
270
|
+
background-color: #fff;
|
271
|
+
}
|
272
|
+
|
273
|
+
.calendar td.time .ampm {
|
274
|
+
text-align: center;
|
275
|
+
}
|
276
|
+
|
277
|
+
.calendar td.time .colon {
|
278
|
+
padding: 0px 2px 0px 3px;
|
279
|
+
font-weight: bold;
|
280
|
+
}
|
281
|
+
|
282
|
+
.calendar td.time span.hilite {
|
283
|
+
border-color: #000;
|
284
|
+
background-color: #667;
|
285
|
+
color: #fff;
|
286
|
+
}
|
287
|
+
|
288
|
+
.calendar td.time span.active {
|
289
|
+
border-color: #f00;
|
290
|
+
background-color: #000;
|
291
|
+
color: #0f0;
|
292
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_tree ./time_machine
|
6
|
+
*/
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This controller provides some default includes (+CmsAccessible+),
|
4
|
+
# before filters (+load_object+, among others), and actions to simplify
|
5
|
+
# CMS object handling. It should never be used directly, but only as a
|
6
|
+
# super class to CmsController.
|
7
|
+
class DefaultCmsController < ApplicationController
|
8
|
+
include CmsAccessible
|
9
|
+
before_filter :set_preview_time
|
10
|
+
before_filter :load_object
|
11
|
+
before_filter :ensure_object_is_active
|
12
|
+
before_filter :ensure_object_is_permitted
|
13
|
+
before_filter :set_google_expire_header
|
14
|
+
|
15
|
+
# Default Action. Delivers files directly if their mime type is not text/html
|
16
|
+
def index
|
17
|
+
deliver_file if @obj.mime_type != "text/html"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Toggles edit markers. The current status is stored in the session.
|
21
|
+
def toggle_editmarkers
|
22
|
+
session[:hide_editmarkers] = !session[:hide_editmarkers]
|
23
|
+
redirect_to cms_id_url(@obj)
|
24
|
+
end
|
25
|
+
|
26
|
+
# This method indicates if this controller should be used automatically when an Obj is
|
27
|
+
# requested via the Rails Connector's standard routes. It returns true by default.
|
28
|
+
#
|
29
|
+
# Overwrite it to return false if you do want your controller to be excluded from Obj dispatching.
|
30
|
+
#
|
31
|
+
# You may also implement a method with the name +use_for_obj_dispatch?+ in controllers not
|
32
|
+
# descending from +DefaultCmsController+ to include them in Obj dispatching.
|
33
|
+
#
|
34
|
+
# @see Obj#controller_name
|
35
|
+
def self.use_for_obj_dispatch?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
#
|
3
|
+
# This class provides a default controller implementation for comment creation.
|
4
|
+
# It should only be used indirectly via a subclass named CommentsController.
|
5
|
+
#
|
6
|
+
# The controller actions only respond to XMLHttpRequests (Ajax).
|
7
|
+
#
|
8
|
+
class DefaultCommentsController < ApplicationController
|
9
|
+
layout nil
|
10
|
+
|
11
|
+
before_filter :ensure_object_is_commentable, :only => :create
|
12
|
+
before_filter :ensure_admin, :only => :delete
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates a comment and calls the +after_create+ callback.
|
16
|
+
#
|
17
|
+
def create
|
18
|
+
respond_to do |format|
|
19
|
+
format.js do
|
20
|
+
@comment = @obj.comments.create(
|
21
|
+
if logged_in?
|
22
|
+
params[:comment].merge({
|
23
|
+
:name => "#{current_user.first_name} #{current_user.last_name}",
|
24
|
+
:email => current_user.email
|
25
|
+
})
|
26
|
+
else
|
27
|
+
params[:comment]
|
28
|
+
end
|
29
|
+
)
|
30
|
+
if @comment.errors.empty?
|
31
|
+
after_create
|
32
|
+
html = render_to_string(:partial => "comments/comment", :locals => {:comment => @comment})
|
33
|
+
render :json => {:comment => html}.to_json
|
34
|
+
else
|
35
|
+
render :json => {:errors => @comment.errors.keys}.to_json
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Deletes a comment.
|
43
|
+
# Allowed only to an admin.
|
44
|
+
#
|
45
|
+
def delete
|
46
|
+
respond_to do |format|
|
47
|
+
format.html do
|
48
|
+
@comment = Comment.find(params[:id])
|
49
|
+
@comment.destroy
|
50
|
+
redirect_to :back
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def ensure_object_is_commentable
|
58
|
+
@obj = Obj.find(params[:obj_id])
|
59
|
+
render :nothing => true unless @obj.allow_comments?
|
60
|
+
unless @obj.allow_anonymous_comments? or logged_in?
|
61
|
+
render '/errors/403_forbidden', :status => 403
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def ensure_admin
|
66
|
+
render("errors/403_forbidden", :status => 403) unless admin?
|
67
|
+
end
|
68
|
+
|
69
|
+
def after_create; end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# This class provides a default controller implementation for WebCRM form using custom attributes.
|
3
|
+
# It should be customized by subclassing.
|
4
|
+
class DefaultCrmFormController < DefaultCmsController
|
5
|
+
|
6
|
+
include Crm::Localizable
|
7
|
+
include Crm::Sanitization
|
8
|
+
|
9
|
+
before_filter :authorize
|
10
|
+
|
11
|
+
class_attribute :editable_attributes_on_register
|
12
|
+
self.editable_attributes_on_register = {
|
13
|
+
:contact => [:gender, :first_name, :last_name, :email]
|
14
|
+
}
|
15
|
+
|
16
|
+
def index
|
17
|
+
unless logged_in?
|
18
|
+
@user = Infopark::Crm::Contact.new(:language => default_language)
|
19
|
+
@user.load(sanitize_user_params(params[:user], editable_attributes_on_register))
|
20
|
+
end
|
21
|
+
@activity = Infopark::Crm::Activity.new(:state => activity_state, :kind => activity_kind)
|
22
|
+
@activity.load(sanitize_activity_params(params[:activity]))
|
23
|
+
if request.post?
|
24
|
+
if logged_in?
|
25
|
+
@activity.contact_id = current_user.id
|
26
|
+
else
|
27
|
+
if @user.email.blank?
|
28
|
+
@user.errors.add(:email, t(:'rails_connector.errors.messages.blank'))
|
29
|
+
raise ActiveResource::ResourceInvalid.new("E-mail can't be blank")
|
30
|
+
end
|
31
|
+
@user.save!
|
32
|
+
@activity.contact_id = @user.id
|
33
|
+
end
|
34
|
+
before_saving_activity(@activity)
|
35
|
+
@activity.save
|
36
|
+
raise ActiveResource::ResourceInvalid, "activity invalid" unless @activity.valid?
|
37
|
+
after_saving_activity(@activity)
|
38
|
+
end
|
39
|
+
rescue ActiveResource::ResourceInvalid => e
|
40
|
+
flash.now[:error] = t("rails_connector.controllers.crm_form.submit_failed")
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
# Returns the activity kind to create.
|
46
|
+
# Override this method for custom logic to get from a given OBJ to an activity kind.
|
47
|
+
#
|
48
|
+
# Defaults to +@obj[:activity_kind]+ or 'contact form' if the former is +nil+.
|
49
|
+
def activity_kind
|
50
|
+
@obj[:activity_kind] || 'contact form'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns the state of a new activity.
|
54
|
+
#
|
55
|
+
# Defaults to the first state assigned to +activity_kind+.
|
56
|
+
def activity_state
|
57
|
+
Infopark::Crm::CustomType.find(activity_kind).states.first
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the language for a new contact, in case you don't have a language field in your form.
|
61
|
+
#
|
62
|
+
# If you want your visitors to choose their language, don't override this method!
|
63
|
+
# Instead, include :language in your +editable_attributes_on_register+ and add
|
64
|
+
# an additional form field to the corresponding view.
|
65
|
+
#
|
66
|
+
# Defaults to the current locale.
|
67
|
+
def default_language
|
68
|
+
I18n.locale.to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
# Provides a callback to change the given activity in-place before saving it.
|
72
|
+
# Be aware that this method may modify the argument.
|
73
|
+
#
|
74
|
+
# This method may be used to prepend the activity's title or otherwise customize
|
75
|
+
# the behavior without having to override #index.
|
76
|
+
#
|
77
|
+
# By default, it assigns a default title if +has_title_input_field?+ is +false+.
|
78
|
+
def before_saving_activity(activity)
|
79
|
+
activity.title = "Website form submission" unless has_title_input_field?
|
80
|
+
end
|
81
|
+
|
82
|
+
# Provides a callback after saving the activity.
|
83
|
+
# This method may be overridden to render a confirmation text,
|
84
|
+
# or redirect the user to a separate confirmation page.
|
85
|
+
#
|
86
|
+
# The method is also available as helper in your views.
|
87
|
+
#
|
88
|
+
# By default, it renders crm_form/confirmation
|
89
|
+
def after_saving_activity(activity)
|
90
|
+
render 'crm_form/confirmation'
|
91
|
+
end
|
92
|
+
|
93
|
+
# Used by views to determine if input field for title should be rendered.
|
94
|
+
# Override this method to return +false+ if you want to set the title programmatically.
|
95
|
+
#
|
96
|
+
# By default, it returns +true+
|
97
|
+
def has_title_input_field?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
helper_method :has_title_input_field?
|
101
|
+
|
102
|
+
# Sanitizes the given hash of POST parameters, cleaning out any key-value pairs that are
|
103
|
+
# potentially dangerous if set by the user.
|
104
|
+
# This prevents users from setting arbitrary activity properties, such as kind or state,
|
105
|
+
# and custom attributes that are not to be set by users.
|
106
|
+
#
|
107
|
+
# By default, it returns a hash only with title and custom values.
|
108
|
+
def sanitize_activity_params(activity_params_or_nil)
|
109
|
+
activity_params_whitelist = [:title]
|
110
|
+
(activity_params_or_nil || {}).reject do |attr, value|
|
111
|
+
!(attr.starts_with?('custom_') && allow_custom_attribute?(attr)) &&
|
112
|
+
!activity_params_whitelist.include?(attr.to_sym)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Default before_filter for this controller that renders
|
117
|
+
# +crm_form/not_logged_in+ if the user is not logged in.
|
118
|
+
#
|
119
|
+
# Drop a custom view to change the look, or override this method
|
120
|
+
# if you want different behavior, like a redirect.
|
121
|
+
def authorize
|
122
|
+
render 'not_logged_in' unless logged_in? || allow_anonymous?
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns +true+ if users should see the form even when they are not logged in.
|
126
|
+
# In that case, the WebCRM activity includes a registration request so that a contact
|
127
|
+
# can be created from it.
|
128
|
+
#
|
129
|
+
# The method is also available as helper in your views.
|
130
|
+
#
|
131
|
+
# By default, it returns +false+, i.e. only logged-in users can see the form
|
132
|
+
def allow_anonymous?
|
133
|
+
false
|
134
|
+
end
|
135
|
+
helper_method :allow_anonymous?
|
136
|
+
|
137
|
+
# Returns +true+ if users should be able to fill in the given custom attribute.
|
138
|
+
#
|
139
|
+
# The method is also available as helper and used in +custom_fields_for+ in
|
140
|
+
# +CrmFormHelper+.
|
141
|
+
#
|
142
|
+
# By default, it returns +true+ for any attribute, i.e. every custom attribute
|
143
|
+
# can be filled in by the user.
|
144
|
+
def allow_custom_attribute?(attribute_name)
|
145
|
+
true
|
146
|
+
end
|
147
|
+
helper_method :allow_custom_attribute?
|
148
|
+
|
149
|
+
# Returns a hash of attributes users are allowed to change in their profile.
|
150
|
+
# Use it in your views and your controller.
|
151
|
+
# The hash has only one key, +:contact+, with an array of symbols.
|
152
|
+
#
|
153
|
+
# Do not override this (instance) method. Assign a new hash in your subclass:
|
154
|
+
#
|
155
|
+
# class CrmFormController < RailsConnector::DefaultCrmFormController
|
156
|
+
#
|
157
|
+
# self.editable_attributes_on_register = {
|
158
|
+
# :contact => [:first_name, :last_name, :email]
|
159
|
+
# }
|
160
|
+
#
|
161
|
+
# end
|
162
|
+
def editable_attributes_on_register
|
163
|
+
self.class.editable_attributes_on_register
|
164
|
+
end
|
165
|
+
helper_method :editable_attributes_on_register
|
166
|
+
end
|
167
|
+
end
|