Git Product home page Git Product logo

adminos's Introduction

Adminos Logo

Adminos

Installation

Install initial adminos-structured files with

$ rails g adminos:install

To add locales to installation:

$ rails g adminos:install --locales=en,cn

Russian language is added and made the default one by default.

Model generation

Generate adminos model with

$ rails g adminos Model field:string body:text --type=sortable

Name, slug, published, meta_description and meta_title fields are always added.

Available model types are: default(if no type is present), section, sortable and table.

For section type, in you model must defined MAX_DEPTH constant (3 by default).

Add sorting to field:

$ rails g adminos Model field:string:sort --type=table

Type table is required for sorting to function properly. Sorting by name is added by default.

Add search form:

$ rails g adminos Model body:text --search=name,body

Specify the fields to search in. It is performed using pg_search gem and directed towards quick word-based search solution, but can be customized further.

If the model will be in multiple locales, you can specify which fields to translate:

$ rails g adminos Model field:string:locale body:text:locale

To translate default fields in case no locale specific custom fields are present, add --locale option:

$ rails g adminos Model --locale

If no need in SEO fields, switch it off using --no-seo.

$ rails g adminos Model --no-seo

Features

Search

By default, search is enabled only on user models.

To add a search, run the following generator.

rails generate adminos:search ModelName

You can use search engines such as ElasticSearch or PgSearch. By default, PgSearch is used if you did not specify the --search = elastic flag when installing adminos.

Cropped

model

  class User < ApplicationRecord
    include Adminos::Cropped
    
    has_one_attached :avatar
    has_one_attached :photo

    cropped :avatar, version: :default, coord_attribute: :avatar_coord 
    cropped :avatar, version: :mobile, coord_attribute: :avatar_mobile_coord

    # default versions name is :default
    # default coord_attribute attribute name is has_one_attached attribute + '_coord'
    cropped :photo
  end

view

  # admin
  # aspect_ratio default 16/9
  = f.input :avatar, as: :cropp, input_html: { coord_attribute: :avatar_coord, version: :default, aspect_ratio: 16/9 }
  = f.input :avatar, as: :cropp, input_html: { coord_attribute: :avatar_mobile_coord, version: :mobile, aspect_ratio: 2/3 }
  = f.input :photo, as: :cropp

  # public
  = image_tag object.avatar_cropped
  = image_tag object.photo_cropped

Deploy the application

Prepare config files.

$ cap staging deploy:check
$ cap staging deploy

Tests

$ rspec

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.