Giter Site home page Giter Site logo

carnival's Introduction

Carnival

By Vizir Logo

Carnival is an easy-to-use and extensible Rails Engine to speed up the development of data management interfaces.

When you use Carnival you'll benefit from a set of features already done. If you need to change anything, you can write your own version of the code, using real Ruby code in Rails standard components without worrying about a specific syntax or DSL.

Features

  • Easy way to CRUD any data;
  • Search data easily. Advanced searches in a minute. You can specify which fields you want to search for;
  • Fancy time filter, based on Toggl design;
  • Nice default layout, ready to use;
  • New and Edit forms are easily configured. If you do not like, you can write your own views.

How it works

It provides a managing infra-structure for your application.

Carnival works with Rails 4.0 onwards.

Getting started

Add the gem to your Gemfile:

gem 'carnival'

Run bundle install.

Then, execute rails generate carnival:install to generate the initializer.

Basic Usage

Carnival started relying only on MVC model. As we developed it, we realized that a Presenter would better describe our models. We used the presenter to avoid fat models to emerge on our design.

Model

It is a commom Active Record model. We only have to include the Carnival Helper:

module Admin
  class Company < ActiveRecord::Base
    include Carnival::ModelHelper
  end
end

Controller

It is also a commom Controller, with some minor differences:

  • Inherits from Carnival::BaseAdminController
  • Uses the default admin layout: layout 'carnival/admin'
  • When creating or editing data, you should configure the permitted params.
module Admin
  class CompaniesController < Carnival::BaseAdminController
    layout 'carnival/admin'

    # ...

    private

    def permitted_params
      params.permit(admin_company: [:name])
    end
  end
end

Presenter

All the "magic" of Carnival happens at Presenter. Each model managed under Carnival Admin will have a presenter associated to it. The presenter describes how the model's attributes will be presented.

module Admin
  class CompanyPresenter < Carnival::BaseAdminPresenter
    field :id,
          actions: [:index, :show], sortable: false,
          advanced_search: { operator: :equal }
    field :name,
          actions: [:index, :new, :edit, :show],
          advanced_search: { operator: :like }
    field :created_at, actions: [:index, :show]

    action :show
    action :edit
    action :destroy
    action :new
  end
end

See more about the Presenter at Presenter Properties.

Menu

The menu of the carnival can be configured in the 'config\initializers\carnival_initializers.rb' file.

Eg.:

config.menu = {
  city: {
    label: 'city',
    class: '',
    link: 'admin_cities_path', # You can use the route name as String to define the link
    subs: [
      {
        label: 'custom_city',
        class: '',
        link: 'admin/custom/cities', # You can also use the full path
      },
      {
        label: 'google',
        class: '',
        link: 'http://www.google.com'
      }
    ]
  },

  # ...
}

Customizing Carnival

Custom Views

Carnival permits that you specify some partials for your page, you just need just add your partial in the app/views/carnival/extra_header.html.haml.

Possible Partials:

  • extra_header

    • Extra html to render in page header.
  • app_logo

    • Define a specific partial for your app logo.
    • Default Value: link_to <App Name>, root_path
  • extra_footer

    • Extra html to render in page footer.

Configurations

Custom AdminUser

If you want to have your own AdminUser class or need to add methods to that class, you need to do the following steps:

  • Configure the ar_admin_user_class in the carnival/_initializers.rb file.
  config.devise_class_name = 'MyAdminClass'
  • Your class need to inherit from Carnival::AdminUser.

Custom Root Action

  config.root_action = 'my_controller#my_action'

Application Name

  config.app_name = 'Application Name'

I18n

You can add custom translations for the actions [:new, :show, :edit, :destroy]

  company:
    new: Create New company
    show: Show company

Integrations

It can be easily integrated with gems that you are already used to use.

Authentication

Rich Text Editor

File upload

Detailed features list

  • Index List

    • Ordering by any column
    • Scope
    • Advanced Search
    • Custom Links
    • Remote Actions
    • Custom Actions
    • Batch Operations
    • Custom Css Cel
    • Delete
    • CSV Export
  • Edit form

    • Create new
    • Update existent
    • Nested Form
    • Associate an existent
    • Create new
    • Update
    • Delete
    • ImagePreview
    • Relation select (Autocomplete)
    • Grid config (field order and size)
    • Select Enum
  • Show

    • Grid config (field order and size)
    • Relation links
    • Custom partial view
    • Show as list
  • Menu

    • Customize Order, route, text, label and class

Additional Docs

You can find more detailed docs in the links below:

carnival's People

Contributors

antonioams avatar apantaliao avatar cartolari avatar chagasaway avatar darthaud avatar diegonakamashi avatar dsakuma avatar karenvizir avatar kenjinino avatar lucascaton avatar paulofelisbino avatar thiagonp avatar tiagogoncalves89 avatar viziradmin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.