Code Monkey home page Code Monkey logo

activeadmin-settings's Introduction

activeadmin-settings

DEPRECATED

This gem is not supported and developed anymore.

--

Easy to use general purpose settings backend for activeadmin.

ActiveadminSettings Demo

Installation

Add to Gemfile:

gem "activeadmin-settings"

Run installer:

$ rails g activeadmin_settings:install

Add i18n configuration to config/application.rb file:

config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :ru]

ActiveRecord

gem "aws-s3"
gem "fog"
gem "mini_magick"
gem "carrierwave"

gem "bson_ext"
gem "devise"
gem "activeadmin-settings"

Run migrations:

$ rake activeadmin_settings:install:migrations
$ rake db:migrate

Mongoid 2.x

If you're using mongoid 2.x the gem expects to see activeadmin-mongoid and carrierwave-mongoid (for image uploading feature) in Gemfile. Here is a working example:

gem "aws-s3"
gem "fog"
gem "mini_magick"
gem "carrierwave-mongoid"

gem "bson_ext"
gem "mongoid"
gem "mongoid-globalize"
gem "devise"
gem "activeadmin-mongoid"
gem "activeadmin-settings"

Mongoid 3.x

Here is an example of Gemfile with a support of 3.x version:

# Mongoid 3.x
gem 'moped',    git: 'git://github.com/mongoid/moped.git'
gem 'mongoid',  '~> 3.0.5'

# Assets
gem 'aws-s3'
gem 'fog'
gem 'mini_magick'
gem 'carrierwave-mongoid',  git:      'git://github.com/jnicklas/carrierwave-mongoid.git',
                            branch:   'mongoid-3.0',
                            require:  'carrierwave/mongoid'

# Activeadmin
gem 'devise',               '>= 2.1.2'
gem 'activeadmin-mongoid',  git: 'git://github.com/elia/activeadmin-mongoid.git'
gem "mongoid-globalize"
gem 'activeadmin-settings'

Configuration

After installation you should find a new Settings menu in the admin. If no configuration found in config/activeadmin_settings.yml only Admins tab is shown. Admin tab implements basic functionality of editing AdminUser objects.

To add some settings go to config/activeadmin_settings.yml. Settings are splitted into groups, each setting name concidered to be uniq, e.g.:

SEO:
  Website Keywords:
    description:    These keywords are included in homepage header meta tag
    default_value:  lorem ipsum simply dummy text printing

  Website Description:
    type:           text
    description:    Website description is used as value for header meta tag on homepage
    default_value:  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

All of the settings may be cplitted to groupes by adding optional param group, e.g.:

Site Wide:
  Title:
    type:           text
    description:    Website Title
    group:          Slider
  Image1:
    type:           file
    group:          Slider
  Copyright:
    type:           text
    description:    eg. (c) 2015
    group:          Footer
  FooterLogo:
    type:           file
    group:          Footer

As result we'll see:

ActiveadminSettings Group Example

There are a few types of settings:

  • string (default) - a regular text input
  • link - text input with a format: (TITLE) URL
  • text - textarea input
  • html - textarea with redactor.js
  • file - input for file upload

Some examples:

Types Examples:
  Logo Image:
    type:           file
    description:    Please make sure logo image size is 287x140 pixels
    default_value:  home/home-logo.jpg

  CEO Message:
    type:           html
    description:    This text is used for the "CEO Message" page
    default_value:  >
                      <p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry.</p>
                      <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>

  Facebook Link:
    type:           link
    description:    Company facebook page link
    default_value:  (Facebook) https://www.facebook.com/

Localization Example:
  Welcome title:
    type:           string
    description:    Localized welcome title
    default_value: 
      en: English default title
      ru: Russian default title
      de: German default title

Settings could be integrated into templates as well as models or controllers code using settings_value helper. For example:

  • <%= settings_value("CEO Message") %> - provides html
  • <%= settings_value("CEO Message", :de) %> - provides localized html for German language
  • <%= image_tag setting_value("Logo Image") %> - provides an image url: <img src="/production-assets-path/home/home-logo.jpg" />
  • <%= settings_value("Facebook Link") %> - provides link: <a href="https://www.facebook.com/" title="Facebook">Facebook</a>

If setting value is null or an empty string default setting value is used which is defined in config/activeadmin_settings.yml. If locale is not specified, default is used.

FUTURE FEATURES

I'm going to add types:

  • Boolean - checkbox or dropdown with two values
  • Dropdown - dropdown with options
  • List - list bases selection

