Git Product home page Git Product logo

phrasing's Introduction

Phrasing!

Build Status

Phrasing is a gem for live editing phrases (copy) on websites.

Installation

Include the gem in your Gemfile

gem "phrasing"

Bundle the Gemfile

bundle install

Run the install script which will create a migration file and a config file.

rails generate phrasing

Migrate your database

rake db:migrate

Setup

The rake task will also generate phrasing_helper.rb in your app/helpers folder. Here you will need to implement the can_edit_phrases? method. Use this to hook-up your existing user authentication system to work with Phrasing.

For example:

module PhrasingHelper
  def can_edit_phrases?
    current_user.is_admin?
  end
end

Include the phrasing html initializer right below the <body> tag in your application layout file.

<%= render 'phrasing/initializer' %>

Include the required javascript files:

//= require phrasing

Include the required javascript files:

//= require jquery
//= require jquery_ujs
//= require phrasing

Include the required stylesheet file:

*= require phrasing

How to use phrasing?

You can start adding new phrases by simply adding them in your view file:

<%= phrase('my-first-phrase') %>

Aside from editing phrases (basically, Rails translations) you can also edit model attributes inline. Use the same phrase method, with the first attribute being the record in question, and the second one the attribute you wish to make editable:

<%= phrase(@post, :title) %>

In the above example, @post is the record with a title attribute.

Security

Since Phrasing can be used to update any attribute in any table (using the model_phrase method), special care must be taken into consideration from a security standpoint.

By default, Phrasing doesn't allow updating of any attribute apart from PhrasingPhrase.value. To be able to work with other attributes, you need to whitelist them.

In the config/initializers/phrasing.rb file you can whitelist your model attributes like this:

config.white_list = ["Post.title", "Post.body"]

or you can whitelist all of them (not recommended) with:

config.allow_update_on_all_models_and_attributes = true

Turbolinks

If you're using Turbolinks make sure the phrasing gem is required after it:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require phrasing

Phrasing Appearance

The phrase view helper can take the options hash as the last parameter. Features:

url: custom_url # point Phrasing to other actions in other controllers
inverse: true # change the hovered background and underline colors to better fit darker backgrounds
class: custom_class # add custom CSS classes to your phrases to change the appearance of phrases in your application
scope: 'homepage.footer' # add scopes just like you would w/ I18.n. If the first argument is 'test', than the key would be 'homepage.footer.test'

Credits

Phrasing is maintained and sponsored by Infinum.

Phrasing leverages parts of Copycat and ZenPen.

License

Phrasing is Copyright © 2013 Infinum. It is free software, and may be redistributed under the terms specified in the LICENSE file.

phrasing's People

Contributors

alagunambi avatar anacar avatar carr avatar cgunther avatar cilim avatar damirsvrtan avatar eoy avatar mdh avatar melcha avatar monorkin avatar paulewetzel avatar petarcurkovic avatar rabsztok avatar uncoverd avatar vfonic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phrasing's Issues

Where to include 'phrasing/initializer' partial?

The documentation says:

Include the phrasing html initializer at the top of your application layout file.

Which is not very specific. The top of application layout file is <!DOCTYPE html>, not <body>, where I saw the partial being added in the dummy app.

Would it be more correct to say that it needs to be added right below the opening <body> tag?

Also, the example syntax shows haml syntax and I think majority of people use erb, so maybe it would be better to have the good ol' erb syntax instead:
<%= render 'phrasing/initializer' %>

Consider using mountable engine for routes

Hi! I'm poking around with this gem (very nice!), but one pain point I ran into was how it injects the routes directly into the application instead of using a mountable engine. I use a catch-all GET route at the bottom of my apps routes to handle any request gracefully, but Phrasing's routes get tacked on afterward, making them inaccessible by default.

My workaround in case anyone else has this issue was to add a constraint on my route to ignore phrasing

get '*path' => 'pages#show', :as => :page, constraints: lambda { |request| !(request.path =~ /phrasing/) }

Reverting back to Rails default translations stills query to database instead in yml file

Reverting back to Rails default translations still querys to the database through prhasing.

1st step
t('footer.link1') //gets translation from config/locales

2nd step. change t to phrase
phrase('footer.link1') //gets translation from db phrasing table

