Tenon

License

This project uses the MIT-LICENSE. Do whatever you want with it as long as you don’t violate the licenses of the various open source pieces on which it depends.

Installation

In your Gemfile

gem 'tenon'

and then bundle install.

in config/application.rb:

require 'active_record/railtie'

in config/routes.rb:

mount Tenon::Engine => '/tenon'

Run command:

$ rake tenon:install:migrations
$ rake db:migrate

You will need to have a database set up at this point. Currently Tenon requires that you use postgres.

Running rake db:migrate probably threw up a devise error. Create config/initializers/devise.rb and paste:

Devise.setup do |config|
  ## paste the secret key line from the error output ##
end

Run that command again:

$ rake db:migrate

Install the Tenon helpers in app/controllers/application_controller.rb:

helper Tenon::Engine.helpers

Install the necessary files to run and customize Tenon (this is now required):

$ rails generate tenon:install

To run seed data (such as creating an admin user) from Tenon, open console and run:

ENV['PASSWORD'] = 'password' # or something at least 8 chars long
Tenon::Engine.load_seed

Restart your app and navigate to /tenon

If you want to be able to use rspec, which would be good, you will also need to run:

bundle exec rails generate rspec:install

Scaffolding

TODO: Write this section

Item Revisions/History

TODO: Write this section

Internationalization

Although Tenon is currently anglocentric it supports the inclusion of additional languages and provides an interface for managing content in multiple languages.

To add internationalized fields, follow these steps:

  1. Tell Tenon which languages you want to support in config/initializers/tenon.rb (You don’t need to add English, Tenon always assumes its in use.)

    config.languages = {
      "French" => :fr,
      "German" => :de
      # etc.
    }
    
  2. Create or update config/i18n_fields.yml to tell Tenon which fields you would like to have internationalized.

    tables:
      cars:
        - title
        - description
    
      events:
        - title
        - location
        - description
    
  3. Generate and run the internationalization migration. The generator will only try to create columns that don’t already exist, so you can use this generator multiple times throughout the development of your application.

    rails generate tenon:i18n_migrations
    rake db:migrate
    
  4. Ensure that you have passed the i18n: true flag anywhere you are using tenon_content on a model.

    class MyModel < ActiveRecord::Base
      tenon_content :description, i18n: true
    end
    

Once you’ve done this and restarted your app you will see a language selection nav in the sidebar of each form that has internationalized fields.

If you want to add internationalization to the default Tenon models you should make your i18n_fields.yml look like this:

tables:
  tenon/events:
    - title
    - location

  tenon/pages:
    - title
    - seo_title
    - seo_keywords
    - seo_description

  tenon/posts:
    - title
    - excerpt
    - seo_title
    - seo_keywords
    - seo_description