locales_panel 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98e51d12e2736c77504068954a72302ea42777ac
4
- data.tar.gz: 1e68bb0516af17c81c62c4ba3d5abc2d6304a2b5
3
+ metadata.gz: afaa0acd3da6432f5873d66a771e287ffa411185
4
+ data.tar.gz: 0fed03c8e8d14057aa3d426ed3c0f3b4e35259ec
5
5
  SHA512:
6
- metadata.gz: 54270f53bc1757822692c7b26c7ae9bd4561dc7b2c310a5875941d5c5c1a608d076b1213ac7c02fbaf95740af8d2c70139c454e11bcd9989eff474698caba0b4
7
- data.tar.gz: 97c77093c56ab52eb74d2411815de1aee41263baffb4e7e7107b7f2207553f9eae57ee686f6979a936b6f17299a0fc4bd4a1db267905a627377eabe2a7500296
6
+ metadata.gz: 7626041cbf2d73a5ff23c44c0bf3656d26741b725e0d1a3346199bc8465bfbc02881795903a97e32386aca16a5d253db17da6a36f86ba59e0fe3843942132dca
7
+ data.tar.gz: 6585a358eeab09b86718f3001b40f5c940f25ee71e2499a8ea85559b29153f733863b4f7b26389c150a0102e4e284972acefe684347475afa635689574cbb53c
data/README.md CHANGED
@@ -1,15 +1,8 @@
1
- **Major issues, too early for use**
2
- - shows readonly locales from application's gems
3
- - could be hacked to overwrite non locale files
4
-
5
- ---
6
1
  # Locales Panel
7
2
 
8
3
  Change translations directly in a published site.
9
4
 
10
- Use by visiting `http://.../locales/edit`. Saving will overwrite YAML locales files. Tool is dedicated for UAT server configuration, where the user can see live changes without server restart.
11
-
12
- When ready for upload, push files from the server to your application's git repository.
5
+ Use by visiting `http://.../locales/edit`. Saving will overwrite YAML locales files.
13
6
 
14
7
  # Installation
15
8
 
@@ -21,26 +14,18 @@ Run in console:
21
14
 
22
15
  $ bundle
23
16
 
24
- To enable live changes, be sure to run with Rails configuration option (typical for non-production):
25
-
26
- config.cache_classes = false
27
-
28
17
  # Join
29
18
 
30
19
  Create pull request or contact on [skype chat](http://kapustka.net/chat?user=kapustka.maciek).
31
20
 
32
- **priority todo**
33
- - fix opening gem locales
34
- - fix security of file save
35
-
36
- **todos**
37
- - css
38
- - reload I18n after change
21
+ **todo**
22
+ - hook for authorization
23
+ - configurable route
39
24
  - download link
40
25
  - add to git link
41
- - work with rails 3
26
+ - check with rails 3
42
27
  - validation
43
28
  - highlight untranslated
44
- - hook for authorization
45
- - configurable route
46
- - translated views
29
+ - translate editor itself
30
+ - css
31
+ - tests for indentation fix, security fix and I18n.reload
@@ -1,15 +1,18 @@
1
1
  class LocalesController < ApplicationController
2
+ before_action { @paths = Rails.configuration.i18n.load_path.delete_if{|path|path['/gems/']}}
3
+
2
4
  def edit
3
5
  @files = []
4
- Rails.configuration.i18n.load_path.each do |path|
5
- @files << { path: path, name: File::basename(path)[0..-5], content: File.read(path) }
6
+ @paths.each do |path|
7
+ @files << { path: path, name: File::basename(path)[0..-5], content: File.read(path).gsub("\n",'&#x000A;').html_safe }
6
8
  end
7
9
  end
8
10
 
9
11
  def update
10
- params[:files].each do |file|
12
+ params[:files].keep_if{|file| file[:path].in? @paths}.each do |file|
11
13
  File.write file[:path], file[:content].gsub("\r",'')
12
14
  end
15
+ I18n.reload!
13
16
  redirect_to edit_locales_path
14
17
  end
15
18
  end
@@ -1,8 +1,9 @@
1
1
  <%= form_tag(locales_path, method: :put) do %>
2
2
  <% @files.each do |file| %>
3
3
  <h2><%= file[:name] %></h2>
4
- <input type="hidden" name="files[][path]" value="<%= file[:path] %>" />
4
+ <input type="hidden" name="files[][path]" value="<%= file[:path] %>"/>
5
5
  <textarea name="files[][content]" cols="80" rows="20" wrap="off" style="width:100%"><%= file[:content] %></textarea>
6
6
  <% end %>
7
- <input type="submit" value="submit" />
8
- <% end %>
7
+ <input type="submit" value="submit"/>
8
+ <% end %>
9
+
@@ -1,3 +1,3 @@
1
1
  module LocalesPanel
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locales_panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Kasprzyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails