feedback_mailer 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in feedback_mailer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Андрей [ws70]
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ feedback_mailer
2
+ ===============
3
+
4
+ Feedback Mailer for Rails app
5
+
6
+ Usage:
7
+
8
+ Gemfile:
9
+
10
+ gem "feedback_mailer"
11
+
12
+ config/initializers/feedback_mailer.rb:
13
+
14
+ FeedbackMailer.setup do |config|
15
+ config.mail_from = "info@site.ru"
16
+ config.mail_to = "info@site.ru"
17
+ config.site_host = "site.ru"
18
+
19
+ # or = [] for text field with theme
20
+ # config.themes = []
21
+ config.themes = [
22
+ "Theme 1",
23
+ "Theme 2"
24
+ ...
25
+ ]
26
+ end
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ class FeedbackController < ApplicationController
3
+ before_filter :build_meta_attributes
4
+ caches_page :index
5
+
6
+ def index; end
7
+
8
+ def create
9
+ @theme = params[:theme].blank? ? I18n.t("feedback_mailer.without_theme") : params[:theme]
10
+ @sender = params[:sender].blank? ? I18n.t("feedback_mailer.without_sender") : params[:sender]
11
+ @body = params[:body].blank? ? "" : params[:body]
12
+ if !@body.blank?
13
+ FeedbackFormMailer.feedback(@theme, @sender, @body).deliver
14
+ flash[:notice] = I18n.t("feedback_mailer.your_letter_sent")
15
+ else
16
+ flash[:error] = I18n.t("feedback_mailer.your_letter_is_not_sent")
17
+ end
18
+ redirect_to after_feedback_path
19
+ end
20
+
21
+ protected
22
+
23
+ def after_feedback_path
24
+ "/contact"
25
+ end
26
+
27
+ def build_meta_attributes
28
+ @meta_title = I18n.t("feedback_mailer.meta_title")
29
+ @meta_description = I18n.t("feedback_mailer.meta_title")
30
+ @meta_keywords = ""
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ class FeedbackFormMailer < ActionMailer::Base
3
+ def feedback(body, sender, theme)
4
+ @body, @sender, @theme = body, sender, theme
5
+ text = ""
6
+ if sender && !sender.blank?
7
+ text += "#{I18n.t('feedback_mailer.email_to_answer')}: #{sender}
8
+
9
+ "
10
+ end
11
+ text += body
12
+ mail(
13
+ :from => FeedbackMailer.mail_from, :to => FeedbackMailer.mail_to,
14
+ :subject => "#{I18n.t('feedback_mailer.letter_from_site')} #{FeedbackMailer.site_host}: #{theme}"
15
+ ) do |format|
16
+ format.text { render :text => text }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ <% content_for :javascripts do %>
2
+ <script type='text/javascript'>
3
+ $(function(){
4
+ $("form.simple").submit(function(){
5
+ $(this).attr("action", "/service/feedback");
6
+ });
7
+ });
8
+ </script>
9
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <%= form_tag "/create_feedback", :class => "simple", :method => :post do %>
2
+ <p>
3
+ <label for="title">Тема</label>
4
+ <span class="required">*</span>
5
+ <% if !FeedbackMailer.themes.blank? %>
6
+ <%= select_tag 'theme', FeedbackMailer.themes %>
7
+ <% else %>
8
+ <%= text_field_tag 'theme', nil %>
9
+ <% end %>
10
+ </p>
11
+ <p>
12
+ <label for="title">Email</label>
13
+ <span class="required">*</span>
14
+ <%= text_field_tag 'sender', nil %>
15
+ </p>
16
+ <p>
17
+ <label for="title">Текст</label>
18
+ <span class="required">*</span>
19
+ <%= text_area_tag 'body', nil, :rows => 10, :cols => 80 %>
20
+ </p>
21
+ <p>
22
+ <%= submit_tag 'Отправить', :class => "btn" %>
23
+ </p>
24
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% page_title "Обратная связь" %>
2
+ <%= render "feedback_mailer/form" %>
3
+ <%= render "feedback_mailer/anti_captcha" %>
@@ -0,0 +1,9 @@
1
+ ru:
2
+ feedback_mailer:
3
+ without_theme: Without theme
4
+ without_sender: Without sender
5
+ your_letter_sent: Your letter sent
6
+ your_letter_is_not_sent: Your letter is not sent
7
+ meta_title: Feedback
8
+ email_to_answer: Email to answer
9
+ letter_from_site: Letter from site
@@ -0,0 +1,9 @@
1
+ ru:
2
+ feedback_mailer:
3
+ without_theme: Без темы
4
+ without_sender: Без отправителя
5
+ your_letter_sent: Ваше письмо отправлено
6
+ your_letter_is_not_sent: Ваше письмо не отправлено, текст сообщения не может быть пустым
7
+ meta_title: Обратная связь
8
+ email_to_answer: Email для ответа
9
+ letter_from_site: Letter from site
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'feedback_mailer/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "feedback_mailer"
8
+ gem.version = FeedbackMailer::VERSION
9
+ gem.authors = ["Андрей [ws70]"]
10
+ gem.email = ["railscode@gmail.com"]
11
+ gem.description = "Feedback Mailer for Rails app"
12
+ gem.summary = "Feedback Mailer for Rails app"
13
+ gem.homepage = "https://github.com/vav/feedback_mailer"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "rails", ">= 2.3.12"
21
+ end
@@ -0,0 +1,2 @@
1
+ require "feedback_mailer/engine"
2
+ require "feedback_mailer/version"
@@ -0,0 +1,12 @@
1
+ module FeedbackMailer
2
+ class Engine < Rails::Engine; end
3
+
4
+ mattr_accessor :mail_from
5
+ mattr_accessor :mail_to
6
+ mattr_accessor :site_host
7
+ mattr_accessor :themes
8
+
9
+ def self.setup
10
+ yield self
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module FeedbackMailer
2
+ VERSION = "0.0.11"
3
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feedback_mailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.11
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Андрей [ws70]
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.12
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.12
30
+ description: Feedback Mailer for Rails app
31
+ email:
32
+ - railscode@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - app/controllers/feedback_controller.rb
43
+ - app/mailers/feedback_form_mailer.rb
44
+ - app/views/feedback_mailer/_anti_captcha.html.erb
45
+ - app/views/feedback_mailer/_form.html.erb
46
+ - app/views/feedback_mailer/index.html.erb
47
+ - config/locales/feedback_mailer.en.yml
48
+ - config/locales/feedback_mailer.ru.yml
49
+ - feedback_mailer.gemspec
50
+ - lib/feedback_mailer.rb
51
+ - lib/feedback_mailer/engine.rb
52
+ - lib/feedback_mailer/version.rb
53
+ homepage: https://github.com/vav/feedback_mailer
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.23
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Feedback Mailer for Rails app
77
+ test_files: []