3rd. step. change back to t
t('phrase') //still gets translation from db table, editing the yml file does not change this value

in my logs

  PhrasingPhrase Load (1.4ms)  SELECT `phrasing_phrases`.* FROM `phrasing_phrases` WHERE `phrasing_phrases`.`locale` = 'tr' AND `phrasing_phrases`.`key` = 'footer.link_1' LIMIT 1

Default phrase values?

I don't want to deploy a new page to production with a bunch of random phrase placeholder names, and I don't see a way to initialize phrases to a default value other than the name of the record. Am I missing it?

Is there a correct way to edit the help docs?

Hi, I've tried editing help.html.haml to simplify instructions for my users, but the changes only appear in development and don't deploy to staging or production. Is there a correct way to customize the help page?

undefined local variable or method `current_user'

Hello, first of all would like to say I really like the idea of this Gem. Unfortunately I seem to be having issues with the can_edit_phrases? method. I have setup everything as per the instructions but whenever I try visit Edit all or save a change I am getting

NameError - undefined local variable or method current_user' for #PhrasingPhrasesController:0x007ffd3bc41680:
app/helpers/phrasing_helper.rb:4:in can_edit_phrases?' phrasing (3.2.6) app/controllers/phrasing_phrases_controller.rb:132:in authorize_editor'`

Looking at PhrasingPhrasesController I see that it inherits directly from ActionController::Base but my current_user method is defined in my ApplicationController (I use a custom auth system not Devise) so I can see why PhrasingPhrasesController does not know about the current_user.

Is there any way to get around this, or is there any reason why PhrasingPhrasesController could not inherit from ApplicationController instead?

Please let me know if you need any more info, this is the first time I have been confident enough to post an issue so not sure if I have given you enough.

Thanks

No styles

Good Job!

That's what I was looking so long.
But look at the picture below — looks like styles issue. Everything is good, no one error in Chrome Developer.
screen shot 2015-07-14 at 23 34 35
My application.scss:

@import "plugins/normalize";
@import "plugins/toastr.min";
@import "font-awesome";
@import "bourbon";
@import "base/base";
@import "neat/settings/visual-grid";
@import "neat";

@import "helpers";

@import "jquery.countdown";
@import "social_buttons";
@import "toast";
@import "devise";
@import "modal";
@import "profile";
@import "modules/modules-dir";
@import "phrasing";

Styles are present in DOM:

screen shot 2015-07-16 at 14 48 52

too much log being generated

I am using a lot of phrasing in a single page for a particular user. The log is so clogged I can barely see other stuff in that log. Is there a way to reduce this? Let us say I have about 15 different words for phrasing in a page.

Adding new entries after default locale is loaded

Bug's happening when I18n fallback is set to true with a default_language, and then if the default_language phrases are already loaded into the database, other locale phrases will not be added to database.

My application.rb in config contains:
config.i18n.default_locale = :en
config.i18n.fallbacks = true

For instance (default locale en):
/de/something - imports all DE phrases
/en/something - imports all EN phrases
/hr/something - error

https://cloud.githubusercontent.com/assets/6040256/7495296/599c0478-f40d-11e4-857e-fcd824d66f9a.png
https://cloud.githubusercontent.com/assets/6040256/7495297/59a191ae-f40d-11e4-9739-506c8a90c069.png
https://cloud.githubusercontent.com/assets/6040256/7495298/59c33534-f40d-11e4-8315-ce23df491f4b.png
https://cloud.githubusercontent.com/assets/6040256/7495299/59c38a70-f40d-11e4-8ef6-692d1dc5041c.png
https://cloud.githubusercontent.com/assets/6040256/7495300/59cdb0ae-f40d-11e4-8722-7222377ba59f.png

Stef and me (mostly Stef) think that problem is at:
https://github.com/infinum/phrasing/blob/master/app/models/phrasing_phrase.rb line: 11

Strange behavior on Heroku

On my Heroku App, Phrases are always editable, even when "Editing" is switched off. Also, the "Saved" Icon is always Green, and never actually saves the changes. However, when using domain.com/phrasing, I can edit the phrase successfully.

In works like a dream on my local machine, though.

My view:
<p><%= phrase ("This is a phrase.") %></p>

I've installed the gem, required the JS, stylesheets, etc.