GLHF

activeadmin-settings's People

Contributors

adastreamer avatar adis-io avatar alexkravets avatar antonzaytsev avatar asecondwill avatar ashalaev avatar caifara avatar crmaxx avatar cyrill62 avatar howells avatar jazzjackrabbit avatar maximgladkov avatar momelnyk avatar rlupiichuk avatar tomcsi avatar valdemarua avatar wild5r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activeadmin-settings's Issues

Settings page is defined in the gem, how to change it then?

The settings admin page used to be copied over. Now it is loaded from inside the gem. Hence one cannot alter the page (like hiding it from the menu for certain users). Is there another way to overrule the gem or should the page be copied again by a generator?

Delete current user

I don't really know why i did this, but if i delete the current admin, i get logged out. logging in as the last remaining admin (id = 1) gets me

Couldn't find AdminUser with id=2

Group values with same prefix

Take a look at Machinima admin. I've been using names like this: "Home - Stat #1 - Title". The user can see a bit modified name: "Stat #1 โ†’ Title".

  1. We can make such behavior by default or at least make it possible to override the function which is generating the name in admin.
  2. It would be nice if the values with same prefix (in this case "Stat #1") were grouped in one box. Even more the values may have few nestings: "Home - Stats - Stat #1 - Title".

CKEditor

Hi, how can I integrate CKEditor for html field?

Add type image

It would be really handy to have size option. Also there will be possible to add preview.

Defined User Model

Is there a way I can define my own user model instead of AdminUser in an initializer?

Many request to database

Hi, if I have 5 custom block in my app with activeadmin-settings
Page generate 5 request to database((
Can I do one request to get 5 setting field ?

401 unauthorised issue

Hi,

I'm getting the following error when updating a setting ...

Started PUT "/admin/settings/32" for 127.0.0.1 at 2013-07-17 08:31:55 +0100
Processing by ActiveadminSettings::SettingsController#update as /
Parameters: {"utf8"=>"โœ“", "authenticity_token"=>"DXK9R5Pb2uwvlPT+xTk3WytF15w6yLvpF6TSqDtZRFg=", "setting"=>{"string"=>"33333"}, "id"=>"32"}
Completed 401 Unauthorized in 61ms

I'm using the following gem versions ...

  • activeadmin (0.5.1)
  • activeadmin-settings (0.4.4)

I'm not sure if this is related to the issue but I recently changed the model that activeadmin uses for login/authentication.

Any help most appreciated as this gem is now being used in a production environment.

Add type URL

Sometimes it's needed to add url for image or some complex html structure. In this case link anchor does not matter or is too complex.

Problem with mount_activeadmin_settings()

By default rails g activeadmin_settings:install add mount_activeadmin_settings() route at the top of route.rb i.e. before active_admin routes that would already be there.

Although, this doesn't cause major issue it does cause problem with user route overriding /admin/user route. So Users link in top nav doesn't point to list of users but points to list of admin users.

Ideally, rake task should be updated to add route at the end of routes.rb or this issue should be mentioned in Readme.

Accessing settings_value from a model

I'm trying to access settings_value() in an activerecord model but it's not found, is there a way to do this?

Very nice work by the way, the gem is working well in my application.

User as admin instead of AdminUser?

I'm using User with is_admin? for my users, yet it seems AA Settings relies on there being AdminUsers. Is there a way to make this configurable?

ArgumentError: 'ActiveadminSettings/pictures' is not a supported controller name

I'm getting this error just after adding the activeadmin-settings gem, and installing it.
after running bundle install, I run:
rake activeadmin_settings:install
rake activeadmin_settings:install:migrations

when I try to run rake db:migrate, I get the exception:
ArgumentError: 'ActiveadminSettings/pictures' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use

I'm using Rails 4.0.4 with Ruby 2.1.1

Settings that are a length greater than 255 chars truncate in MySQL

Because t.string :string is used in the ActiveAdmin Settings migrations, long strings (or settings of type text) are truncated at 255 in MySQL.

The solution is to revise the migration to be the following:

# This migration comes from activeadmin_settings (originally 20121123145237)
class CreateActiveadminSettingsSettings < ActiveRecord::Migration
  def change
    create_table :activeadmin_settings_settings do |t|
      t.string :name
      t.text :string
      t.string :file

      t.timestamps
    end
  end
end

By using t.text it should allow any length, I believe.

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.