live-front-rails 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dc31d13b1ac2ac3790da8c8a36fb9bedc294081
4
- data.tar.gz: a45aa4c6f7589f15b5b498718cb755f747b5c9a2
3
+ metadata.gz: a03d60baa03e5f7887c945bc26c20bd8de32fc4f
4
+ data.tar.gz: 28c43fa33f8cadb6e2206c68c08a61efe1a431bb
5
5
  SHA512:
6
- metadata.gz: 58e1c519b556b4cbb8b15a0834d98835d1bbba0a528c07371186aa66e5b7b8897eacdd5d40186cefd8b448568fd8f99d078f8c7c6cf3e777168be78dbed2c386
7
- data.tar.gz: a922a58c81f7cc1c490f28c40ddfeba7bcfd4e7dac4a1459df86fd18db36819fb0832df860c0c11e57b547fa0a675c9525a9db381ebe5489fa12df6097f161c9
6
+ metadata.gz: eb51f292b6fab324cff286bcdd085342166880903f971f523705a782b8a1b74737af3dfe876f0599c328ff31970eb7d55491100de8d761790128b7cfcf983d49
7
+ data.tar.gz: 843262ba0f60ee886ee34a42385159022396cc23a13b7824c0af426462ffe80b5423416f233447e681cfac0b9e0d9c63ac15d5847e9e3b676dfa626a07e96bd2
data/README.md CHANGED
@@ -79,12 +79,20 @@ nav_link(path: 'tree#show', params: {state: [:_blank, :active]}) { "Hello" }
79
79
  # => '<li class="home active">Hello</li>'
80
80
  ```
81
81
 
82
+ ### SignInFormHelper
83
+
84
+ Form helper to insert basic sign in form.
85
+
86
+ ```
87
+ sign_in_form_for(:sessions, url: sessions_path, class: 'sign-in-form')
88
+ ```
89
+
82
90
  ## Installation
83
91
 
84
92
  Add this line to your application's Gemfile:
85
93
 
86
94
  ```ruby
