phrasing 4.0.0rc15 → 4.0.0rc16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +5 -0
  4. data/4.0.0_changes.md +0 -0
  5. data/CHANGELOG.md +0 -0
  6. data/Gemfile +9 -8
  7. data/MIT-LICENSE +0 -0
  8. data/README-3.md +0 -0
  9. data/Rakefile +0 -0
  10. data/app/assets/fonts/icomoon.dev.svg +0 -0
  11. data/app/assets/fonts/icomoon.eot +0 -0
  12. data/app/assets/fonts/icomoon.svg +0 -0
  13. data/app/assets/fonts/icomoon.ttf +0 -0
  14. data/app/assets/fonts/icomoon.woff +0 -0
  15. data/app/assets/images/phrasing_icon_edit_all.png +0 -0
  16. data/app/assets/javascripts/editor.js +1 -0
  17. data/app/assets/javascripts/phrasing.js +13 -0
  18. data/app/assets/javascripts/phrasing_engine.js +0 -0
  19. data/app/assets/stylesheets/phrasing.scss +0 -0
  20. data/app/assets/stylesheets/phrasing_edit_mode_bubble.scss +0 -0
  21. data/app/assets/stylesheets/phrasing_engine.css +0 -0
  22. data/app/assets/stylesheets/phrasing_fonts.scss +0 -0
  23. data/app/controllers/phrasing_phrase_versions_controller.rb +0 -0
  24. data/app/helpers/inline_helper.rb +0 -0
  25. data/app/models/phrasing_phrase.rb +0 -0
  26. data/app/models/phrasing_phrase_version.rb +0 -0
  27. data/app/views/layouts/phrasing.html.haml +0 -0
  28. data/app/views/phrasing/_initializer.html.haml +0 -0
  29. data/app/views/phrasing/_menu.html.haml +0 -0
  30. data/app/views/phrasing/_messages.html.haml +0 -0
  31. data/app/views/phrasing/_production_warning.html.haml +0 -0
  32. data/app/views/phrasing_phrases/edit.html.haml +0 -0
  33. data/app/views/phrasing_phrases/help.html.haml +0 -0
  34. data/app/views/phrasing_phrases/import_export.html.haml +0 -0
  35. data/app/views/phrasing_phrases/index.html.haml +0 -0
  36. data/config/routes.rb +0 -0
  37. data/lib/generators/phrasing/phrasing_generator.rb +0 -0
  38. data/lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb +0 -0
  39. data/lib/generators/phrasing/templates/config/initializers/phrasing.rb +0 -0
  40. data/lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb +0 -0
  41. data/lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb +0 -0
  42. data/lib/phrasing/rails/engine.rb +0 -0
  43. data/lib/phrasing/serializer.rb +0 -0
  44. data/lib/phrasing/version.rb +1 -1
  45. data/spec/controllers/phrasing_phrases_controller.rb +0 -0
  46. data/spec/dummy/Rakefile +0 -0
  47. data/spec/dummy/app/assets/stylesheets/application.scss +0 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +0 -0
  49. data/spec/dummy/app/controllers/site_controller.rb +3 -0
  50. data/spec/dummy/app/helpers/application_helper.rb +0 -0
  51. data/spec/dummy/app/helpers/phrasing_helper.rb +0 -0
  52. data/spec/dummy/app/models/.gitkeep +0 -0
  53. data/spec/dummy/app/views/layouts/application.html.erb +0 -0
  54. data/spec/dummy/app/views/site/example.html.erb +1 -0
  55. data/spec/dummy/app/views/site/index.html.erb +4 -0
  56. data/spec/dummy/config.ru +0 -0
  57. data/spec/dummy/config/application.rb +0 -0
  58. data/spec/dummy/config/boot.rb +0 -0
  59. data/spec/dummy/config/database.yml +0 -0
  60. data/spec/dummy/config/environment.rb +0 -0
  61. data/spec/dummy/config/environments/development.rb +0 -0
  62. data/spec/dummy/config/environments/production.rb +0 -0
  63. data/spec/dummy/config/environments/test.rb +0 -0
  64. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
  65. data/spec/dummy/config/initializers/inflections.rb +0 -0
  66. data/spec/dummy/config/initializers/mime_types.rb +0 -0
  67. data/spec/dummy/config/initializers/phrasing.rb +0 -0
  68. data/spec/dummy/config/initializers/secret_token.rb +0 -0
  69. data/spec/dummy/config/initializers/session_store.rb +0 -0
  70. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
  71. data/spec/dummy/config/locales/en.yml +0 -0
  72. data/spec/dummy/config/routes.rb +1 -0
  73. data/spec/dummy/db/.gitkeep +0 -0
  74. data/spec/dummy/db/migrate/20131120000855_create_phrasing_phrases.phrasing_rails_engine.rb +0 -0
  75. data/spec/dummy/db/migrate/20131120000856_create_phrasing_phrase_versions.phrasing_rails_engine.rb +0 -0
  76. data/spec/dummy/db/schema.rb +3 -4
  77. data/spec/dummy/public/404.html +0 -0
  78. data/spec/dummy/public/422.html +0 -0
  79. data/spec/dummy/public/500.html +0 -0
  80. data/spec/dummy/public/favicon.ico +0 -0
  81. data/spec/factories/phrasing_phrases.rb +0 -0
  82. data/spec/features/dummy_spec.rb +44 -3
  83. data/spec/features/phrasing_spec.rb +2 -4
  84. data/spec/lib/phrasing_serializer_spec.rb +3 -0
  85. data/spec/lib/phrasing_spec.rb +0 -0
  86. data/spec/models/phrasing_phrase_spec.rb +0 -0
  87. data/spec/spec_helper.rb +3 -0
  88. metadata +4 -4
  89. data/spec/dummy/db/test.sqlite3 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 363ff7e672836ac3143fef33947f95101b10d314
