odania 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.txt → MIT-LICENSE} +1 -3
  3. data/README.md +3 -3
  4. data/Rakefile +33 -3
  5. data/app/assets/config/odania_manifest.js +0 -0
  6. data/app/assets/javascripts/application.js +13 -0
  7. data/app/assets/javascripts/textAngular.js +15 -0
  8. data/app/assets/javascripts/textAngular/textAngular-rangy.min.js +478 -0
  9. data/app/assets/javascripts/textAngular/textAngular-sanitize.min.js +322 -0
  10. data/app/assets/javascripts/textAngular/textAngular.min.js +1481 -0
  11. data/app/assets/stylesheets/scaffold.css +80 -0
  12. data/app/assets/stylesheets/textAngular/application.css +15 -0
  13. data/app/assets/stylesheets/textAngular/textAngular.css +204 -0
  14. data/app/controllers/admin/home_controller.rb +2 -0
  15. data/app/controllers/admin/languages_controller.rb +74 -0
  16. data/app/controllers/admin_controller.rb +4 -0
  17. data/app/controllers/application_controller.rb +3 -0
  18. data/app/controllers/categories_controller.rb +34 -0
  19. data/app/controllers/home_controller.rb +11 -0
  20. data/app/controllers/protected/home_controller.rb +2 -0
  21. data/app/controllers/protected_controller.rb +22 -0
  22. data/app/controllers/registration_controller.rb +12 -0
  23. data/app/helpers/standard_form_builder.rb +71 -0
  24. data/app/helpers/standard_form_helper.rb +13 -0
  25. data/app/models/admin.rb +37 -0
  26. data/app/models/language.rb +5 -0
  27. data/app/models/user.rb +47 -0
  28. data/app/views/admin/home/index.html.erb +1 -0
  29. data/app/views/admin/languages/_form.html.erb +16 -0
  30. data/app/views/admin/languages/_language.json.jbuilder +2 -0
  31. data/app/views/admin/languages/edit.html.erb +6 -0
  32. data/app/views/admin/languages/index.html.erb +27 -0
  33. data/app/views/admin/languages/index.json.jbuilder +1 -0
  34. data/app/views/admin/languages/new.html.erb +5 -0
  35. data/app/views/admin/languages/show.html.erb +9 -0
  36. data/app/views/admin/languages/show.json.jbuilder +1 -0
  37. data/app/views/categories/index.html.erb +9 -0
  38. data/app/views/categories/show.html.erb +16 -0
  39. data/app/views/devise/confirmations/new.html.erb +11 -0
  40. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  41. data/app/views/devise/mailer/email_changed.html.erb +7 -0
  42. data/app/views/devise/mailer/password_change.html.erb +4 -0
  43. data/app/views/devise/mailer/reset_password_instructions.html.erb +9 -0
  44. data/app/views/devise/mailer/unlock_instructions.html.erb +8 -0
  45. data/app/views/devise/passwords/edit.html.erb +13 -0
  46. data/app/views/devise/passwords/new.html.erb +11 -0
  47. data/app/views/devise/registrations/edit.html.erb +39 -0
  48. data/app/views/devise/registrations/new.html.erb +15 -0
  49. data/app/views/devise/sessions/new.html.erb +14 -0
  50. data/app/views/devise/shared/_links.html.erb +25 -0
  51. data/app/views/devise/unlocks/new.html.erb +11 -0
  52. data/app/views/home/index.html.erb +11 -0
  53. data/app/views/languages/_form.html.erb +20 -0
  54. data/app/views/languages/edit.html.erb +6 -0
  55. data/app/views/languages/index.html.erb +27 -0
  56. data/app/views/languages/new.html.erb +5 -0
  57. data/app/views/languages/show.html.erb +9 -0
  58. data/app/views/protected/home/index.html.erb +1 -0
  59. data/config/initializers/elasticsearch.rb +5 -0
  60. data/config/locales/devise.en.yml +64 -0
  61. data/config/routes.rb +23 -0
  62. data/db/seeds.rb +5 -0
  63. data/lib/odania.rb +7 -56
  64. data/lib/odania/engine.rb +14 -0
  65. data/lib/odania/version.rb +1 -1
  66. data/lib/tasks/odania_tasks.rake +4 -0
  67. data/lib/templates/erb/scaffold/_form.html.erb +27 -0
  68. data/lib/templates/erb/scaffold/edit.html.erb +6 -0
  69. data/lib/templates/erb/scaffold/index.html.erb +31 -0
  70. data/lib/templates/erb/scaffold/new.html.erb +5 -0
  71. data/lib/templates/erb/scaffold/show.html.erb +11 -0
  72. metadata +129 -84
  73. data/.codeclimate.yml +0 -30
  74. data/.gitignore +0 -17
  75. data/.rspec +0 -2
  76. data/.rubocop.yml +0 -1156
  77. data/.travis.yml +0 -20
  78. data/Gemfile +0 -4
  79. data/Gemfile.lock +0 -113
  80. data/Guardfile +0 -31
  81. data/features/plugin.feature +0 -35
  82. data/features/step_definitions/plugin_steps.rb +0 -75
  83. data/features/support/env.rb +0 -1
  84. data/lib/odania/config.rb +0 -17
  85. data/lib/odania/config/backend.rb +0 -31
  86. data/lib/odania/config/backend_group.rb +0 -43
  87. data/lib/odania/config/domain.rb +0 -59
  88. data/lib/odania/config/duplicates.rb +0 -28
  89. data/lib/odania/config/global_config.rb +0 -210
  90. data/lib/odania/config/layout.rb +0 -30
  91. data/lib/odania/config/page.rb +0 -29
  92. data/lib/odania/config/page_base.rb +0 -47
  93. data/lib/odania/config/plugin_config.rb +0 -58
  94. data/lib/odania/config/style.rb +0 -36
  95. data/lib/odania/config/sub_domain.rb +0 -113
  96. data/lib/odania/config/subdomain_config.rb +0 -124
  97. data/lib/odania/consul.rb +0 -138
  98. data/lib/odania/plugin.rb +0 -103
  99. data/odania.gemspec +0 -34
  100. data/spec/fixtures/global_config.json +0 -135
  101. data/spec/fixtures/plugin_config_1.json +0 -102
  102. data/spec/lib/odania/config/global_config_spec.rb +0 -69
  103. data/spec/lib/odania/config/plugin_config_spec.rb +0 -31
  104. data/spec/lib/odania/plugin_spec.rb +0 -25
  105. data/spec/lib/odania_spec.rb +0 -10
  106. data/spec/spec_helper.rb +0 -19
  107. data/spec/support/consul_mock.rb +0 -123
  108. data/tasks/odania.rake +0 -8
  109. data/tasks/rspec.rake +0 -7
