paulmassen / really-simple-admin

Really Simple Admin is a Sinatra solution for a simple backend.

Home Page:https://really-simple-admin.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Really Simple Admin

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

Prerequisites

Installation

  1. Fork
  2. Clone:
$ cd /my-projects-folder
$ git clone https://github.com/[insert-username]/really-simple-admin my-app
$ cd my-app
  1. Install dependencies:
$ bundle install
  1. Set MongoDB URL environment variable:
$ set MONGOLAB_URI='mongodb://127.0.0.1/my-app'
  1. Run:
$ bundle exec ruby app.rb

Configuration

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.

schema.yml

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.

form.yml

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".

seed.yml

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

Deployment

Deploy

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.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Really Simple Admin is a Sinatra solution for a simple backend.

https://really-simple-admin.herokuapp.com/

License:MIT License


Languages

Language:JavaScript 98.2%Language:CSS 1.3%Language:HTML 0.3%Language:Ruby 0.3%