anoubis 1.0.1 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/app/controllers/anoubis/application_controller.rb +4 -0
  4. data/app/controllers/anoubis/core/index/actions.rb +1 -1
  5. data/app/controllers/anoubis/core/index_controller.rb +3 -3
  6. data/app/controllers/anoubis/data/actions.rb +947 -0
  7. data/app/controllers/anoubis/data/callbacks.rb +66 -0
  8. data/app/controllers/anoubis/data/convert.rb +422 -0
  9. data/app/controllers/anoubis/data/defaults.rb +215 -0
  10. data/app/controllers/anoubis/data/get.rb +529 -0
  11. data/app/controllers/anoubis/data/load.rb +87 -0
  12. data/app/controllers/anoubis/data/set.rb +47 -0
  13. data/app/controllers/anoubis/data/setup.rb +102 -0
  14. data/app/controllers/anoubis/data_controller.rb +21 -0
  15. data/app/controllers/anoubis/etc/field.rb +7 -0
  16. data/app/controllers/anoubis/output/basic.rb +1 -1
  17. data/app/controllers/anoubis/sso/client/index_controller.rb +2 -2
  18. data/app/controllers/anoubis/sso/server/login_controller.rb +5 -5
  19. data/app/controllers/anoubis/sso/server/user_controller.rb +2 -2
  20. data/app/controllers/anoubis/tenant/index_controller.rb +3 -3
  21. data/app/models/anoubis/application_record.rb +141 -0
  22. data/app/services/anoubis/log_service.rb +97 -0
  23. data/app/services/anoubis/request_service.rb +134 -0
  24. data/config/locales/en.yml +20 -6
  25. data/config/locales/ru.yml +25 -13
  26. data/config/routes.rb +19 -19
  27. data/lib/anoubis/version.rb +1 -1
  28. metadata +32 -33
  29. data/app/controllers/anoubis/core/data/actions.rb +0 -962
  30. data/app/controllers/anoubis/core/data/callbacks.rb +0 -68
  31. data/app/controllers/anoubis/core/data/convert.rb +0 -407
  32. data/app/controllers/anoubis/core/data/defaults.rb +0 -217
  33. data/app/controllers/anoubis/core/data/get.rb +0 -531
  34. data/app/controllers/anoubis/core/data/load.rb +0 -89
  35. data/app/controllers/anoubis/core/data/set.rb +0 -49
  36. data/app/controllers/anoubis/core/data/setup.rb +0 -104
  37. data/app/controllers/anoubis/core/data_controller.rb +0 -28
  38. data/app/controllers/anoubis/sso/client/data/actions.rb +0 -5
  39. data/app/controllers/anoubis/sso/client/data/callbacks.rb +0 -5
  40. data/app/controllers/anoubis/sso/client/data/convert.rb +0 -5
  41. data/app/controllers/anoubis/sso/client/data/defaults.rb +0 -5
  42. data/app/controllers/anoubis/sso/client/data/get.rb +0 -5
  43. data/app/controllers/anoubis/sso/client/data/load.rb +0 -26
  44. data/app/controllers/anoubis/sso/client/data/set.rb +0 -5
  45. data/app/controllers/anoubis/sso/client/data/setup.rb +0 -5
  46. data/app/controllers/anoubis/sso/client/data_controller.rb +0 -21
  47. data/app/controllers/anoubis/tenant/data/actions.rb +0 -11
  48. data/app/controllers/anoubis/tenant/data/callbacks.rb +0 -11
  49. data/app/controllers/anoubis/tenant/data/convert.rb +0 -11
  50. data/app/controllers/anoubis/tenant/data/defaults.rb +0 -11
  51. data/app/controllers/anoubis/tenant/data/get.rb +0 -11
  52. data/app/controllers/anoubis/tenant/data/load.rb +0 -52
  53. data/app/controllers/anoubis/tenant/data/set.rb +0 -11
  54. data/app/controllers/anoubis/tenant/data/setup.rb +0 -11
  55. data/app/controllers/anoubis/tenant/data_controller.rb +0 -28
  56. data/app/controllers/anoubis/tenants_controller.rb +0 -7
  57. data/app/controllers/anoubis/users_controller.rb +0 -7
  58. data/app/mailers/anoubis/application_mailer.rb +0 -8
