ucb_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +34 -4
  2. data/app/controllers/ucb_rails/admin/base_controller.rb +4 -0
  3. data/app/controllers/ucb_rails/admin/users_controller.rb +70 -0
  4. data/app/controllers/ucb_rails/bootstrap_controller.rb +34 -0
  5. data/app/controllers/ucb_rails/controller_methods.rb +67 -6
  6. data/app/controllers/ucb_rails/home_controller.rb +5 -0
  7. data/app/controllers/ucb_rails/ldap_person_search_controller.rb +15 -0
  8. data/app/controllers/ucb_rails/sessions_controller.rb +33 -8
  9. data/app/helpers/ucb_rails/admin/users_helper.rb +14 -0
  10. data/app/helpers/ucb_rails/extractable_helper.rb +17 -0
  11. data/app/helpers/ucb_rails/icons_helper.rb +7 -0
  12. data/app/helpers/ucb_rails/ldap_person_search_helper.rb +21 -0
  13. data/app/helpers/ucb_rails/lps_typeahead_helper.rb +50 -0
  14. data/app/helpers/ucb_rails/renderer/base.rb +52 -0
  15. data/app/helpers/ucb_rails/renderer/ldap_person_search_result_link.rb +81 -0
  16. data/app/models/ucb_rails/ldap_person/entry.rb +54 -0
  17. data/app/models/ucb_rails/ldap_person/finder.rb +67 -0
  18. data/app/models/ucb_rails/ldap_person/test_finder.rb +50 -0
  19. data/app/models/ucb_rails/user.rb +28 -0
  20. data/app/models/ucb_rails/user_ldap_service.rb +50 -0
  21. data/app/models/ucb_rails/user_session_manager/active_in_user_table.rb +37 -0
  22. data/app/models/ucb_rails/user_session_manager/admin_in_user_table.rb +13 -0
  23. data/app/models/ucb_rails/user_session_manager/base.rb +44 -0
  24. data/app/models/ucb_rails/user_session_manager/in_people_ou.rb +27 -0
  25. data/app/models/ucb_rails/user_session_manager/in_people_ou_add_to_users_table.rb +19 -0
  26. data/app/models/ucb_rails/user_session_manager/ldap_person_user_wrapper.rb +29 -0
  27. data/app/models/ucb_rails/user_table_active.rb +3 -0
  28. data/app/views/ucb_rails/admin/users/_form.html.haml +16 -0
  29. data/app/views/ucb_rails/admin/users/_user.html.haml +12 -0
  30. data/app/views/ucb_rails/admin/users/edit.html.haml +3 -0
  31. data/app/views/ucb_rails/admin/users/index.html.haml +40 -0
  32. data/app/views/ucb_rails/lps/_form.html.haml +16 -0
  33. data/app/views/ucb_rails/lps/_modal.html.haml +6 -0
  34. data/app/views/ucb_rails/lps/_results.html.haml +21 -0
  35. data/app/views/ucb_rails/lps/search.js.haml +2 -0
  36. data/config/routes.rb +18 -1
  37. data/lib/generators/ucb_rails/install_generator.rb +27 -23
  38. data/lib/generators/ucb_rails/templates/README +13 -0
  39. data/lib/generators/ucb_rails/templates/app/assets/javascripts/application.js +19 -0
  40. data/lib/generators/ucb_rails/templates/app/assets/javascripts/lps.js +71 -0
  41. data/lib/generators/ucb_rails/templates/app/assets/javascripts/lps_typeahead.js +56 -0
  42. data/lib/generators/ucb_rails/templates/app/assets/javascripts/typeahead.js +8 -0
  43. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/application.css +14 -0
  44. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/bootstrap_and_overrides.css.scss +3 -0
  45. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/ucb_rails.css.scss +51 -0
  46. data/lib/generators/ucb_rails/templates/app/helpers/ucb_rails/application_helper.rb +12 -0
  47. data/lib/generators/ucb_rails/templates/app/views/layouts/_developer.html.haml +13 -0
  48. data/lib/generators/ucb_rails/templates/app/views/layouts/_footer.html.haml +5 -0
  49. data/lib/generators/ucb_rails/templates/app/views/layouts/_navigation.html.haml +25 -0
  50. data/lib/generators/ucb_rails/templates/app/views/layouts/application.html.haml +22 -0
  51. data/lib/generators/ucb_rails/templates/config/initializers/local/active_record/dom_and_haml.rb +61 -0
  52. data/lib/generators/ucb_rails/templates/config/initializers/local/haml_buffer.rb +20 -0
  53. data/lib/generators/ucb_rails/templates/config/initializers/local/simple_form.rb +142 -0
  54. data/lib/generators/ucb_rails/templates/config/initializers/local/simple_form_bootstrap.rb +45 -0
  55. data/lib/generators/ucb_rails/templates/config/initializers/local/ucb_rails.rb +45 -0
  56. data/lib/generators/ucb_rails/templates/config/locales/simple_form.en.yml +26 -0
  57. data/lib/generators/ucb_rails/templates/db/migrate/create_users.rb +23 -0
  58. data/lib/generators/ucb_rails/templates/lib/templates/haml/scaffold/_form.html.haml +10 -0
  59. data/lib/ucb_rails/engine.rb +22 -1
  60. data/lib/ucb_rails/log_tagger.rb +20 -0
  61. data/lib/ucb_rails/version.rb +1 -1
  62. data/lib/ucb_rails.rb +16 -0
  63. metadata +312 -10
  64. data/lib/generators/ucb_rails/templates/initializer.rb +0 -4
