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,80 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ margin: 33px;
5
+ }
6
+
7
+ body, p, ol, ul, td {
8
+ font-family: verdana, arial, helvetica, sans-serif;
9
+ font-size: 13px;
10
+ line-height: 18px;
11
+ }
12
+
13
+ pre {
14
+ background-color: #eee;
15
+ padding: 10px;
16
+ font-size: 11px;
17
+ }
18
+
19
+ a {
20
+ color: #000;
21
+ }
22
+
23
+ a:visited {
24
+ color: #666;
25
+ }
26
+
27
+ a:hover {
28
+ color: #fff;
29
+ background-color: #000;
30
+ }
31
+
32
+ th {
33
+ padding-bottom: 5px;
34
+ }
35
+
36
+ td {
37
+ padding: 0 5px 7px;
38
+ }
39
+
40
+ div.field,
41
+ div.actions {
42
+ margin-bottom: 10px;
43
+ }
44
+
45
+ #notice {
46
+ color: green;
47
+ }
48
+
49
+ .field_with_errors {
50
+ padding: 2px;
51
+ background-color: red;
52
+ display: table;
53
+ }
54
+
55
+ #error_explanation {
56
+ width: 450px;
57
+ border: 2px solid red;
58
+ padding: 7px 7px 0;
59
+ margin-bottom: 20px;
60
+ background-color: #f0f0f0;
61
+ }
62
+
63
+ #error_explanation h2 {
64
+ text-align: left;
65
+ font-weight: bold;
66
+ padding: 5px 5px 5px 15px;
67
+ font-size: 12px;
68
+ margin: -7px -7px 0;
69
+ background-color: #c00;
70
+ color: #fff;
71
+ }
72
+
73
+ #error_explanation ul li {
74
+ font-size: 12px;
75
+ list-style: square;
76
+ }
77
+
78
+ label {
79
+ display: block;
80
+ }
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,204 @@
1
+ .ta-hidden-input {
2
+ width: 1px;
3
+ height: 1px;
4
+ border: none;
5
+ margin: 0;
6
+ padding: 0;
7
+ position: absolute;
8
+ top: -10000px;
9
+ left: -10000px;
10
+ opacity: 0;
11
+ overflow: hidden;
12
+ }
13
+
14
+ /* add generic styling for the editor */
15
+ .ta-root.focussed > .ta-scroll-window.form-control {
16
+ border-color: #66afe9;
17
+ outline: 0;
18
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
19
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
20
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
21
+ }
22
+
23
+ .ta-editor.ta-html, .ta-scroll-window.form-control {
24
+ min-height: 300px;
25
+ height: auto;
26
+ overflow: auto;
27
+ font-family: inherit;
28
+ font-size: 100%;
29
+ }
30
+
31
+ .ta-scroll-window.form-control {
32
+ position: relative;
33
+ padding: 0;
34
+ }
35
+
36
+ .ta-scroll-window > .ta-bind {
37
+ height: auto;
38
+ min-height: 300px;
39
+ padding: 6px 12px;
40
+ }
41
+
42
+ .ta-editor:focus {
43
+ user-select: text;
44
+ }
45
+
46
+ /* add the styling for the awesomness of the resizer */
47
+ .ta-resizer-handle-overlay {
48
+ z-index: 100;
49
+ position: absolute;
50
+ display: none;
51
+ }
52
+
53
+ .ta-resizer-handle-overlay > .ta-resizer-handle-info {
54
+ position: absolute;
55
+ bottom: 16px;
56
+ right: 16px;
57
+ border: 1px solid black;
58
+ background-color: #FFF;
59
+ padding: 0 4px;
60
+ opacity: 0.7;
61
+ }
62
+
63
+ .ta-resizer-handle-overlay > .ta-resizer-handle-background {
64
+ position: absolute;
65
+ bottom: 5px;
66
+ right: 5px;
67
+ left: 5px;
68
+ top: 5px;
69
+ border: 1px solid black;
70
+ background-color: rgba(0, 0, 0, 0.2);
71
+ }
72
+
73
+ .ta-resizer-handle-overlay > .ta-resizer-handle-corner {
74
+ width: 10px;
75
+ height: 10px;
76
+ position: absolute;
77
+ }
78
+
79
+ .ta-resizer-handle-overlay > .ta-resizer-handle-corner-tl {
80
+ top: 0;
81
+ left: 0;
82
+ border-left: 1px solid black;
83
+ border-top: 1px solid black;
84
+ }
85
+
86
+ .ta-resizer-handle-overlay > .ta-resizer-handle-corner-tr {
87
+ top: 0;
88
+ right: 0;
89
+ border-right: 1px solid black;
90
+ border-top: 1px solid black;
91
+ }
92
+
93
+ .ta-resizer-handle-overlay > .ta-resizer-handle-corner-bl {
94
+ bottom: 0;
95
+ left: 0;
96
+ border-left: 1px solid black;
97
+ border-bottom: 1px solid black;
98
+ }
99
+
100
+ .ta-resizer-handle-overlay > .ta-resizer-handle-corner-br {
101
+ bottom: 0;
102
+ right: 0;
103
+ border: 1px solid black;
104
+ cursor: se-resize;
105
+ background-color: white;
106
+ }
107
+
108
+ /* copy the popover code from bootstrap so this will work even without it */
109
+ .popover {
110
+ position: absolute;
111
+ top: 0;
112
+ left: 0;
113
+ z-index: 1060;
114
+ display: none;
115
+ max-width: 276px;
116
+ padding: 1px;
117
+ font-size: 14px;
118
+ font-weight: normal;
119
+ line-height: 1.42857143;
120
+ text-align: left;
121
+ white-space: normal;
122
+ background-color: #fff;
123
+ -webkit-background-clip: padding-box;
124
+ background-clip: padding-box;
125
+ border: 1px solid #ccc;
126
+ border: 1px solid rgba(0, 0, 0, .2);
127
+ border-radius: 6px;
128
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
129
+ box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
130
+ }
131
+
132
+ .popover.top {
133
+ margin-top: -10px;
134
+ }
135
+
136
+ .popover.bottom {
137
+ margin-top: 10px;
138
+ }
139
+
140
+ .popover-title {
141
+ padding: 8px 14px;
142
+ margin: 0;
143
+ font-size: 14px;
144
+ background-color: #f7f7f7;
145
+ border-bottom: 1px solid #ebebeb;
146
+ border-radius: 5px 5px 0 0;
147
+ }
148
+
149
+ .popover-content {
150
+ padding: 9px 14px;
151
+ }
152
+
153
+ .popover > .arrow,
154
+ .popover > .arrow:after {
155
+ position: absolute;
156
+ display: block;
157
+ width: 0;
158
+ height: 0;
159
+ border-color: transparent;
160
+ border-style: solid;
161
+ }
162
+
163
+ .popover > .arrow {
164
+ border-width: 11px;
165
+ }
166
+
167
+ .popover > .arrow:after {
168
+ content: "";
169
+ border-width: 10px;
170
+ }
171
+
172
+ .popover.top > .arrow {
173
+ bottom: -11px;
174
+ left: 50%;
175
+ margin-left: -11px;
176
+ border-top-color: #999;
177
+ border-top-color: rgba(0, 0, 0, .25);
178
+ border-bottom-width: 0;
179
+ }
180
+
181
+ .popover.top > .arrow:after {
182
+ bottom: 1px;
183
+ margin-left: -10px;
184
+ content: " ";
185
+ border-top-color: #fff;
186
+ border-bottom-width: 0;
187
+ }
188
+
189
+ .popover.bottom > .arrow {
190
+ top: -11px;
191
+ left: 50%;
192
+ margin-left: -11px;
193
+ border-top-width: 0;
194
+ border-bottom-color: #999;
195
+ border-bottom-color: rgba(0, 0, 0, .25);
196
+ }
197
+
198
+ .popover.bottom > .arrow:after {
199
+ top: 1px;
200
+ margin-left: -10px;
201
+ content: " ";
202
+ border-top-width: 0;
203
+ border-bottom-color: #fff;
204
+ }
@@ -0,0 +1,2 @@
1
+ class Admin::HomeController < AdminController
2
+ end
@@ -0,0 +1,74 @@
1
+ class Admin::LanguagesController < AdminController
2
+ before_action :set_language, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /languages
5
+ # GET /languages.json
6
+ def index
7
+ @languages = Language.all
8
+ end
9
+
10
+ # GET /languages/1
11
+ # GET /languages/1.json
12
+ def show
13
+ end
14
+
15
+ # GET /languages/new
16
+ def new
17
+ @language = Language.new
18
+ end
19
+
20
+ # GET /languages/1/edit
21
+ def edit
22
+ end
23
+
24
+ # POST /languages
25
+ # POST /languages.json
26
+ def create
27
+ @language = Language.new(language_params)
28
+
29
+ respond_to do |format|
30
+ if @language.save
31
+ format.html {redirect_to @language, notice: 'Language was successfully created.'}
32
+ format.json {render :show, status: :created, location: @language}
33
+ else
34
+ format.html {render :new}
35
+ format.json {render json: @language.errors, status: :unprocessable_entity}
36
+ end
37
+ end
38
+ end
39
+
40
+ # PATCH/PUT /languages/1
41
+ # PATCH/PUT /languages/1.json
42
+ def update
43
+ respond_to do |format|
44
+ if @language.update(language_params)
45
+ format.html {redirect_to @language, notice: 'Language was successfully updated.'}
46
+ format.json {render :show, status: :ok, location: @language}
47
+ else
48
+ format.html {render :edit}
49
+ format.json {render json: @language.errors, status: :unprocessable_entity}
50
+ end
51
+ end
52
+ end
53
+
54
+ # DELETE /languages/1
55
+ # DELETE /languages/1.json
56
+ def destroy
57
+ @language.destroy
58
+ respond_to do |format|
59
+ format.html {redirect_to languages_url, notice: 'Language was successfully destroyed.'}
60
+ format.json {head :no_content}
61
+ end
62
+ end
63
+
64
+ private
65
+ # Use callbacks to share common setup or constraints between actions.
66
+ def set_language
67
+ @language = Language.find(params[:id])
68
+ end
69
+
70
+ # Never trust parameters from the scary internet, only allow the white list through.
71
+ def language_params
72
+ params.require(:language).permit(:name)
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ class AdminController < ApplicationController
2
+ before_action :authenticate_admin!
3
+ layout 'admin'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,34 @@
1
+ class CategoriesController < ApplicationController
2
+ def index
3
+ @categories = $elasticsearch.search index: 'categories', type: 'category', body: {
4
+ query: {
5
+ bool: {
6
+ must: [
7
+ {match: {domain: @domain}},
8
+ {match: {subdomain: @subdomain}},
9
+ {regexp: {category: "#{@req_url}.*"}}
10
+ ]
11
+ }
12
+ }
13
+ }
14
+
15
+ @hits = @categories['hits']['hits']
16
+ end
17
+
18
+ def show
19
+ @category = params[:id]
20
+ @pages = $elasticsearch.search index: 'contents', type: 'content', body: {
21
+ query: {
22
+ bool: {
23
+ must: [
24
+ {match: {domain: @domain}},
25
+ {match: {subdomain: @subdomain}},
26
+ {regexp: {category: "#{@category}.*"}}
27
+ ]
28
+ }
29
+ }
30
+ }
31
+
32
+ @hits = @pages['hits']['hits']
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ class HomeController < ApplicationController
2
+ def redirect_to_locale
3
+ accepted_langs = %w(de en)
4
+ locale = http_accept_language.preferred_language_from(accepted_langs)
5
+
6
+ redirect_to locale_root_path(locale: locale)
7
+ end
8
+
9
+ def index
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ class Protected::HomeController < ProtectedController
2
+ end
@@ -0,0 +1,22 @@
1
+ class ProtectedController < ApplicationController
2
+ before_action :authenticate_user!
3
+ after_action :add_flash_to_header
4
+ layout 'protected'
5
+
6
+ skip_before_action :verify_authenticity_token
7
+
8
+ def add_flash_to_header
9
+ # add different flashes to header
10
+ response.headers['X-Flash-Error'] = flash[:error] unless flash[:error].blank?
11
+ response.headers['X-Flash-Warning'] = flash[:warning] unless flash[:warning].blank?
12
+ response.headers['X-Flash-Notice'] = flash[:notice] unless flash[:notice].blank?
13
+ response.headers['X-Flash-Message'] = flash[:message] unless flash[:message].blank?
14
+
15
+ # make sure flash does not appear on the next page
16
+ flash.discard
17
+ end
18
+
19
+ def bad_api_request(msg)
20
+ render json: {message: msg}, status: :bad_request
21
+ end
22
+ end