weeler 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/README.md +15 -0
- data/app/controllers/weeler/translations_controller.rb +7 -0
- data/app/views/layouts/weeler/base.html.haml +1 -1
- data/app/views/weeler/translations/index.html.haml +8 -1
- data/app/views/weeler/translations/usage_stats.html.haml +28 -0
- data/lib/i18n/backend/weeler.rb +9 -2
- data/lib/i18n/backend/weeler/translation.rb +0 -1
- data/lib/i18n/backend/weeler/usage_logger.rb +19 -0
- data/lib/weeler/action_controller/acts/restful.rb +15 -3
- data/lib/weeler/action_dispatch/routing/mapper.rb +1 -0
- data/lib/weeler/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04354c614713ac3f01bbd9ef74db3d3adfbf6e5e
|
4
|
+
data.tar.gz: b7cb66aa043d0f4474d030fc8a3098c2f110eeb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3995b5e005fae4e1d03fa0bcbee009fd7cfa0ace18d0be818250c690b6afec317ed9ee0b31f213a19c112308463aa039e1be74ea53dd420162833e6ff7e7cc8f
|
7
|
+
data.tar.gz: aca2e0510b49b00a85d99a8329eec36874b10105ead3cd20b13da590a68f38b0c43056ea6424265a3033c85c575b731b944044a02917e2124380416a02f31c84
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
## 1.4.0
|
2
|
+
|
3
|
+
* Added translation usage stats
|
4
|
+
* Fixed a transliteration bug
|
5
|
+
|
6
|
+
### Contributors
|
7
|
+
|
8
|
+
* Artis Raugulis
|
9
|
+
|
10
|
+
## 1.3.0
|
11
|
+
|
12
|
+
### Features & Enhancements
|
13
|
+
|
14
|
+
* Added option to customize what happens after successful create, update, destroy
|
15
|
+
|
16
|
+
### Contributors
|
17
|
+
|
18
|
+
* Artis Raugulis
|
19
|
+
|
1
20
|
## 1.2.0
|
2
21
|
|
3
22
|
### Features & Enhancements
|
@@ -38,9 +57,9 @@
|
|
38
57
|
|
39
58
|
## 1.0.4
|
40
59
|
|
41
|
-
### Bug Fixes
|
60
|
+
### Bug Fixes
|
42
61
|
|
43
|
-
* Fixed seoable bug that called not weeler function.
|
62
|
+
* Fixed seoable bug that called not weeler function.
|
44
63
|
|
45
64
|
### Contributors
|
46
65
|
|
data/README.md
CHANGED
@@ -124,6 +124,21 @@ You can do this by overriding private methods in your controller.
|
|
124
124
|
{ action: :index }
|
125
125
|
end
|
126
126
|
|
127
|
+
Or you can override what happens after successful <tt>:create</tt>, <tt>:update</tt>, <tt>:destroy</tt> actions.
|
128
|
+
You can do this by overriding private methods in your controller.
|
129
|
+
|
130
|
+
def after_create_action
|
131
|
+
redirect_to( after_create_path, {:notice => "Successfully created item"} )
|
132
|
+
end
|
133
|
+
|
134
|
+
def after_update_action
|
135
|
+
redirect_to( after_update_path, {:notice => "Successfully updated item"} )
|
136
|
+
end
|
137
|
+
|
138
|
+
def after_destroy_action
|
139
|
+
redirect_to( after_destroy_path, {:notice => "Successfully destroyed item"})
|
140
|
+
end
|
141
|
+
|
127
142
|
You should implement form file with your own active record attributes.
|
128
143
|
To do that, create <tt>_form.html.haml</tt> in <tt>views/weeler/_YOUR_RESOURCE_/_form.html.haml</tt>
|
129
144
|
where <tt>_YOUR_RESOURCE_</tt> is name of your resource.
|
@@ -49,6 +49,13 @@ module Weeler
|
|
49
49
|
redirect_to weeler_translations_path, flash: {success: "Translation succesfully removed."}
|
50
50
|
end
|
51
51
|
|
52
|
+
def usage_stats
|
53
|
+
@used_keys = []
|
54
|
+
Weeler.i18n_cache.instance_variable_get(:@data).keys.each do |key|
|
55
|
+
@used_keys << [key, Weeler.i18n_cache.read(key)] if key.start_with?('usage_stats')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
52
59
|
def export
|
53
60
|
respond_to do |format|
|
54
61
|
format.xlsx do
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
%body{data: {controller: controller_name, action: action_name, name_space: 'weeler', tag: "#{yield :weeler_body_tag}" }}
|
14
14
|
= render "header_navbar"
|
15
|
-
.container
|
15
|
+
.container-fluid
|
16
16
|
= render "flash"
|
17
17
|
.row.row-offcanvas.row-offcanvas-right
|
18
18
|
= render "side_navbar"
|
@@ -11,7 +11,14 @@
|
|
11
11
|
= link_to 'Show translations', weeler_translations_path(show_translation_keys: false)
|
12
12
|
- else
|
13
13
|
= link_to 'Show translation keys', weeler_translations_path(show_translation_keys: true)
|
14
|
-
|
14
|
+
%h1 Stats
|
15
|
+
%p.lead.text-muted
|
16
|
+
- if Settings.log_key_usage == 'true'
|
17
|
+
= 'Translation usage stat gathering is ON'
|
18
|
+
- else
|
19
|
+
= 'Translation usage stat gathering is OFF'
|
20
|
+
%p.lead.text-muted
|
21
|
+
= link_to 'Go to Stats', {action: :usage_stats}
|
15
22
|
.row
|
16
23
|
%nav.navbar.navbar-default{role: "navigation"}
|
17
24
|
/ Collect the nav links, forms, and other content for toggling
|
@@ -0,0 +1,28 @@
|
|
1
|
+
.header.container
|
2
|
+
.row
|
3
|
+
.col-lg-12
|
4
|
+
.page-header
|
5
|
+
%h1 Translation stats
|
6
|
+
%p.lead.text-muted
|
7
|
+
- if Settings.log_key_usage == 'true'
|
8
|
+
= 'Translation usage stat gathering is ON'
|
9
|
+
- else
|
10
|
+
= 'Translation usage stat gathering is OFF'
|
11
|
+
%p.lead.text-muted
|
12
|
+
= link_to 'Back to Translation list', {action: :index}
|
13
|
+
|
14
|
+
.container
|
15
|
+
.row
|
16
|
+
.col-lg-12
|
17
|
+
%table.table
|
18
|
+
%thead
|
19
|
+
%tr
|
20
|
+
%th Usage
|
21
|
+
%th Key
|
22
|
+
%th text
|
23
|
+
%tbody
|
24
|
+
- @used_keys.each do |key, usage|
|
25
|
+
%tr
|
26
|
+
%td= usage
|
27
|
+
%td= key.to_s.gsub('usage_stats/en/', '')
|
28
|
+
%td= t(key.to_s.gsub('usage_stats/en/', ''))
|
data/lib/i18n/backend/weeler.rb
CHANGED
@@ -4,6 +4,7 @@ require 'i18n/backend/weeler/dedupe'
|
|
4
4
|
require 'i18n/backend/weeler/html_checker'
|
5
5
|
require 'i18n/backend/weeler/exporter'
|
6
6
|
require 'i18n/backend/weeler/importer'
|
7
|
+
require 'i18n/backend/weeler/usage_logger'
|
7
8
|
|
8
9
|
module I18n
|
9
10
|
module Backend
|
@@ -28,6 +29,7 @@ module I18n
|
|
28
29
|
autoload :Translation, 'i18n/backend/weeler/translation'
|
29
30
|
autoload :Exporter, 'i18n/backend/weeler/exporter'
|
30
31
|
autoload :Importer, 'i18n/backend/weeler/importer'
|
32
|
+
autoload :UsageLogger, 'i18n/backend/weeler/usage_logger'
|
31
33
|
|
32
34
|
module Implementation
|
33
35
|
include Base, Flatten
|
@@ -57,6 +59,7 @@ module I18n
|
|
57
59
|
protected
|
58
60
|
|
59
61
|
def lookup(locale, key, scope = [], options = {})
|
62
|
+
return fallback_backend_translation locale, key if key.to_s.start_with?('i18n')
|
60
63
|
key = normalize_flat_keys(locale, key, scope, options[:separator])
|
61
64
|
return lookup_in_cache(locale, key, scope, options)
|
62
65
|
end
|
@@ -67,6 +70,11 @@ module I18n
|
|
67
70
|
# reload cache if cache timestamp differs from last translations update
|
68
71
|
reload_cache if ((!ActiveRecord::Base.connection.table_exists?('settings')) || i18n_cache.read('UPDATED_AT') != Settings.i18n_updated_at)
|
69
72
|
|
73
|
+
# log locale/key usage for statistics
|
74
|
+
if Settings.log_key_usage == 'true'
|
75
|
+
log_key_usage(locale, key)
|
76
|
+
end
|
77
|
+
|
70
78
|
return nil if i18n_cache.read([:missing, [locale, key]])
|
71
79
|
|
72
80
|
keys = expand_keys key
|
@@ -75,7 +83,7 @@ module I18n
|
|
75
83
|
|
76
84
|
result = i18n_cache.read([locale, check_key])
|
77
85
|
|
78
|
-
return result.value unless result.blank?
|
86
|
+
return result.value unless result.blank?
|
79
87
|
end
|
80
88
|
|
81
89
|
# mark translation as missing
|
@@ -161,4 +169,3 @@ module I18n
|
|
161
169
|
end
|
162
170
|
end
|
163
171
|
end
|
164
|
-
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Backend
|
5
|
+
class Weeler
|
6
|
+
|
7
|
+
module UsageLogger
|
8
|
+
|
9
|
+
def log_key_usage(locale, key)
|
10
|
+
existing = i18n_cache.read([:usage_stats, [locale, key]])
|
11
|
+
value = existing.present? ? (existing.to_i + 1) : 1
|
12
|
+
i18n_cache.write [:usage_stats, [locale, key]], value
|
13
|
+
end
|
14
|
+
|
15
|
+
Weeler.send(:include, UsageLogger)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -83,7 +83,7 @@ module Weeler
|
|
83
83
|
def create
|
84
84
|
@item = model.new(items_params)
|
85
85
|
if @item.save
|
86
|
-
|
86
|
+
after_create_action
|
87
87
|
else
|
88
88
|
render :action => 'new'
|
89
89
|
end
|
@@ -91,7 +91,7 @@ module Weeler
|
|
91
91
|
|
92
92
|
def update
|
93
93
|
if @item.update_attributes(items_params)
|
94
|
-
|
94
|
+
after_update_action
|
95
95
|
else
|
96
96
|
render :action => 'edit'
|
97
97
|
end
|
@@ -99,7 +99,7 @@ module Weeler
|
|
99
99
|
|
100
100
|
def destroy
|
101
101
|
@item.destroy
|
102
|
-
|
102
|
+
after_destroy_action
|
103
103
|
end
|
104
104
|
|
105
105
|
def remove_image
|
@@ -142,6 +142,18 @@ module Weeler
|
|
142
142
|
|
143
143
|
private
|
144
144
|
|
145
|
+
def after_create_action
|
146
|
+
redirect_to( after_create_path, {:notice => "Successfully created item"} )
|
147
|
+
end
|
148
|
+
|
149
|
+
def after_update_action
|
150
|
+
redirect_to( after_update_path, {:notice => "Successfully updated item"} )
|
151
|
+
end
|
152
|
+
|
153
|
+
def after_destroy_action
|
154
|
+
redirect_to( after_destroy_path, {:notice => "Successfully destroyed item"})
|
155
|
+
end
|
156
|
+
|
145
157
|
def after_create_path
|
146
158
|
{ action: :edit, id: @item.id }
|
147
159
|
end
|
data/lib/weeler/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weeler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artūrs Braučs
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -412,6 +412,7 @@ files:
|
|
412
412
|
- app/views/weeler/translations/edit.html.haml
|
413
413
|
- app/views/weeler/translations/index.html.haml
|
414
414
|
- app/views/weeler/translations/new.html.haml
|
415
|
+
- app/views/weeler/translations/usage_stats.html.haml
|
415
416
|
- config/initializers/weeler_mime_types.rb
|
416
417
|
- lib/.DS_Store
|
417
418
|
- lib/generators/weeler/.DS_Store
|
@@ -433,6 +434,7 @@ files:
|
|
433
434
|
- lib/i18n/backend/weeler/html_checker.rb
|
434
435
|
- lib/i18n/backend/weeler/importer.rb
|
435
436
|
- lib/i18n/backend/weeler/translation.rb
|
437
|
+
- lib/i18n/backend/weeler/usage_logger.rb
|
436
438
|
- lib/i18n/humanize_missing_translations.rb
|
437
439
|
- lib/i18n/weeler.rb
|
438
440
|
- lib/tasks/weeler.rake
|
@@ -540,7 +542,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
540
542
|
version: '0'
|
541
543
|
requirements: []
|
542
544
|
rubyforge_project:
|
543
|
-
rubygems_version: 2.4.
|
545
|
+
rubygems_version: 2.4.5
|
544
546
|
signing_key:
|
545
547
|
specification_version: 4
|
546
548
|
summary: CMS for weby.lv projects.
|