@@ -0,0 +1,12 @@
1
+ class RegistrationController < Devise::RegistrationsController
2
+
3
+ private
4
+
5
+ def sign_up_params
6
+ params.require(:user).permit(:name, :email, :password, :password_confirmation, :terms_of_service)
7
+ end
8
+
9
+ def account_update_params
10
+ params.require(:user).permit(:password, :password_confirmation, :current_password)
11
+ end
12
+ end
@@ -0,0 +1,71 @@
1
+ class StandardFormBuilder < ActionView::Helpers::FormBuilder
2
+ def submit(label, *args)
3
+ options = args.extract_options!
4
+ new_class = options[:class] || 'button'
5
+ super(label, *(args << options.merge(:class => new_class)))
6
+ end
7
+
8
+ def array_text_field(method, key, val, options = {})
9
+ @template.content_tag(
10
+ 'div',
11
+ @template.content_tag(
12
+ 'label',
13
+ method,
14
+ for: "#{@object_name}_#{method}",
15
+ class: 'input-group-addon'
16
+ ) +
17
+ "<input type=\"text\" name=\"#{@object.class.to_s.downcase}[#{method}][#{key}]\" value=\"#{val}\" class=\"form-control\" />".html_safe,
18
+ class: 'input-group'
19
+ )
20
+ end
21
+
22
+ def array_text_area(method, key, val, options = {})
23
+ @template.content_tag(
24
+ 'div',
25
+ @template.content_tag(
26
+ 'label',
27
+ method,
28
+ for: "#{@object_name}_#{method}",
29
+ class: 'input-group-addon'
30
+ ) +
31
+ "<textarea name=\"#{@object.class.to_s.downcase}[#{method}][#{key}]\" class=\"form-control\">#{val}</textarea>".html_safe,
32
+ class: 'input-group'
33
+ )
34
+ end
35
+
36
+ def self.create_tagged_field(method_name)
37
+ define_method(method_name) do |label, *args|
38
+ options = args.extract_options!
39
+
40
+ custom_label = options[:label] || @object.class.human_attribute_name(label.to_s)
41
+ label_class = options[:label_class] || 'input-group-addon'
42
+ options[:class] = 'form-control' if options[:class].nil?
43
+
44
+ if @object.class.validators_on(label).collect(&:class).include? ActiveModel::Validations::PresenceValidator
45
+ if label_class.nil?
46
+ label_class = 'required'
47
+ else
48
+ label_class = label_class + ' required'
49
+ end
50
+ end
51
+
52
+ @template.content_tag(
53
+ 'div',
54
+ @template.content_tag(
55
+ 'label',
56
+ custom_label,
57
+ for: "#{@object_name}_#{label}",
58
+ class: label_class
59
+ ) + super(label, *(args << options)),
60
+ class: 'input-group'
61
+ )
62
+ end
63
+ end
64
+
65
+ field_helpers.each do |name|
66
+ next if %w(fields_for hidden_field).include? name.to_s
67
+
68
+ create_tagged_field(name)
69
+ end
70
+ create_tagged_field 'select'
71
+ end
@@ -0,0 +1,13 @@
1
+ module StandardFormHelper
2
+ def standard_form_for(name, *args, &block)
3
+ options = args.extract_options!
4
+
5
+ content_tag('div',
6
+ content_tag(
7
+ 'dl',
8
+ form_for(name, *(args << options.merge(:builder => StandardFormBuilder)), &block)
9
+ ),
10
+ class: 'standard_form'
11
+ )
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ class Admin
2
+ include Mongoid::Document
3
+ include Mongoid::Timestamps
4
+
5
+ # Include default devise modules. Others available are:
6
+ # :confirmable, :lockable, :timeoutable and :omniauthable
7
+ devise :database_authenticatable, :rememberable, :trackable, :validatable
8
+
9
+ ## Database authenticatable
10
+ field :email, type: String, default: ""
11
+ field :encrypted_password, type: String, default: ""
12
+
13
+ ## Recoverable
14
+ field :reset_password_token, type: String
15
+ field :reset_password_sent_at, type: Time
16
+
17
+ ## Rememberable
18
+ field :remember_created_at, type: Time
19
+
20
+ ## Trackable
21
+ field :sign_in_count, type: Integer, default: 0
22
+ field :current_sign_in_at, type: Time
23
+ field :last_sign_in_at, type: Time
24
+ field :current_sign_in_ip, type: String
25
+ field :last_sign_in_ip, type: String
26
+
27
+ ## Confirmable
28
+ # field :confirmation_token, type: String
29
+ # field :confirmed_at, type: Time
30
+ # field :confirmation_sent_at, type: Time
31
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
32
+
33
+ ## Lockable
34
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
35
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
36
+ # field :locked_at, type: Time
37
+ end
@@ -0,0 +1,5 @@
1
+ class Language
2
+ include Mongoid::Document
3
+
4
+ field :name, type: String
5
+ end
@@ -0,0 +1,47 @@
1
+ class User
2
+ include Mongoid::Document
3
+ include Mongoid::Timestamps
4
+
5
+ # Include default devise modules. Others available are:
6
+ # :confirmable, :lockable, :timeoutable and :omniauthable
7
+ devise :database_authenticatable, :registerable, :confirmable,
8
+ :recoverable, :rememberable, :trackable, :validatable
9
+
10
+ ## Database authenticatable
11
+ field :email, type: String, default: ''
12
+ field :encrypted_password, type: String, default: ''
13
+
14
+ ## Recoverable
15
+ field :reset_password_token, type: String
16
+ field :reset_password_sent_at, type: Time
17
+
18
+ ## Rememberable
19
+ field :remember_created_at, type: Time
20
+
21
+ ## Trackable
22
+ field :sign_in_count, type: Integer, default: 0
23
+ field :current_sign_in_at, type: Time
24
+ field :last_sign_in_at, type: Time
25
+ field :current_sign_in_ip, type: String
26
+ field :last_sign_in_ip, type: String
27
+
28
+ ## Confirmable
29
+ field :confirmation_token, type: String
30
+ field :confirmed_at, type: Time
31
+ field :confirmation_sent_at, type: Time
32
+ field :unconfirmed_email, type: String
33
+
34
+ ## Lockable
35
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
36
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
37
+ # field :locked_at, type: Time
38
+
39
+ field :name, type: String
40
+ field :locale, type: String, default: 'de'
41
+ field :terms_of_service, type: Mongoid::Boolean
42
+
43
+ has_many :projects
44
+
45
+ validates :name, uniqueness: {case_sensitive: false}, length: {minimum: 2}
46
+ validates :terms_of_service, acceptance: true
47
+ end
@@ -0,0 +1 @@
1
+ <h1>Admin Home</h1>
@@ -0,0 +1,16 @@
1
+ <%= form_for(language, builder: StandardFormBuilder) do |f| %>
2
+ <% if language.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(language.errors.count, 'error') %> prohibited this language from being saved:</h2>
5
+
6
+ <ul>
7
+ <% language.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= f.text_field :name %>
15
+ <%= f.submit t('form.send') %>
16
+ <% end %>
@@ -0,0 +1,2 @@
1
+ json.extract! language, :id, :name, :created_at, :updated_at
2
+ json.url language_url(language, format: :json)
@@ -0,0 +1,6 @@
1
+ <h1>Editing Language</h1>
2
+
3
+ <%= render 'form', language: @language %>
4
+
5
+ <%= link_to 'Show', @language %> |
6
+ <%= link_to 'Back', languages_path %>
@@ -0,0 +1,27 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Languages</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th colspan="3"></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @languages.each do |language| %>
15
+ <tr>
16
+ <td><%= language.name %></td>
17
+ <td><%= link_to 'Show', language %></td>
18
+ <td><%= link_to 'Edit', edit_language_path(language) %></td>
19
+ <td><%= link_to 'Destroy', language, method: :delete, data: {confirm: 'Are you sure?'} %></td>
20
+ </tr>
21
+ <% end %>
22
+ </tbody>
23
+ </table>
24
+
25
+ <br>
26
+
27
+ <%= link_to 'New Language', new_language_path %>
@@ -0,0 +1 @@
1
+ json.array! @languages, partial: 'languages/language', as: :language
@@ -0,0 +1,5 @@
1
+ <h1>New Language</h1>
2
+
3
+ <%= render 'form', language: @language %>
4
+
5
+ <%= link_to 'Back', languages_path %>
@@ -0,0 +1,9 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @language.name %>
6
+ </p>
7
+
8
+ <%= link_to 'Edit', edit_language_path(@language) %> |
9
+ <%= link_to 'Back', languages_path %>
@@ -0,0 +1 @@
1
+ json.partial! "languages/language", language: @language
@@ -0,0 +1,9 @@
1
+ <h1><%= t('Categories') %></h1>
2
+
3
+ <table>
4
+ <% @categories.each do |category| %>
5
+ <tr>
6
+ <td><%= link_to category.title, category_path(category, locale: I18n.locale.to_s) %></td>
7
+ </tr>
8
+ <% end %>
9
+ </table>
@@ -0,0 +1,16 @@
1
+ <h1><%= t('Category _category', category: @category.title) %></h1>
2
+
3
+ <p>
4
+ <table>
5
+ <% @category_xrefs.each do |category_xref|
6
+ ref = category_xref.ref %>
7
+ <% if ref.is_active %>
8
+ <tr>
9
+ <td>
10
+ <%= link_to ref.title, polymorphic_url([ref], {locale: ref.language.iso_639_1}) %>
11
+ </td>
12
+ </tr>
13
+ <% end %>
14
+ <% end %>
15
+ </table>
16
+ </p>
@@ -0,0 +1,11 @@
1
+ <h2><%= t('.resend_confirmation_instructions') %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), builder: StandardFormBuilder, html: {method: :post}) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
7
+
8
+ <%= f.submit t('.resend_confirmation_instructions') %>
9
+ <% end %>
10
+
11
+ <%= render 'devise/shared/links' %>
@@ -0,0 +1,5 @@
1
+ <% require 'devise/version' %>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
+
4
+ <p><%= t('.instruction') %></p>
5
+ <p><%= link_to t('.action'), confirmation_url(@resource, confirmation_token: (Devise::VERSION.start_with?('3.') ? @token : @resource.confirmation_token)) %></p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @email %>!</p>
2
+
3
+ <% if @resource.try(:unconfirmed_email?) %>
4
+ <p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
5
+ <% else %>
6
+ <p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
7
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <% require 'devise/version' %>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
+
4
+ <p><%= t('.message') %></p>
@@ -0,0 +1,9 @@
1
+ <% require 'devise/version' %>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
+
4
+ <p><%= t('.instruction') %></p>
5
+
6
+ <p><%= link_to t('.action'), edit_password_url(@resource, reset_password_token: (Devise::VERSION.start_with?('3.', '4.') ? @token : @resource.reset_password_token)) %></p>
7
+
8
+ <p><%= t('.instruction_2') %></p>
9
+ <p><%= t('.instruction_3') %></p>
@@ -0,0 +1,8 @@
1
+ <% require 'devise/version' %>
2
+ <p><%= t('.greeting', recipient: @resource.email) %></p>
3
+
4
+ <p><%= t('.message') %></p>
5
+
6
+ <p><%= t('.instruction') %></p>
7
+
8
+ <p><%= link_to t('.action'), unlock_url(@resource, unlock_token: (Devise::VERSION.start_with?('3.') ? @token : @resource.unlock_token)) %></p>
@@ -0,0 +1,13 @@
1
+ <h2><%= t('.change_your_password') %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), builder: StandardFormBuilder, html: {method: :put}) do |f| %>
4
+ <%= devise_error_messages! %>
5
+ <%= f.hidden_field :reset_password_token %>
6
+
7
+ <%= f.password_field :password, autocomplete: 'off' %>
8
+ <%= f.password_field :password_confirmation, autocomplete: 'off' %>
9
+
10
+ <%= f.submit t('.change_my_password') %>
11
+ <% end %>
12
+
13
+ <%= render 'devise/shared/links' %>
@@ -0,0 +1,11 @@
1
+ <h2><%= t('.forgot_your_password') %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), builder: StandardFormBuilder, html: {method: :post}) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.email_field :email, autofocus: true %>
7
+
8
+ <%= f.submit t('.send_me_reset_password_instructions') %>
9
+ <% end %>
10
+
11
+ <%= render 'devise/shared/links' %>
@@ -0,0 +1,39 @@
1
+ <h2><%= t('.title', resource: resource_class.model_name.human) %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br/>
8
+ <%= f.email_field :email %>
9
+ </div>
10
+
11
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
12
+ <p>
13
+ <%= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) %>
14
+ </p>
15
+ <% end %>
16
+
17
+ <div class="field">
18
+ <%= f.label :password %> <i>(<%= t('.leave_blank_if_you_don_t_want_to_change_it') %>)</i><br/>
19
+ <%= f.password_field :password, autocomplete: 'off' %>
20
+ </div>
21
+
22
+ <div class="field">
23
+ <%= f.label :password_confirmation %><br/>
24
+ <%= f.password_field :password_confirmation %>
25
+ </div>
26
+
27
+ <div class="field">
28
+ <%= f.label :current_password %> <i>(<%= t('.we_need_your_current_password_to_confirm_your_changes') %>)</i><br/>
29
+ <%= f.password_field :current_password %>
30
+ </div>
31
+
32
+ <div><%= f.submit t('.update') %></div>
33
+ <% end %>
34
+
35
+ <h3><%= t('.cancel_my_account') %></h3>
36
+
37
+ <p><%= t('.unhappy') %> <%= link_to t('.cancel_my_account'), registration_path(resource_name), data: {confirm: t('.are_you_sure')}, method: :delete %>.</p>
38
+
39
+ <%= link_to t('devise.shared.links.back'), :back %>
@@ -0,0 +1,15 @@
1
+ <h2><%= t('.sign_up') %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), builder: StandardFormBuilder) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <%= f.text_field :name, autofocus: true %>
7
+ <%= f.email_field :email %>
8
+ <%= f.password_field :password, autocomplete: 'off' %>
9
+ <%= f.password_field :password_confirmation, autocomplete: 'off' %>
10
+ <%= f.check_box :terms_of_service %>
11
+
12
+ <%= f.submit t('.sign_up') %>
13
+ <% end %>
14
+
15
+ <%= render 'devise/shared/links' %>