@@ -0,0 +1,102 @@
1
+ module Anoubis
2
+ ##
3
+ # Module consists all procedures and functons of {DataController}
4
+ module Data
5
+ ##
6
+ # Module setups system parameters for {DataController}
7
+ module Setup
8
+ ##
9
+ # Setups frame data information. It loads menu data, sets titles and tabs of the frame.
10
+ def setup_frame
11
+ self.load_menu_data
12
+ if self.etc.menu
13
+ self.get_parent_data
14
+ if self.etc.data.parent
15
+ self.output.title = self.etc.menu.page_title.sub '%{title}', self.etc.data.parent.sys_title.to_s
16
+ else
17
+ self.output.title = self.etc.menu.page_title
18
+ end
19
+ self.output.short = self.etc.menu.short_title
20
+ self.output.mode = self.etc.menu.mode
21
+ self.output.access = self.etc.menu.access
22
+ end
23
+ tabs = self.tabs
24
+ tabs.each do |key, item|
25
+ item = self.get_tab key, item
26
+ self.output.addTab(item)
27
+ end
28
+ end
29
+
30
+ ##
31
+ # Setups order for current tab. Parameters is set into {Anoubis::Etc::TabItem#sort self.etc.tab.sort} and
32
+ # {Anoubis::Etc::TabItem#order self.etc.tab.order} attributes.
33
+ def setup_order
34
+ sort = nil
35
+ first = nil
36
+ self.etc.data.fields.each do |key, field|
37
+ if field.order
38
+ first = key if !first
39
+ first = key if field.order.default
40
+ if params.key? :sort
41
+ sort = key if params[:sort] == key.to_s
42
+ end
43
+ end
44
+ end
45
+ sort = first if !sort
46
+ if sort
47
+ self.etc.tab.sort = sort.to_s
48
+ self.etc.tab.order = self.etc.data.fields[sort].order.order
49
+ if params.key? :order
50
+ self.etc.tab.order = :desc if params[:order] == 'desc'
51
+ self.etc.tab.order = :asc if params[:order] == 'asc'
52
+ end
53
+ end
54
+ end
55
+
56
+ ##
57
+ # @!group Block of fields setup functions
58
+
59
+ ##
60
+ # Setups defined fields and places it into attribute {Anoubis::Etc::Data#fields self.etc.data.fields}
61
+ def setup_fields
62
+ if !self.etc.data.fields
63
+ self.etc.data.fields = {}
64
+
65
+ fields = self.fields
66
+
67
+ fields.each_key do |key|
68
+ if fields[key].key? :edit
69
+ if self.menu_access fields[key][:edit], false
70
+ fields[key][:editable] = fields[key][:edit]
71
+ end
72
+ end
73
+ self.etc.data.fields[key] = Anoubis::Etc::Field.new(key, self.get_model, fields[key].merge(action: self.etc.action))
74
+ end
75
+ self.setup_order if %w[index export].include? self.etc.action
76
+ end
77
+ end
78
+
79
+ ##
80
+ # Setups additional parameters for table field with type 'datetime'
81
+ # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
82
+ # @param key [Symbol] key of table field.
83
+ def setup_fields_datetime (key)
84
+ self.etc.data.fields[key][:format] = 'full' if !self.etc.data.fields[key].has_key? :format
85
+ self.etc.data.fields[key][:format] = 'full' if !['full', 'month', 'date', 'datetime'].include? self.etc.data.fields[key][:format]
86
+ end
87
+
88
+
89
+
90
+ ##
91
+ # Setups additional parameters for table field with type 'float'
92
+ # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
93
+ # @param key [Symbol] key of table field.
94
+ def setup_fields_float (key)
95
+ self.etc.data.fields[key][:precision] = 2 if !self.etc.data.fields[key][:precision]
96
+ self.etc.data.fields[key][:point] = ',' if !self.etc.data.fields[key][:point]
97
+ self.etc.data.fields[key][:separator] = '' if !self.etc.data.fields[key][:separator]
98
+ end
99
+ # @!endgroup
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,21 @@
1
+ require_dependency "anoubis/data/actions"
2
+ require_dependency "anoubis/data/load"
3
+ require_dependency "anoubis/data/get"
4
+ require_dependency "anoubis/data/set"
5
+ require_dependency "anoubis/data/setup"
6
+ require_dependency "anoubis/data/defaults"
7
+ require_dependency "anoubis/data/convert"
8
+ require_dependency "anoubis/data/callbacks"
9
+
10
+ ##
11
+ # Main data controller class
12
+ class Anoubis::DataController < Anoubis::ApplicationController
13
+ include Anoubis::Data::Actions
14
+ include Anoubis::Data::Load
15
+ include Anoubis::Data::Get
16
+ include Anoubis::Data::Set
17
+ include Anoubis::Data::Setup
18
+ include Anoubis::Data::Defaults
19
+ include Anoubis::Data::Convert
20
+ include Anoubis::Data::Callbacks
21
+ end
@@ -152,6 +152,13 @@ module Anoubis
152
152
 
