refinerycms-contacts 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +73 -0
- data/Guardfile +27 -0
- data/LICENSE.md +8 -0
- data/Rakefile +20 -0
- data/app/assets/javascripts/refinery/contacts/admin/contacts.js +17 -0
- data/app/assets/javascripts/refinery/contacts/admin/jquery.chosen.min.js +10 -0
- data/app/assets/javascripts/refinery/contacts/contacts.js +23 -0
- data/app/assets/stylesheets/refinery/contacts/admin/chosen.css.scss +396 -0
- data/app/assets/stylesheets/refinery/contacts/contacts.css.scss +79 -0
- data/app/controllers/refinery/contacts/admin/contacts_controller.rb +14 -0
- data/app/controllers/refinery/contacts/mail_messages_controller.rb +26 -0
- data/app/helpers/refinery/contacts/admin/contacts_helper.rb +18 -0
- data/app/mailers/refinery/contacts/contact_mailer.rb +15 -0
- data/app/models/refinery/contact_page.rb +11 -0
- data/app/models/refinery/contacts/contact.rb +18 -0
- data/app/models/refinery/contacts/mail.rb +13 -0
- data/app/models/refinery/contacts/mail_message.rb +15 -0
- data/app/models/refinery/contacts/table_less_model.rb +23 -0
- data/app/sweepers/refinery/contacts/admin/contact_sweeper.rb +22 -0
- data/app/views/refinery/admin/pages/tabs/contacts/_contacts.html.erb +12 -0
- data/app/views/refinery/admin/pages/tabs/contacts/_contacts_bar.html.erb +4 -0
- data/app/views/refinery/admin/pages/tabs/contacts/_form.html.erb +24 -0
- data/app/views/refinery/contacts/admin/contacts/_actions.html.erb +25 -0
- data/app/views/refinery/contacts/admin/contacts/_contact.html.erb +17 -0
- data/app/views/refinery/contacts/admin/contacts/_contacts.html.erb +2 -0
- data/app/views/refinery/contacts/admin/contacts/_form.html.erb +93 -0
- data/app/views/refinery/contacts/admin/contacts/_mail_fields.html.erb +7 -0
- data/app/views/refinery/contacts/admin/contacts/_records.html.erb +18 -0
- data/app/views/refinery/contacts/admin/contacts/_sortable_list.html.erb +5 -0
- data/app/views/refinery/contacts/admin/contacts/edit.html.erb +1 -0
- data/app/views/refinery/contacts/admin/contacts/index.html.erb +7 -0
- data/app/views/refinery/contacts/admin/contacts/new.html.erb +1 -0
- data/app/views/refinery/contacts/contact_mailer/contact_form.html.erb +1 -0
- data/app/views/refinery/contacts/contact_mailer/contact_form.text.erb +1 -0
- data/app/views/refinery/contacts/contacts/_error_info.html.erb +15 -0
- data/app/views/refinery/contacts/contacts/_form.html.erb +47 -0
- data/app/views/refinery/contacts/contacts/_show.html.erb +50 -0
- data/app/views/refinery/contacts/contacts/_success_info.html.erb +8 -0
- data/changelog.md +2 -0
- data/config/initializers/recaptcha.rb +5 -0
- data/config/initializers/refinery/core.rb +4 -0
- data/config/locales/en.yml +80 -0
- data/config/locales/sk.yml +80 -0
- data/config/routes.rb +23 -0
- data/db/migrate/1_create_contacts_contacts.rb +36 -0
- data/db/migrate/2_create_contacts_mails.rb +17 -0
- data/db/migrate/3_create_contact_pages.rb +20 -0
- data/db/migrate/4_add_homepage_to_contacts.rb +11 -0
- data/db/seeds.rb +13 -0
- data/lib/generators/refinery/contacts_generator.rb +28 -0
- data/lib/generators/refinery/templates/config/initializers/recaptcha.rb.erb +7 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/contacts.rb.erb +4 -0
- data/lib/refinery/contacts.rb +23 -0
- data/lib/refinery/contacts/configuration.rb +10 -0
- data/lib/refinery/contacts/engine.rb +44 -0
- data/lib/refinery/contacts/extensions/pages_extension.rb +40 -0
- data/lib/refinery/contacts/version.rb +17 -0
- data/lib/refinerycms-contacts.rb +1 -0
- data/lib/tasks/refinery/contacts.rake +13 -0
- data/readme.md +170 -0
- data/refinerycms-contacts.gemspec +27 -0
- data/script/rails +10 -0
- data/spec/models/refinery/contacts/contact_spec.rb +18 -0
- data/spec/models/refinery/contacts/mail_spec.rb +18 -0
- data/spec/requests/refinery/contacts/admin/contacts_spec.rb +101 -0
- data/spec/requests/refinery/contacts/admin/mails_spec.rb +101 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/support/factories/refinery/contacts.rb +7 -0
- data/spec/support/factories/refinery/mails.rb +7 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/testing.rake +8 -0
- metadata +147 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if searching? %>
|
2
|
+
<h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
|
3
|
+
<% end %>
|
4
|
+
<div class='pagination_container'>
|
5
|
+
<% if @contacts.any? %>
|
6
|
+
<%= render 'contacts' %>
|
7
|
+
<% else %>
|
8
|
+
<p>
|
9
|
+
<% unless searching? %>
|
10
|
+
<strong>
|
11
|
+
<%= t('.no_items_yet') %>
|
12
|
+
</strong>
|
13
|
+
<% else %>
|
14
|
+
<%= t('no_results', :scope => 'refinery.admin.search') %>
|
15
|
+
<% end %>
|
16
|
+
</p>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<section id='records'>
|
2
|
+
<%= render 'records' %>
|
3
|
+
</section>
|
4
|
+
<aside id='actions'>
|
5
|
+
<%= render 'actions' %>
|
6
|
+
</aside>
|
7
|
+
<%= render '/refinery/admin/make_sortable', :tree => false if !searching? and ::Refinery::Contacts::Admin::ContactsController.sortable? and ::Refinery::Contacts::Contact.count > 1 %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @mail_message.text %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @mail_message.text %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if flash[:mail_message] # Rendering errors %>
|
2
|
+
<div class="errorExplanation" id="errorExplanation">
|
3
|
+
<p><%= t('.problems_in_following_fields') %>:</p>
|
4
|
+
<ul>
|
5
|
+
<% unless Refinery::Contacts.client_side_validations %>
|
6
|
+
<% flash[:mail_message].errors.full_messages.each do |value| %>
|
7
|
+
<li><%= value %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
<% if flash[:recaptcha_error].present? %>
|
11
|
+
<li><%= t("recaptcha.errors.#{flash[:recaptcha_error]}") %></li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<% if @page.mails.present? %>
|
2
|
+
<%= form_for (flash[:mail_message].present?) ? flash[:mail_message] : Refinery::Contacts::MailMessage.new ,
|
3
|
+
:url=> deliver_contacts_mail_messages_path,
|
4
|
+
:validate => true do |f| %>
|
5
|
+
|
6
|
+
<%= render 'refinery/contacts/contacts/success_info' %>
|
7
|
+
<%= render 'refinery/contacts/contacts/error_info' %>
|
8
|
+
|
9
|
+
|
10
|
+
<div class="field ">
|
11
|
+
<%= f.label :recipient_id %>
|
12
|
+
<%= f.collection_select :recipient_id, @page.mails, :id, :mail, {:prompt=> true} %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
|
16
|
+
<div class="field ">
|
17
|
+
<%= f.label :name %>
|
18
|
+
<%= f.text_field :name %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="field ">
|
22
|
+
<%= f.label :sender_mail %>
|
23
|
+
<%= f.text_field :sender_mail %>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="field ">
|
27
|
+
<%= f.label :subject %>
|
28
|
+
<%= f.text_field :subject%>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div class="field ">
|
32
|
+
<%= f.label :text %>
|
33
|
+
<%= f.text_area :text, :rows=>"7", :cols=>"55" %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="field ">
|
37
|
+
<%= f.label t('.antispam') %>
|
38
|
+
<%= recaptcha_tags %>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="field">
|
42
|
+
<%= f.label " " %>
|
43
|
+
<%= f.submit t('.submit') %>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% end %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%# cache "refinery/contacts/contact/#{@page.contact.id}" do # Because of flash error rendering, caching is now commented %>
|
2
|
+
<% if @page.contact.present? %>
|
3
|
+
<% if @page.contact_page.contact_info %>
|
4
|
+
<% if @page.contact.company.present? %>
|
5
|
+
<strong><%= @page.contact.company %></strong><br/>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if @page.contact.street.present? %>
|
9
|
+
<%= @page.contact.street %><br/>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% if @page.contact.city.present? %>
|
13
|
+
<%= @page.contact.city %> <%= @page.contact.zip_code %><br>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% if @page.contact.province.present? %>
|
17
|
+
<%= @page.contact.province %><br/>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<% if @page.contact.country.present? %>
|
21
|
+
<%= @page.contact.country %><br/>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<br/>
|
25
|
+
<% if @page.contact.homepage.present? %>
|
26
|
+
<strong><%= t('.web') %></strong>
|
27
|
+
<%= link_to @page.contact.homepage, @page.contact.homepage, :target=>"_blank" %><br/>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% if @page.contact.tel1.present? || @page.contact.tel2.present? || @page.contact.tel3.present? %>
|
31
|
+
<strong><%= t('.tel') %></strong>
|
32
|
+
<%= [@page.contact.tel1 , @page.contact.tel2, @page.contact.tel3 ].reject{|c| c.empty?}.join(' , ') %><br>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<% if @page.contact.fax.present? %>
|
36
|
+
<strong><%= t('.fax') %></strong>
|
37
|
+
<%= @page.contact.fax %><br/>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<%= render :partial=> 'refinery/contacts/contacts/form' %>
|
42
|
+
<% end %>
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<%# end %>
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if flash[:notice] # Success %>
|
2
|
+
<div id="flash_container">
|
3
|
+
<div id="flash" class="flash flash_notice" style='visibility: hidden;' >
|
4
|
+
<%= flash[:notice] %>
|
5
|
+
<%= link_to t("refinery.message.close_this_message"), "", :id => "flash_close" %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
data/changelog.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
en:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
contacts:
|
5
|
+
title: Contacts
|
6
|
+
tab_name: Contact form
|
7
|
+
admin:
|
8
|
+
pages:
|
9
|
+
tabs:
|
10
|
+
contacts:
|
11
|
+
form:
|
12
|
+
show_contact_info: Show contact informations
|
13
|
+
contact_info_help: Show contact informations like company title, adress, telephone number ...
|
14
|
+
show_contact_form_for: Show contact form for
|
15
|
+
choose_contact: Click to choose contact
|
16
|
+
contacts:
|
17
|
+
admin:
|
18
|
+
contacts:
|
19
|
+
mail_fields:
|
20
|
+
remove: remove
|
21
|
+
form:
|
22
|
+
add_mail: Add e-mail
|
23
|
+
actions:
|
24
|
+
create_new: Add New Contact
|
25
|
+
reorder: Reorder Contacts
|
26
|
+
reorder_done: Done Reordering Contacts
|
27
|
+
records:
|
28
|
+
title: Contacts
|
29
|
+
sorry_no_results: Sorry! There are no results found.
|
30
|
+
no_items_yet: There are no Contacts yet. Click "Add New Contact" to add your first contact.
|
31
|
+
contact:
|
32
|
+
view_live_html: View this contact live <br/><em>(opens in a new window)</em>
|
33
|
+
edit: Edit this contact
|
34
|
+
delete: Remove this contact forever
|
35
|
+
contacts:
|
36
|
+
flash:
|
37
|
+
successfull_delivery: E-mail was send successfully.
|
38
|
+
show:
|
39
|
+
web: 'Web:'
|
40
|
+
tel: 'Tel.:'
|
41
|
+
fax: 'Fax:'
|
42
|
+
form:
|
43
|
+
submit: Send
|
44
|
+
antispam: Antispam
|
45
|
+
error_info:
|
46
|
+
problems_in_following_fields: Problems in following fields
|
47
|
+
activerecord:
|
48
|
+
attributes:
|
49
|
+
refinery/contact_page:
|
50
|
+
contact_info: Contact information
|
51
|
+
refinery/contacts/mail:
|
52
|
+
mail: E-mail
|
53
|
+
refinery/contacts/contact:
|
54
|
+
title: Title
|
55
|
+
street: Street
|
56
|
+
city: City
|
57
|
+
zip_code: Zip Code
|
58
|
+
province: Province
|
59
|
+
country: Country
|
60
|
+
tel1: Tel1
|
61
|
+
tel2: Tel2
|
62
|
+
tel3: Tel3
|
63
|
+
fax: Fax
|
64
|
+
company: Company
|
65
|
+
homepage: Homepage (starts with http://)
|
66
|
+
|
67
|
+
activemodel:
|
68
|
+
attributes:
|
69
|
+
refinery/contacts/mail_message:
|
70
|
+
recipient_id: Recipient
|
71
|
+
name: Name
|
72
|
+
subject: Subject
|
73
|
+
text: Text
|
74
|
+
sender_mail: Your e-mail
|
75
|
+
recaptcha:
|
76
|
+
errors:
|
77
|
+
incorrect-captcha-sol: Captcha code is incorrect
|
78
|
+
verification_failed: Captcha code is incorrect
|
79
|
+
recaptcha_unavailable: Captcha verification failed. Please try again.
|
80
|
+
recaptcha-not-reachable: Captcha verification failed. Please try again.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
sk:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
contacts:
|
5
|
+
title: Kontakty
|
6
|
+
tab_name: Kontaktný formulár
|
7
|
+
admin:
|
8
|
+
pages:
|
9
|
+
tabs:
|
10
|
+
contacts:
|
11
|
+
form:
|
12
|
+
show_contact_info: Zobraziť kontaktné informácie
|
13
|
+
contact_info_help: Zobrazí na stránke informácie ako názov spoločnosti, telefónny kontakt, adresa a pod.
|
14
|
+
show_contact_form_for: Zobraziť kontaktný formulár pre
|
15
|
+
choose_contact: Kliknite pre výber kontaktu
|
16
|
+
contacts:
|
17
|
+
admin:
|
18
|
+
contacts:
|
19
|
+
mail_fields:
|
20
|
+
remove: odstrániť
|
21
|
+
form:
|
22
|
+
add_mail: Pridať e-mail
|
23
|
+
actions:
|
24
|
+
create_new: Pridať kontakt
|
25
|
+
reorder: Preusporiadať kontakty
|
26
|
+
reorder_done: Uložiť usporiadanie kontaktov
|
27
|
+
records:
|
28
|
+
title: Kontakty
|
29
|
+
sorry_no_results: Ľutujeme, ale neboli nájdené žiadne výsledky.
|
30
|
+
no_items_yet: Nie sú vytvorené žiadne kontakty. Kliknite na "Pridať kontakt" pre pridanie prvého kontaktu.
|
31
|
+
contact:
|
32
|
+
view_live_html: Zobraziť náhľad kontaktu<br/><em>(otvorí sa v novom okne)</em>
|
33
|
+
edit: Upraviť kontakt
|
34
|
+
delete: Zmazať kontakt
|
35
|
+
contacts:
|
36
|
+
flash:
|
37
|
+
successfull_delivery: E-mail bol úspešne odoslaný.
|
38
|
+
show:
|
39
|
+
web: 'Web:'
|
40
|
+
tel: 'Tel.:'
|
41
|
+
fax: 'Fax:'
|
42
|
+
form:
|
43
|
+
submit: Odoslať
|
44
|
+
antispam: Antispam
|
45
|
+
error_info:
|
46
|
+
problems_in_following_fields: Vyskytli sa nasledovné problémy
|
47
|
+
activerecord:
|
48
|
+
attributes:
|
49
|
+
refinery/contact_page:
|
50
|
+
contact_info: Kontaktné informácie
|
51
|
+
refinery/contacts/mail:
|
52
|
+
mail: E-mail
|
53
|
+
refinery/contacts/contact:
|
54
|
+
title: Názov
|
55
|
+
street: Ulica
|
56
|
+
city: Mesto
|
57
|
+
zip_code: PSČ
|
58
|
+
province: Provincia
|
59
|
+
country: Štát
|
60
|
+
tel1: Tel. č1
|
61
|
+
tel2: Tel. č2
|
62
|
+
tel3: Tel. č3
|
63
|
+
fax: Fax
|
64
|
+
company: Spoločnosť
|
65
|
+
homepage: Webová stránka (začína http://)
|
66
|
+
|
67
|
+
activemodel:
|
68
|
+
attributes:
|
69
|
+
refinery/contacts/mail_message:
|
70
|
+
recipient_id: Adresát
|
71
|
+
name: Meno
|
72
|
+
subject: Predmet
|
73
|
+
text: Text
|
74
|
+
sender_mail: Váš e-mail
|
75
|
+
recaptcha:
|
76
|
+
errors:
|
77
|
+
incorrect-captcha-sol: Captcha kód je zadaný nesprávne
|
78
|
+
verification_failed: Captcha kód je zadaný nesprávne
|
79
|
+
recaptcha_unavailable: Nepodarilo sa verifikovať captchu. Skúste odoslať formulár opäť.
|
80
|
+
recaptcha-not-reachable: Nepodarilo sa verifikovať captchu. Skúste odoslať formulár opäť.
|
data/config/routes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Refinery::Core::Engine.routes.append do
|
2
|
+
|
3
|
+
# Frontend routes
|
4
|
+
namespace :contacts, :path => '' do
|
5
|
+
resources :mail_messages, :only => :deliver do
|
6
|
+
collection do
|
7
|
+
post :deliver, :as => :deliver
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Admin routes
|
13
|
+
namespace :contacts, :path => '' do
|
14
|
+
namespace :admin, :path => 'refinery' do
|
15
|
+
resources :contacts, :except => :show do
|
16
|
+
collection do
|
17
|
+
post :update_positions
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class CreateContactsContacts < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_contacts do |t|
|
5
|
+
t.string :title
|
6
|
+
t.string :company
|
7
|
+
t.string :street
|
8
|
+
t.string :city
|
9
|
+
t.string :zip_code
|
10
|
+
t.string :province
|
11
|
+
t.string :country
|
12
|
+
t.string :tel1
|
13
|
+
t.string :tel2
|
14
|
+
t.string :tel3
|
15
|
+
t.string :fax
|
16
|
+
t.integer :position
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def down
|
24
|
+
if defined?(::Refinery::UserPlugin)
|
25
|
+
::Refinery::UserPlugin.destroy_all({:name => "refinerycms-contacts"})
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(::Refinery::Page)
|
29
|
+
::Refinery::Page.delete_all({:link_url => "/contacts/contacts"})
|
30
|
+
end
|
31
|
+
|
32
|
+
drop_table :refinery_contacts
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateContactsMails < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_contacts_mails do |t|
|
5
|
+
t.integer :contact_id
|
6
|
+
t.string :mail
|
7
|
+
end
|
8
|
+
add_index :refinery_contacts_mails, :contact_id
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
remove_index :refinery_contacts_mails , :contact_id
|
14
|
+
drop_table :refinery_contacts_mails
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|