ucb_rails_cli 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +83 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/bin/ucb_rails +5 -0
  13. data/lib/ucb_rails_cli/cli.rb +182 -0
  14. data/lib/ucb_rails_cli/templates/Gemfile_additions +13 -0
  15. data/lib/ucb_rails_cli/templates/config/config.yml +69 -0
  16. data/lib/ucb_rails_cli/templates/config/initializers/ucb_rails_user.rb +54 -0
  17. data/lib/ucb_rails_cli/templates/config/routes.rb +5 -0
  18. data/lib/ucb_rails_cli/templates/controllers/application_controller.rb +5 -0
  19. data/lib/ucb_rails_cli/templates/helpers/application_helper.rb +11 -0
  20. data/lib/ucb_rails_cli/templates/images/.keep +0 -0
  21. data/lib/ucb_rails_cli/templates/images/logo-ucberkeley-white.png +0 -0
  22. data/lib/ucb_rails_cli/templates/javascripts/application.js +16 -0
  23. data/lib/ucb_rails_cli/templates/stylesheets/application.css +18 -0
  24. data/lib/ucb_rails_cli/templates/stylesheets/main.sass +2 -0
  25. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_layout.sass +8 -0
  26. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_overrides.sass +4 -0
  27. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_variables.sass +11 -0
  28. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/base.sass +3 -0
  29. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/components/_footer.sass +18 -0
  30. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/components/_navbar.sass +99 -0
  31. data/lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/main.sass +2 -0
  32. data/lib/ucb_rails_cli/templates/views/_footer.html.haml +12 -0
  33. data/lib/ucb_rails_cli/templates/views/_navigation.html.haml +42 -0
  34. data/lib/ucb_rails_cli/templates/views/application.html.haml +43 -0
  35. data/lib/ucb_rails_cli/version.rb +3 -0
  36. data/lib/ucb_rails_cli.rb +6 -0
  37. metadata +136 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5c695e9c94e73ca99ebcbdf8a2848c466d36d95
