Really Simple Admin is a starting block for apps that only need a backend for one admin to change some settings, but don't really need anything complicated. It uses the sinatra webframework, mongodb as a datastore and JSONForm for easy form creation.
The backend is protected using HTTP Basic authentication with a single username and password. To edit settings, the admin is presented a form that is defined with yaml config files. This form updates a single mongodb document, to be used in the application for any means.
To see it in action, trying logging into the demo: Demo
- Fork
- Clone:
$ cd /my-projects-folder
$ git clone https://github.com/[insert-username]/really-simple-admin my-app
$ cd my-app
- Install dependencies:
$ bundle install
- Set MongoDB URL environment variable:
$ set MONGOLAB_URI='mongodb://127.0.0.1/my-app'
- Run:
$ bundle exec ruby app.rb
There are three configuration files that can be found in the /config
folder. These files are translated into JSON and used with JSONForm to define the form in the admin panel. Refer to JSONForm wiki for documentation and JSONForm Playground for examples.
This file describes the expected shape and types for the data. As with JSONForm, it uses the JSON-Schema format to describe the data, with the exception that the outermost node is assumed to be an object.
name:
title: Name
description: Nickname allowed
type: string
gender:
title: Gender
type: string
enum:
- Female
- Male
- Alien
This would define a schema as having a name
, that can be any string, and a gender
which can take on the values Female
, Male
or Alien
.
This file lists the order and presentation of the fields in the admin form and used as the form argument for JSONForm.
- key: name
fieldHtmlClass: input-xxlarge
- gender
- type: submit
title: Update
This defines a form that will first have a wide name
input, then a gender
select box and then a submit
button labeled "Update".
This file is used to set the initial values for the data. It should fullfil the schema as defined in schema.yml
.
name: George Takei
gender: Male
Really Simple Admin is a sinatra app, so instructions for deploying sinatra on your chosen platform should work.
As with development environment, it requires the environment variable MONGOLAB_URI
to be set to the url of the mongodb database.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request