Is there some important part I'm missing? Let me know if I'm missing any code that I should post.

CSS for Phrasing is not being included in the asset pipeline

This is probably moreso project-specific for me; but I'm sure others maybe have run into this. I'm using Sass and no matter where I put phrasing in the order of application.scss, the CSS isn't included. If I create a phrasing.scss and include it at the bottom of my application.scss, all of the CSS will overwrite my existing CSS and change the fonts and sizes when a user is logged in to edit. Is there anyway around this that I can get the floating edit-box on the bottom right, without having all my other CSS overwritten? I feel like this would confuse my client if I manually created a phrasing.scss file with all the custom assets/stylesheets/* from phrasing, but I also want the sweet edit-box in the bottom right. Thanks :)
image

Nested key/values not imported correctly from locale yml file

Hello,

I've been playing with Phrasing for a few days now, it's pretty slick - so thanks for making it available.

I noticed that the creation of PhrasingPhrases during i18n interception behaves differently than importing a file. For example:

I have Phrasing installed and running, I also use devise. If i login/logout, the Devise localization messages are automatically detected by Phrasing and imported. I get key / value pairs like this:

devise.confirmations.confirmed Hi, %{first_name}! Welcome to MyWebsite!

So far so good.

What if I want to import my locale file to begin with, this way my end-user can begin modifying his locale messages immediately and is not required for them to have appeared first.

If I import a basic yaml document

france:
  hello: "Hello world"
  devise:
    confirmations:
      confirmed: "Hi, %{first_name}! Welcome to MyWebsite!"
      confirmed_seller: "Hi, %{first_name}! Your %{trial_length} day trial has started. You should %{ad_path}"
      send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."

The import behavior, however, only seems to recognize the "devise" key, and the other nested keys are just lumped into one big hashy value. This sometimes generates an error "TypeError: can't cast Hash to text", but sometimes it 'works' - but doesn't generate a useful key/value pair.

["key", "devise"], ["locale", "france"], ["updated_at", Thu, 13 Feb 2014 18:47:18 UTC +00:00], ["value", {"confirmations"=>{"confirmed"=>"Hi, %{first_name}! Welcome to MyWebsite!", "confirmed_seller"=>"Hi, %{first_name}! Your %{trial_length} day trial has started. You should %{ad_path}", "send_instructions"=>"You will receive an email with instructions about how to confirm your account in a few minutes.", "send_paranoid_instructions"=>"If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."}}]]

I wrote a bit of a modified PhrasingPhrase model to create dot separated nested key values from the larger hash. It works for me, but I doubt it's the ideal way to do it.

a private method:

def self.flatten_hash(my_hash, parent=[])
  my_hash.flat_map do |key, value|
    case value
      when Hash then flatten_hash( value, parent+[key] )
      else [(parent+[key]).join('.'), value]
    end
  end
end

and then in the import_yaml method:

hash.each do |locale, data|
    flat_array = self.flatten_hash(data) 
    nested_hash = Hash[*flat_array]
    nested_hash.each do |key, value|

the rest is the same.

Any thoughts? Am I not formatting my locale yml document correctly? Is this not a use case you all have bumped into?

Thanks!

Abnormally long initial page load times

With only opne phrase on my site's index page, the initial pageload takes way too long. Is this a known byproduct of phrasing, or could I be doing something better?

CSS:
*= require phrasing

JS:
//= require jquery
//= require jquery_ujs
//= require jquery
//= require jquery.turbolinks
//= require phrasing
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

View:

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <%= render 'phrasing/initializer' %>

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Disable links when editing as Admin

It might be a good idea to disable links when in editing mode.

$(function() {
  $(document).on('click', 'a', function(e){
    if ($(this).find('.phrasable_on').length) {
      if(e.preventDefault()){
        e.preventDefault();
      } else if(window.event) {
          window.event.returnValue = false;
      } else {
        return false;          
      }        
    }
  })
})

Conflict with jquery2

jquery-rails offers two jquery versions: 1.11 and 2.x.
To use jquery v2 we need to put this on application.js:
//= require jquery2

The problem is that phrasing is loading just jquery, so when use that with jquery2 it is crashing javascript.

Content not getting updated.

am using Rails 4 and Ruby 2

