SimpleText
A simple markdown document system to present documents such as Terms & Conditions or a Privacy Policy.
Usage
Generate the migration and run migrations:
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
*= require simple_text/application
Add the documents management routes to a protected part of the routes:
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:
get '/disclaimer', to: 'documents#show', name: 'disclaimer'
And finally, link to your document:
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 work:
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 optional via config