admin_generator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03e88b869b80a4bd750a6e538e3d63f2e505fce4
4
+ data.tar.gz: 0bdb127e846b766d320dbb52f5bd809d1a2a1213
5
+ SHA512:
6
+ metadata.gz: 2a9c2302d2c6606b22baade89d23964060a130a68357d26229905a1eb77b3ac74a902cedb00b74dc8cdf0584a09f1c610b8c20d5bb8622f38a9d5579a8c01028
7
+ data.tar.gz: d852363896128483463429e741cb32546cbb90f19479a13b31943f10dd2a596e3caefd30d66d973b0427b5498f208ed157fa9e692f4ab6a15cd36dd26b3ea37d
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *~
11
+ admin_generator-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in admin_generator.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 jiikko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # AdminGenerator
2
+
3
+ よくある管理画面(sorcery )のベースを作成するgenerator。
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'admin_generator', github: "jiikko/admin_generator"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Usage
18
+ ```shell
19
+ $ bundle exec rails g admin_generator:admin install
20
+ ```
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it ( https://github.com/[my-github-username]/admin_generator/fork )
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create a new Pull Request
@@ -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,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'admin_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "admin_generator"
8
+ spec.version = AdminGenerator::VERSION
9
+ spec.authors = ["jiikko"]
10
+ spec.email = ["n905i.1214@gmail.com"]
11
+
12
+ spec.summary = %q{generate admin page with sorcery}
13
+ spec.description = %q{generate admin page with sorcery.}
14
+ spec.homepage = "https://github.com/jiikko/admin_generator"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency "sorcery", "~> 0.9"
25
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "admin_generator"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ require "admin_generator/version"
2
+ require 'rails/generators'
3
+
4
+ module AdminGenerator
5
+ class AdminGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def init
9
+ gem "sorcery"
10
+
11
+ directory "controllers", "app/controllers"
12
+ directory "views", "app/views"
13
+
14
+ generate "sorcery:install"
15
+ generate "sorcery:install", "activity_logging brute_force_protection --only-submodules"
16
+
17
+ route "namespace :admin do\n root 'home#index'\n end"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module AdminGenerator
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,12 @@
1
+ class Admin::BaseController < ApplicationController
2
+ before_action :login_required
3
+ layout 'admin/application'
4
+
5
+ private
6
+
7
+ def login_required
8
+ unless current_user
9
+ redirect_to admin_login_path
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class Admin::HomeController < Admin::BaseController
2
+ def index
3
+ cookies.permanent[:admin] = true # analyticsの解析が入らないようにするやつ
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ class Admin::SettionsController < Admin::BaseController
2
+ skip_before_filter :login_required, only: %[new, create]
3
+ before_action :login_required, only: %w[destroy]
4
+
5
+ def new
6
+ cookies.permanent[:admin] = true # analyticsの解析が入らないようにするやつ
7
+ redirect_to admin_root_path if current_user
8
+ end
9
+
10
+ def create
11
+ @user = login(params[:username], params[:password], params[:remember_me])
12
+ if @user
13
+ redirect_back_or_to admin_root_path, notice: 'ログインしました'
14
+ else
15
+ flash.now[:alert] = t('invalid_email_or_password')
16
+ render :new
17
+ end
18
+ end
19
+
20
+ def destroy
21
+ logout
22
+ redirect_to root_url, notice: t('sign_out')
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ h1 トップページ
2
+
3
+ = link_to 'ログアウト', admin_logout_path
@@ -0,0 +1,18 @@
1
+ <div class="span10">
2
+ <h1>管理者ログイン</h1>
3
+ <%= form_tag admin_sessions_path do %>
4
+ <div class="field">
5
+ <%= label_tag :username %>
6
+ <%= text_field_tag :username, params[:username] %>
7
+ </div>
8
+ <div class="field">
9
+ <%= label_tag :password %>
10
+ <%= password_field_tag :password %>
11
+ </div>
12
+ <div class="field">
13
+ <%= check_box_tag :remember_me, 1, params[:remember_me] %>
14
+ <%= label_tag :remember_me %>
15
+ </div>
16
+ <div class="actions"><%= submit_tag t('sign_in'), class: 'btn btn-large btn-primary' %></div>
17
+ <% end %>
18
+ </div>
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: admin_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - jiikko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sorcery
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ description: generate admin page with sorcery.
56
+ email:
57
+ - n905i.1214@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - admin_generator.gemspec
71
+ - bin/console
72
+ - bin/setup
73
+ - lib/admin_generator.rb
74
+ - lib/admin_generator/version.rb
75
+ - lib/templates/controllers/admin/base_controller.rb
76
+ - lib/templates/controllers/admin/home_controller.rb
77
+ - lib/templates/controllers/admin/sessios_controller.rb
78
+ - lib/templates/views/admin/home/index.html.slim
79
+ - lib/templates/views/admin/sessions/new.html.erb
80
+ homepage: https://github.com/jiikko/admin_generator
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.6.11
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: generate admin page with sorcery
104
+ test_files: []