I have installed the gem and done the following steps,

Step1: rake phrasing:install

Step2: rake db:migrate

Step3:
module PhrasingHelper

def can_edit_phrases?
current_user.has_role :admin?
end

end
Step4: Included the phrasing html initializer at the top of body

<% render 'phrasing/initializer' %>

Step5: Included javascript and css also.

Step5: Then i have included below line in my view file

<%= phrase('my-first-phrase') %>

Now, i was able to edit the text but it is not getting saved. When i refresh the page the edited text is not there (only old text is there).
Error am facing in javascript console is:

GET http://localhost:3000/ 404 (Not Found) jquery.js?body=1:8707
send jquery.js?body=1:8707
jQuery.extend.ajax jquery.js?body=1:8137
savePhraseViaAjax phrasing.js?body=1:89
(anonymous function) phrasing.js?body=1:70

What i am missing here. Could you please help me in this.

Chrome flickering and reloading page when moving back and forward

We are using Phrasing on a small app we are developing. It is working well however for some reason whenever we click a link when logged in as admin or move back or forwards, the page flickers for a while before settling.

Any ideas how to solve this?

Thanks!

Phrasing try to load keys, which it should don't care

In my log file one part of load trace looks a bit weird, because at the view file for 'navigation' I don't use phrasing helper, just 't' helper for I18n, for example:
= link_to t('navigation.home'), root_path
= link_to t('navigation.boards'), adverts_path
= link_to t('navigation.about_us'), about_us_path

and in log file I see:

PhrasingPhrase Load (0.3ms) SELECT "phrasing_phrases".* FROM "phrasing_phrases" WHERE "phrasing_phrases"."locale" = $1 AND "phrasing_phrases"."key" = $2 ORDER BY "phrasing_phrases"."id" ASC LIMIT 1 [["locale", "uk"], ["key", "navigation.home"]] PhrasingPhrase Load (0.2ms) SELECT "phrasing_phrases".* FROM "phrasing_phrases" WHERE "phrasing_phrases"."locale" = $1 AND "phrasing_phrases"."key" = $2 ORDER BY "phrasing_phrases"."id" ASC LIMIT 1 [["locale", "uk"], ["key", "navigation.boards"]] PhrasingPhrase Load (0.3ms) SELECT "phrasing_phrases".* FROM "phrasing_phrases" WHERE "phrasing_phrases"."locale" = $1 AND "phrasing_phrases"."key" = $2 ORDER BY "phrasing_phrases"."id" ASC LIMIT 1 [["locale", "uk"], ["key", "navigation.about_us"]] PhrasingPhrase Load (0.2ms) SELECT "phrasing_phrases".* FROM "phrasing_phrases" WHERE "phrasing_phrases"."locale" = $1 AND "phrasing_phrases"."key" = $2 ORDER BY "phrasing_phrases"."id" ASC LIMIT 1 [["locale", "uk"], ["key", "navigation.career"]]
Should it load translations keys, which I don't using via 'phrase' helper but just with 't' ? it's slowing down page loading

$.cookie is not a function typeerror for phrasing 2.1.3

I get the following error in console:
phrasing.self-8ef2d93….js?body=1:134 Uncaught TypeError: $.cookie is not a function
at phrasing_setup (phrasing.self-8ef2d93….js?body=1:134)
at HTMLDocument. (jquery.turbolinks.self-176b981….js?body=1:30)
at HTMLDocument.dispatch (jquery.self-bd7ddd3….js?body=1:5227)
at HTMLDocument.elemData.handle (jquery.self-bd7ddd3….js?body=1:4879)
at Object.trigger (jquery.self-bd7ddd3….js?body=1:5131)
at HTMLDocument. (jquery.self-bd7ddd3….js?body=1:5861)
at Function.each (jquery.self-bd7ddd3….js?body=1:371)
at jQuery.fn.init.each (jquery.self-bd7ddd3….js?body=1:138)
at jQuery.fn.init.trigger (jquery.self-bd7ddd3….js?body=1:5860)
at HTMLDocument.onLoad (jquery.turbolinks.self-176b981….js?body=1:35)

application.js
//= require jquery
//= require jquery.turbolinks
//= require phrasing
//= require jquery_ujs
//= require jquery-ui
//= require turbolinks

StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  % rake db:migrate
  rake aborted!
  StandardError: An error has occurred, this and all later migrations canceled:

  Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

    class CreatePhrasingPhrases < ActiveRecord::Migration[4.2]
  db/migrate/20180327015847_create_phrasing_phrases.rb:1:in `<top (required)>'

  Caused by:
  StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

    class CreatePhrasingPhrases < ActiveRecord::Migration[4.2]
  db/migrate/20180327015847_create_phrasing_phrases.rb:1:in `<top (required)>'
  Tasks: TOP => db:migrate

Phrasing on link

Completly disable the possibility to click on the link if phrasing can be done in it.

Now you can open a tooltip but with a lot of hard effort.

Changes on js can be done to fix that

Phrasing floating edit bubble not displaying properly

For some reason Phrasing's CSS and JS isn't being pulled in. The Editing controls box is just being shown as another element of the page.

application.js:

//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require phrasing
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

application.css.scss:

@import "bootstrap-sprockets";
@import "bootstrap";
@import "phrasing";
/*
*= require phrasing
*/

Layout: application.html.erb:

   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
   <%= csrf_meta_tags %>

   <%= render 'phrasing/initializer' %>

View:

 <% if current_user.try(:admin) %>
    <p><%= phrase("you're an admin") %></p>
 <% end %>

problem with activerecord-sqlserver-adapter (4.2.3)

I am using activerecord-sqlserver-adapter (4.2.3) against a legacy database. When I edit an individual phrase(@model, :prop), it works fine for me. But when I click the edit-all button, I get this error:

PhrasingPhrase Load (1.7ms) EXEC sp_executesql N'SELECT [phrasing_phrases].* FROM [phrasing_phrases] WHERE [phrasing_phrases].[locale] = ''en'' AND (value is not null) ORDER BY phrasing_phrases.key'
TinyTds::Error: Incorrect syntax near the keyword 'key'.: EXEC sp_executesql N'SELECT [phrasing_phrases].* FROM [phrasing_phrases] WHERE [phrasing_phrases].[locale]'SELECT [phrasing_phrases].* FROM [phrasing_phrases] WHERE [phrasing_phrases].[locale] = ''en'' AND (value is not null) ORDER BY phrasing_phrases.key' AND (value is not null) ORDER BY phrasing_phrases.key'
Completed 500 Internal Server Error in 3ms

TinyTds::Error - Incorrect syntax near the keyword 'key'.: activerecord-sqlserver-adapter (4.2.3) lib/active_record/connection_adapters/sqlserver/database_statements.rb:336:in `handle_to_names_and_values_dblib'

The SQL is coming out a malformed, this [phrasing_phrases].[locale] = ''en'', should be [phrasing_phrases].[locale] = 'en' . When I look at what rails logs in the terminal window, it looks like ' 'en' ' , 2 single quotes on wither side of the "en" value.

Also, the order by clause , "ORDER BY phrasing_phrases.key", which is causing the current error, also raises an error when run in an Sql Manager query window. Changing the order by clause to "phrasing_phrases.[key]" eliminates the error in the sql manage window.

sync between i18n yml files and db?

Hi,

First of all, thank you very much for this great gem!

I have a little question:
How to force phrasing to "sync"/"update" with the i18n yml file?

For exemple, I modified a yml file but the change didn't appear on the page because the entry in the database wasn't updated.

Thanks!

Strange value for 'locale' in database table (PostgreSQL)

Recently I have discovered some strange inserts in "phrasing_phrases" table. A couple of dozens records with "locale" like this:

bgphrasing/remote_update_phrase?klass=PhrasingPhrase

How do you think we can dig into it?

(Rails 3.2.16, PostgreSQL 9.3, Phrasing 3.1.0 )

Thank you for your time.

[SOLVED] Using Phrasing with Nested Attributes

How would one go about using phrasing with nested attributes?

Where an app has many elements:

32 <% @app.elements.each do |element| %>
33          <tr>
34                 <td>    
35                       <%= phrase(@app.element, :name) %>
36                </td>

This error is generated:

undefined method `element' for #<App:0x007fd5dc2c6000>
app/views/apps/show.html.erb:35:in `block in _app_views_apps_show_html_erb___3008268376876323990_70278249316180'
> app/views/apps/show.html.erb:32:in `_app_views_apps_show_html_erb___3008268376876323990_70278249316180'