4
- data.tar.gz: c1b2b2a8a483553b3659ebd3aacbe3396bbbab53
3
+ metadata.gz: 2a638909e5f75504ad5a6775cf1af6fc6d0706dc
4
+ data.tar.gz: 2c772e81d2089512e022b26ceea9f0199f7bd638
5
5
  SHA512:
6
- metadata.gz: 236cbd26a05837f61ac6ba1fdb501f024ae5f5c49328e8177243365f5a9bbfa73133f35d93c6d0a64af99c598bfa6c5ac5a559ab038cdef18d28e4de77e037ec
7
- data.tar.gz: 00d517390daab7df483099dfe4636c184f200ae11ca26e082b3a97d28ace82e33e3da476ff34f707a81150d21c675eca06dc3673298b21efd3fede54c5d7b683
6
+ metadata.gz: 2daf9ac1fa5d83e5cbdce6b91989012ef6bd50ac2d3065a16bdfec3c7330817168032d4e8dfbaf9bad4f88dc2cb01ecfd54b85987fd0e134c7b4d0174f97e621
7
+ data.tar.gz: 627ffd7cf5922061e5674f4072ac9296f9be293aa8c3ce24bfab1df022b831c8c0968180c4efdec652d716fb108156bf37cc272d24d8e564abeea39c38629bdd
data/.gitignore CHANGED
@@ -2,7 +2,8 @@
2
2
  .ruby-version
3
3
  spec/dummy/.sass-cache/
4
4
  spec/dummy/db/development.sqlite3
5
+ spec/dummy/db/test.sqlite3
5
6
  spec/dummy/log/development.log
6
7
  spec/dummy/log/test.log
7
8
  tmp
8
- Gemfile.lock
9
+ Gemfile.lock
@@ -1,5 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ before_install:
4
+ - gem update bundler
5
+ script:
6
+ - RAILS_ENV=test bundle exec rake db:migrate --trace
7
+ - bundle exec rspec spec/
3
8
 
4
9
  matrix:
5
10
  include:
File without changes
File without changes
data/Gemfile CHANGED
@@ -1,16 +1,17 @@
1
- # A sample Gemfile
2
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
3
2
 
4
3
  gemspec
5
4
 
6
- rails_version = ENV["RAILS_VERSION"] || "5.0.0"
5
+ rails_version = ENV['RAILS_VERSION'] || '5.0.0'
7
6
 
8
- gem "rails", "~> #{rails_version}"
7
+ gem 'nokogiri', '~> 1.6.8'
8
+ gem 'rails', "~> #{rails_version}"
9
9
 
10
+ gem 'capybara'
10
11
  gem 'factory_girl_rails'
11
- gem 'sqlite3'
12
- gem 'rspec-rails'
13
- gem 'capybara', '~> 2.7.0'
14
12
  gem 'jasmine-rails'
13
+ gem 'poltergeist'
15
14
  gem 'pry-rails'
16
- gem 'sass', '3.4.0'
15
+ gem 'rspec-rails'
16
+ gem 'sass'
17
+ gem 'sqlite3'
File without changes
File without changes
data/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -303,6 +303,7 @@ var editor = (function() {
303
303
 
304
304
  function rehighlightLastSelection() {
305
305
 
306
+ window.getSelection().removeAllRanges();
306
307
  window.getSelection().addRange( lastSelection );
307
308
  }
308
309
 
@@ -55,11 +55,13 @@ var phrasing_setup = function(){
55
55
  Phrasing.Bus.on('phrasing:edit-mode:on', function(){
56
56
  $('.phrasable').addClass("phrasable-on").attr("contenteditable", 'true');
57
57
  localStorage.setItem(Phrasing.EDIT_MODE_KEY, 'true');
58
+ disable_links();
58
59
  });
59
60
 
60
61
  Phrasing.Bus.on('phrasing:edit-mode:off', function(){
61
62
  $('.phrasable').removeClass("phrasable-on").attr("contenteditable", "false");
62
63
  localStorage.setItem(Phrasing.EDIT_MODE_KEY, "false");
64
+ enable_links();
63
65
  });
64
66
 
65
67
  // Initialize the editing bubble
@@ -148,6 +150,17 @@ var phrasing_setup = function(){
148
150
  $('#edit-mode-onoffswitch').prop('checked', false).change();
149
151
  }
150
152
 
153
+ function disable_links() {
154
+ $('a').on("click.phrasing", function(e){
155
+ if($(this).find('span').hasClass('phrasable')) {
156
+ e.preventDefault();
157
+ }
158
+ });
159
+ }
160
+
161
+ function enable_links() {
162
+ $('a').off('click.phrasing')
163
+ }
151
164
  };
152
165
 
153
166
  $(document).ready(phrasing_setup);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Phrasing
2
- VERSION = "4.0.0rc15"
2
+ VERSION = "4.0.0rc16"
3
3
  end
File without changes
@@ -1,4 +1,7 @@
1
1
  class SiteController < ApplicationController
2
2
  def index
3
3
  end
4
+
5
+ def example
6
+ end
4
7
  end
File without changes
File without changes
@@ -0,0 +1 @@
1
+ Example page for phrasing
@@ -11,3 +11,7 @@
11
11
  <div><%= phrase 'test', scope: :site %></div>
12
12
 
13
13
  <div><%= distance_of_time_in_words(Time.now, Time.now) %></div>
14
+
15
+ <div><%= link_to phrase('Editable link'), example_path %></div>
16
+
17
+ <%= link_to 'Uneditable link', example_path %>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,4 @@
1
1
  Dummy::Application.routes.draw do
2
2
  root to: "site#index"
3
+ get 'example', to: 'site#example'
3
4
  end
File without changes
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -13,14 +12,14 @@
13
12
 
14
13
  ActiveRecord::Schema.define(version: 20131120000856) do
15
14
 
16
- create_table "phrasing_phrase_versions", force: true do |t|
17
- t.string "phrasing_phrase_id"
15
+ create_table "phrasing_phrase_versions", force: :cascade do |t|
16
+ t.integer "phrasing_phrase_id"
18
17
  t.text "value"
19
18
  t.datetime "created_at"
20
19
  t.datetime "updated_at"
21
20
  end
22
21
 
23
- create_table "phrasing_phrases", force: true do |t|
22
+ create_table "phrasing_phrases", force: :cascade do |t|
24
23
  t.string "locale"
25
24
  t.string "key"
26
25
  t.text "value"
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,31 +2,34 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  feature "use #phrase" do
5
-
6
5
  it "should see the header phrase" do
7
6
  visit root_path
8
7
  expect(page).to have_content('The Header')
9
8
  end
10
9
 
11
10
  it "should see the header phrase modified if created before visiting" do
11
+ PhrasingPhrase.where(key: 'site.index.header').destroy_all
12
12
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'The Header1')
13
13
  visit root_path
14
14
  expect(page).to have_content 'The Header1'
15
15
  end
16
16
 
17
17
  it "creates a phrasing_phrase if the yaml has an entry" do
18
+ PhrasingPhrase.where(key: 'site.index.header').destroy_all
18
19
  expect(PhrasingPhrase.find_by_key('site.index.header')).to be_nil
19
20
  visit root_path
20
21
  expect(PhrasingPhrase.find_by_key('site.index.header')).not_to be_nil
21
22
  end
22
23
 
23
24
  it "creates a phrasing_phrase if the yaml does not have an entry" do
25
+ PhrasingPhrase.where(key: 'site.index.intro').destroy_all
24
26
  expect(PhrasingPhrase.find_by_key('site.index.intro')).to be_nil
25
27
  visit root_path
26
28
  expect(PhrasingPhrase.find_by_key('site.index.intro')).not_to be_nil
27
29
  end
28
30
 
29
31
  it "shows the phrasing_phrase instead of the yaml" do
32
+ PhrasingPhrase.where(key: 'site.index.header').destroy_all
30
33
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'A different header')
31
34
  visit root_path
32
35
  expect(page).not_to have_content 'The Header'
@@ -34,6 +37,7 @@ feature "use #phrase" do
34
37
  end
35
38
 
36
39
  it "allows to treat every translation as html safe" do
40
+ PhrasingPhrase.where(key: 'site.index.header').destroy_all
37
41
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: '<strong>Strong header</strong>')
38
42
  visit root_path
39
43
  expect(page).to have_content 'Strong header'
@@ -47,9 +51,46 @@ feature "use #phrase" do
47
51
  expect(page).to have_content 'models.errors.test'
48
52
  expect(page).to have_content 'site.test'
49
53
  end
54
+
55
+ context 'preventing link redirects', js: true do
56
+ context 'edit mode is enabled' do
57
+ it 'should prevent phrasing link redirects' do
58
+ visit root_path
59
+ find('#phrasing-onoffswitch').click
60
+ click_link 'Editable link'
61
+ expect(page).not_to have_content 'Example page for phrasing'
62
+ expect(page).to have_content 'Editable link'
63
+ end
64
+
65
+ it 'should not prevent other link redirects' do
66
+ visit root_path
67
+ click_link 'Uneditable link'
68
+ expect(page).to have_content 'Example page for phrasing'
69
+ expect(page).not_to have_content 'Editable link'
70
+ end
71
+
72
+ it 'should not prevent the phrasing edit all phrases link' do
73
+ visit root_path
74
+ find('#phrasing-edit-all-phrases-icon-container').click
75
+ expect(page).to have_content 'Phrasing'
76
+ end
77
+ end
78
+
79
+ context 'edit mode is disabled' do
80
+ it 'should not prevent link redirects' do
81
+ visit root_path
82
+ click_link 'Editable link'
83
+ expect(page).to have_content 'Example page for phrasing'
84
+ expect(page).not_to have_content 'Editable link'
85
+ end
86
+ end
87
+ end
50
88
  end