153
153
  end
154
154
 
155
+ ##
156
+ # Initialize additional parameters for {Anoubis::Etc::Field#type 'hash' field type} for controller actions.
157
+ # @param options [Hash] field's initial options
158
+ def initialize_hash (options)
159
+
160
+ end
161
+
155
162
  ##
156
163
  # Initialize additional parameters for {Anoubis::Etc::Field#type 'number' field type} for controller actions.
157
164
  # @param options [Hash] field's initial options
@@ -30,7 +30,7 @@ module Anoubis
30
30
  self.result = 0
31
31
  self.tab = ''
32
32
  self.messages = {
33
- '0': I18n.t('success'),
33
+ '0': I18n.t('anoubis.success'),
34
34
  '-1': I18n.t('errors.access_not_allowed'),
35
35
  '-2': I18n.t('errors.incorrect_parameters')
36
36
  }
@@ -1,5 +1,5 @@
1
- require_dependency "anubis/sso/client/index/actions"
2
- require_dependency "anubis/sso/client/index/callbacks"
1
+ require_dependency "anoubis/sso/client/index/actions"
2
+ require_dependency "anoubis/sso/client/index/callbacks"
3
3
 
4
4
  class Anoubis::Sso::Client::IndexController < Anoubis::Sso::Client::ApplicationController
5
5
  include Anoubis::Sso::Client::Index::Actions
@@ -23,7 +23,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
23
23
 
24
24
  result = {
25
25
  result: 0,
26
- message: I18n.t('core.success')
26
+ message: I18n.t('anoubis.success')
27
27
  }
28
28
  code = 200
29
29
 
@@ -107,7 +107,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
107
107
  def create
108
108
  result = {
109
109
  result: 0,
110
- message: I18n.t('core.success')
110
+ message: I18n.t('anoubis.success')
111
111
  }
112
112
  code = 200
113
113
 
@@ -155,7 +155,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
155
155
  def update
156
156
  result = {
157
157
  result: 0,
158
- message: I18n.t('core.success')
158
+ message: I18n.t('anoubis.success')
159
159
  }
160
160
 
161
161
  if self.system
@@ -213,7 +213,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
213
213
  def destroy
214
214
  result = {
215
215
  result: 0,
216
- message: I18n.t('core.success')
216
+ message: I18n.t('anoubis.success')
217
217
  }
218
218
 
219
219
  begin
@@ -263,7 +263,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
263
263
  def show
264
264
  result = {
265
265
  result: 0,
266
- message: I18n.t('core.success')
266
+ message: I18n.t('anoubis.success')
267
267
  }
268
268
 
269
269
  if self.system
@@ -6,7 +6,7 @@ class Anoubis::Sso::Server::UserController < Anoubis::Sso::Server::ApplicationCo
6
6
  def show
7
7
  result = {
8
8
  result: 0,
9
- message: I18n.t('anubis.core.success')
9
+ message: I18n.t('anoubis.success')
10
10
  }
11
11
  code = 200
12
12
 
@@ -25,7 +25,7 @@ class Anoubis::Sso::Server::UserController < Anoubis::Sso::Server::ApplicationCo
25
25
  def update
26
26
  result = {
27
27
  result: 0,
28
- message: I18n.t('anubis.core.success')
28
+ message: I18n.t('anoubis.success')
29
29
  }
30
30
  code = 200
31
31
 
@@ -1,6 +1,6 @@
1
- require_dependency "anubis/tenant/application_controller"
2
- require_dependency "anubis/tenant/index/actions"
3
- require_dependency "anubis/tenant/index/callbacks"
1
+ require_dependency "anoubis/tenant/application_controller"
2
+ require_dependency "anoubis/tenant/index/actions"
3
+ require_dependency "anoubis/tenant/index/callbacks"
4
4
 
5
5
  module Anoubis
6
6
  ##
@@ -2,9 +2,29 @@
2
2
  class Anoubis::ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
4
 
5
+ after_initialize :initialize_anubis_application_record
6
+
5
7
  ## Redis database variable
6
8
  attr_accessor :redis
7
9
 
10
+ # @!attribute [rw] need_refresh
11
+ # @return [Boolean] defines when table representation data should be updated even after simple update
12
+ attr_accessor :need_refresh
13
+
14
+ ##
15
+ # Fires after ApplicationRecord initialized for define default values
16
+ def initialize_anubis_application_record
17
+ self.need_refresh = false
18
+
19
+ after_initialize_anubis_application_record
20
+ end
21
+
22
+ ##
23
+ # Fires after initialize default variables
24
+ def after_initialize_anubis_application_record
25
+
26
+ end
27
+
8
28
  ##
9
29
  # Returns {https://github.com/redis/redis-rb Redis database} class
10
30
  # @return [Class] {https://github.com/redis/redis-rb Redis} class reference
@@ -42,4 +62,125 @@ class Anoubis::ApplicationRecord < ActiveRecord::Base
42
62
  end
43
63
  return value + ':'
44
64
  end
65
+
66
+ ##
67
+ # Return defined locale according by I18n
68
+ # @return [String] current locale
69
+ def current_locale
70
+ I18n.locale.to_s
71
+ end
72
+
73
+ ##
74
+ # Returns {current_locale}. If current locale isn't set then returns {default_locale}.
75
+ # @return [String] current locale
76
+ def get_locale
77
+ if current_locale && current_locale != ''
78
+ return current_locale
79
+ end
80
+
81
+ default_locale
82
+ end
83
+
84
+ ##
85
+ # Default locale that setup in Rails.configuration.i18n.default_locale configuration parameter
86
+ # @return [String] default locale
87
+ def default_locale
88
+ Rails.configuration.i18n.default_locale.to_s
89
+ end
90
+
91
+ ##
92
+ # Returns localized field by identifier
93
+ # @param field [String] Field identifier
94
+ # @param used_locale [String | nil] Locale identifier (by default used {current_locale})
95
+ # @return [String] localized field
96
+ def get_locale_field(field, used_locale = nil)
97
+ field = field.to_s.to_sym
98
+ used_locale = current_locale.to_s unless used_locale
99
+
100
+ return '' unless self[field]
101
+ return self[field][used_locale] if self[field].key? used_locale
102
+ return '' unless self[field].key? default_locale.to_s
103
+
104
+ self[field][default_locale.to_s]
105
+ end
106
+
107
+ ##
108
+ # Sets localized data
109
+ # @param field [String] field identifier
110
+ # @param value [String] localized string
111
+ # @param used_locale [String | nil] Locale identifier (by default used {current_locale})
112
+ def set_locale_field(field, value, used_locale = nil)
113
+ field = field.to_s.to_sym
114
+ used_locale = current_locale.to_s unless used_locale
115
+
116
+ self[field] = {} unless self[field]
117
+ self[field][default_locale.to_s] = value unless self[field].key? default_locale.to_s
118
+ self[field][used_locale] = value
119
+ end
120
+
121
+ ##
122
+ # Returns true if field has localized data
123
+ # @param field [String] Field identifier
124
+ # @param used_locale [String | nil] Locale identifier (by default used {current_locale})
125
+ # @return [Boolean] true if field has localized data
126
+ def is_field_localized(field, used_locale = nil)
127
+ field = field.to_s.to_sym
128
+ used_locale = current_locale.to_s unless used_locale
129
+
130
+ return false unless self[field]
131
+ return true if self[field].key? used_locale
132
+
133
+ false
134
+ end
135
+
136
+ ##
137
+ # Checks if this record may be destroyed.
138
+ def can_destroy?
139
+ result = true
140
+ self.class.reflect_on_all_associations.all? do |assoc|
141
+ result = self.send(assoc.name).nil? if assoc.macro == :has_one
142
+ result = self.send(assoc.name).empty? if (assoc.macro == :has_many) && result
143
+ end
144
+ result
145
+ end
146
+
147
+ ##
148
+ # Returns system title of table element
149
+ # @return [String] System title
150
+ def sys_title
151
+ id.to_s
152
+ end
153
+
154
+ ##
155
+ # Returns the ability to create new data. By default all items may be deleted. For another result
156
+ # procedure should be overridden.
157
+ # @param args [Hash] transferred parameters
158
+ # @option args [String] :controller Called controller identifier
159
+ # @option args [String] :tab Called controller tab element
160
+ # @return [Boolean] true if new data may be created.
161
+ def can_new(args = {})
162
+ true
163
+ end
164
+
165
+ ##
166
+ # Returns the ability to edit the data. By default all items may be edited. For another result
167
+ # procedure should be overridden.
168
+ # @param args [Hash] transferred parameters
169
+ # @option args [String] :controller Called controller identifier
170
+ # @option args [String] :tab Called controller tab element
171
+ # @return [Boolean] true if data may be edited
172
+ def can_edit(args = {})
173
+ true
174
+ end
175
+
176
+ ##
177
+ # Returns the ability to delete a data. By default all items may be deleted. For another result
178
+ # procedure should be overridden.
179
+ # @param args [Hash] transferred parameters
180
+ # @option args [String] :controller Called controller identifier
181
+ # @option args [String] :tab Called controller tab element
182
+ # @return [Boolean] true if data may be deleted
183
+ def can_delete(args = {})
184
+ true
185
+ end
45
186
  end