87
- gem 'live-front-rails', github: 'LiveTyping/live-front-rails'
95
+ gem 'live-front-rails'
88
96
  ```
89
97
 
90
98
  And then execute:
@@ -0,0 +1,45 @@
1
+ .basic-sign-in-form {
2
+ max-width: 400px;
3
+ padding: 15px;
4
+ margin: 0 auto;
5
+
6
+ .sign-in-form-heading {
7
+ font-weight: 300;
8
+ margin-bottom: 15px;
9
+ }
10
+
11
+ .form-control {
12
+ background-color: #F5F5F5;
13
+ position: relative;
14
+ font-size: 16px;
15
+ height: auto;
16
+ padding: 14px 10px;
17
+
18
+ &:active,
19
+ &:focus {
20
+ background-color: #fff;
21
+ z-index: 2;
22
+ }
23
+ }
24
+
25
+ input {
26
+ box-shadow: none;
27
+ }
28
+
29
+ input[type="email"] {
30
+ border-bottom-left-radius: 0;
31
+ border-bottom-right-radius: 0;
32
+ }
33
+
34
+ input[type="password"] {
35
+ margin-top: -1px;
36
+ border-top-left-radius: 0;
37
+ border-top-right-radius: 0;
38
+ }
39
+
40
+ .btn {
41
+ margin-top: 15px;
42
+ padding: 10px;
43
+ font-size: 16px;
44
+ }
45
+ }
@@ -0,0 +1,7 @@
1
+ en:
2
+ sign_in_form:
3
+ heading: Sign in
4
+ form:
5
+ email: email
6
+ password: password
7
+ submit: Sign in
@@ -0,0 +1,7 @@
1
+ ru:
2
+ sign_in_form:
3
+ heading: Вход
4
+ form:
5
+ email: email
6
+ password: пароль
7
+ submit: Вход
@@ -0,0 +1,17 @@
1
+ module LiveFront
2
+ module SignInFormHelper
3
+ def sign_in_form_for(model, options = {})
4
+ klass = options.delete(:class)
5
+ options.merge!(html: { class: ['basic-sign-in-form', klass].compact.join(' ') })
6
+
7
+ form_for model, options do |f|
8
+ [
9
+ content_tag(:h3, I18n.t('sign_in_form.heading'), class: 'sign-in-form-heading'),
10
+ f.email_field(:email, class: 'form-control', placeholder: I18n.t('sign_in_form.form.email'), autofocus: true),
11
+ f.password_field(:password, class: 'form-control', placeholder: I18n.t('sign_in_form.form.password')),
12
+ f.submit(I18n.t('sign_in_form.form.submit'), class: 'btn btn-primary btn-block')
13
+ ].join('').html_safe
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module LiveFront
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'live-front/version'
2
2
  require 'live-front/application_helper'
3
3
  require 'live-front/tab_helper'
4
+ require 'live-front/sign_in_form_helper'
4
5
 
5
6
  module LiveFront
6
7
  if defined?(Rails)
@@ -8,6 +9,7 @@ module LiveFront
8
9
  initializer 'live_front.view_helpers' do
9
10
  ActionView::Base.send :include, LiveFront::ApplicationHelper
10
11
  ActionView::Base.send :include, LiveFront::TabHelper
12
+ ActionView::Base.send :include, LiveFront::SignInFormHelper
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe LiveFront::SignInFormHelper do
4
+ describe '#sign_in_form_for' do
5
+ it 'creates sign in form' do
6
+ form = sign_in_form_for :sessions, url: '/login', class: 'my-sign-in-form'
7
+
8
+ expect(form).to match(/class="basic-sign-in-form my-sign-in-form"/)
9
+ expect(form).to match(/action="\/login"/)
10
+ expect(form).to match(/name="sessions\[email\]"/)
11
+ expect(form).to match(/name="sessions\[password\]"/)
12
+ expect(form).to match(/<h3 class="sign-in-form-heading">Sign in<\/h3>/)
13
+ end
14
+ end
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,21 +1,35 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
 
3
+ require 'pathname'
4
+ require 'rack/test'
3
5
  require 'active_support'
4
6
  require 'action_view'
5
7
  require 'action_controller'
8
+ require 'i18n'
6
9
 
7
10
  require 'live-front-rails'
8
11
 
9
12
  include ActionView::Context
10
13
  include ActionView::Helpers::FormTagHelper
14
+ include ActionView::Helpers::FormHelper
11
15
  include LiveFront::ApplicationHelper
12
16
  include LiveFront::TabHelper
17
+ include LiveFront::SignInFormHelper
18
+
19
+ I18n.load_path += Dir[
20
+ Pathname.new(File.expand_path('../../config/locales', __FILE__)).join('*.{rb,yml}')
21
+ ]
22
+ I18n.default_locale = :en
13
23
 
14
24
  class FooController < ActionController::Base
15
25
  def foo
16
26
  end
17
27
  end
18
28
 
29
+ def protect_against_forgery?
30
+ false
31
+ end
32
+
19
33
  def controller
20
34
  FooController.new
21
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live-front-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Krivko
@@ -92,11 +92,16 @@ files:
92
92
  - LICENSE.txt
93
93
  - README.md
94
94
  - Rakefile
95
+ - app/assets/stylesheets/sign_in_form.scss
96
+ - config/locales/sign_in_form.en.yml
97
+ - config/locales/sign_in_form.ru.yml
95
98
  - lib/live-front-rails.rb
96
99
  - lib/live-front/application_helper.rb
100
+ - lib/live-front/sign_in_form_helper.rb
97
101
  - lib/live-front/tab_helper.rb
98
102
  - lib/live-front/version.rb
99
103
  - live-front-rails.gemspec
104
+ - spec/helpers/sign_in_form_helper_spec.rb
100
105
  - spec/helpers/tab_helper_spec.rb
101
106
  - spec/spec_helper.rb
102
107
  homepage: https://github.com/LiveTyping/live-front-rails
@@ -124,5 +129,6 @@ signing_key:
124
129
  specification_version: 4
125
130
  summary: Useful helpers used at Live Typing
126
131
  test_files:
132
+ - spec/helpers/sign_in_form_helper_spec.rb
127
133
  - spec/helpers/tab_helper_spec.rb
128
134
  - spec/spec_helper.rb