Skip to content

Commit ba359c6

Browse files
authored
Merge pull request #178 from prograils/cleanup_making_lit_zeitwerk_and_classic_compatible
Cleanup making lit zeitwerk and classic compatible
2 parents 573b2f4 + 43b23b2 commit ba359c6

21 files changed

+226
-213
lines changed

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
language: ruby
2+
jobs:
3+
exclude:
4+
- rvm: 3.0.1
5+
gemfile: gemfiles/rails_5.2.gemfile
26
rvm:
37
- 2.7.3
4-
- 3.0.0
8+
- 3.0.1
59
gemfile:
610
- gemfiles/rails_5.2.gemfile
711
- gemfiles/rails_6.0.gemfile

README.md

+38-26
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ Highly inspired by Copycopter by thoughtbot.
2222
9. (On request) stores paths where translation keys were called
2323
10. (On request) is able to show all translation keys used to render current page
2424

25+
2526
### Screenshots
2627

27-
Check wiki: [Screenshots](https://github.com/prograils/lit/wiki/Screenshots)
28+
[Feature overview on YouTube](https://www.youtube.com/watch?v=_T9Kg05VvLI)
29+
30+
![lit live translation](https://prograils-com-stuff.s3.amazonaws.com/lit/lit-front.gif)
31+
32+
Check wiki for more: [Screenshots](https://github.com/prograils/lit/wiki/Screenshots)
2833

2934
### Installation
3035

@@ -199,31 +204,32 @@ Also applies to upgrading from `0.4.pre.alpha` versions.
199204

200205
1. Add `Lit::FrontendHelper` to your `ApplicationController`
201206

202-
```ruby
203-
helper Lit::FrontendHelper
204-
```
207+
```ruby
208+
helper Lit::FrontendHelper
209+
```
205210

206211
2. In you layout file include lit assets
207212

208-
```erb
209-
<% if admin_user_signed_in? %>
210-
<%= lit_frontend_assets %>
211-
<% end %>
212-
```
213+
```erb
214+
<% if admin_user_signed_in? %>
215+
<%= lit_frontend_assets %>
216+
<% end %>
217+
```
213218

214219
3. You're good to go - now log in to lit (if required) and open your frontend in separate tab (to have session persisted). On the bottom-right of your page you should see "Enable / disable lit highlight" - after enabling it you'll be able to click and translate phrases directly in your frontend
215220

216221
4. Once enabled, all translations called via `t` helper function be rendered inside `<span />` tag, what may break your layout (ie if you're using translated values as button values or as placeholders, etc). To avoid that add `skip_lit: true` to `t()` call or use `I18n.t`.
217222

218223
5. This feature requires jQuery! (at least for now)
219224

225+
220226
### Storing request info
221227

222-
1. Include `Lit::Concerns::RequestInfoStore` concern in your `ApplicationController`
228+
1. Include `Lit::RequestInfoStore` concern in your `ApplicationController`
223229

224-
```ruby
225-
include Lit::Concerns::RequestInfoStore
226-
```
230+
```ruby
231+
include Lit::RequestInfoStore
232+
```
227233

228234
2. In lit initializer (`lit.rb`) set `store_request_info` config to true
229235

@@ -238,25 +244,31 @@ Lit.store_request_info = true
238244

239245
1. Add `Lit::FrontendHelper` in your `ApplicationController`
240246

241-
```ruby
242-
include Lit::FrontendHelper
243-
```
247+
```ruby
248+
helper Lit::FrontendHelper
249+
```
244250

245-
2. Include `Lit::Concerns::RequestKeysStore` concern in your `ApplicationController`
251+
2. Include `Lit::RequestKeysStore` concern in your `ApplicationController`
246252

247-
```ruby
248-
include Lit::Concerns::RequestKeysStore
249-
```
253+
```ruby
254+
include Lit::RequestKeysStore
255+
```
250256

251-
3. On the bottom of you layout file call `lit_translations_info` helper function
257+
3. Enable storing of request keys in lit initializer `config/initializers/lit.rb`
252258

253-
```erb
254-
<%= lit_translations_info %>
255-
```
259+
```ruby
260+
Lit.store_request_keys = true
261+
```
262+
263+
4. On the bottom of you layout file call `lit_translations_info` helper function
264+
265+
```erb
266+
<%= lit_translations_info %>
267+
```
256268

257-
4. From now on you'll be able to see all translation keys that were used to render current page. This feature works great with on-site live translations!
269+
5. From now on you'll be able to see all translation keys that were used to render current page. This feature works great with on-site live translations!
258270

259-
5. Lit authorized user must be signed in for this feature to work! This feature requires jQuery!
271+
6. Lit authorized user must be signed in for this feature to work! This feature requires jQuery!
260272

261273

262274

app/assets/stylesheets/lit/lit_frontend.css

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
.lit-key-generic {
22
}
3-
.lit-key-highlight{
4-
text-decoration: underline wavy red !important;
3+
.lit-key-highlight {
4+
text-decoration: underline !important;
5+
text-decoration-color: red !important;
6+
text-decoration-style: wavy !important;
57
}
6-
#lit_button_wrapper{
8+
#lit_button_wrapper {
79
position: fixed;
810
bottom: 20px;
911
right: 20px;
@@ -15,16 +17,15 @@
1517
cursor: pointer;
1618
color: white;
1719
}
18-
#lit_button_wrapper.lit-highlight-enabled{
20+
#lit_button_wrapper.lit-highlight-enabled {
1921
background-color: lightgreen;
2022
}
21-
#lit_textarea{
23+
#lit_textarea {
2224
position: absolute;
2325
padding: 0 0 1px 0;
2426
margin: 0 0 0 0;
2527
border: 0;
2628
border-bottom: 1px solid red;
27-
2829
}
2930
.lit-translations-info.collapsed {
3031
position: fixed;
@@ -38,7 +39,7 @@
3839
cursor: pointer;
3940
color: white;
4041
}
41-
.lit-translations-info.expanded{
42+
.lit-translations-info.expanded {
4243
position: absolute;
4344
display: block;
4445
width: 80%;
@@ -52,16 +53,16 @@
5253
z-index: 90;
5354
}
5455

55-
.lit-translations-info.collapsed span.lit-open-button{
56+
.lit-translations-info.collapsed span.lit-open-button {
5657
display: block;
5758
}
58-
.lit-translations-info.expanded span.lit-open-button{
59+
.lit-translations-info.expanded span.lit-open-button {
5960
display: none;
6061
}
61-
.lit-translations-info.collapsed span.lit-close-button{
62+
.lit-translations-info.collapsed span.lit-close-button {
6263
display: none;
6364
}
64-
.lit-translations-info.expanded span.lit-close-button{
65+
.lit-translations-info.expanded span.lit-close-button {
6566
display: block;
6667
position: fixed;
6768
right: 10%;
@@ -71,16 +72,16 @@
7172
background-color: white;
7273
padding: 10px 10px 5px;
7374
}
74-
.lit-translations-info.collapsed ul.lit-translations-list{
75+
.lit-translations-info.collapsed ul.lit-translations-list {
7576
display: none;
7677
}
77-
.lit-translations-info.expanded ul.lit-translations-list{
78+
.lit-translations-info.expanded ul.lit-translations-list {
7879
}
7980

80-
.lit-translations-info.expanded ul.lit-translations-list li{
81+
.lit-translations-info.expanded ul.lit-translations-list li {
8182
margin: 5px;
8283
}
8384

84-
.lit-translations-info.expanded #lit_textarea{
85+
.lit-translations-info.expanded #lit_textarea {
8586
padding: 2px;
8687
}

app/controllers/lit/concerns/request_info_store.rb

-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
module Lit
2-
module RequestInfoStore
3-
extend ::ActiveSupport::Concern
4-
included do
5-
before_action :store_request_path
6-
end
7-
8-
private
9-
10-
def store_request_path
11-
Thread.current[:lit_current_request_path] = request&.path
12-
end
13-
end
14-
end
15-
161
module Lit::Concerns::RequestInfoStore
172
extend ActiveSupport::Concern
183

app/controllers/lit/concerns/request_keys_store.rb

-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
module Lit
2-
module RequestKeysStore
3-
extend ::ActiveSupport::Concern
4-
included do
5-
before_action :init_request_keys
6-
end
7-
8-
private
9-
10-
def init_request_keys
11-
Thread.current[:lit_request_keys] = {}
12-
end
13-
end
14-
end
15-
161
module Lit::Concerns::RequestKeysStore
172
extend ActiveSupport::Concern
183

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Lit::RequestInfoStore
2+
extend ::ActiveSupport::Concern
3+
included { before_action :store_request_path }
4+
5+
private
6+
7+
def store_request_path
8+
Thread.current[:lit_current_request_path] = request&.path
9+
end
10+
end
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Lit::RequestKeysStore
2+
extend ::ActiveSupport::Concern
3+
included { before_action :init_request_keys }
4+
5+
private
6+
7+
def init_request_keys
8+
Thread.current[:lit_request_keys] = {}
9+
end
10+
end

0 commit comments

Comments
 (0)