Code Monkey home page Code Monkey logo

copycat's Introduction

Copycat

Copycat is a Rails engine that allows users to edit live website copy.

How to use

Add copycat to your Gemfile and run bundle install.

Copycat uses a database table to store the copy items, and so it is necessary to create that:

rake copycat:install
rake db:migrate

Since Copycat data is stored locally on an indexed table with no foreign keys, page loads are very fast and changes appear instantly.

In a view, use the Rails i18n translate method where you would like to display some editable copy:

<h1><%= t('site.index.header') %></h1>

Visit the page in your browser, and a Copycat translation will be created for the key. Then visit /copycat_translations in your browser, log in with the username and password generated in config/initializers/copycat.rb, and you can edit the value of that token.

Rails i18n API

You can read about the Rails internationalization framework here.

Deploying

To transfer changes from staging to production:

  • Download copy as YAML on staging
  • Login to Copycat on production
  • Upload YAML to production

Since this process requires no code commits, non-developers can also 'deploy' copy changes.

You can also commit Copycat's YAML export, which is compatible with i18n, to your git repository.

Routes

The default route to edit copy is '/copycat_translations'. This can be customized in the initializer.

The Copycat routes are configured automatically by the engine, after your Rails application's routes.rb file is run. This means that if your routes include a catchall route at the bottom, the Copycat route will be masked. In this case you can manually draw the Copycat routes prior to the catchall route with the following line in config/routes.rb:

Rails.application.routes.draw do
  Copycat.routes(self)
end

Logging

Because Copycat does a SQL query for each token, it can produce a lot of noise in the log output. Therefore by default the logger is disabled for the Copycat ActiveRecord class. It can be enabled with the environment variable COPYCAT_DEBUG, e.g.

COPYCAT_DEBUG=1 rails s

Example

See an example application here.

Developing

As a Rails engine, Copycat is developed using a nested dummy Rails app. After cloning the repository and running bundler, the plugin must be installed in the dummy app:

bundle
cd spec/dummy
rake copycat:install
rake db:create db:migrate db:test:prepare
cd ../..

Now you can run the test suite:

rspec spec/

License

Copycat is released under the MIT license. See MIT-LICENSE file.

copycat's People

Contributors

steve9001 avatar asross avatar kanedaki avatar

Watchers

 avatar James Cloos avatar

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.