meyasubako 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcdf5c629bc103c25e023658da5225c098cd94e9
4
+ data.tar.gz: 620f0e25280f2ffdf71bf9fb5d6a1733a56310e9
5
+ SHA512:
6
+ metadata.gz: ac248ff7f591350b587acdf28403cbffdc751223ff79a5357e1f7ce27053ecb2fdb19417462428428719bd09400e43ef81aadac824c28005f7c9f280ac382bce
7
+ data.tar.gz: 892293ee63a561f780f237a2bcbd99fbf27b5ad51d4dc9c91740411d5f57a8e7c9ea403cc22f7b1c542541c80f7c6b573f44209488e17cb8383069490a6ca768
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 kami
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Meyasubako
2
+
3
+ [![Build Status](https://travis-ci.org/kami30k/meyasubako.svg)](https://travis-ci.org/kami30k/meyasubako)
4
+
5
+ Meyasubako provides easy to install opinion box for Rails application.
6
+ The submitted opinion is sent by ActionMailer.
7
+ Please look at following demo.
8
+
9
+ Meyasubako (目安箱) is "Opinion Box" in Japanese.
10
+
11
+ ## Demo
12
+
13
+ ![](doc/demo.gif)
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'meyasubako'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ ```
26
+ $ bundle
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ At first, you have to add `require` to your asset files.
32
+
33
+ In `app/assets/javascripts/application.js`:
34
+
35
+ ```js
36
+ //= require meyasubako
37
+ ```
38
+
39
+ In `app/assets/stylesheets/application.css`:
40
+
41
+ ```css
42
+ /*
43
+ *= require meyasubako
44
+ */
45
+ ```
46
+
47
+ Then, you can render opinion box using `render_meyasubako` method where you like in views.
48
+
49
+ ```erb
50
+ <%= render_meyasubako %>
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ You can configure email's `to` and `from`.
56
+ To do this, create `config/initializers/meyasubako.rb` and add this lines:
57
+
58
+ ```ruby
59
+ Meyasubako.configure do |config|
60
+ config.to = 'username@example.com'
61
+ config.from = 'username@example.com'
62
+ end
63
+ ```
64
+
65
+ ## Customize
66
+
67
+ If you want to customize the theme color, set `$meyasubako_color` to your `app/assets/stylesheets/application.scss` like this:
68
+
69
+ ```scss
70
+ /*
71
+ *= require_tree .
72
+ *= require_self
73
+ */
74
+
75
+ $meyasubako_color: #ffa933;
76
+
77
+ @import 'meyasubako';
78
+ ```
79
+
80
+ ![](doc/screenshot.png)
81
+
82
+ ## Languages
83
+
84
+ Following languages are available.
85
+ If you want to add additional language, please send pull request :)
86
+
87
+ - [English](config/locales/en.yml)
88
+ - [Japanese](config/locales/ja.yml)
89
+
90
+ ## Contributing
91
+
92
+ 1. Fork it ( https://github.com/kami30k/meyasubako/fork )
93
+ 2. Create your feature branch (git checkout -b my-new-feature)
94
+ 3. Commit your changes (git commit -am 'Add some feature')
95
+ 4. Push to the branch (git push origin my-new-feature)
96
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,50 @@
1
+ class Meyasubako
2
+ constructor: ->
3
+ @setToggleEvent()
4
+ @setSubmitEvent()
5
+
6
+ setToggleEvent: ->
7
+ $('.meyasubako__heading').on 'click', ->
8
+ container = $('.meyasubako__container')
9
+
10
+ # Switch form visibility
11
+ if container.is(':visible') then container.hide() else container.show()
12
+
13
+ setSubmitEvent: ->
14
+ $('.meyasubako__submit').on 'click', ->
15
+ # Return if textarea is empty
16
+ return false unless $('.meyasubako__content').val()
17
+
18
+ # Disable form
19
+ $('.meyasubako__content').attr('disabled', 'disabled')
20
+ $('.meyasubako__submit').attr('disabled', 'disabled')
21
+
22
+ # Show sending message
23
+ $('.meyasubako__message__container').fadeIn()
24
+
25
+ # Blink message
26
+ interval =
27
+ setInterval ->
28
+ $('.meyasubako__message--sending').fadeOut 500, ->
29
+ $(this).fadeIn 500
30
+ , 1000
31
+
32
+ $.ajax
33
+ type: 'post'
34
+ url: '/meyasubako'
35
+ data:
36
+ authenticity_token: $('#authenticity_token').val()
37
+ content: $('.meyasubako__content').val()
38
+
39
+ success: ->
40
+ # Clear animation
41
+ $('.meyasubako__message--sending').stop()
42
+
43
+ # Stop blinking
44
+ clearInterval(interval)
45
+
46
+ # Show success message
47
+ $('.meyasubako__message--sending').hide()
48
+ $('.meyasubako__message--success').fadeIn()
49
+
50
+ window.Meyasubako = Meyasubako
@@ -0,0 +1,111 @@
1
+ //
2
+ // Customizable variables
3
+ //
4
+
5
+ $meyasubako_color: #39c !default;
6
+
7
+ .meyasubako {
8
+ //
9
+ // Functions
10
+ //
11
+
12
+ @function whiten($color, $weight) {
13
+ @return mix($color, #fff, 100% - $weight);
14
+ }
15
+
16
+ //
17
+ // Variables
18
+ //
19
+
20
+ $base_color: darken(mix(#333, $meyasubako_color), 10%);
21
+
22
+ //
23
+ // Styles
24
+ //
25
+
26
+ position: fixed;
27
+ bottom: 0;
28
+ right: 20px;
29
+ width: 240px;
30
+ background-color: #fff;
31
+ color: $base_color;
32
+ font-size: 16px;
33
+ font-family:'Helvetica Neue', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
34
+ line-height: 1.5;
35
+
36
+ * {
37
+ box-sizing: border-box;
38
+ }
39
+
40
+ #{&}__heading {
41
+ cursor: pointer;
42
+ margin: 0;
43
+ padding: 8px 0 8px 16px;
44
+ border-radius: 2px 2px 0 0;
45
+ background-color: $meyasubako_color;
46
+ color: #fff;
47
+ font-size: 80%;
48
+ font-weight: normal;
49
+ transition: 200ms;
50
+
51
+ &:hover {
52
+ background-color: darken($meyasubako_color, 5%);
53
+ color: darken(#fff, 5%);
54
+ }
55
+ }
56
+
57
+ #{&}__container {
58
+ display: none;
59
+ overflow: hidden;
60
+ padding: 16px;
61
+ border-right: 1px solid whiten($base_color, 80%);
62
+ border-left: 1px solid whiten($base_color, 80%);
63
+ }
64
+
65
+ #{&}__message__container {
66
+ display: none;
67
+ margin-bottom: 8px;
68
+ padding: 8px;
69
+ border-radius: 2px;
70
+ background-color: whiten($meyasubako_color, 95%);
71
+ color: $meyasubako_color;
72
+ font-size: 70%;
73
+ }
74
+
75
+ #{&}__message {
76
+ margin: 0;
77
+ }
78
+
79
+ #{&}__message--success {
80
+ display: none;
81
+ }
82
+
83
+ #{&}__content {
84
+ resize: none;
85
+ width: 100%;
86
+ height: 120px;
87
+ margin-bottom: 8px;
88
+ padding: 8px;
89
+ border: 1px solid whiten($base_color, 80%);
90
+ border-radius: 2px;
91
+ color: $base_color;
92
+ font-size: 80%;
93
+ vertical-align: bottom;
94
+ }
95
+
96
+ #{&}__submit {
97
+ cursor: pointer;
98
+ float: right;
99
+ padding: 8px 16px;
100
+ border: none;
101
+ border-radius: 2px;
102
+ background-color: $meyasubako_color;
103
+ color: #fff;
104
+ transition: 200ms;
105
+
106
+ &:hover {
107
+ background-color: darken($meyasubako_color, 5%);
108
+ color: darken(#fff, 5%);
109
+ }
110
+ }
111
+ }
@@ -0,0 +1,9 @@
1
+ module Meyasubako
2
+ class MeyasubakoController < ActionController::Base
3
+ def create
4
+ MeyasubakoMailer.email(params[:content]).deliver_now
5
+
6
+ render nothing: true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Meyasubako
2
+ module MeyasubakoHelper
3
+ def render_meyasubako
4
+ render 'meyasubako/new'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Meyasubako
2
+ class MeyasubakoMailer < ActionMailer::Base
3
+ default template_path: 'meyasubako_mailer'
4
+
5
+ def email(content)
6
+ @content = content
7
+
8
+ mail(
9
+ to: Meyasubako.config.to,
10
+ from: Meyasubako.config.from,
11
+ subject: I18n.t('meyasubako.subject')
12
+ )
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ <div class="meyasubako">
2
+ <h2 class="meyasubako__heading"><%= I18n.t('meyasubako.heading') %></h2>
3
+
4
+ <div class="meyasubako__container">
5
+ <div class="meyasubako__message__container">
6
+ <p class="meyasubako__message meyasubako__message--sending">
7
+ <%= I18n.t('meyasubako.message.sending') %>
8
+ </p>
9
+
10
+ <p class="meyasubako__message meyasubako__message--success">
11
+ <%= I18n.t('meyasubako.message.success') %>
12
+ </p>
13
+ </div>
14
+
15
+ <%= hidden_field_tag :authenticity_token, form_authenticity_token %>
16
+
17
+ <textarea id="meyasubako__content" class="meyasubako__content" placeholder="<%= I18n.t('meyasubako.content') %>"></textarea>
18
+
19
+ <input type="button" class="meyasubako__submit" value="<%= I18n.t('meyasubako.submit') %>">
20
+ </div>
21
+
22
+ <script>
23
+
24
+ new Meyasubako();
25
+
26
+ </script>
27
+ </div>
@@ -0,0 +1 @@
1
+ <%= @content %>
@@ -0,0 +1,9 @@
1
+ en:
2
+ meyasubako:
3
+ heading: Opinion Box
4
+ content: Please send us your opinion.
5
+ submit: Submit
6
+ message:
7
+ sending: Sending ...
8
+ success: Thank you for sending your opinion.
9
+ subject: Opinion from Meyasubako
@@ -0,0 +1,9 @@
1
+ ja:
2
+ meyasubako:
3
+ heading: ご意見箱
4
+ content: あなたのご意見をお聞かせください。
5
+ submit: 送信する
6
+ message:
7
+ sending: 送信中 ...
8
+ success: ご意見をお聞かせいただき、ありがとうございました。
9
+ subject: 目安箱にご意見が届いています
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Meyasubako::Engine.routes.draw do
2
+ post '/', to: 'meyasubako#create'
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'active_support/configurable'
2
+
3
+ module Meyasubako
4
+ class Config
5
+ include ActiveSupport::Configurable
6
+
7
+ config_accessor :to
8
+ config_accessor :from
9
+
10
+ configure do |config|
11
+ config.to = 'username@example.com'
12
+ config.from = 'username@example.com'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Meyasubako
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Meyasubako
4
+
5
+ initializer 'meyasubako' do
6
+ ActiveSupport.on_load :action_view do
7
+ ActionView::Base.send :include, Meyasubako::MeyasubakoHelper
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Meyasubako
2
+ VERSION = '0.0.1'
3
+ end
data/lib/meyasubako.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'meyasubako/engine'
2
+
3
+ module Meyasubako
4
+ autoload :Config, 'meyasubako/config'
5
+
6
+ class << self
7
+ def configure
8
+ yield config
9
+ end
10
+
11
+ def config
12
+ @config ||= Config.new
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: meyasubako
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kami
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sass-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coffee-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: capybara
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: capybara-email
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: poltergeist
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: letter_opener_web
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Easy to install opinion box for Rails application.
154
+ email:
155
+ - kami30k@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - MIT-LICENSE
161
+ - README.md
162
+ - Rakefile
163
+ - app/assets/javascripts/meyasubako.coffee
164
+ - app/assets/stylesheets/meyasubako.scss
165
+ - app/controllers/meyasubako/meyasubako_controller.rb
166
+ - app/helpers/meyasubako/meyasubako_helper.rb
167
+ - app/mailers/meyasubako/meyasubako_mailer.rb
168
+ - app/views/meyasubako/_new.html.erb
169
+ - app/views/meyasubako_mailer/email.text.erb
170
+ - config/locales/en.yml
171
+ - config/locales/ja.yml
172
+ - config/routes.rb
173
+ - lib/meyasubako.rb
174
+ - lib/meyasubako/config.rb
175
+ - lib/meyasubako/engine.rb
176
+ - lib/meyasubako/version.rb
177
+ homepage: https://github.com/kami30k/meyasubako
178
+ licenses:
179
+ - MIT
180
+ metadata: {}
181
+ post_install_message:
182
+ rdoc_options: []
183
+ require_paths:
184
+ - lib
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 2.2.2
198
+ signing_key:
199
+ specification_version: 4
200
+ summary: Easy to install opinion box for Rails application.
201
+ test_files: []