@@ -0,0 +1,71 @@
1
+ $(function() {
2
+
3
+ // clear search fields and results
4
+ function clearLdapPersonSearchForm() {
5
+ $('#first_name').val('');
6
+ $('#last_name').val('');
7
+ $("#lps-results").empty();
8
+ }
9
+
10
+ function setHiddenField(link, dataAttribute) {
11
+ var selector = '#' + dataAttribute;
12
+ var value = link.data(dataAttribute);
13
+
14
+ $(selector).val(value);
15
+ }
16
+
17
+ // add hidden fields to from coming from data attribute of link
18
+ function setHiddenFields(link) {
19
+ setHiddenField(link, 'search-field-name');
20
+ setHiddenField(link, 'result-link-http-method');
21
+ setHiddenField(link, 'result-link-text');
22
+ setHiddenField(link, 'result-link-class');
23
+ setHiddenField(link, 'result-link-url');
24
+ }
25
+
26
+ function setSearchUrl(link) {
27
+ var url = link.data('search-url');
28
+ var formAction = url == undefined ? '/ucb_rails/ldap_person_search' : url;
29
+ $('form#lps-form').attr('action', formAction);
30
+ }
31
+
32
+ // open search dialog
33
+ $('.ldap-person-search').click(function() {
34
+ $('#lps-modal').modal('show');
35
+ $('#first_name').focus();
36
+
37
+ var link = $(this);
38
+ setHiddenFields(link);
39
+ setSearchUrl(link)
40
+ });
41
+
42
+ // Clear button
43
+ $('#lps-clear').click(function() {
44
+ clearLdapPersonSearchForm();
45
+ });
46
+
47
+ // modal shown
48
+ $("#lps-modal").on('show', function() {
49
+ //clearLdapPersonSearchForm();
50
+ $("#first_name").focus();
51
+ });
52
+
53
+ // modal hidden
54
+ $("#lps-modal").on('hide', function() {
55
+ clearLdapPersonSearchForm();
56
+ });
57
+
58
+ // Default handler for search. Implementers should specify a result-link-class
59
+ // data attribute on the element that starts the search.
60
+ $(document).on('click', 'a.result-link-default', function (e) {
61
+ var link = $(this);
62
+ alert('Default click handler: ' + link.data('uid'));
63
+ e.preventDefault();
64
+ hideLpsModal();
65
+ });
66
+
67
+ });
68
+
69
+ function hideLpsModal() {
70
+ $("#lps-modal").modal('hide');
71
+ }
@@ -0,0 +1,56 @@
1
+ $(function() {
2
+
3
+ // prevent browser autocomplete from competing with Bootstrap typeahead
4
+ $('.typeahead-lps-search').attr('autocomplete', 'off');
5
+
6
+ // typing in search field clears uid field
7
+ $('.typeahead-lps-search').keyup(function() {
8
+ var uidSelector = '#' + $(this).data('uid-dom-id');
9
+ $(uidSelector).val('');
10
+ });
11
+
12
+ // default handler for ldap search result link when used with typeahead
13
+ $(document).on('click', 'a.lps-typeahead-item', function (e) {
14
+ var link = $(this);
15
+ var searchFieldSelector = '#' + link.parents('.modal').find('form input#search-field-name').val();
16
+ var searchField = $(searchFieldSelector);
17
+ var uidSelector = '#' + searchField.data('uid-dom-id');
18
+ $(uidSelector).val(link.data('uid'));
19
+ $(searchFieldSelector).val(link.data('first-name') + ' ' + link.data('last-name'));
20
+ e.preventDefault();
21
+ hideLpsModal();
22
+ });
23
+
24
+ // set up typeahead callbacks
25
+ $('.typeahead-lps-search').typeahead({
26
+ source: function(query, process) {
27
+ return $.ajax({
28
+ url: $(this)[0].$element[0].dataset.url,
29
+ type: 'get',
30
+ data: {query: query},
31
+ dataType: 'json',
32
+
33
+ success: function(uid_name_json) {
34
+ names = [];
35
+ map = {};
36
+
37
+ $.each(uid_name_json, function (i, person) {
38
+ map[person.first_last_name] = person;
39
+ names.push(person.first_last_name);
40
+ });
41
+
42
+ process(names);
43
+ }
44
+ });
45
+ },
46
+ updater: function (item) {
47
+ var uidSelector = '#' + $(this)[0].$element[0].dataset.uidDomId;
48
+ $(uidSelector).val(map[item].uid);
49
+ return item;
50
+ },
51
+ matcher: function (item) {
52
+ return true;
53
+ },
54
+ });
55
+
56
+ })
@@ -0,0 +1,8 @@
1
+ // This file was created as part of the ucb_rails installation
2
+
3
+ $(function() {
4
+
5
+ // prevent browser autocomplete from competing with Bootstrap typeahead
6
+ $('.typeahead').attr('autocomplete', 'off');
7
+
8
+ });
@@ -0,0 +1,14 @@
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
+ *= require dataTables/jquery.dataTables.bootstrap
13
+ *= require_tree .
14
+ */
@@ -0,0 +1,3 @@
1
+ $baseFontSize: 13px;
2
+
3
+ @import "bootstrap";
@@ -0,0 +1,51 @@
1
+ a.brand, span.brand {
2
+ &.rails-development {
3
+ background-color: gold;
4
+ color: blue;
5
+ }
6
+
7
+ &.rails-quality_assurance {
8
+ background-color: blue;
9
+ color: gold;
10
+ }
11
+
12
+ }
13
+
14
+ table {
15
+ th.c, td.c {
16
+ text-align: center;
17
+ }
18
+
19
+ th.min, td.min {
20
+ width: 1%;
21
+ }
22
+
23
+ }
24
+
25
+ #lps-modal {
26
+ width: 750px;
27
+
28
+ form {
29
+ input[type="text"] {
30
+ width: 140px;
31
+ margin-right: 10px;
32
+ }
33
+
34
+ #lps-search {
35
+ margin-left: 20px;
36
+ margin-right: 10px;
37
+ }
38
+ }
39
+
40
+ tr.ldap-result-exists {
41
+ opacity: 0.5;
42
+ }
43
+
44
+ }
45
+
46
+ div.control-group.lps-typeahead {
47
+ i.ldap-person-search {
48
+ cursor: pointer;
49
+ }
50
+
51
+ }
@@ -0,0 +1,12 @@
1
+ module UcbRails::ApplicationHelper
2
+
3
+ def app_name
4
+ "Untitled App"
5
+ end
6
+
7
+ # TODO: resolve w/handing of brand() in bootstrap-view-helpers
8
+ def app_name_with_env
9
+ RailsEnvironment.production? ? app_name : "#{app_name} - #{Rails.env.titleize}"
10
+ end
11
+
12
+ end
@@ -0,0 +1,13 @@
1
+ = nav_dropdown("Developer") do
2
+ = dropdown_item("Bootstrap Examples", bvh_path)
3
+
4
+ - if RailsEnvironment.development?
5
+ = dropdown_divider
6
+
7
+ - if defined?(Rack::MiniProfilerRails)
8
+ = nav_list_header('Mini-Profiler')
9
+ = dropdown_item("Enable", url_for(params.merge(pp: 'enable')))
10
+ = dropdown_item("Disable", url_for(params.merge(pp: 'disable')))
11
+ = dropdown_item("Help", url_for(params.merge(pp: 'help')))
12
+ - else
13
+ = dropdown_item('Install rack-mini-profiler to enable this menu')
@@ -0,0 +1,5 @@
1
+ .footer
2
+ %hr
3
+ .container
4
+ %p.muted.credit
5
+ = [UcbRails[:user_session_manager], session[:omniauth_provider] ].join(', ')
@@ -0,0 +1,25 @@
1
+ = nav_bar do
2
+
3
+ = brand(app_name, url: root_path, with_environment: true)
4
+
5
+ = nav_bar_links do
6
+ - if logged_in?
7
+ - if admin?
8
+ = nav_dropdown("Admin") do
9
+ = dropdown_item(announcements_text, admin_announcements_path)
10
+ = dropdown_item(icon('user', "Users"), ucb_rails_admin_users_path)
11
+
12
+ = render partial: 'layouts/developer'
13
+
14
+
15
+ - else
16
+ %li
17
+ = link_to('Login', login_path)
18
+
19
+ - if logged_in?
20
+ = nav_bar_links(pull: 'right') do
21
+ = nav_dropdown("Logged in as #{current_user.first_last_name}") do
22
+ = dropdown_item(announcements_text, hidden_announcements_path)
23
+ = dropdown_divider
24
+ = dropdown_item(icon('remove', 'Logout'), logout_path)
25
+
@@ -0,0 +1,22 @@
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
+ = stylesheet_link_tag "application", :media => "all", "data-turbolinks-track" => false
8
+ =# include_gon
9
+ = javascript_include_tag "application"
10
+ = csrf_meta_tags
11
+ = yield(:head)
12
+ %body{data: {controller: controller.controller_name, action: controller.action_name}}
13
+ = render 'layouts/navigation'
14
+ #main{:role => "main"}
15
+ .container-fluid
16
+ .content
17
+ .row-fluid
18
+ .span12
19
+ = user_announcements
20
+ = flash_messages
21
+ = yield
22
+ = render partial: 'layouts/footer'
@@ -0,0 +1,61 @@
1
+ class ActiveRecord::Base
2
+
3
+ # Create dom id for new or persisted instances. Optionsal _prefix_ parameter.
4
+ #
5
+ # User.new.dom_id => "new_user"
6
+ # User.new.dom_id('my_prefix') => "my_prefix_user"
7
+ # User.find(10).dom_id => "user_10"
8
+ # User.find(10).dom_id('edit') => "edit_user_10"
9
+ #
10
+ def dom_id(prefix = nil)
11
+ prefix ||= 'new' unless id
12
+ [ prefix, self.class.model_name.singular, id ].compact * '_'
13
+ end
14
+
15
+ # Assists in using haml object shortcut [] to put attributes on elements
16
+ #
17
+ # %tr[share]
18
+ # #=> <tr id="share_1" class="shares">
19
+ #
20
+ # %tr[share, :class => 'foo', 'data-bar' => 42]
21
+ # #=> <tr id="share_1" class="shares foo" data-bar="42">
22
+ #
23
+ def haml_attributes(options = {})
24
+ options_out = (options || {}).merge(
25
+ 'id' => dom_id,
26
+ 'always_css_class' => self.class.model_name.singular)
27
+
28
+ self.class.haml_attributes_helper(options_out)
29
+ end
30
+
31
+ class << self
32
+
33
+ def dom_id
34
+ model_name.plural
35
+ end
36
+
37
+ # Assists in using haml object shortcut [] to put attributes on elements
38
+ #
39
+ # %table[Share]
40
+ # #=> <table id="shares" class="table">
41
+ #
42
+ # %table[Share, :class => 'foo', 'data-bar' => 42]
43
+ # #=> <table id="shares" class="table foo" data-bar="42">
44
+ #
45
+ def haml_attributes(options = {})
46
+ options_out = (options || {}).merge('always_css_class' => 'table')
47
+ haml_attributes_helper(options_out)
48
+ end
49
+
50
+ def haml_attributes_helper(options = {})
51
+ attributes = options.stringify_keys
52
+
53
+ attributes["id"] = attributes.delete("id") || dom_id
54
+ attributes["class"] = [attributes.delete('always_css_class'), attributes.delete("class")].
55
+ flatten.map(&:presence).compact
56
+ attributes
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,20 @@
1
+ class Haml::Buffer
2
+
3
+ alias_method :orig_parse_object_ref, :parse_object_ref
4
+
5
+ # Override the method that figures out id/class given something like:
6
+ #
7
+ # %tag[object]
8
+ #
9
+ # An object/class can implement :haml_id_and_class_hash and use that
10
+ # rather than the default.
11
+ def parse_object_ref(ref)
12
+ object, options = ref
13
+
14
+ if object.respond_to?(:haml_attributes)
15
+ object.haml_attributes(options)
16
+ else
17
+ orig_parse_object_ref(ref)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,142 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, :class => :input,
9
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input :placeholder => "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
45
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
46
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # :inline => input + label
54
+ # :nested => label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ # config.form_class = :simple_form
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
110
+ # Default is enabled.
111
+ config.browser_validations = false
112
+
113
+ # Collection of methods to detect if a file type was given.
114
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
115
+
116
+ # Custom mappings for input types. This should be a hash containing a regexp
117
+ # to match as key, and the input type that will be used when the field name
118
+ # matches the regexp as value.
119
+ # config.input_mappings = { /count/ => :integer }
120
+
121
+ # Custom wrappers for input types. This should be a hash containing an input
122
+ # type as key and the wrapper that will be used for all inputs with specified type.
123
+ # config.wrapper_mappings = { :string => :prepend }
124
+
125
+ # Default priority for time_zone inputs.
126
+ # config.time_zone_priority = nil
127
+
128
+ # Default priority for country inputs.
129
+ # config.country_priority = nil
130
+
131
+ # Default size for text inputs.
132
+ # config.default_input_size = 50
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ # config.cache_discovery = !Rails.env.development?
142
+ end
@@ -0,0 +1,45 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
4
+ b.use :html5
5
+ b.use :placeholder
6
+ b.use :label
7
+ b.wrapper :tag => 'div', :class => 'controls' do |ba|
8
+ ba.use :input
9
+ ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
10
+ ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
11
+ end
12
+ end
13
+
14
+ config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
15
+ b.use :html5
16
+ b.use :placeholder
17
+ b.use :label
18
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
19
+ input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
20
+ prepend.use :input
21
+ end
22
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
23
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
24
+ end
25
+ end
26
+
27
+ config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
28
+ b.use :html5
29
+ b.use :placeholder
30
+ b.use :label
31
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
32
+ input.wrapper :tag => 'div', :class => 'input-append' do |append|
33
+ append.use :input
34
+ end
35
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
36
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
37
+ end
38
+ end
39
+
40
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
41
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
42
+ # to learn about the different styles for forms and inputs,
43
+ # buttons and other elements.
44
+ config.default_wrapper = :bootstrap
45
+ end
@@ -0,0 +1,45 @@
1
+ ############################################################
2
+ # Load credentials from config/credentials.yml
3
+ ############################################################
4
+
5
+ credentials_file = Rails.root.join('config/credentials.yml')
6
+ credentials = File.exists?(credentials_file) ? YAML.load_file(credentials_file) : {}
7
+
8
+ ############################################################
9
+ # UCB::LDAP
10
+ ############################################################
11
+
12
+ UCB::LDAP.host = 'nds.berkeley.edu'
13
+ ldap_credentials = credentials["ldap"] || credentials[Rails.env].try(:[], "ldap")
14
+ UCB::LDAP.authenticate(ldap_credentials['username'], ldap_credentials['password']) if ldap_credentials
15
+
16
+ ############################################################
17
+ # OmniAuth
18
+ ############################################################
19
+
20
+ Rails.application.config.middleware.use OmniAuth::Builder do
21
+ provider(:developer, fields: [:uid], uid_field: :uid) unless RailsEnvironment.production?
22
+
23
+ cas_host = RailsEnvironment.production? ? 'auth.berkeley.edu/cas' : 'auth-test.berkeley.edu/cas'
24
+ provider :cas, host: cas_host
25
+ end
26
+
27
+ UcbRails.config do |config|
28
+
29
+ #########################################################
30
+ # manage login authorization, current user, etc.
31
+ #########################################################
32
+
33
+ # config.user_session_manager = "UcbRails::UserSessionManager::InPeopleOu"
34
+ # config.user_session_manager = "UcbRails::UserSessionManager::InPeopleOuAddToUsersTable"
35
+ config.user_session_manager = "UcbRails::UserSessionManager::ActiveInUserTable"
36
+ # config.user_session_manager = "UcbRails::UserSessionManager::AdminInUserTable"
37
+
38
+ #########################################################
39
+ # omniauth authentication provider
40
+ #########################################################
41
+
42
+ config.omniauth_provider = :cas # goes to CalNet
43
+ # config.omniauth_provider = :developer # Users test ldap entries
44
+
45
+ end
@@ -0,0 +1,26 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Labels and hints examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+
@@ -0,0 +1,23 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users, :force => true do |t|
4
+ t.string :uid, :null => false, :limit => 10
5
+ t.string :first_name, :limit => 60
6
+ t.string :last_name, :limit => 60
7
+ t.string :first_last_name, :limit => 100
8
+ t.string :email, :limit => 256
9
+ t.string :phone, :limit => 30
10
+ t.boolean :inactive, :null => false, :default => false
11
+ t.boolean :admin, :null => false, :default => false
12
+ t.datetime :last_login_at
13
+ t.datetime :last_request_at
14
+ t.datetime :last_logout_at
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :users, :uid, :unique => true
19
+ add_index :users, :first_name
20
+ add_index :users, :last_name
21
+ add_index :users, :email
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ = simple_form_for(@<%= singular_table_name %>) do |f|
2
+ = f.error_notification
3
+
4
+ .form-inputs
5
+ <%- attributes.each do |attribute| -%>
6
+ = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
7
+ <%- end -%>
8
+
9
+ .form-actions
10
+ = f.button :submit