51
89
 
52
90
  feature "locales" do
91
+ before do
92
+ PhrasingPhrase.destroy_all
93
+ end
53
94
 
54
95
  it "displays different text based on users' locale" do
55
96
  FactoryGirl.create(:phrasing_phrase, locale: 'en', key: 'site.index.intro', value: 'world')
@@ -70,7 +111,7 @@ feature "locales" do
70
111
  expect(page).not_to have_content 'world'
71
112
  expect(page).not_to have_content 'mundo'
72
113
 
73
- I18n.locale = :en # reset
114
+ I18n.locale = :en # reset
74
115
  end
75
116
 
76
117
  end
@@ -94,4 +135,4 @@ feature "yaml" do
94
135
  expect(PhrasingPhrase.find_by_key('site.index.footer')).to be_nil
95
136
  end
96
137
  end
97
- end
138
+ end
@@ -294,7 +294,7 @@ feature 'phrase versions' do
294
294
  end
295
295
 
296
296
  feature "downloading and uploading yaml files" do
297
- after do
297
+ before do
298
298
  PhrasingPhrase.destroy_all
299
299
  end
300
300
 
@@ -368,10 +368,9 @@ end
368
368
 
369
369
  feature "locales" do
370
370
  before do
371
- end
372
- after do
373
371
  PhrasingPhrase.destroy_all
374
372
  end
373
+
375
374
  it "imports yaml containing multiple locales" do
376
375
  file = Tempfile.new 'phrasing'
377
376
  file.write <<-YAML
@@ -405,5 +404,4 @@ feature "locales" do
405
404
  expect(yaml).to match(/en:\s*hello: world/)
406
405
  expect(yaml).to match(/es:\s*hello: mundo/)
407
406
  end
408
-
409
407
  end
@@ -129,6 +129,9 @@ describe Phrasing::Serializer do
129
129
  end
130
130
 
131
131
  context 'export_yaml' do
132
+ before do
133
+ PhrasingPhrase.destroy_all
134
+ end
132
135
  it 'flattened phrases' do
133
136
  FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
134
137
  FactoryGirl.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
File without changes
File without changes
@@ -2,9 +2,12 @@ ENV["RAILS_ENV"] = 'test'
2
2
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
3
  require 'rspec/rails'
4
4
  require 'capybara/rspec'
5
+ require 'capybara/poltergeist'
5
6
  require 'tempfile'
6
7
  require 'pry'
7
8
 
9
+ Capybara.javascript_driver = :poltergeist
10
+
8
11
  Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each { |f| require f }
9
12
 
10
13
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phrasing
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0rc15
4
+ version: 4.0.0rc16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Car
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-21 00:00:00.000000000 Z
12
+ date: 2017-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -145,6 +145,7 @@ files:
145
145
  - spec/dummy/app/helpers/phrasing_helper.rb
146
146
  - spec/dummy/app/models/.gitkeep
147
147
  - spec/dummy/app/views/layouts/application.html.erb
148
+ - spec/dummy/app/views/site/example.html.erb
148
149
  - spec/dummy/app/views/site/index.html.erb
149
150
  - spec/dummy/config.ru
150
151
  - spec/dummy/config/application.rb
@@ -167,7 +168,6 @@ files:
167
168
  - spec/dummy/db/migrate/20131120000855_create_phrasing_phrases.phrasing_rails_engine.rb
168
169
  - spec/dummy/db/migrate/20131120000856_create_phrasing_phrase_versions.phrasing_rails_engine.rb
169
170
  - spec/dummy/db/schema.rb
170
- - spec/dummy/db/test.sqlite3
171
171
  - spec/dummy/public/404.html
172
172
  - spec/dummy/public/422.html
173
173
  - spec/dummy/public/500.html
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: 1.3.1
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.4.5
204
+ rubygems_version: 2.6.11
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: Edit phrases inline for Rails applications!
Binary file