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

Approach: "optional embedded points" for user-dev's customization #6

Open
gcsis opened this issue Aug 9, 2012 · 5 comments
Open

Approach: "optional embedded points" for user-dev's customization #6

gcsis opened this issue Aug 9, 2012 · 5 comments

Comments

@gcsis
Copy link

gcsis commented Aug 9, 2012

Hello Athos, let me bother you with this idea :-)

I think you could use "optional embedded points" for user-dev customization.

With that, you get to keep the static code for hybrid deployds and allow customization in simple way, because the execution of a target html-generate-* not overwrite this customization done by the developer.
You as plug-in developer, can continue with the important staff while only add embed-points where you and the community will be requiring.

Here is a choice of implementation:

js generated must also have this function:

function embed(embedName, args, defaultValue) {
   var rv = defaultValue;
   try {
      rv = eval (embedName + "(args, defaultValue);")
   } catch (e) {}
   return rv;
}

at points where you want to allow customization, add code like in this example:
*See single line of code added in the existing generated (where it is called "embed (.....)") *

function getAuthors() {
    $.ajax({
        cache : false,
        type : "GET",
        async : false,
        dataType : "jsonp",
        url : serverUrl + '/author/list',
        success : function(data) {
            if (data) {
                var options = new Object();
                $.each(data, function(val, text) {
                   var key = this.id;
                   var value = this.id;
                   options[key] = embed('author_select_option_value',this,value);
                });
                var manyToOneSelectForAuthor = $('select[data-gorm-relation="many-to-one"][name="author"]');
                _refreshSelectDropDown(manyToOneSelectForAuthor, options)
            }
        },
        error : function(xhr) {
            alert(xhr.responseText);
        }
    });
}  

Then, the generated HMTL should include a js called eg. "book-embeds.js" or perhaps better, as jsonp content loaded from the controller! (thinking about a possible special mechanism/method to facilitate and expand things).

in this book-embeds.js example could look like this:

   var author_select_option_value = function(author) { return author.name; };

Author now will select for your name!
Furthermore, if this point-embedded were not defined for dev-user, no problem, it take the default value (author.id).

The number of points and places could be many and very useful. Each one will have its own "name" that identifies and helps the developer. Surely each point will require some additional documentation for the dev-user.

I'm interested in your views.

Finally, congratulate you for this GREAT plug-in with a great future!

regards
Jorge Colombo

@gcsis
Copy link
Author

gcsis commented Aug 10, 2012

In case you are interested in this idea there is also an improvement that could be done on it, that involves exposing the all points embeddable availables and pretty tips into xxxx-embeds.js or analog loading mechanism from controllers, and in each execution of the generate-xxxx will be updated (without overwriting), like this:

/* for each item to return select option value (args represents each obtained Author) */
var author_select_option_value ;  // (args, defaultValue){ }

(also, this allows avoids "eval()" to improve performance)
Jorge

@corinnekrych
Copy link
Member

Hello Jorge

Indeed the idea is interested, would you mean some hook like Field Plugin provided By Robert Fletcher?

I'll dig that in more details. I think it's could really improved scaffolding.
Cheers
Athos alias Corinne

@gcsis
Copy link
Author

gcsis commented Aug 14, 2012

Regarding the mechanism of hook I gave you is just a tiny little thing.

I do not mean something like the plugin fields. We know this topic well covered by JQM (HTML5 input types: password, email, phone, number, etc). Although the idea in some ways it seems.

I come from develop in a language that generates code entirely free of errors using templates where each one is specialized in each "type of standard process". You have for example: List-Browse, Data-Form, Report, Single-Window, and more. This language is Clarion. Its mechanism is similar to grails scaffolding. It has a template scripting language itself in "design time" allows the developer to embed your own code in a lot of points. There are other pre-assembled code blocks (like mini-templates) called "extensions" that are part of an extensive library de "commonly used features" (conceptually similar to jquery UI plugins).

How this works:
The developer chooses for example, template List-Browse, gives his name, said the primary file, open a WYSIWYG windows, choose the properties for columns list, hit other "extension controls" if needed, and then ordered to "generate" (and compile).
The important thing here is that, if something did not like it, it reopens the process designer, makes the necessary changes and generate it again (many times as desired). Always at design time.

Clarion's Secret:
As Grails, Clarion has scaffolding, but also has a file (app file) for each project where the parameterization and customization is stored for each "template process" with "extensions" + "embed code" added by developer. This file is not overwritten at each generation, it is another part of the input data generation and specializes the end result. This "extensions + scaffold" is equivalent to "Grails + plugins".

I understand that from my point of view (from where I come) you've planted a seed in the soil of grails that is very interesting (no more GSP, json, JQM compliance, hibrid & generate for each specific mobile, w/its PhoneGap "extension", oriented to standard process, etc.).

Maybe you see it as a paradigm shift in code generation, and perhaps difficult to make it and too pretentious, but the potential means that in the future, the community could create extensions of hundreds of features (in the form of grails plugins) like to PhoneGap, range / date rollers & many UI controls, auto-complete input, existing JQ / JQM plugins, infinity scroller, etc.etc.).

I took a fork from github and I'm watching something more in depth your code.
I'll try to experiment Clarion'mechanism in grails. When I achieve it (minimally) I upload it.

Sorry for my english (I speak spanish) :-)
Jorge

@corinnekrych
Copy link
Member

Hi Jorge,

Indeed it seems you're taking scaffolding a step further. Not 'a la Grails' but I would be interested to see what you're proposing. Is it http://www.softvelocity.com/ ?

For the scaffolding I'm working with proposal from users, I think we're going to try to stick more to Grails scaffolding. TO DO for scaffolding will be in this order:

  1. Make it work in dynamic mode during all design phase (where the domain class are changing fast), allowing user to change customize templates, then generating views in order to package them with PhoneGap factory. We've just pushed plugin in github yesterday.
  2. A mechanism like Fields http://freeside.co/grails-fields/guide/customizingFieldRendering.html but for HTML templates
    could be interesting, it gives extension point for UI widget
  3. More advanced mechanism like you describe where you have special marker for extension point, but for this last one waiting for your feedback ;-)

Best Regards,
Corinne
Athos for 3musket33rs

@gcsis
Copy link
Author

gcsis commented Aug 17, 2012

Yes, it's Softvelocity (before Topspeed). I was of. Clarion tech support for Latin America in '96-99 (and I used it since its creation ~87). Now I'm Grails fun! :-)

Today I saw in detail Field plugin, their approach would give a granular customization of the guidelines provided in JQM http://jquerymobile.com/demos/1.1.1/docs/forms/forms-all-mini.html and also facilitate make other "templates-chains", example for Twitter Boostrap http://twitter.github.com/bootstrap/base-css.html, but I'm content with JQM !

in p.3 : I'm working on it and within days I'll prepare a technical detail for you. I'm seeing how to do it but with the least possible interference in your scaffolding.

regards
Jorge Colombo
Buenos Aires, Argentina

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

2 participants