red_base 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +339 -0
- data/README.rdoc +40 -0
- data/Rakefile +42 -0
- data/app/assets/fonts/DroidNaskh-Bold.ttf +0 -0
- data/app/assets/fonts/DroidNaskh-Regular.ttf +0 -0
- data/app/assets/fonts/OpenSans-Bold.ttf +0 -0
- data/app/assets/fonts/OpenSans-BoldItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-ExtraBold.ttf +0 -0
- data/app/assets/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Italic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Light.ttf +0 -0
- data/app/assets/fonts/OpenSans-LightItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Regular.ttf +0 -0
- data/app/assets/fonts/OpenSans-Semibold.ttf +0 -0
- data/app/assets/fonts/OpenSans-SemiboldItalic.ttf +0 -0
- data/app/assets/javascripts/red_base/application.js +20 -0
- data/app/assets/javascripts/red_base/dashboard/angular.js +9 -0
- data/app/assets/javascripts/red_base/dashboard/app.js +65 -0
- data/app/assets/javascripts/red_base/dashboard/application.js.erb +24 -0
- data/app/assets/javascripts/red_base/dashboard/functions.js.erb +91 -0
- data/app/assets/javascripts/red_base/dashboard/init.js +38 -0
- data/app/assets/javascripts/red_base/dashboard/init.js~ +0 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-animate.js +1226 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-gettext.js +202 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-resource.js +578 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-route.js +880 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular.js +20031 -0
- data/app/assets/javascripts/red_base/dashboard/lib/lodash.underscore.js +4893 -0
- data/app/assets/javascripts/red_base/dashboard/lib/restangular.js +1066 -0
- data/app/assets/javascripts/red_base/dashboard/locale/translations.js +5 -0
- data/app/assets/javascripts/red_base/dashboard/modules/anim.js +32 -0
- data/app/assets/javascripts/red_base/dashboard/modules/api.js +32 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/auth.js +34 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/group.js +174 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/user.js +122 -0
- data/app/assets/javascripts/red_base/dashboard/modules/list-view.js +293 -0
- data/app/assets/javascripts/red_base/dashboard/modules/logs.js +41 -0
- data/app/assets/javascripts/red_base/dashboard/modules/modules.js +50 -0
- data/app/assets/javascripts/red_base/dashboard/modules/nav.js.erb +92 -0
- data/app/assets/javascripts/red_base/dashboard/templates/application.handlebars.erb +42 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/details.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/index.handlebars.erb +7 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/new.handlebars.erb +39 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/index.handlebars.erb +31 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/details.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/index.handlebars.erb +11 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/new.handlebars.erb +33 -0
- data/app/assets/javascripts/red_base/dashboard/templates/components/list-view.handlebars.erb +59 -0
- data/app/assets/javascripts/red_base/dashboard/templates/components/model-form.handlebars.erb +3 -0
- data/app/assets/javascripts/red_base/dashboard/templates/modules.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/navigation.handlebars.erb +43 -0
- data/app/assets/javascripts/red_base/dashboard/templates/widgets.handlebars +23 -0
- data/app/assets/javascripts/red_base/dashboard/variables.js.erb +17 -0
- data/app/assets/javascripts/red_base/groups.js +2 -0
- data/app/assets/javascripts/red_base/home.js +2 -0
- data/app/assets/javascripts/red_base/i18n.js +13 -0
- data/app/assets/javascripts/red_base/locale/en.json +27 -0
- data/app/assets/javascripts/red_base/locale/fa.json +27 -0
- data/app/assets/javascripts/red_base/users.js +2 -0
- data/app/assets/stylesheets/red_base/base.css.scss +402 -0
- data/app/assets/stylesheets/red_base/dashboard/dashboard.css.scss +169 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/application.css +21 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/base.css.scss.erb +28 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/base.css.scss~ +15 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/direction.css.scss +38 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/application.css +21 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css.scss.erb +31 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css.scss~ +1 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css_flymake.scss +25 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/buttons.css.scss.erb +45 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/direction.css.scss +37 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/red_base/dashboard/sidebar.css.scss +93 -0
- data/app/assets/stylesheets/red_base/devise.css.scss +34 -0
- data/app/assets/stylesheets/red_base/groups.css +4 -0
- data/app/assets/stylesheets/red_base/home.css.scss +14 -0
- data/app/assets/stylesheets/red_base/ltr/application.css +20 -0
- data/app/assets/stylesheets/red_base/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/ltr/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/red_base/mixins.css.scss +15 -0
- data/app/assets/stylesheets/red_base/mixins.css.scss~ +7 -0
- data/app/assets/stylesheets/red_base/rtl/application.css +20 -0
- data/app/assets/stylesheets/red_base/rtl/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/rtl/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/red_base/users.css +4 -0
- data/app/assets/stylesheets/red_base/variables.css.scss +100 -0
- data/app/controllers/red_base/api/v1/groups_controller.rb +65 -0
- data/app/controllers/red_base/api/v1/logs_controller.rb +12 -0
- data/app/controllers/red_base/api/v1/permissions_controller.rb +17 -0
- data/app/controllers/red_base/api/v1/users_controller.rb +54 -0
- data/app/controllers/red_base/api_controller.rb +51 -0
- data/app/controllers/red_base/application_controller.rb +34 -0
- data/app/controllers/red_base/dashboard_controller.rb +40 -0
- data/app/controllers/red_base/home_controller.rb +19 -0
- data/app/controllers/red_base/omniauth/callbacks_controller.rb +43 -0
- data/app/controllers/red_base/users/omniauth_callbacks_controller.rb~ +2 -0
- data/app/helpers/red_base/application_helper.rb +4 -0
- data/app/helpers/red_base/dashboard_helper.rb +5 -0
- data/app/helpers/red_base/groups_helper.rb +4 -0
- data/app/helpers/red_base/home_helper.rb +4 -0
- data/app/helpers/red_base/users_helper.rb +4 -0
- data/app/models/ability.rb +39 -0
- data/app/models/red_base/group.rb +27 -0
- data/app/models/red_base/permission.rb +15 -0
- data/app/models/red_base/user.rb +77 -0
- data/app/views/angularjs_templates/auth/groups/details.html +21 -0
- data/app/views/angularjs_templates/auth/groups/index.html +5 -0
- data/app/views/angularjs_templates/auth/groups/new.html +40 -0
- data/app/views/angularjs_templates/auth/index.html +30 -0
- data/app/views/angularjs_templates/auth/users/details.html +28 -0
- data/app/views/angularjs_templates/auth/users/index.html +6 -0
- data/app/views/angularjs_templates/auth/users/new.html +45 -0
- data/app/views/angularjs_templates/index.html +8 -0
- data/app/views/angularjs_templates/list-view/index.html +66 -0
- data/app/views/angularjs_templates/locale/fa.po +25 -0
- data/app/views/angularjs_templates/locale/templates.pot +24 -0
- data/app/views/angularjs_templates/logs/index.html +6 -0
- data/app/views/angularjs_templates/modules.html +17 -0
- data/app/views/angularjs_templates/nav.html.erb +38 -0
- data/app/views/angularjs_templates/nav.html.erb~ +43 -0
- data/app/views/devise/confirmations/new.html.erb +34 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +44 -0
- data/app/views/devise/passwords/new.html.erb +32 -0
- data/app/views/devise/registrations/edit.html.erb +29 -0
- data/app/views/devise/registrations/new.html.erb +91 -0
- data/app/views/devise/sessions/new.html.erb +98 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +30 -0
- data/app/views/layouts/red_base/application.html.erb +90 -0
- data/app/views/layouts/red_base/dashboard.html.erb +21 -0
- data/app/views/red_base/api/v1/groups/create.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/groups/destroy.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/destroy.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/groups/edit.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/index.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/index.json.jbuilder +6 -0
- data/app/views/red_base/api/v1/groups/new.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/show.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/show.json.jbuilder +5 -0
- data/app/views/red_base/api/v1/groups/update.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/logs/index.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/permissions/index.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/create.html.erb +2 -0
- data/app/views/red_base/api/v1/users/create.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/destroy.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/distroy.html.erb +2 -0
- data/app/views/red_base/api/v1/users/edit.html.erb +2 -0
- data/app/views/red_base/api/v1/users/index.html.erb +2 -0
- data/app/views/red_base/api/v1/users/index.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/users/show.html.erb +2 -0
- data/app/views/red_base/api/v1/users/show.json.jbuilder +2 -0
- data/app/views/red_base/api/v1/users/update.json.jbuilder +1 -0
- data/app/views/red_base/dashboard/index.html.erb +37 -0
- data/app/views/red_base/home/index.html.erb +119 -0
- data/config/initializers/devise.rb +28 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/devise.fa.yml +56 -0
- data/config/locales/fa/LC_MESSAGES/red_base.mo +0 -0
- data/config/locales/fa/messages.mo +0 -0
- data/config/locales/fa/red_base.po +181 -0
- data/config/locales/red_base.pot +181 -0
- data/config/routes.rb +33 -0
- data/db/migrate/20131013091000_devise_create_red_base_users.rb +64 -0
- data/db/migrate/20131020124701_create_red_base_groups.rb +9 -0
- data/db/migrate/20131021170923_create_red_base_permissions.rb +10 -0
- data/db/migrate/20131123120422_add_permissions_groups_table.rb +8 -0
- data/db/seeds.rb +15 -0
- data/lib/devise_patch.rb~ +5 -0
- data/lib/generators/red_base/USAGE +8 -0
- data/lib/generators/red_base/angularjs_resource_generator.rb +74 -0
- data/lib/generators/red_base/install_all_generator.rb +38 -0
- data/lib/generators/red_base/install_generator.rb +42 -0
- data/lib/generators/red_base/install_specs_generator.rb +48 -0
- data/lib/generators/red_base/js_scaffold_generator.rb +232 -0
- data/lib/generators/red_base/templates/README +41 -0
- data/lib/generators/red_base/templates/README~ +4 -0
- data/lib/generators/red_base/templates/SPECS +13 -0
- data/lib/generators/red_base/templates/angularjs/details.html.erb +20 -0
- data/lib/generators/red_base/templates/angularjs/details.html.erb~ +0 -0
- data/lib/generators/red_base/templates/angularjs/index.html.erb +59 -0
- data/lib/generators/red_base/templates/angularjs/module.js.erb +259 -0
- data/lib/generators/red_base/templates/angularjs/new.html.erb +43 -0
- data/lib/generators/red_base/templates/api/controller.rb.erb +54 -0
- data/lib/generators/red_base/templates/api/controller.rb.erb~ +37 -0
- data/lib/generators/red_base/templates/devise.rb +251 -0
- data/lib/generators/red_base/templates/devise.rb~ +238 -0
- data/lib/generators/red_base/templates/fast_gettext.rb +4 -0
- data/lib/generators/red_base/templates/features/api.feature +92 -0
- data/lib/generators/red_base/templates/features/api.step.rb +7 -0
- data/lib/generators/red_base/templates/features/step_definitions/email_steps.rb +206 -0
- data/lib/generators/red_base/templates/features/support/email_spec.rb +1 -0
- data/lib/generators/red_base/templates/features/support/env.rb +79 -0
- data/lib/generators/red_base/templates/formtastic.rb +76 -0
- data/lib/generators/red_base/templates/js_scaffold.README +25 -0
- data/lib/generators/red_base/templates/red_base.rb +14 -0
- data/lib/generators/red_base/templates/red_base.rb~ +251 -0
- data/lib/generators/red_base/templates/seeds.rb +1 -0
- data/lib/generators/red_base/templates/spec/factories/groups.rb +5 -0
- data/lib/generators/red_base/templates/spec/factories/users.rb +10 -0
- data/lib/generators/red_base/templates/spec/spec_helper.rb +69 -0
- data/lib/generators/red_base/templates/spec/support/devise.rb +3 -0
- data/lib/generators/red_base/templates/views/create.json.jbuilder.erb +2 -0
- data/lib/generators/red_base/templates/views/destroy.json.jbuilder.erb +1 -0
- data/lib/generators/red_base/templates/views/index.json.jbuilder.erb +10 -0
- data/lib/generators/red_base/templates/views/index.json.jbuilder.erb~ +0 -0
- data/lib/generators/red_base/templates/views/show.json.jbuilder.erb +6 -0
- data/lib/generators/red_base/templates/views/update.json.jbuilder.erb +6 -0
- data/lib/generators/red_base/views_generator.rb +41 -0
- data/lib/red_base/active_record.rb +78 -0
- data/lib/red_base/active_record.rb~ +0 -0
- data/lib/red_base/api/groups_api.rb +41 -0
- data/lib/red_base/api/permissions_api.rb +24 -0
- data/lib/red_base/api/root.rb +15 -0
- data/lib/red_base/api/users_api.rb +20 -0
- data/lib/red_base/api.rb +61 -0
- data/lib/red_base/cucumber/auth.rb +45 -0
- data/lib/red_base/cucumber/exceptions.rb +40 -0
- data/lib/red_base/cucumber/interaction.rb +43 -0
- data/lib/red_base/cucumber/query.rb +28 -0
- data/lib/red_base/cucumber/urls.rb +76 -0
- data/lib/red_base/cucumber.rb +25 -0
- data/lib/red_base/dashboard/controller.rb +42 -0
- data/lib/red_base/dashboard/module.rb +45 -0
- data/lib/red_base/dashboard/module.rb~ +25 -0
- data/lib/red_base/dashboard.rb +60 -0
- data/lib/red_base/dashboard.rb~ +18 -0
- data/lib/red_base/engine.rb +132 -0
- data/lib/red_base/exceptions.rb +26 -0
- data/lib/red_base/i18n.rb +35 -0
- data/lib/red_base/initialize.rb +7 -0
- data/lib/red_base/omniauth/callbacks.rb +58 -0
- data/lib/red_base/omniauth/callbakcs.rb~ +7 -0
- data/lib/red_base/omniauth.rb +24 -0
- data/lib/red_base/omniauth.rb~ +1 -0
- data/lib/red_base/plugins.rb +44 -0
- data/lib/red_base/version.rb +22 -0
- data/lib/red_base.rb +30 -0
- data/lib/tasks/grunt/Gruntfile.js +25 -0
- data/lib/tasks/red_base_tasks.rake +23 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +52 -0
- metadata +661 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Set the default text field size when input is a string. Default is nil.
|
4
|
+
# Formtastic::FormBuilder.default_text_field_size = 50
|
5
|
+
|
6
|
+
# Set the default text area height when input is a text. Default is 20.
|
7
|
+
# Formtastic::FormBuilder.default_text_area_height = 5
|
8
|
+
|
9
|
+
# Set the default text area width when input is a text. Default is nil.
|
10
|
+
# Formtastic::FormBuilder.default_text_area_width = 50
|
11
|
+
|
12
|
+
# Should all fields be considered "required" by default?
|
13
|
+
# Defaults to true.
|
14
|
+
# Formtastic::FormBuilder.all_fields_required_by_default = true
|
15
|
+
|
16
|
+
# Should select fields have a blank option/prompt by default?
|
17
|
+
# Defaults to true.
|
18
|
+
# Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
19
|
+
|
20
|
+
# Set the string that will be appended to the labels/fieldsets which are required
|
21
|
+
# It accepts string or procs and the default is a localized version of
|
22
|
+
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
23
|
+
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
24
|
+
# abbr tag, you can simply give a string as below
|
25
|
+
# Formtastic::FormBuilder.required_string = "(required)"
|
26
|
+
|
27
|
+
# Set the string that will be appended to the labels/fieldsets which are optional
|
28
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
29
|
+
# Formtastic::FormBuilder.optional_string = "(optional)"
|
30
|
+
|
31
|
+
# Set the way inline errors will be displayed.
|
32
|
+
# Defaults to :sentence, valid options are :sentence, :list, :first and :none
|
33
|
+
# Formtastic::FormBuilder.inline_errors = :sentence
|
34
|
+
# Formtastic uses the following classes as default for hints, inline_errors and error list
|
35
|
+
|
36
|
+
# If you override the class here, please ensure to override it in your stylesheets as well
|
37
|
+
# Formtastic::FormBuilder.default_hint_class = "inline-hints"
|
38
|
+
# Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
|
39
|
+
# Formtastic::FormBuilder.default_error_list_class = "errors"
|
40
|
+
|
41
|
+
# Set the method to call on label text to transform or format it for human-friendly
|
42
|
+
# reading when formtastic is used without object. Defaults to :humanize.
|
43
|
+
# Formtastic::FormBuilder.label_str_method = :humanize
|
44
|
+
|
45
|
+
# Set the array of methods to try calling on parent objects in :select and :radio inputs
|
46
|
+
# for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
|
47
|
+
# that is found on the object will be used.
|
48
|
+
# Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
49
|
+
# Formtastic::FormBuilder.collection_label_methods = [
|
50
|
+
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
51
|
+
|
52
|
+
# Specifies if labels/hints for input fields automatically be looked up using I18n.
|
53
|
+
# Default value: true. Overridden for specific fields by setting value to true,
|
54
|
+
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
|
55
|
+
# Formtastic::FormBuilder.i18n_lookups_by_default = false
|
56
|
+
|
57
|
+
# Specifies if I18n lookups of the default I18n Localizer should be cached to improve performance.
|
58
|
+
# Defaults to true.
|
59
|
+
# Formtastic::FormBuilder.i18n_cache_lookups = false
|
60
|
+
|
61
|
+
# Specifies the class to use for localization lookups. You can create your own
|
62
|
+
# class and use it instead by subclassing Formtastic::Localizer (which is the default).
|
63
|
+
# Formtastic::FormBuilder.i18n_localizer = MyOwnLocalizer
|
64
|
+
|
65
|
+
# You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
|
66
|
+
# specifying that class here. Defaults to Formtastic::FormBuilder.
|
67
|
+
# Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
|
68
|
+
|
69
|
+
# You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
|
70
|
+
# and `<textarea>` tags by setting this to false (defaults to true).
|
71
|
+
# Formtastic::FormBuilder.use_required_attribute = true
|
72
|
+
|
73
|
+
# You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
|
74
|
+
# this to false. Doing so will add a `novalidate` attribute to the `<form>` tag.
|
75
|
+
# See http://diveintohtml5.org/forms.html#validation for more info.
|
76
|
+
# Formtastic::FormBuilder.perform_browser_validations = true
|
@@ -0,0 +1,25 @@
|
|
1
|
+
==================================================
|
2
|
+
Steps to installation:
|
3
|
+
|
4
|
+
0. You have to have a working model to use this scaffold. So create
|
5
|
+
your model and setup validations, relations and other stuff.
|
6
|
+
|
7
|
+
1. Add resource to routes.rb for example in case of `car` scaffold do:
|
8
|
+
|
9
|
+
namespace :api, :defaults => {:format => :json} do
|
10
|
+
namespace :v1 do
|
11
|
+
resources :cars
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
2. The Angularjs module of your resource should be added as an dependency
|
16
|
+
to another Angularjs module. Add it by hand or if you want to view module
|
17
|
+
in dashboard's main page add your resource to `config/initializers/red_base.rb`
|
18
|
+
like this:
|
19
|
+
|
20
|
+
config.dashboard_modules = {
|
21
|
+
:car => {
|
22
|
+
:icon => "fa fa-car",
|
23
|
+
:sidemenu => true,
|
24
|
+
},
|
25
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RedBase::Engine.setup do |config|
|
2
|
+
# Logger settings for RedBase.
|
3
|
+
# Default value is the rails logger
|
4
|
+
# config.logger = Logger.new(STDOUT)
|
5
|
+
|
6
|
+
# Add your models which want to manage their permissions
|
7
|
+
config.models_with_permission = []
|
8
|
+
|
9
|
+
# Url prefix for dashboard section. default is '/dashboard'
|
10
|
+
# config.dashboard_namespace = :dashboard
|
11
|
+
|
12
|
+
# If you want to use red base layout in rtl mode
|
13
|
+
# config.layout_direction = :rtl
|
14
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# The secret key used by Devise. Devise uses this key to generate
|
5
|
+
# random tokens. Changing this key will render invalid all existing
|
6
|
+
# confirmation, reset password and unlock tokens in the database.
|
7
|
+
config.secret_key = '<%= SecureRandom.hex(64) %>'
|
8
|
+
|
9
|
+
# ==> Mailer Configuration
|
10
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
11
|
+
# note that it will be overwritten if you use your own mailer class
|
12
|
+
# with default "from" parameter.
|
13
|
+
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
14
|
+
|
15
|
+
# Configure the class responsible to send e-mails.
|
16
|
+
# config.mailer = 'Devise::Mailer'
|
17
|
+
|
18
|
+
# ==> ORM configuration
|
19
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
20
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
21
|
+
# available as additional gems.
|
22
|
+
require 'devise/orm/<%= options[:orm] %>'
|
23
|
+
|
24
|
+
# ==> Configuration for any authentication mechanism
|
25
|
+
# Configure which keys are used when authenticating a user. The default is
|
26
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
27
|
+
# authenticating a user, both parameters are required. Remember that those
|
28
|
+
# parameters are used only when authenticating and not when retrieving from
|
29
|
+
# session. If you need permissions, you should implement that in a before filter.
|
30
|
+
# You can also supply a hash where the value is a boolean determining whether
|
31
|
+
# or not authentication should be aborted when the value is not present.
|
32
|
+
# config.authentication_keys = [ :email ]
|
33
|
+
|
34
|
+
# Configure parameters from the request object used for authentication. Each entry
|
35
|
+
# given should be a request method and it will automatically be passed to the
|
36
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
37
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
38
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
39
|
+
# config.request_keys = []
|
40
|
+
|
41
|
+
# Configure which authentication keys should be case-insensitive.
|
42
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
43
|
+
# to authenticate or find a user. Default is :email.
|
44
|
+
config.case_insensitive_keys = [ :email ]
|
45
|
+
|
46
|
+
# Configure which authentication keys should have whitespace stripped.
|
47
|
+
# These keys will have whitespace before and after removed upon creating or
|
48
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
49
|
+
config.strip_whitespace_keys = [ :email ]
|
50
|
+
|
51
|
+
# Tell if authentication through request.params is enabled. True by default.
|
52
|
+
# It can be set to an array that will enable params authentication only for the
|
53
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
54
|
+
# enable it only for database (email + password) authentication.
|
55
|
+
# config.params_authenticatable = true
|
56
|
+
|
57
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
58
|
+
# It can be set to an array that will enable http authentication only for the
|
59
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
60
|
+
# enable it only for database authentication. The supported strategies are:
|
61
|
+
# :database = Support basic authentication with authentication key + password
|
62
|
+
# config.http_authenticatable = false
|
63
|
+
|
64
|
+
# If http headers should be returned for AJAX requests. True by default.
|
65
|
+
# config.http_authenticatable_on_xhr = true
|
66
|
+
|
67
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
68
|
+
# config.http_authentication_realm = 'Application'
|
69
|
+
|
70
|
+
# It will change confirmation, password recovery and other workflows
|
71
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
72
|
+
# Does not affect registerable.
|
73
|
+
# config.paranoid = true
|
74
|
+
|
75
|
+
# By default Devise will store the user in session. You can skip storage for
|
76
|
+
# particular strategies by setting this option.
|
77
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
78
|
+
# may want to disable generating routes to Devise's sessions controller by
|
79
|
+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
80
|
+
config.skip_session_storage = [:http_auth]
|
81
|
+
|
82
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
83
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
84
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
85
|
+
# from the server. You can disable this option at your own risk.
|
86
|
+
# config.clean_up_csrf_token_on_authentication = true
|
87
|
+
|
88
|
+
# ==> Configuration for :database_authenticatable
|
89
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
90
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
91
|
+
#
|
92
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
93
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
94
|
+
# a value less than 10 in other environments.
|
95
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
96
|
+
|
97
|
+
# Setup a pepper to generate the encrypted password.
|
98
|
+
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
99
|
+
|
100
|
+
# ==> Configuration for :confirmable
|
101
|
+
# A period that the user is allowed to access the website even without
|
102
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
103
|
+
# able to access the website for two days without confirming his account,
|
104
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
105
|
+
# the user cannot access the website without confirming his account.
|
106
|
+
# config.allow_unconfirmed_access_for = 2.days
|
107
|
+
|
108
|
+
# A period that the user is allowed to confirm their account before their
|
109
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
110
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
111
|
+
# their account can't be confirmed with the token any more.
|
112
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
113
|
+
# before confirming their account.
|
114
|
+
# config.confirm_within = 3.days
|
115
|
+
|
116
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
117
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
118
|
+
# db field (see migrations). Until confirmed new email is stored in
|
119
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
120
|
+
config.reconfirmable = true
|
121
|
+
|
122
|
+
# Defines which key will be used when confirming an account
|
123
|
+
# config.confirmation_keys = [ :email ]
|
124
|
+
|
125
|
+
# ==> Configuration for :rememberable
|
126
|
+
# The time the user will be remembered without asking for credentials again.
|
127
|
+
# config.remember_for = 2.weeks
|
128
|
+
|
129
|
+
# If true, extends the user's remember period when remembered via cookie.
|
130
|
+
# config.extend_remember_period = false
|
131
|
+
|
132
|
+
# Options to be passed to the created cookie. For instance, you can set
|
133
|
+
# :secure => true in order to force SSL only cookies.
|
134
|
+
# config.rememberable_options = {}
|
135
|
+
|
136
|
+
# ==> Configuration for :validatable
|
137
|
+
# Range for password length. Default is 8..128.
|
138
|
+
config.password_length = 8..128
|
139
|
+
|
140
|
+
# Email regex used to validate email formats. It simply asserts that
|
141
|
+
# one (and only one) @ exists in the given string. This is mainly
|
142
|
+
# to give user feedback and not to assert the e-mail validity.
|
143
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
144
|
+
|
145
|
+
# ==> Configuration for :timeoutable
|
146
|
+
# The time you want to timeout the user session without activity. After this
|
147
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
148
|
+
# config.timeout_in = 30.minutes
|
149
|
+
|
150
|
+
# If true, expires auth token on session timeout.
|
151
|
+
# config.expire_auth_token_on_timeout = false
|
152
|
+
|
153
|
+
# ==> Configuration for :lockable
|
154
|
+
# Defines which strategy will be used to lock an account.
|
155
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
156
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
157
|
+
# config.lock_strategy = :failed_attempts
|
158
|
+
|
159
|
+
# Defines which key will be used when locking and unlocking an account
|
160
|
+
# config.unlock_keys = [ :email ]
|
161
|
+
|
162
|
+
# Defines which strategy will be used to unlock an account.
|
163
|
+
# :email = Sends an unlock link to the user email
|
164
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
165
|
+
# :both = Enables both strategies
|
166
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
167
|
+
# config.unlock_strategy = :both
|
168
|
+
|
169
|
+
# Number of authentication tries before locking an account if lock_strategy
|
170
|
+
# is failed attempts.
|
171
|
+
# config.maximum_attempts = 20
|
172
|
+
|
173
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
174
|
+
# config.unlock_in = 1.hour
|
175
|
+
|
176
|
+
# ==> Configuration for :recoverable
|
177
|
+
#
|
178
|
+
# Defines which key will be used when recovering the password for an account
|
179
|
+
# config.reset_password_keys = [ :email ]
|
180
|
+
|
181
|
+
# Time interval you can reset your password with a reset password key.
|
182
|
+
# Don't put a too small interval or your users won't have the time to
|
183
|
+
# change their passwords.
|
184
|
+
config.reset_password_within = 6.hours
|
185
|
+
|
186
|
+
# ==> Configuration for :encryptable
|
187
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
188
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
189
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
190
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
191
|
+
# REST_AUTH_SITE_KEY to pepper).
|
192
|
+
#
|
193
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
194
|
+
# config.encryptor = :sha512
|
195
|
+
|
196
|
+
# ==> Scopes configuration
|
197
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
198
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
199
|
+
# are using only default views.
|
200
|
+
# config.scoped_views = false
|
201
|
+
|
202
|
+
# Configure the default scope given to Warden. By default it's the first
|
203
|
+
# devise role declared in your routes (usually :user).
|
204
|
+
# config.default_scope = :user
|
205
|
+
|
206
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
207
|
+
# only the current scope. By default, Devise signs out all scopes.
|
208
|
+
# config.sign_out_all_scopes = true
|
209
|
+
|
210
|
+
# ==> Navigation configuration
|
211
|
+
# Lists the formats that should be treated as navigational. Formats like
|
212
|
+
# :html, should redirect to the sign in page when the user does not have
|
213
|
+
# access, but formats like :xml or :json, should return 401.
|
214
|
+
#
|
215
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
216
|
+
# should add them to the navigational formats lists.
|
217
|
+
#
|
218
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
219
|
+
# config.navigational_formats = ['*/*', :html]
|
220
|
+
|
221
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
222
|
+
config.sign_out_via = :delete
|
223
|
+
|
224
|
+
# ==> OmniAuth
|
225
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
226
|
+
# up on your models and hooks.
|
227
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
228
|
+
|
229
|
+
# ==> Warden configuration
|
230
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
231
|
+
# change the failure app, you can configure them inside the config.warden block.
|
232
|
+
#
|
233
|
+
# config.warden do |manager|
|
234
|
+
# manager.intercept_401 = false
|
235
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
236
|
+
# end
|
237
|
+
|
238
|
+
# ==> Mountable engine configurations
|
239
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
240
|
+
# is mountable, there are some extra configurations to be taken into account.
|
241
|
+
# The following options are available, assuming the engine is mounted as:
|
242
|
+
#
|
243
|
+
# mount MyEngine, at: '/my_engine'
|
244
|
+
#
|
245
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
246
|
+
# config.router_name = :my_engine
|
247
|
+
#
|
248
|
+
# When using omniauth, Devise cannot automatically set Omniauth path,
|
249
|
+
# so you need to do it manually. For the users scope, it would be:
|
250
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
251
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
RedBase::Engine.load_seed
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :redbase_user, :class => RedBase::User do
|
3
|
+
email "admin@example.com"
|
4
|
+
first_name "admin"
|
5
|
+
last_name "admin"
|
6
|
+
password "123123123"
|
7
|
+
password_confirmation "123123123"
|
8
|
+
association :group, :factory => :redbase_group, :name => "admin"
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'factory_girl_rails'
|
7
|
+
require 'email_spec'
|
8
|
+
|
9
|
+
|
10
|
+
Rails.backtrace_cleaner.remove_silencers!
|
11
|
+
|
12
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
13
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
14
|
+
# run as spec files by default. This means that files in spec/support that end
|
15
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
16
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
17
|
+
# end with _spec.rb. You can configure this pattern with with the --pattern
|
18
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
19
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
20
|
+
|
21
|
+
# Checks for pending migrations before tests are run.
|
22
|
+
# If you are not using ActiveRecord, you can remove this line.
|
23
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.include(EmailSpec::Helpers)
|
27
|
+
config.include(EmailSpec::Matchers)
|
28
|
+
|
29
|
+
# ## Mock Framework
|
30
|
+
#
|
31
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
32
|
+
#
|
33
|
+
# config.mock_with :mocha
|
34
|
+
# config.mock_with :flexmock
|
35
|
+
# config.mock_with :rr
|
36
|
+
config.mock_with :rspec
|
37
|
+
|
38
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
39
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
40
|
+
|
41
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
42
|
+
# examples within a transaction, remove the following line or assign false
|
43
|
+
# instead of true.
|
44
|
+
config.use_transactional_fixtures = true
|
45
|
+
|
46
|
+
# If true, the base class of anonymous controllers will be inferred
|
47
|
+
# automatically. This will be the default behavior in future versions of
|
48
|
+
# rspec-rails.
|
49
|
+
config.infer_base_class_for_anonymous_controllers = false
|
50
|
+
|
51
|
+
# Run specs in random order to surface order dependencies. If you find an
|
52
|
+
# order dependency and want to debug it, you can fix the order by providing
|
53
|
+
# the seed, which is printed after each run.
|
54
|
+
# --seed 1234
|
55
|
+
config.order = "random"
|
56
|
+
|
57
|
+
# database cleaner config
|
58
|
+
config.before(:suite) do
|
59
|
+
DatabaseCleaner.strategy = :truncation
|
60
|
+
end
|
61
|
+
config.before(:each) do
|
62
|
+
DatabaseCleaner.start
|
63
|
+
end
|
64
|
+
config.after(:each) do
|
65
|
+
DatabaseCleaner.clean
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
json.msg _("Items removed successfully.")
|
@@ -0,0 +1,10 @@
|
|
1
|
+
json.array! @<%= resource.pluralize.underscore %> do |<%= resource.underscore %>|
|
2
|
+
json.extract! <%= resource.underscore %>, :id<%= fields_as_params %><% fields.each do |name, type| %><% case type
|
3
|
+
when "belongs_to" %>
|
4
|
+
json.<%= name %> do if <%= resource.underscore %>.<%= name %>
|
5
|
+
json.id <%= resource.underscore %>.<%= name %>.id
|
6
|
+
json.name <%= resource.underscore %>.<%= name %>.name
|
7
|
+
end
|
8
|
+
end
|
9
|
+
<% when "has_many" %> json.<%= name %> <%= resource.underscore %>.<%= name %>, :id, :name<% end %><% end %>
|
10
|
+
end
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json.extract! @<%= resource.underscore %>, :id<%= fields_as_params %><% fields.each do |name, type| %><% case type
|
2
|
+
when "belongs_to" %>json.<%= name %> do
|
3
|
+
json.id @<%= resource.underscore %>.<%= name %>.id
|
4
|
+
json.name @<%= resource.underscore %>.<%= name %>.name
|
5
|
+
end
|
6
|
+
<% when "has_many" %>json.<%= name %> @<%= resource.underscore %>.<%= name %>, :id, :name<% end %><% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json.extract! @<%= resource.underscore %>, :id<%= fields_as_params %>
|
2
|
+
<% fields.each do |name, type| %><% if type == "has_many" %>json.<%= name %> @<%= resource.underscore %>.<%= name %>, :id, :name
|
3
|
+
<% end %><% if type == "belongs_to" %>json.<%= name %> do
|
4
|
+
json.id @<%= resource.underscore %>.<%= name %>_id
|
5
|
+
json.name @<%= resource.underscore %>.<%= name %>.name
|
6
|
+
end<% end %><% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
module RedBase
|
21
|
+
module Generators
|
22
|
+
class ViewsGenerator < Rails::Generators::Base
|
23
|
+
source_root File.expand_path('../../../../app/', __FILE__)
|
24
|
+
|
25
|
+
desc "Copy all templates and assets to main application"
|
26
|
+
|
27
|
+
def copy_views_file
|
28
|
+
directory "views/red_base", "app/views/red_base"
|
29
|
+
directory "views/layouts/red_base", "app/views/layouts/red_base"
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_assets_file
|
33
|
+
directory "assets/javascripts/red_base", "app/assets/javascripts/red_base"
|
34
|
+
directory "assets/stylesheets/red_base", "app/assets/stylesheets/red_base"
|
35
|
+
directory "assets/images/red_base", "app/assets/images/red_base"
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
module ActiveRecord
|
21
|
+
class Base
|
22
|
+
|
23
|
+
class Permissions
|
24
|
+
@@permissions = {
|
25
|
+
:read => nil,
|
26
|
+
:update => nil,
|
27
|
+
:create => nil,
|
28
|
+
:destory => nil,
|
29
|
+
}
|
30
|
+
|
31
|
+
@@only_owner = false
|
32
|
+
|
33
|
+
# return an array of strings representation of permissions
|
34
|
+
def self.permission_strings(model)
|
35
|
+
strings = []
|
36
|
+
@@permissions.each do |key, value|
|
37
|
+
strings << {
|
38
|
+
:name => "#{key}|#{model.model_name}",
|
39
|
+
:string => _("can %s %s") % [_(key.to_s), model.model_name.human]
|
40
|
+
}
|
41
|
+
|
42
|
+
end
|
43
|
+
strings
|
44
|
+
end
|
45
|
+
|
46
|
+
# Define permissions using this method
|
47
|
+
def self.permissions(*args)
|
48
|
+
|
49
|
+
args.each do |permission|
|
50
|
+
if permission.class == Symbol
|
51
|
+
if not @@permissions.include? permission
|
52
|
+
@@permission[permission] = nil
|
53
|
+
|
54
|
+
elsif permission.class == Hash
|
55
|
+
|
56
|
+
permission.each do |key, value|
|
57
|
+
@@permissions[key.to_sym] = value
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# This force user to have access to resources which is his.
|
68
|
+
def self.only_his_objects
|
69
|
+
@@only_owner = true
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.only_his_objects?
|
73
|
+
@@only_owner
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module RedBase
|
2
|
+
module API
|
3
|
+
class GroupsAPI < Grape::API
|
4
|
+
|
5
|
+
resource :groups do
|
6
|
+
|
7
|
+
desc "Return all the groups"
|
8
|
+
get do
|
9
|
+
authenticated_user
|
10
|
+
# TODO: Check for admin user only
|
11
|
+
RedBase::Group.includes(:permissions)
|
12
|
+
end
|
13
|
+
|
14
|
+
delete do
|
15
|
+
authenticated_user
|
16
|
+
|
17
|
+
#if can? :delete, Group
|
18
|
+
#end
|
19
|
+
Group.delete(params[:id].split(","))
|
20
|
+
end
|
21
|
+
|
22
|
+
post do
|
23
|
+
authenticated_user
|
24
|
+
|
25
|
+
permissions = [];
|
26
|
+
|
27
|
+
params[:permissions].each do |perm_string|
|
28
|
+
perm, model = perm_string.split "|"
|
29
|
+
permission = Permission.find_or_create_by_model_and_permission_type(model, perm)
|
30
|
+
permissions << permission
|
31
|
+
end
|
32
|
+
|
33
|
+
Group.create!({
|
34
|
+
name: params[:name],
|
35
|
+
permissions: permissions,
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|