4
+ data.tar.gz: cad1bbe4cdf17094f6e8614c761371c1ae37208f
5
+ SHA512:
6
+ metadata.gz: 1db0e4809bf4c8de956dc556d569404b266edf797df50c43bad062129b60c40c01ec9a1e88e89efc4e2b2aabfd2bd24fa7a62a8f20120631c1af50094bc60f9d
7
+ data.tar.gz: 642f1c621cb4ef01fab1ea8837727de52d77a9ab3a440d2689267387136f9e2df59be6022982d3a70024030e20ee57a398db09670f98d1e9e988266c3f0e21b0
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at darinwilson@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ucb_rails_cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Darin Wilson
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.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # ucb_rails CLI
2
+
3
+ This is the gem for the ucb_rails command line tool. You can use this tool to generate new Rails apps for UCB, which contain many useful features right out of the box:
4
+
5
+ * authentication through [CAS](https://calnetweb.berkeley.edu/calnet-technologists/cas) and user management via the [ucb_rails_user gem](https://github.com/ucb-ist-eas/ucb_rails_user)
6
+ * default home page for logged-in and not-logged-in users
7
+ * nav bar with drop-down menus for developers and admins
8
+ * styles consistent with [UCB brand guidelines](http://brand.berkeley.edu/)
9
+ * HAML for views
10
+ * SASS for CSS
11
+ * RSpec for tests
12
+ * [Datatables](https://datatables.net/) for client-side table sorting
13
+
14
+ **NOTE:** Applications generated with this tool have turbolinks turned off.
15
+
16
+ ## Prerequisites
17
+
18
+ * Ruby >= 2.3
19
+ * Rails >= 5.1
20
+
21
+ Older versions of these might work, but haven't been tested.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ gem install ucb_rails_cli
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ To generate a new app:
32
+
33
+ ```bash
34
+ ucb_rails new my_app_name
35
+ ```
36
+
37
+ This will generate a new Rails app (it runs `rails new` behind the scenes), then adds a lot of extras to give you a working UCB Rails app.
38
+
39
+ If you have options that you want to pass to the `rails new` command, you can specify those using the `rails_options` option:
40
+
41
+ ```bash
42
+ ucb_rails new my_app_name --rails_options "--database postgresql"
43
+ ```
44
+
45
+ Once that command has run, set up the database:
46
+
47
+ ```bash
48
+ cd my_app_name
49
+ bin/rake db:create
50
+ bin/rake db:migrate
51
+ ```
52
+
53
+ then open `config/config.yml` and add the username and password to access LDAP (you can get these credentials from another developer).
54
+
55
+ Now you can start the server:
56
+
57
+ ```bash
58
+ bin/rails s
59
+ ```
60
+
61
+ and point your browser to http://localhost:3000 as usual. You should be able to login and create a user record in your local db by clicking the "Login" link and logging into CAS.
62
+
63
+ ## Customizing Default Behavior
64
+
65
+ An app generated with this tool will have a lot of working features right away. But it's possible to customize or even replace behaviors as needed.
66
+
67
+ ### User Management
68
+
69
+ The user model, login and logout, and user management are provided by the [ucb_rails_user engine.](https://github.com/ucb-ist-eas/ucb_rails_user) See the [README](https://github.com/ucb-ist-eas/ucb_rails_user#overriding-model-and-controller-behavior) file for details on how to add or overwrite behavior to any user-related features.
70
+
71
+ ### CSS
72
+
73
+ Apps generated with `ucb_rails` have default styles in place that are consistent with the [UCB brand guidelines](https://github.com/ucb-ist-eas/ucb_rails_user#overriding-model-and-controller-behavior). These are all located in `app/assets/stylesheets/themes/ucb_standard.` If you don't want to use these styles, just remove this line from `app/assets/stylesheets/main.sass:`
74
+
75
+ ```sass
76
+ @import "themes/ucb_standard/main"
77
+ ```
78
+
79
+ Note that the generated app handles SASS imports slightly differently than standard Rails apps. Rather than use the Sprockets style `*= require_tree .` we just `require main.sass` and use SASS-style imports in `main.sass`.
80
+
81
+ This is to work around the issue of `require_tree` not allowing for the order of the files that get imported. You usually want files containing SASS variables to be included first, so that they're available to other files. Using the `@import` statement explicitly gives you this control.
82
+
83
+ This means that you'll need to manually add an `@import` statement to `main.sass` whenever you add a new SASS file to the project, but you'll have a lot more control over how things are imported.
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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ucb_rails_cli"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/ucb_rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "ucb_rails_cli"
4
+
5
+ UcbRailsCli::Cli.start(ARGV)
@@ -0,0 +1,182 @@
1
+ require "thor"
2
+
3
+ module UcbRailsCli
4
+ class Cli < Thor
5
+ ## error messages
6
+ INSTALL_RAILS = "Unable to find rails - please make sure you've installed Rails 5.1 or greater"
7
+ GEMFILE_ERROR = "Unable to add new gems to Gemfile - check the console output for more info"
8
+ LAYOUT_FILES = "Unable to copy view templates - check the console output for more info"
9
+ HELPER_FILES = "Unable to copy helpers - check the console output for more info"
10
+ ASSETS = "Unable to copy app assets - check the console output for more info"
11
+ ROUTES = "Unable to copy routes file - check the console output for more info"
12
+ MIGRATIONS = "Unable to copy migrations from ucb_rails_user gem - check the console output for more info"
13
+ CONTROLLERS = "Unable to copy controllers - check the console output for more info"
14
+ CONFIG_FILES = "Unable to copy config files - check the console output for more info"
15
+ GITIGNORE = "Unable to update .gitignore - check the console output for more info"
16
+ RSPEC = "Unable to install RSpec - check the console output for more info"
17
+
18
+ desc "new APP_NAME", "generate a new UCB Rails app called NAME"
19
+ option :rails_options
20
+ def new(app_name)
21
+ puts "Generating #{app_name}..."
22
+
23
+ verify_rails or exit_with_error(INSTALL_RAILS)
24
+
25
+ create_rails_app(app_name) or exit_with_error
26
+
27
+ add_to_gemfile(app_name) or exit_with_error(GEMFILE_ERROR)
28
+
29
+ add_layout_files(app_name) or exit_with_error(LAYOUT_FILES)
30
+
31
+ add_helpers(app_name) or exit_with_error(HELPER_FILES)
32
+
33
+ add_assets(app_name) or exit_with_error(ASSETS)
34
+
35
+ add_routes(app_name) or exit_with_error(ROUTES)
36
+
37
+ add_controllers(app_name) or exit_with_error(CONTROLLERS)
38
+
39
+ add_config_files(app_name) or exit_with_error(CONFIG_FILES)
40
+
41
+ update_gitignore(app_name) or exit_with_error(GITIGNORE)
42
+
43
+ install_migrations(app_name) or exit_with_error(MIGRATIONS)
44
+
45
+ setup_rspec(app_name) or exit_with_error(RSPEC)
46
+
47
+ puts <<-END
48
+
49
+ ********************************************************************
50
+ Finished! Your new app is in ./#{app_name}
51
+
52
+ From here, you should set up the database:
53
+
54
+ cd #{app_name}
55
+ bin/rake db:create
56
+ bin/rake db:migrate
57
+
58
+ then add the missing values in config/config.yml - you can get the
59
+ credentials from another developer.
60
+
61
+ At that point, you can start the server as usual:
62
+
63
+ bin/rails server
64
+
65
+ then access the homepage at http://localhost:3000. You should be able
66
+ to login with your usual UCB credentials.
67
+
68
+ Enjoy!
69
+
70
+ END
71
+ end
72
+
73
+ private
74
+
75
+ def exit_with_error(msg="")
76
+ puts msg
77
+ exit -1
78
+ end
79
+
80
+ def verify_rails
81
+ begin
82
+ `rails --version` =~ /Rails 5\./
83
+ rescue Exception => e
84
+ return false
85
+ end
86
+ end
87
+
88
+ def create_rails_app(app_name)
89
+ result = system("rails new #{app_name} #{options[:rails_options]}")
90
+ return true if result
91
+
92
+ puts "Unable to run \"rails new\" to create a new app - check the console output \n" +
93
+ "for more details about what went wrong"
94
+ false
95
+ end
96
+
97
+ def add_to_gemfile(app_name)
98
+ puts "Adding gems to Gemfile..."
99
+ if system("cat #{template_dir}/Gemfile_additions >> #{app_name}/Gemfile")
100
+ puts "Installing new gems..."
101
+ system "cd #{app_name} && bundle install"
102
+ end
103
+ end
104
+
105
+ def add_layout_files(app_name)
106
+ puts "Installing template files..."
107
+ if system("cp #{template_dir}/views/* #{app_name}/app/views/layouts")
108
+ system "rm -f #{app_name}/app/views/layouts/application.html.erb"
109
+ else
110
+ false
111
+ end
112
+ end
113
+
114
+ def add_helpers(app_name)
115
+ puts "Installing helpers..."
116
+ file_contents = `cat #{template_dir}/helpers/application_helper.rb`
117
+ .gsub("%APP_NAME", humanize(app_name))
118
+ system "echo '#{file_contents}' > #{app_name}/app/helpers/application_helper.rb"
119
+ true
120
+ end
121
+
122
+ def add_assets(app_name)
123
+ puts "Installing assets..."
124
+ result =
125
+ system("cp #{template_dir}/stylesheets/main.sass #{app_name}/app/assets/stylesheets") &&
126
+ system("cp -R #{template_dir}/stylesheets/themes #{app_name}/app/assets/stylesheets") &&
127
+ system("cp #{template_dir}/images/* #{app_name}/app/assets/images")
128
+ if result
129
+ # don't clobber the default file until we're sure everything else went through
130
+ system "cp #{template_dir}/stylesheets/application.css #{app_name}/app/assets/stylesheets"
131
+ system "cp #{template_dir}/javascripts/application.js #{app_name}/app/assets/javascripts"
132
+ else
133
+ false
134
+ end
135
+ end
136
+
137
+ def add_routes(app_name)
138
+ puts "Installing routes..."
139
+ system "cp #{template_dir}/config/routes.rb #{app_name}/config/routes.rb"
140
+ end
141
+
142
+ def add_controllers(app_name)
143
+ puts "Installing controllers..."
144
+ system "cp #{template_dir}/controllers/* #{app_name}/app/controllers/"
145
+ end
146
+
147
+ def add_config_files(app_name)
148
+ puts "Installing config files..."
149
+ system("cp #{template_dir}/config/config.yml #{app_name}/config") &&
150
+ system("cp #{template_dir}/config/initializers/ucb_rails_user.rb #{app_name}/config/initializers")
151
+ end
152
+
153
+ def update_gitignore(app_name)
154
+ puts "Updating .gitignore..."
155
+ system "echo 'config/config.yml' >> #{app_name}/.gitignore"
156
+ end
157
+
158
+ def install_migrations(app_name)
159
+ puts "Installing migrations from ucb_rails_user..."
160
+ system "cd #{app_name} && bin/rails railties:install:migrations"
161
+ end
162
+
163
+ def setup_rspec(app_name)
164
+ puts "Setting up rspec..."
165
+ system("cd #{app_name} && bin/spring stop && bin/rails generate rspec:install") &&
166
+ system("rm -rf #{app_name}/test")
167
+ end
168
+
169
+ def template_dir
170
+ "#{File.dirname(__dir__)}/ucb_rails_cli/templates"
171
+ end
172
+
173
+ def humanize(str)
174
+ str
175
+ .gsub("_", " ")
176
+ .split
177
+ .map(&:capitalize)
178
+ .join(" ")
179
+ end
180
+
181
+ end
182
+ end
@@ -0,0 +1,13 @@
1
+
2
+ ########################
3
+ # UCB Rails gems
4
+ gem "haml", "~> 5.0"
5
+ gem "better_errors"
6
+ gem "binding_of_caller"
7
+ gem "ucb_rails_user", github: "ucb-ist-eas/ucb_rails_user"
8
+ gem "rails_view_helpers", github: "ucb-ist-eas/rails_view_helpers", branch: "rails5"
9
+
10
+ group :development, :test do
11
+ gem 'rspec-rails', '~> 3.5'
12
+ end
13
+
@@ -0,0 +1,69 @@
1
+ # You can have configuration per-environment by nesting under the
2
+ # environment key, or have a top level.
3
+
4
+ ldap:
5
+ host: "nds.berkeley.edu"
6
+ username:
7
+ password:
8
+
9
+ development:
10
+
11
+ # Default behavior will do the right thing. Only set if you want
12
+ # non-standard behavior.
13
+ # cas:
14
+ # host: 'auth.berkeley.edu'
15
+ # host: 'auth-test.berkeley.edu'
16
+
17
+ # email:
18
+ # default:
19
+ # from: user@gmail.com
20
+ # default_url_options:
21
+ # host: example.com
22
+ # delivery_method: :smtp
23
+ # # delivery_method: :sendmail
24
+ # # delivery_method: :test
25
+ # # delivery_method: :file
26
+ # raise_delivery_errors: true
27
+ # # send_mail_settings:
28
+ # # location: "/usr/sbin/sendmail"
29
+ # # arguments: "-i -t"
30
+ # smtp_settings:
31
+ # address: smtp.gmail.com
32
+ # port: 587
33
+ # domain: gmail.com
34
+ # user_name: <username>
35
+ # password: <password>
36
+ # authentication: plain
37
+ # enable_starttls_auto: true
38
+ # subject_prefix: '[My App {env}] '
39
+
40
+ # exception_notification:
41
+ # email:
42
+ # email_prefix: '[My App - Error {env}] '
43
+ # sender_address: user@example.com
44
+ # exception_recipients:
45
+ # - user1@example.com
46
+ # - user2@example.com
47
+
48
+ # Default behavior will select the correct host. No need to set anything if
49
+ # you aren't specifying username/password.
50
+ # ldap:
51
+ # host: 'nds.berkeley.edu'
52
+ # host: 'nds-test.berkeley.edu'
53
+ # username: <username>
54
+ # password: <password>
55
+ # # by default test entries returned in all but PROD
56
+ # include_test_entries: true
57
+ # include_test_entries: false
58
+
59
+
60
+ test:
61
+ email:
62
+ default:
63
+ from: test-user@examle.com
64
+ default_url_options:
65
+ host: example.com
66
+ delivery_method: :test
67
+ raise_delivery_errors: true
68
+ subject_prefix: '[My App {env}] '
69
+
@@ -0,0 +1,54 @@
1
+ ############################################################
2
+ # Load configuration from config/config.yml
3
+ ############################################################
4
+
5
+ config = UcbRailsUser::Configuration::Configuration.new
6
+
7
+ ############################################################
8
+ # ActionMailer
9
+ ############################################################
10
+
11
+ #UcbRails::Configuration::Email.configure(config.for('email'))
12
+
13
+ ############################################################
14
+ # Exception Notification
15
+ ############################################################
16
+
17
+ #UcbRails::Configuration::ExceptionNotification.configure(config.for('exception_notification'))
18
+
19
+ ############################################################
20
+ # UCB::LDAP
21
+ ############################################################
22
+
23
+ UcbRailsUser::Configuration::Ldap.configure(config.for('ldap'))
24
+
25
+ ############################################################
26
+ # OmniAuth
27
+ ############################################################
28
+
29
+ UcbRailsUser::Configuration::Cas.configure(config.for('cas'))
30
+
31
+ ############################################################
32
+ # UcbRails
33
+ ############################################################
34
+
35
+ UcbRailsUser.config do |config|
36
+
37
+ #########################################################
38
+ # manage login authorization, current user, etc.
39
+ #########################################################
40
+
41
+ # config.user_session_manager = "UcbRailsUser::UserSessionManager::InPeopleOu"
42
+ # KEEP THIS NEXT ONE
43
+ config.user_session_manager = "UcbRailsUser::UserSessionManager::InPeopleOuAddToUsersTable"
44
+ # config.user_session_manager = "UcbRailsUser::UserSessionManager::ActiveInUserTable"
45
+ # config.user_session_manager = "UcbRailsUser::UserSessionManager::AdminInUserTable"
46
+
47
+ #########################################################
48
+ # omniauth authentication provider
49
+ #########################################################
50
+
51
+ config.omniauth_provider = :cas # goes to CalNet
52
+ # config.omniauth_provider = :developer # Users test ldap entries
53
+
54
+ end
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3
+ root to: UcbRailsUser::HomeController.action(:index)
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ include UcbRailsUser::Concerns::ControllerMethods
3
+
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,11 @@
1
+ module ApplicationHelper
2
+
3
+ def app_name
4
+ "%APP_NAME"
5
+ end
6
+
7
+ def app_name_with_env
8
+ Rails.env.production? ? app_name : "#{app_name} - #{Rails.env.titleize}"
9
+ end
10
+
11
+ end
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require ucb_rails_user/scripts
15
+ //= require_tree .
16
+
@@ -0,0 +1,18 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *
13
+ ************************
14
+ * UCB: don't import stylesheets here - use main.sass to take full advantage of Sass imports
15
+ * http://www.mattboldt.com/organizing-css-and-sass-rails/
16
+ *
17
+ *= require main
18
+ */
@@ -0,0 +1,2 @@
1
+ @import "themes/ucb_standard/main"
2
+ @import "ucb_rails_user/main"
@@ -0,0 +1,8 @@
1
+ #main
2
+ margin-top: 60px
3
+ margin-bottom: 16px
4
+
5
+ // this is to override a body style that's coming from (I think) Bootstrap
6
+ body
7
+ @include standard-text
8
+
@@ -0,0 +1,4 @@
1
+ // patches to default Bootstrap styles go here
2
+
3
+ h1, h2, h3, h4, h5, h6
4
+ font-family: $header-font
@@ -0,0 +1,11 @@
1
+ // TYPEOGRAPHY
2
+ $header-font: "freight-micro-pro", "Source Serif Pro", serif
3
+ $text-font: "Open Sans", sans-serif
4
+
5
+ @mixin standard-text
6
+ font-family: $text-font
7
+ font-size: 14px
8
+
9
+ // COLORS
10
+ $blue: #003262
11
+ $gold: #FDBF2D
@@ -0,0 +1,3 @@
1
+ @import "variables"
2
+ @import "overrides"
3
+ @import "layout"
@@ -0,0 +1,18 @@
1
+ footer#site-footer
2
+ background-color: #003262
3
+ padding: 20px 0
4
+ font-family: $text-font
5
+ font-weight: 600
6
+
7
+ .logo
8
+ margin-left: -30px
9
+
10
+ .copyright
11
+ margin-top: 42px
12
+ color: #ccc
13
+ font-size: 13px
14
+ font-weight: 200
15
+ text-align: right
16
+
17
+
18
+
@@ -0,0 +1,99 @@
1
+ .navbar
2
+ margin-bottom: 20px
3
+ border: 1px solid transparent
4
+ font-family: $text-font
5
+
6
+ // this matches Bootstrap's mysterious -15px margin for the .row class
7
+ .navbar-left
8
+ padding-left: 0
9
+ margin-left: -15px
10
+
11
+ a
12
+ margin-left: -15px
13
+
14
+ .navbar-inverse
15
+ background-color: $blue
16
+ border-color: $blue
17
+
18
+ .navbar-brand
19
+ font-size: 14px
20
+ color: #fff
21
+ line-height: 20px
22
+ padding-top: 11px
23
+ font-weight: 600
24
+
25
+ .navbar-nav > li > a
26
+ font-size: 16px
27
+ color: #fff
28
+ border-bottom: none
29
+ padding-top: 11px
30
+ line-height: 20px
31
+ padding-left: 15px
32
+ padding-right: 15px
33
+ font-weight: 600
34
+
35
+ .navbar-inverse
36
+ background-color: #003262
37
+ border-color: #003262
38
+ .navbar-brand
39
+ color: #9d9d9d
40
+ &:focus, &:hover
41
+ color: #fff
42
+ background-color: transparent
43
+
44
+ .navbar-text
45
+ color: #9d9d9d
46
+
47
+ .navbar-nav >
48
+ li > a
49
+ color: #9d9d9d
50
+ &:focus, &:hover
51
+ color: #fdb515
52
+ background-color: transparent
53
+
54
+ .active > a
55
+ color: #fff
56
+ background-color: #003262
57
+ &:focus, &:hover
58
+ color: #fff
59
+ background-color: #003262
60
+
61
+ .disabled > a
62
+ color: #444
63
+ background-color: transparent
64
+ &:focus, &:hover
65
+ color: #444
66
+ background-color: transparent
67
+
68
+ .navbar-toggle
69
+ border-color: #333
70
+ &:focus, &:hover
71
+ background-color: #333
72
+
73
+ .icon-bar
74
+ background-color: #fff
75
+
76
+ .navbar-collapse, .navbar-form
77
+ border-color: #101010
78
+
79
+ .navbar-nav > .open > a
80
+ color: #fff
81
+ background-color: #003262
82
+ &:focus, &:hover
83
+ color: #fff
84
+ background-color: #003262
85
+
86
+ .navbar-link
87
+ color: #9d9d9d
88
+ &:hover
89
+ color: #fff
90
+
91
+ .btn-link
92
+ color: #9d9d9d
93
+ &:focus, &:hover
94
+ color: #fff
95
+
96
+ &[disabled]
97
+ &:focus, &:hover
98
+ color: #444
99
+
@@ -0,0 +1,2 @@
1
+ @import "base/base"
2
+ @import "components/**/*"
@@ -0,0 +1,12 @@
1
+ %footer#site-footer
2
+ .container
3
+ .row
4
+ .col-sm-6.col-md-7
5
+ .block.logo{:style => "margin-bottom:20px;"}
6
+ %a{:href => "http://www.berkeley.edu/"}
7
+ %img{:alt => "University of California Berkeley", :src => image_path("logo-ucberkeley-white.png")}
8
+ .col-sm-6.col-md-5
9
+ .row
10
+ .col-sm-12
11
+ .copyright
12
+ \© 2017 UC Regents; all rights reserved
@@ -0,0 +1,42 @@
1
+ %nav.navbar.navbar-inverse.navbar-fixed-top
2
+ .container
3
+ #navbar.collapse.navbar-collapse
4
+ %ul.nav.navbar-nav.navbar-left
5
+ %li
6
+ = link_to "Home", "/"
7
+
8
+ %ul.nav.navbar-nav.navbar-right
9
+ - if logged_in?
10
+ - if superuser?
11
+ %li.dropdown
12
+ %a.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}
13
+ Admin
14
+ %span.caret
15
+ %ul.dropdown-menu
16
+ %li
17
+ %a{:href => admin_users_path} Users
18
+ - if Rails.env.development?
19
+ %li.dropdown
20
+ %a.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}
21
+ Developer
22
+ %span.caret
23
+ %ul.dropdown-menu
24
+ %li
25
+ %a{:href => admin_users_path} Users
26
+ %li.dropdown
27
+ %a.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}
28
+ Logged in as #{current_user.full_name}
29
+ %span.caret
30
+ %ul.dropdown-menu
31
+ - if Rails.env.development?
32
+ - if superuser?
33
+ %li
34
+ %a{:href => admin_toggle_superuser_path} Disable superuser
35
+ - else
36
+ %li
37
+ %a{:href => admin_toggle_superuser_path} Enable superuser
38
+ %li
39
+ %a{:href => logout_path} Logout
40
+ - else
41
+ %li
42
+ = link_to('Login', login_path)
@@ -0,0 +1,43 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:charset => "utf-8"}
5
+ %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
6
+ %title= content_for?(:title) ? yield(:title) : app_name_with_env
7
+
8
+
9
+ %link{:href => "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700,800", :rel => "stylesheet"}
10
+ %link{:href => "http://fonts.googleapis.com/css?family=Source+Serif+Pro:400,600,700", :rel => "stylesheet"}>
11
+ %link{:rel => "stylesheet", :href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", :integrity => "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u", :crossorigin => "anonymous"}
12
+ %link{:rel => "stylesheet", :href => "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" }
13
+ %link{:rel => "stylesheet", :href => "https://jqueryui.com/resources/demos/style.css" }
14
+ %link{:rel => "icon", :type => "image/ico", :href => "/assets/favicon.ico" }
15
+
16
+ = stylesheet_link_tag "application", :media => "all", "data-turbolinks-track" => false
17
+
18
+ = csrf_meta_tags
19
+
20
+ %script{:src => "https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"}
21
+ %script{:src => "https://code.jquery.com/ui/1.12.1/jquery-ui.js"}
22
+ %script{:crossorigin => "anonymous", :integrity => "sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa", :src => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"}
23
+
24
+ = javascript_tag "window._token = '#{form_authenticity_token}'"
25
+ = javascript_include_tag "application"
26
+
27
+ = yield(:head)
28
+
29
+ %body{data: {controller: controller.controller_name, action: controller.action_name}}
30
+
31
+ = render 'layouts/navigation'
32
+
33
+ #main{:role => "main"}
34
+ - if logged_in?
35
+ -#= user_announcements
36
+ .container
37
+ %div.row
38
+ = flash_messages
39
+ %div.row
40
+ = yield
41
+
42
+ = render partial: 'layouts/footer'
43
+
@@ -0,0 +1,3 @@
1
+ module UcbRailsCli
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "ucb_rails_cli/version"
2
+ require "ucb_rails_cli/cli"
3
+
4
+ module UcbRailsCli
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ucb_rails_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Darin Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Spin up a new UCB Rails app
70
+ email:
71
+ - darinwilson@gmail.com
72
+ executables:
73
+ - ucb_rails
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - bin/ucb_rails
88
+ - lib/ucb_rails_cli.rb
89
+ - lib/ucb_rails_cli/cli.rb
90
+ - lib/ucb_rails_cli/templates/Gemfile_additions
91
+ - lib/ucb_rails_cli/templates/config/config.yml
92
+ - lib/ucb_rails_cli/templates/config/initializers/ucb_rails_user.rb
93
+ - lib/ucb_rails_cli/templates/config/routes.rb
94
+ - lib/ucb_rails_cli/templates/controllers/application_controller.rb
95
+ - lib/ucb_rails_cli/templates/helpers/application_helper.rb
96
+ - lib/ucb_rails_cli/templates/images/.keep
97
+ - lib/ucb_rails_cli/templates/images/logo-ucberkeley-white.png
98
+ - lib/ucb_rails_cli/templates/javascripts/application.js
99
+ - lib/ucb_rails_cli/templates/stylesheets/application.css
100
+ - lib/ucb_rails_cli/templates/stylesheets/main.sass
101
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_layout.sass
102
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_overrides.sass
103
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/_variables.sass
104
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/base/base.sass
105
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/components/_footer.sass
106
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/components/_navbar.sass
107
+ - lib/ucb_rails_cli/templates/stylesheets/themes/ucb_standard/main.sass
108
+ - lib/ucb_rails_cli/templates/views/_footer.html.haml
109
+ - lib/ucb_rails_cli/templates/views/_navigation.html.haml
110
+ - lib/ucb_rails_cli/templates/views/application.html.haml
111
+ - lib/ucb_rails_cli/version.rb
112
+ homepage: https://github.com/ucb-ist-eas/ucb_rails_cli
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.4.8
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Spin up a new UCB Rails app
136
+ test_files: []