Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hooks for 3rd-party extensions #271

Closed
sferik opened this issue Feb 3, 2011 · 13 comments
Closed

Add hooks for 3rd-party extensions #271

sferik opened this issue Feb 3, 2011 · 13 comments
Assignees
Milestone

Comments

@sferik
Copy link
Collaborator

sferik commented Feb 3, 2011

Everyone has a slightly different idea of what RailsAdmin should do. As a result, people have been submitting patches to extend RailsAdmin functionality. So far, the majority of these patches have been merged.

In general, I'm overjoyed with the number of people who want to contribute to this project. I don't want to discourage contributions in any way. At the same time, merging in every patch will eventually turn RailsAdmin in bloatware.

I believe the best solution to balance these interests is to create APIs that will allow developers to easily extend RailsAdmin. It may even be possible to do this with Railties.

Here are some goals:

  1. Distribution. Extensions will be packaged as gems and installed via a Gemfile.
  2. Migrations. Extensions will be able to register database migrations, which can be installed via a rake task.
  3. Testability. It should be easy for extension developers to write tests that check their code against the latest version of RailsAdmin.
  4. Compatibility. As a general rule, extensions should be compatible with each other. Running one extensions should not prevent you from running another extension, even if they offer some overlapping functionality.
  5. Discoverability. Users of RailsAdmin should have a place where they can easily find and compare extensions.

I'm interested in getting feedback from those of you who have been submitting patches. Does this sound good? How could it be better?

@ccabot
Copy link
Collaborator

ccabot commented Feb 3, 2011

Issue #169 talks about this, too.

@ccabot
Copy link
Collaborator

ccabot commented Feb 3, 2011

It helps me to consider some use cases when I'm thinking about something as abstract as this. Do you have any in mind? I'm thinking along the lines of features where RA needs to provide a useful default but people might reasonably want to override that with one of several different options. A few I can think of offhand are authn, authz, history/auditing, ORM support, templates/skins/css. Are these the sort of things that you're thinking of?

@sferik
Copy link
Collaborator Author

sferik commented Feb 4, 2011

Yes, your examples are all good candidates for 3rd-party extensions. Another example I would give is the CKEditor patch.

When this issue is resolve, the next step should be to take some of the existing code that has been merged into master and factor it into 3rd-party extensions to serve as examples of how to build extensions.

@sferik
Copy link
Collaborator Author

sferik commented Mar 29, 2011

I've created an extensions label for issues which I think are good candidates for extensions instead of core features.

@sferik
Copy link
Collaborator Author

sferik commented Mar 29, 2011

I'm copying over @slawosz comments #169 so I can close that issue. Going forward, this will be the canonical issue for our extensions API.

To make Rails Admin real killer feature we should provide extensions and modularity, like Spree, Radiant, Redmine in very elegant way. I think we can start disscusion now, and anyone is welcome to give an example about cases, where Rails Admin can not help. It is very important, becouse in real life our apps often has a bit complicated requirements.

If it is possible please link sample apps, where Rails Admin does not help.

I have already noticed one corner case: state mashine. Yesterday I was talking with someone about Rails Admin and he pointed me, that when model has defined some states, RA should generate select box instead of text box. I don't think it should be included directly in RA, rather we should build powerfull api to accomplish that feature.

A proof of concept:
slawosz/rails_admin@master...override_form_for_attribute

@gunn
Copy link
Collaborator

gunn commented Mar 29, 2011

An official gem prefix would be a good idea. We'd name our gems like rails_admin-carrierwave or ra-carrierwave. I prefer the latter however there are two unrelated gems with this prefix already.

To find gems we would just run gem list -r rails_admin-.

@sferik
Copy link
Collaborator Author

sferik commented Mar 29, 2011

@gunn: I agree. I like the rails_admin- prefix. It's a little verbose, but it avoids any ambiguity.

@tpitale
Copy link

tpitale commented Jun 16, 2011

Another case, from another issue, seems to be uploaders (Paperclip/CarrierWave et al).

@benhutton
Copy link

Any ETA on this?

Some extensions I've been thinking about:

  • Globalize3
  • publishing/save as draft
  • full versioning and reverting to older versions
  • some sort of slick markdown previewing editor like github uses

@ghost ghost assigned kaapa Aug 20, 2011
@schof
Copy link

schof commented Sep 13, 2011

I'd be open to supporting an effort to standardize extensions across frameworks. We've already made pretty good progress in Spree. In particular, I think the concept of a Versionfile is worth considering (for more info see the spree extension guide.)

@bbenezech
Copy link
Collaborator

What's the added value over classic Gemfile versioning? Spree extensions aren't classic gems?

@schof
Copy link

schof commented Sep 14, 2011

The advantage is that you peg certain "versions" of an extension to specific versions of the framework. For instance the same 1.0 version of an extension might work with Spree 0.60.x, 0.70.x, and edge (but not say version 0.30.x) We also wanted a way to convey edge versions of extensions (stuff on the master branch) and indicate likely compatibility with edge versions of Spree.

(and yes, spree extensions are classic gems.)

@bbenezech
Copy link
Collaborator

Added the field extensions generator, the action generator (with custom actions), and a theme generator.
It needs more doc to have a real API, work is on the way (feel free to join). But everything in this ticket is getting pretty well covered, except maybe gem versioning, but that can be the topic of a new, cleaner ticket.

meghaarora42 added a commit to meghaarora42/rails_admin that referenced this issue Sep 28, 2015
The exisiting structure used an Object as a cache where the keys are the
values of option elements, and values are the HTML content of the option
elements. In Javascript, if a numeric value in the form of a string is
assigned as a key, it gets converted to an integer. Optimization
routines would then order the object to ensure faster access to
elements. For example:

cache = {}
cache['2'] = "two"
cache['1'] = "one"
console.log(cache[2])  #=> "two"
console.log(cache[1])  #=> "one"
console.log(cache)     #=> {1: "one", 2: "two"}

Note the coercion of strings to ints above. This messes with the
ordering of multiselect options list whenever there is a user input. To
avoid this from happening, the keys need to have a string that can't be
coerced automatically, and then preserve the value of the option
element.

I chose to use an object that stores the option value and the option
HTML as the value of the cache and a string of the format 'o_<option
value>' as the key. This ensures that the insertion order is preserved.
This is the new structure:

cache = {
  'o_271': { id: 271, value: 'CartItem railsadminteam#271'},
  'o_270': { id: 270, value: 'CartItem railsadminteam#270}'
}
meghaarora42 added a commit to meghaarora42/rails_admin that referenced this issue Sep 28, 2015
The existing structure used an Object as a cache where the keys are the
values of option elements, and values are the HTML content of the option
elements. In Javascript, if a numeric value in the form of a string is
assigned as a key, it gets converted to an integer. Optimization
routines would then order the object to ensure faster access to
elements. For example:

cache = {}
cache['2'] = "two"
cache['1'] = "one"
console.log(cache[2])  #=> "two"
console.log(cache[1])  #=> "one"
console.log(cache)     #=> {1: "one", 2: "two"}

Note the coercion of strings to ints above. This messes with the
ordering of multiselect options list whenever there is a user input. To
avoid this from happening, the keys need to have a string that can't be
coerced automatically, and then preserve the value of the option
element.

I chose to use an object that stores the option value and the option
HTML as the value of the cache and a string of the format 'o_<option
value>' as the key. This ensures that the insertion order is preserved.
This is the new structure:

cache = {
  'o_271': { id: 271, value: 'CartItem railsadminteam#271'},
  'o_270': { id: 270, value: 'CartItem railsadminteam#270}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants