riddick 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/README.md +18 -2
- data/TODO-0.0.4 +4 -0
- data/lib/riddick/server.rb +14 -9
- data/lib/riddick/version.rb +1 -1
- data/lib/riddick/views/index.erb +32 -28
- data/riddick.gemspec +1 -0
- data/screenshot.png +0 -0
- metadata +23 -4
- data/.rbenv-version +0 -1
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Friendly GUI for managing your I18n translations.
|
|
6
6
|
|
7
7
|
By default it uses Redis as I18n backend for translations, but you can add your own key-value backend.
|
8
8
|
|
9
|
-
![Screenshot](
|
9
|
+
![Screenshot](https://raw.github.com/kostia/riddick/master/screenshot.png)
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -70,7 +70,7 @@ riddick:
|
|
70
70
|
default: 'Edit'
|
71
71
|
delete: 'Delete'
|
72
72
|
confirm: 'Are you sure?'
|
73
|
-
notice
|
73
|
+
notice:
|
74
74
|
empty: 'You have no translations yet.'
|
75
75
|
set:
|
76
76
|
success: 'Translation successfully stored!'
|
@@ -191,6 +191,22 @@ __Details__: Normally your using a proxy server like NGinx or Apache in front of
|
|
191
191
|
Unfortunately the assets from a mounted Sinatra app will not be served because
|
192
192
|
they aren't in the `public` directory of your app.
|
193
193
|
|
194
|
+
### You are using redis not only for storing translations
|
195
|
+
|
196
|
+
If your are using redis to store other stuff you can separate your I18n translations in namespace. Please use redis-namespace gem.
|
197
|
+
```ruby
|
198
|
+
# Gemfile
|
199
|
+
gem 'redis-namespace'
|
200
|
+
```
|
201
|
+
|
202
|
+
Change your configuration in i18n.rb
|
203
|
+
```ruby
|
204
|
+
# config/initializers/i18n.rb
|
205
|
+
I18n.backend = I18n::Backend::Chain.new I18n::Backend::KeyValue.new(Redis::Namespace.new(:riddick)), I18n.backend
|
206
|
+
```
|
207
|
+
|
208
|
+
Your I18n translations will be stored in `riddick` namespace.
|
209
|
+
|
194
210
|
## Internals
|
195
211
|
|
196
212
|
Take a look at http://railscasts.com/episodes/256-i18n-backends
|
data/TODO-0.0.4
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
* Pagination (see Sidekiq for details)
|
2
|
+
* Change from Erb to Slim
|
1
3
|
* API for writing own backends + examples for ActiveRecordBackend in README
|
2
4
|
* Split Riddick::Server in Riddick::GuiServer and Riddick::ApiServer (JSON)
|
3
5
|
* Build Rails-Engine
|
@@ -7,3 +9,5 @@
|
|
7
9
|
* Simple URL-Helpers for:
|
8
10
|
* Generating URL for editing, updating and deleting translations
|
9
11
|
* Generating JS and HTML snippet for editing a translation
|
12
|
+
|
13
|
+
- Sprockets // Will not be implemented for it's then too complicated in production
|
data/lib/riddick/server.rb
CHANGED
@@ -41,11 +41,20 @@ module Riddick
|
|
41
41
|
url('del') + "?k=#{URI.escape k}"
|
42
42
|
end
|
43
43
|
|
44
|
+
# Shortcut for namepspaces localization
|
45
|
+
def t(path, default = nil)
|
46
|
+
I18n.t "riddick.#{path}", default: default
|
47
|
+
end
|
48
|
+
|
44
49
|
# Truncate a string with default length 30. Truncation string is '...' by default
|
45
50
|
# and can be changed by changing the appropriate translation (see README for further details).
|
46
51
|
def truncate(v, l = 30)
|
47
52
|
s = v.to_s
|
48
|
-
s.size > l ? s.first(l) +
|
53
|
+
s.size > l ? s.first(l) + t('truncation', '...') : s
|
54
|
+
end
|
55
|
+
|
56
|
+
def h(text)
|
57
|
+
Rack::Utils.escape_html(text)
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
@@ -77,11 +86,9 @@ module Riddick
|
|
77
86
|
k, v = params[:k], params[:v]
|
78
87
|
if k && v && !k.empty? && !v.empty?
|
79
88
|
Riddick::Backends.store_translation k, v
|
80
|
-
session[:flash_success] =
|
81
|
-
default: 'Translation successfully stored!')
|
89
|
+
session[:flash_success] = t('notice.set.success', 'Translation successfully stored!')
|
82
90
|
else
|
83
|
-
session[:flash_error] =
|
84
|
-
default: 'Error: either path or translation is empty!')
|
91
|
+
session[:flash_error] = t('notice.set.error', 'Error: either path or translation is empty!')
|
85
92
|
end
|
86
93
|
redirect my_url
|
87
94
|
end
|
@@ -93,11 +100,9 @@ module Riddick
|
|
93
100
|
k = params[:k]
|
94
101
|
if k && !k.empty?
|
95
102
|
Riddick::Backends.delete_translation k
|
96
|
-
session[:flash_success] =
|
97
|
-
default: 'Translation successfully deleted!')
|
103
|
+
session[:flash_success] = t('notice.del.success', 'Translation successfully deleted!')
|
98
104
|
else
|
99
|
-
session[:flash_error] =
|
100
|
-
default: 'Error: no such key or key empty!')
|
105
|
+
session[:flash_error] = t('notice.del.error', 'Error: no such key or key empty!')
|
101
106
|
end
|
102
107
|
redirect(request.referer || root_url)
|
103
108
|
end
|
data/lib/riddick/version.rb
CHANGED
data/lib/riddick/views/index.erb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html lang="en">
|
3
3
|
<head>
|
4
|
-
<title><%=
|
4
|
+
<title><%= t 'head.title', 'Welcome to Riddick!' %></title>
|
5
5
|
<meta charset="utf-8">
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
7
|
<!--[if IE ]><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"><![endif]-->
|
@@ -17,14 +17,14 @@
|
|
17
17
|
<div class="container">
|
18
18
|
<div class="navbar">
|
19
19
|
<div class="navbar-inner">
|
20
|
-
<a href="<%= root_url %>" class="brand"><%=
|
20
|
+
<a href="<%= root_url %>" class="brand"><%= t 'nav.brand', 'Riddick' %></a>
|
21
21
|
<ul class="nav">
|
22
22
|
<li class="<%= 'active' if request.path == root_url %>">
|
23
|
-
<a href="<%= root_url %>"><%=
|
23
|
+
<a href="<%= root_url %>"><%= t 'nav.all', 'All translations' %></a></li>
|
24
24
|
<li class="<%= 'active' if request.path == my_url %>">
|
25
|
-
<a href="<%= my_url %>"><%=
|
25
|
+
<a href="<%= my_url %>"><%= t 'nav.my', 'My translations' %></a></li>
|
26
26
|
<li class="<%= 'active' if request.path == default_url %>">
|
27
|
-
<a href="<%= default_url %>"><%=
|
27
|
+
<a href="<%= default_url %>"><%= t 'nav.default', 'Default translations' %></a></li>
|
28
28
|
</ul>
|
29
29
|
</div>
|
30
30
|
</div>
|
@@ -32,15 +32,15 @@
|
|
32
32
|
<!-- Form for posting new and changing existing translations. -->
|
33
33
|
<form action="<%= set_url %>" method="post" class="form-horizontal well">
|
34
34
|
<select name="k" data-chosen="chosen" data-for="textarea[name=v]"
|
35
|
-
data-placeholder="<%=
|
35
|
+
data-placeholder="<%= t 'form.select.placeholder', 'en.greeting' %>">
|
36
36
|
<option></option>
|
37
37
|
<% @translations.each do |k, v| %>
|
38
|
-
<option value="<%= k %>" data-v='<%= v %>'><%= k %></option>
|
38
|
+
<option value="<%= h(k) %>" data-v='<%= h(v) %>'><%= h(k) %></option>
|
39
39
|
<% end %>
|
40
40
|
</select>
|
41
|
-
<button type="submit" class="btn btn-success"><%=
|
42
|
-
<textarea name="v" type="text"
|
43
|
-
placeholder="<%=
|
41
|
+
<button type="submit" class="btn btn-success"><%= t 'form.button', 'Change' %></button><br />
|
42
|
+
<textarea name="v" type="text" rows="6"
|
43
|
+
placeholder="<%= t 'form.textarea.placeholder', 'Hello World!' %>"></textarea>
|
44
44
|
</form>
|
45
45
|
|
46
46
|
<!-- Flash notifications. -->
|
@@ -54,42 +54,46 @@
|
|
54
54
|
<% if @translations.any? %>
|
55
55
|
<table class="table table-striped">
|
56
56
|
<tr>
|
57
|
-
<th><%=
|
58
|
-
<th><%=
|
59
|
-
<th><%=
|
57
|
+
<th><%= t 'table.header.path', 'Path' %></th>
|
58
|
+
<th><%= t 'table.header.translation', 'Translation' %></th>
|
59
|
+
<th><%= t 'table.header.actions', 'Actions' %></th>
|
60
60
|
</tr>
|
61
61
|
<% @translations.each_pair do |k, v| %>
|
62
62
|
<tr>
|
63
63
|
<% if v.kind_of? Riddick::Backends::KeyValue::Value %>
|
64
64
|
<!-- Details for custom translation. -->
|
65
65
|
<td><span class="badge badge-success"><%= k %></span></td>
|
66
|
-
<td><code>
|
67
|
-
<a rel="popover" data-title="<%= I18n.t 'riddick.table.popover.my', default: 'My translation' %>"
|
68
|
-
data-content='<%= v %>' data-trigger="hover"><%= truncate v %></a>
|
69
|
-
</code></td>
|
70
66
|
<td>
|
71
|
-
<
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
<code>
|
68
|
+
<a rel="popover" data-title="<%= t 'table.popover.my', 'My translation' %>"
|
69
|
+
data-content='<%= h(v) %>' data-trigger="hover"><%= h(truncate(v)) %></a>
|
70
|
+
</code>
|
71
|
+
</td>
|
72
|
+
<td>
|
73
|
+
<a href="#custom-translations" data-choose="<%= h(k) %>" data-v='<%= h(v) %>'
|
74
|
+
class="btn btn-mini"><%= t 'table.edit.my', 'Edit' %></a>
|
75
|
+
<a href="<%= del_url k %>" data-confirm="<%= t 'table.confirm', 'Are you sure?' %>"
|
76
|
+
class="btn btn-mini btn-danger"><%= t 'table.delete', 'Delete' %></a>
|
75
77
|
</td>
|
76
78
|
<% else %>
|
77
79
|
<!-- Details for default translation. -->
|
78
80
|
<td><span class="badge"><%= k %></span></td>
|
79
|
-
<td><code>
|
80
|
-
<a rel="popover" data-title="<%= I18n.t 'riddick.table.popover.default', default: 'Default translation' %>"
|
81
|
-
data-content='<%= v %>' data-trigger="hover"><%= truncate v %></a>
|
82
|
-
</code></td>
|
83
81
|
<td>
|
84
|
-
<
|
85
|
-
|
82
|
+
<code>
|
83
|
+
<a rel="popover" data-title="<%= t 'table.popover.default', 'Default translation' %>"
|
84
|
+
data-content='<%= h(v) %>' data-trigger="hover"><%= h(truncate(v)) %></a>
|
85
|
+
</code>
|
86
|
+
</td>
|
87
|
+
<td>
|
88
|
+
<a href="#custom-translations" data-choose="<%= h(k) %>" data-v='<%= h(v) %>'
|
89
|
+
class="btn btn-mini"><%= t 'table.edit.default', 'Edit' %></a>
|
86
90
|
</td>
|
87
91
|
<% end %>
|
88
92
|
</tr>
|
89
93
|
<% end %>
|
90
94
|
</table>
|
91
95
|
<% else %>
|
92
|
-
<div class="alert alert-info"><%=
|
96
|
+
<div class="alert alert-info"><%= t 'notice.empty', 'You have no translations yet.' %></div>
|
93
97
|
<% end %>
|
94
98
|
|
95
99
|
<div class="well"><a href="https://github.com/kostia/riddick">https://github.com/kostia/riddick</a></div>
|
data/riddick.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'i18n'
|
19
19
|
gem.add_dependency 'redis'
|
20
20
|
gem.add_dependency 'sinatra'
|
21
|
+
gem.add_development_dependency 'activesupport', '>= 3.0.0'
|
21
22
|
gem.add_development_dependency 'capybara'
|
22
23
|
gem.add_development_dependency 'pry'
|
23
24
|
gem.add_development_dependency 'rack-test'
|
data/screenshot.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: activesupport
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.0.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: capybara
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +181,6 @@ extensions: []
|
|
165
181
|
extra_rdoc_files: []
|
166
182
|
files:
|
167
183
|
- .gitignore
|
168
|
-
- .rbenv-version
|
169
184
|
- .rspec
|
170
185
|
- Gemfile
|
171
186
|
- README.md
|
@@ -191,6 +206,7 @@ files:
|
|
191
206
|
- lib/riddick/version.rb
|
192
207
|
- lib/riddick/views/index.erb
|
193
208
|
- riddick.gemspec
|
209
|
+
- screenshot.png
|
194
210
|
- spec/backends/key_value_spec.rb
|
195
211
|
- spec/backends/redis_spec.rb
|
196
212
|
- spec/backends/simple_spec.rb
|
@@ -216,9 +232,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
232
|
- - ! '>='
|
217
233
|
- !ruby/object:Gem::Version
|
218
234
|
version: '0'
|
235
|
+
segments:
|
236
|
+
- 0
|
237
|
+
hash: -4598769758788901426
|
219
238
|
requirements: []
|
220
239
|
rubyforge_project:
|
221
|
-
rubygems_version: 1.8.
|
240
|
+
rubygems_version: 1.8.25
|
222
241
|
signing_key:
|
223
242
|
specification_version: 3
|
224
243
|
summary: Friendly GUI for managing your I18n translations
|
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p0
|