Parameters:
{"id"=>"2"}

When replacing line 35 with:

 <%= phrase(@element, :name) %>

I get in return:

 undefined method `id' for nil:NilClass

NameError: uninitialized constant Phrasing::Rails::Application

05:24:30 ~/projects/TESTS/phrasing$ rake phrasing:install
rake aborted!
NameError: uninitialized constant Phrasing::Rails::Application
/home/itsnikolay/projects/TESTS/phrasing/config/application.rb:10:in `<module:Phrasing>'
/home/itsnikolay/projects/TESTS/phrasing/config/application.rb:9:in `<top (required)>'
/home/itsnikolay/projects/TESTS/phrasing/Rakefile:4:in `<top (required)>'

new clear app
rails 4.10
ruby 2.1.1

JS problems on iOS Safari

It seems that phrasing is breaking my JS on load as admin on iOS version 9.3.4 Safari.

The error at hand seems to be:

QuotaExceededError: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota. setItem — phrasing.self-ef6f808779f443cb83ac8cc7280d2d3f6f2a97c9043a08645491254e8f7b6992.js:61 (anonymous function) — phrasing.self-ef6f808779f443cb83ac8cc7280d2d3f6f2a97c9043a08645491254e8f7b6992.js:61 dispatch — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4671 handle — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4339 trigger — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4580 (anonymous function) — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:5290 each — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:385 each — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:137 trigger — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:5289 (anonymous function) — phrasing.self-ef6f808779f443cb83ac8cc7280d2d3f6f2a97c9043a08645491254e8f7b6992.js:24 dispatch — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4671 handle — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4339 trigger — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:4580 (anonymous function) — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:5290 each — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:385 each — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:137 trigger — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:5289 (anonymous function) — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:8482 phrasing_setup — phrasing.self-ef6f808779f443cb83ac8cc7280d2d3f6f2a97c9043a08645491254e8f7b6992.js:147 fire — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:3149 fireWith — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:3261 ready — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:3473 completed — jquery.self-a714331225dda820228db323939889f149aec0127aeb06255646b616ba1ca419.js:3504

on

Phrasing.Bus.on('phrasing:edit-mode:off', function(){ $('.phrasable').removeClass("phrasable-on").attr("contenteditable", "false"); localStorage.setItem(Phrasing.EDIT_MODE_KEY, "false"); });

Add better css to the tooltip.

Add better styling to the tooltip.

Currently you can override the tooltip style accidentally with projects style.
I suggest adding bem methodology and introducing !important overrides

Check the image:
screen shot 2017-07-18 at 11 44 53

Error: Missing partial phrasing/_initializer

method=GET path=/faq format=html controller=FaqController action=faq status=500 error='ActionView::Template::Error: Missing partial phrasing/_initializer with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :arb, :jbuilder]}. Searched in:

  • "/home/ray/IdeaProjects/MinnowBooster/app/views"
  • "/home/ray/.gems/gems/phrasing-2.1.3/app/views"
  • "/home/ray/.gems/bundler/gems/activeadmin-7848a53ffae2/app/views"
  • "/home/ray/.gems/gems/kaminari-core-1.1.1/app/views"
  • "/home/ray/.gems/gems/devise-4.3.0/app/views"
    ' duration=29.52 view=0.00 db=0.79

When I put this in my application.html.erb

<%= render 'phrasing/initializer'%>

Disable Phrasing in Active Admin

Possibly related to #27, is it possible to disable phrasing for parts of the application? Active Admin becomes quite slow when polluted with Phrasing queries.

bug No proper lookup in existing translations

scenario

