Sha256: 94c5a9f2c6de4e8713d4216be290e10b058ef7d2f703983d09c71d3f2a695c69

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

# SimpleText
A simple markdown document system to present documents such as Terms & Conditions or a Privacy Policy.
## Usage
Generate the migration and run migrations:
```Ruby
rake simple_text:migrations:install
rake db:migrate
```
Which will generate a migration for the `documents` table.

Optionally, add the SimpleText css to your `application.css`
```Scss
*= require simple_text/application
```

Add the documents management routes to a protected part of the routes:
```Ruby
resources :documents, only: [:edit, :update, :index, :new, :create]
```

In a document, `name` is the key for the document, `title` is shown to users above the document.

If you've created a document, add the public route to your routes:
```Ruby
get '/disclaimer', to: 'documents#show', name: 'disclaimer'
```

And finally, link to your document:
```Ruby
link_to 'Disclaimer', disclaimer_path
```

## Customizing the view
If you want different styling for your document, just overwrite the `documents/show` view in your application.
The contents of the document can be rendered by calling `to_html` on the document object.

## Overriding the default controller
For certain functionality, overriding the `DocumentsController` is required, e.g. to make [Pundit](https://github.com/elabs/pundit) work:
```Ruby
class DocumentsController < SimpleText::DocumentsController
  after_action :verify_authorized, :except => :index
  after_action :verify_policy_scoped, :only => :index
  after_action :make_authorized, except: :index
  after_action :make_scoped, only: :index

  def make_authorized
    authorize @document
  end

  def make_scoped
    policy_scope @documents
  end
end
```

## Some TODO's
- Make the model name changable.
- Write tests.
- Make integration of [Whodunnit](https://github.com/fletcher91/whodunnit) optional via config

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_text-0.0.23 README.md
simple_text-0.0.22 README.md
simple_text-0.0.21 README.md
simple_text-0.0.20 README.md