volt-user-templates 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36034976bc2df09e8899d2b4906c1870e5fc0b99
4
+ data.tar.gz: 21b82dd942bec3d470f1f82039fa45c527dc4b0b
5
+ SHA512:
6
+ metadata.gz: 7b5c496f8a0ae3718908822843d5e6bd5d6c55813cd802aa0fcdc6b7ce5feadebc35d653683cd6b7a308ff66099488b9d1c6cec28b8121769b428eef555109d8
7
+ data.tar.gz: 6ae40c51bffd2bff3643b77e6e34e4a5aa950aa22aba572844ae9cdb35962c2214766f26d37f73b882fcefb9db2646c718458ec9750db53d36f5045b93eab338
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in volt-user-templates.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Volt User Templates
2
+
3
+ Volt user templates provide out of the box templates for users to signup, login, and logout. (Forgot password coming soon)
4
+
5
+ ## Install
6
+
7
+ volt-user-templates now ships with volt, but if you have removed it, you can add it back with the following:
8
+
9
+ In your Gemfile, put:
10
+
11
+ ```ruby
12
+ gem 'volt-user-templates'
13
+ ```
14
+
15
+ Then in any component you want to use the templates in, add the following to config/dependencies.rb
16
+
17
+ ```ruby
18
+ component 'user-templates'
19
+ ```
20
+
21
+ ## Use
22
+
23
+ You can use volt-user-template two different ways.
24
+
25
+ 1) You can add routes for it's templates
26
+
27
+ Add the following to your main components route file:
28
+
29
+ ```ruby
30
+ get '/signup', _controller: 'user-templates', _action: 'signup'
31
+ get '/login', _controller: 'user-templates', _action: 'login'
32
+ ```
33
+
34
+ Now you can link to /signup and /login
35
+
36
+ 2) You can include the templates as tags:
37
+
38
+ ### Login
39
+
40
+ ```html
41
+ <:user-templates:login post-login-url="/" />
42
+ ```
43
+
44
+ The login template takes an optional post-login-url that will be redirected to after a successful login.
45
+
46
+ ### Signup
47
+
48
+ ```html
49
+ <:user-templates:signup post-signup-url="/" />
50
+ ```
51
+
52
+ Signup takes an optional post-signup-url that will be redirected to after signup.
53
+
54
+ ### Logout
55
+
56
+ volt-user-templates provides a nav bar tag that provides a login/logout link and shows the users name.
57
+
58
+ ```html
59
+ <:user-templates:menu />
60
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,2 @@
1
+ # Component dependencies
2
+ component 'fields'
@@ -0,0 +1 @@
1
+ # Component routes
@@ -0,0 +1,29 @@
1
+ module UserTemplates
2
+ class LoginController < Volt::ModelController
3
+ reactive_accessor :errors
4
+ reactive_accessor :login
5
+ reactive_accessor :password
6
+
7
+ def do_login
8
+ Volt.login(login, password).then do
9
+ # Successful login, clear out the form
10
+ self.errors = nil
11
+ self.login = ''
12
+ self.password = ''
13
+
14
+ go(attrs.post_login_url.or('/'))
15
+
16
+ nil
17
+ end.fail do |errors|
18
+ # Login fail
19
+ self.errors = errors
20
+ end
21
+ end
22
+
23
+ def use_username?
24
+ auth = Volt.config.auth
25
+ auth && auth.use_username
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ module UserTemplates
2
+ class MenuController < Volt::ModelController
3
+ def show_name
4
+ user = Volt.user
5
+ user._name.or(user._email).or(Volt.user._username)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ module UserTemplates
2
+ class SignupController < Volt::ModelController
3
+ def index
4
+ self.model = store._users.buffer
5
+ end
6
+
7
+ def signup
8
+ save!.then do |result|
9
+ flash._notices << "Signup successful"
10
+
11
+ post_signup_url = attrs.post_signup_url.or('/')
12
+
13
+ go post_signup_url
14
+ end.fail do |err|
15
+ puts "ERR: #{err.inspect}"
16
+ end
17
+ end
18
+
19
+ def use_username?
20
+ auth = Volt.config.auth
21
+ auth && auth.use_username
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ <:Title>
2
+ Login
3
+
4
+ <:Body>
5
+ <div class="row">
6
+ <div class="col-md-6 col-md-offset-3">
7
+ <div class="span4 offset4 well">
8
+ <legend>Please Login</legend>
9
+
10
+ <form e-submit="do_login">
11
+ {{ if errors.present? }}
12
+ <div class="alert alert-danger">{{ errors }}</div>
13
+ {{ end }}
14
+
15
+ <div class="form-group">
16
+ <label class="control-label">
17
+ {{ if use_username? }}
18
+ Username
19
+ {{ else }}
20
+ Email
21
+ {{ end }}
22
+ </label>
23
+ <input class="form-control" type="text" value="{{ login }}">
24
+ </div>
25
+
26
+ <div class="form-group">
27
+ <label class="control-label">Password</label>
28
+ <input class="form-control" type="password" value="{{ password }}">
29
+ </div>
30
+
31
+ <button class="btn btn-info btn-block">Login</button>
32
+ </form>
33
+
34
+ <hr />
35
+ Don't have an account? <a href="/signup">Signup here</a>
36
+ </div>
37
+ </div>
38
+ </div>
39
+
@@ -0,0 +1,25 @@
1
+ <:Body>
2
+
3
+ {{ if Volt.user }}
4
+ <li class="dropdown">
5
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
6
+ <span class="glyphicon glyphicon-user"></span>
7
+ {{ show_name }}
8
+ <span class="caret"></span>
9
+ </a>
10
+ <ul class="dropdown-menu" role="menu">
11
+ <li>
12
+ <a href="/account">Account</a>
13
+ </li>
14
+ <li class="divider"></li>
15
+ <li><a e-click="Volt.logout">Logout</a></li>
16
+ </ul>
17
+ </li>
18
+ {{ else }}
19
+ <li>
20
+ <a href="/login">
21
+ <span class="glyphicon glyphicon-user"></span>
22
+ Login
23
+ </a>
24
+ </li>
25
+ {{ end }}
@@ -0,0 +1,27 @@
1
+ <:Title>
2
+ Signup
3
+
4
+ <:Body>
5
+ <div class="row">
6
+ <div class="col-md-6 col-md-offset-3">
7
+ <div class="span4 offset4 well">
8
+ <legend>Signup</legend>
9
+
10
+ <form e-submit="signup">
11
+ {{ if use_username? }}
12
+ <:fields:text value="{{ _username }}" />
13
+ {{ else }}
14
+ <:fields:text value="{{ _email }}" />
15
+ {{ end}}
16
+ <:fields:text type="password" value="{{ _password }}" />
17
+ <hr />
18
+ <:fields:text value="{{ _name }}" label="Full Name" />
19
+
20
+ <button class="btn btn-info btn-block">Signup</button>
21
+ <hr />
22
+ Already have an account? <a href="/login">Login here</a>
23
+
24
+ </form>
25
+ </div>
26
+ </div>
27
+ </div>
@@ -0,0 +1,9 @@
1
+ require "volt/user/templates/version"
2
+
3
+ class Volt
4
+ class User
5
+ class Templates
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ version = File.read(File.expand_path('../VERSION', __FILE__)).strip
6
+
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "volt-user-templates"
10
+ spec.version = version
11
+ spec.authors = ["Ryan Stout"]
12
+ spec.email = ["ryanstout@gmail.com"]
13
+ spec.summary = %q{Volt user templates provide out of the box templates for users to signup, login, and logout. }
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "volt-fields", "~> 0.0.10"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: volt-user-templates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Stout
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: volt-fields
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.10
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - ryanstout@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - VERSION
53
+ - app/user-templates/config/dependencies.rb
54
+ - app/user-templates/config/routes.rb
55
+ - app/user-templates/controllers/login_controller.rb
56
+ - app/user-templates/controllers/menu_controller.rb
57
+ - app/user-templates/controllers/signup_controller.rb
58
+ - app/user-templates/views/login/index.html
59
+ - app/user-templates/views/menu/index.html
60
+ - app/user-templates/views/signup/index.html
61
+ - lib/volt/user/templates.rb
62
+ - volt-user-templates.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Volt user templates provide out of the box templates for users to signup,
87
+ login, and logout.
88
+ test_files: []