have a .yml with translations
have views using t('title', scope: 'home') etc
replace I18n.t with phrase method without visting all the pages first (in this case phrase('home.title')

If you visit the page now, phrasing will look up in the database if the key exists. Because I haven't visited the pages before swapping out I18n.t with phrasing, It ofcourse will not find it. Thus it will create a new PhrasingPhrase record with both the key and value set to the key you wish to look up (key and value will be 'home.title').

This could be an issue on your production server, where you probaly will create a translation file beforehand and let the client do the final touchup.

Anyway I fixed the bug, by first looking up the key. If it can't find it, set the value as the key, otherwise use the translation.

Here's the code, when I have time I'll (or maybe someone else could) write a test for it and create a proper pull request

class PhrasingPhrase < ActiveRecord::Base
  def self.create_phrase(key)
    phrasing_phrase = PhrasingPhrase.new
    phrasing_phrase.locale = I18n.locale.to_s
    phrasing_phrase.key = key.to_s

    # Instead of making the value the same as the key, look for the translation first.
    begin
      value = I18n.t key, raise: true
    rescue I18n::MissingTranslationData
      value = key.to_s
    end

    phrasing_phrase.value = value
    phrasing_phrase.save!

    phrasing_phrase
  end
end

Trouble hooking-up Phrasing Gem to Rails app's authentication system

Hi, sorry for the noob question here. Thank you for this awesome gem! I think the problem I'm having is my implementation, not the gem itself.

I've setup the Phrasing Gem in my rails app and aside from the authentication it works properly. But I have to bypass the auth system by logging into my application before adding the following method:

# app/helpers/phrasing_helper.rb

module PhrasingHelper

  def can_edit_phrases?
    current_user.admin?
  end

end

Because if I try load my app and am not already logged in as admin I get this error:

NoMethodError in StaticPagesController#home undefined method `admin?'
for nil:NilClass

Extracted source (around line #8):
def can_edit_phrases? current_user.admin? end

def can_edit_phrases?

It also works normally if I edit the method to say 'true' instead of 'current_user.admin?' but that's obviously not good.

Thanks in advance for any help.

How to call different "can_edit_phrase"?

I am developing a website with different roles where I do not want to call the same authentication all the time.
Admin should always be able to edit, but other roles only on specific pages.
So I need some <%= phrase('text',:role) %> or something :)

Rails Number Helpers Breaking

Rails number helpers began breaking after I installed phrasing in my rails app. In my view I'm doing the following:

number_with_delimiter(activity_report.steps, :delimiter => ',')

This code throws a can't cast Hash to text exception. Once I removed the phrasing gem from my project the helpers began working normally again.

Any help would be much appreciated.

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_phrasing_phrases_on_locale" DETAIL: Key (locale)=(en) already exists.

Hi guys!

Thanks a lot for this gem, I'm really excited to test it.

But, I'm having a problem. After follow the Readme instructions, I'm getting this error:

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_phrasing_phrases_on_locale" DETAIL: Key (locale)=(en) already exists. : INSERT INTO "phrasing_phrases" ("locale", "key", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"

I can't figure out why.

I'll appreciate your help. I'm running Rails 5 and POSTGRESQL

Thanks!

Phrasing and Postgresql : error on editing value in phrasing_phrases form

Here is the production.log :

ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: character varying = integer
LINE 1: ..." WHERE "phrasing_phrase_versions"."phrasing_phrase_id" = 1
^
I have checked the column "phrasing_phrase_id" in my database and it is integer.

It happens on Rails 3.2.16, pg 0.17, Debian Squeeze.

I really like your project and I hope you can help me.

Uncaught ReferenceError: lastSelection is not defined

When i logged in as admin. Editing and all working fine, but i couldn't send any other ajax request from that page. When i send any other ajax request it throws the following error: Uncaught ReferenceError: lastSelection is not defined

This is happening only when i refresh the page. Works fine when i came to the page by clicking the link of this page (no error), i thought this is a turbo link problem so i have also installed turbolink gem as you mentioned in doc, but same error is happening.

Could you please help me in this.

Automatically imports other gems translations?

I am using phrasing in addition to a few other gems with create pages and have translations available. When I visit the path to a page generated by another gem, anything which is translatable in that gem is dumped into the phrases DB.

For example with the rails_admin gem, any time the dashboard is visited all of the labels are added to the phrases DB.

Is there a way around this?
phrasing-unintended-keys

Strange value for 'locale' in database table (PostgreSQL)

Recently I have discovered some strange inserts in "phrasing_phrases" table. A couple of dozens records with "locale" like this:

bgphrasing/remote_update_phrase?klass=PhrasingPhrase

How do you think we can dig into it?

(Rails 3.2.16, PostgreSQL 9.3, Phrasing 3.1.0 )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.