@@ -0,0 +1,97 @@
1
+ ##
2
+ # Graylog logging service
3
+ class Anoubis::LogService
4
+ # {https://www.rubydoc.info/gems/gelf/GELF/Notifier GELF::Notifier} service
5
+ attr_accessor :logger
6
+ # Hash of permanent parameters that added before sending data to Graylog server
7
+ attr_accessor :perm
8
+
9
+ ##
10
+ # Returns Graylog server URL
11
+ # @return [String] Graylog server URL
12
+ def url
13
+ begin
14
+ value = Rails.configuration.graylog_server
15
+ rescue StandardError
16
+ value = '127.0.0.1'
17
+ end
18
+
19
+ value
20
+ end
21
+
22
+ ##
23
+ # Returns Graylog server port
24
+ # @return [String] Graylog server port
25
+ def port
26
+ begin
27
+ value = Rails.configuration.graylog_port
28
+ rescue StandardError
29
+ value = 12201
30
+ end
31
+
32
+ value
33
+ end
34
+
35
+ ##
36
+ # Returns Graylog facility identifier in input source
37
+ # @return [String] Graylog facility identifier
38
+ def facility
39
+ begin
40
+ value = Rails.configuration.graylog_facility
41
+ rescue StandardError
42
+ value = 'Graylog'
43
+ end
44
+
45
+ value
46
+ end
47
+
48
+ ##
49
+ # Setups basic initialization parameters.
50
+ def initialize
51
+ self.logger = GELF::Notifier.new(url, port, 'WAN', { facility: facility })
52
+ logger.collect_file_and_line = false
53
+ logger.rescue_network_errors = true
54
+ self.perm = {}
55
+ end
56
+
57
+ ##
58
+ # Send data to Graylog server
59
+ # @param text [String] Logged text data
60
+ # @param type [String] Log level ('debug', 'error', 'info', 'warn')
61
+ # @param object [Hash] Additional parameters for logged data
62
+ def log(text, type = 'info', object = nil)
63
+ type = 'info' unless %w[info warn error].include? type.downcase
64
+ loc = caller_locations(1, 1).first
65
+
66
+ data = {
67
+ short_message: text,
68
+ level: level(type),
69
+ line: loc.lineno,
70
+ file: loc.path
71
+ }
72
+
73
+ data.merge!(object) if object
74
+ data.merge!(self.perm)
75
+ logger.notify data
76
+ nil
77
+ end
78
+
79
+ ##
80
+ # Returns {https://www.rubydoc.info/github/graylog-labs/gelf-rb/GELF/Levels GELF::Levels} according by type
81
+ # @param type [String] Log level ('debug', 'error', 'info', 'warn')
82
+ # @return [GELF::Levels] GELF::Levels
83
+ def level(type)
84
+ case type
85
+ when 'debug'
86
+ return GELF::DEBUG
87
+ when 'info'
88
+ return GELF::INFO
89
+ when 'warn'
90
+ return GELF::WARN
91
+ when 'error'
92
+ return GELF::ERROR
93
+ end
94
+
95
+ GELF::UNKNOWN
96
+ end
97
+ end
@@ -0,0 +1,134 @@
1
+ ##
2
+ # Request service
3
+ class Anoubis::RequestService
4
+ ## Redis database variable
5
+ attr_accessor :redis
6
+
7
+ ## Returns {https://github.com/redis/redis-rb Redis} prefix for storing cache data
8
+ attr_accessor :redis_prefix
9
+
10
+ ## Log service {Anoubis::LogService}
11
+ attr_accessor :log
12
+
13
+ ## Cookies data for current session
14
+ attr_accessor :cookies
15
+
16
+ ##
17
+ # Setups basic initialization parameters.
18
+ # @param log [Anoubis::LogService] Log service
19
+ def initialize(log = nil)
20
+ self.redis = Redis.new
21
+ @cookies = nil
22
+ self.log = log ? log : Anoubis::LogService.new
23
+ end
24
+
25
+ ##
26
+ # Returns cookies data for current session
27
+ # @return [Hash] Cookies data
28
+ def cookies
29
+ return @cookies if @cookies
30
+
31
+ @cookies = redis.get cookie_path
32
+ if @cookies
33
+ begin
34
+ @cookies = JSON.parse(self.cookies, { symbolize_names: true })
35
+ rescue
36
+ @cookies = {}
37
+ end
38
+ else
39
+ @cookies = {}
40
+ end
41
+
42
+ @cookies
43
+ end
44
+
45
+ ##
46
+ # Setups cookies data for current session
47
+ # @param data [Hash] Defined cookies parameters
48
+ def cookies=(data)
49
+ @cookies = data
50
+ store_cookies
51
+ end
52
+
53
+ ##
54
+ # Returns redis path for storing cookies data
55
+ # @return [String] Redis storing path
56
+ def cookie_path
57
+ redis_prefix + 'cookies'
58
+ end
59
+
60
+ ##
61
+ # Store current cookies to {https://github.com/redis/redis-rb Redis} cache
62
+ def store_cookies
63
+ redis.set cookie_path, @cookies.to_json
64
+ end
65
+
66
+ ##
67
+ # Unzip {https://www.rubydoc.info/gems/rest-client/RestClient RestClient} response data if returned data is GZipped
68
+ # @param response [RestClient::RawResponse] Received {https://www.rubydoc.info/gems/rest-client/RestClient/RawResponse RestClient::RawResponse}
69
+ # @return [String] Unzipped string
70
+ def unzip(response)
71
+ result = response.body
72
+ begin
73
+ if response.headers.key? :content_encoding
74
+ if response.headers[:content_encoding] == 'gzip'
75
+ sio = StringIO.new( response.body )
76
+ gz = Zlib::GzipReader.new( sio )
77
+ result = gz.read()
78
+ end
79
+ end
80
+ rescue => e
81
+ self.log 'Error was received when page encoded. ' + e.to_s, 'debug'
82
+ result = nil
83
+ end
84
+
85
+ result
86
+ end
87
+
88
+ ##
89
+ # Store data to file
90
+ # @param file_name [String] Name of file
91
+ # @param text [String] Saved text
92
+ def store(file_name, text)
93
+ file = File.open(file_name, "w")
94
+ file.write(text)
95
+ file.close
96
+ end
97
+
98
+ ##
99
+ # Transform cookies string to hash
100
+ # @param str [String] Cookies string
101
+ # @return [Hash] Cookies data
102
+ def parse_cookie(str)
103
+ cookies = { }
104
+
105
+ arr = str.split('; ')
106
+ arr.each do |line|
107
+ index = line.index '='
108
+ if index
109
+ key = line[0..(index - 1)]
110
+ value = line[(index + 1)..(line.length - 1)]
111
+ end
112
+ cookies[key.to_s.to_sym] = value.to_s
113
+ end
114
+
115
+ cookies
116
+ end
117
+
118
+ ##
119
+ # Returns {https://github.com/redis/redis-rb Redis} prefix for storing cache data. Prefix can be set in Rails.configuration.anoubis_redis_prefix configuration parameter.
120
+ # @return [String] {https://github.com/redis/redis-rb Redis} prefix
121
+ def redis_prefix
122
+ @redis_prefix ||= get_redis_prefix
123
+ end
124
+
125
+ private def get_redis_prefix
126
+ begin
127
+ value = Rails.configuration.anoubis_redis_prefix
128
+ rescue
129
+ return ''
130
+ end
131
+
132
+ value + ':'
133
+ end
134
+ end
@@ -30,16 +30,30 @@ en:
30
30
 
31
31
 
32
32
 
33
+
34
+
35
+
33
36
  anoubis:
34
- all: All
35
- success: Successful
36
- error: Error
37
+ all: "All"
38
+ success: "Successful"
39
+ error: "Error"
40
+ errors:
41
+ incorrect_login: "Incorrect login or password"
42
+ incorrect_user: "Incorrect user"
43
+ access_not_allowed: "Access not allowed"
44
+ session_expired: "Session expired"
37
45
  install:
38
46
  menu:
39
47
  dashboard:
40
- title: Dashboard
41
- page_title: Dashboad
42
- short_title: Dashboard
48
+ title: "Dashboard"
49
+ page_title: "Dashboard"
50
+ short_title: "Dashboard"
51
+
52
+
53
+
54
+
55
+
56
+
43
57
 
44
58
 
45
59