Assets and namespaces (tests are pased) #2

Open
wants to merge 28 commits into
from

2 participants

@kuraga

No description provided.

@kristianmandrup

Really sweet :)

@kuraga kuraga fix 3
Apotomo uses Ruby 1.8 syntax!
ea0b868
@kuraga

Don't you think that Namespace.js shouldn't be in Apotomo? I can crate a gem for it...

@kristianmandrup

I'm not sure if Namespace.js is the best option? I just needed something that would provide namespaces for pure javascript in an easy fashion. Perhaps we should just stick with coffeescript for now, and not support non-coffeescript (since coffee is default in Rails anyways!).

@kristianmandrup

About call_fun, I think you should provide a block wrapper construct like I suggested previously.

call_fun :toggle_active, 'TopBar', {item: 'item:first'}`

# enter widget TopBar scope
js_widget :top_bar do |w|
  w.call_fun :toggle_active,  {item: 'item:first'}
  w.call_fun :toggle_active,  {item: 'item:last'}
end

# for deeper namespace, use String
js_widget 'My::TopBar' do |w|
  w.call_fun :toggle_active,  {item: 'item:first'}
  w.call_fun :toggle_active,  {item: 'item:last'}
end

# or "." syntax
js_widget 'My.TopBar' do |w|
  ...

Nice ;)

@kuraga

About Namespace.js: I don't know about library choice because I didn't work with JavaScript namespaces... But library is not maintained, yes?

But the main thought that library should be in a separated gem... And what's the reason to make _library_in CoffeeScript? No, I think libraries (if they are still not in a separated gem) should be in a 'precompiled form', or in original form.

@kuraga

About technologies: I think we should with Nick about them. And I have a thought about fixing technologies stack... I.e. Ruby 1.9.3 and Rails 3.2+ only... I don't know. But we may clean code base, couple/decouple some features... And break compatibility making a new major version... If Nick will want. And 'not support non-coffeescript' for example. I think we may to think complexity: it's time to upgrade Apotomo! ;-)

But I think we should fix technologies used for docs examples. I.e. make all examples in haml and coffeescript (erb and javascript).

@kuraga

About wrapper: I agree but I don't have time for this now. I can do something later but I want to make existance patches stable. Because I'll understand what and how should I do for a new functionality.

@kristianmandrup

Instead of Namespace.js I thingit is better to just use Require.js which does the same thing but is much more advanced ;)

http://requirejs.org/docs/api.html#define

http://www.youtube.com/watch?v=VGlDR1QiV3A

https://github.com/jwhitley/requirejs-rails

Nice!

kuraga added some commits Mar 19, 2013
@kuraga kuraga fix 4
We didn't refactor tree structure yet!
06dfb70
@kuraga kuraga fix 5
We didn't rename `display` to show yet!
2afdd39
@kuraga kuraga fix 6 ad4f407
@kuraga kuraga fix 7
Restore JqueryHelper
4d02781
@kuraga kuraga small typo 75ea0a2
@kuraga

Oh, I didn't understand that there is two variants here: and namespace.coffee isn't a coffeescript version of Namespace.js!. And Namespace.js is similar to Require.js (they do load modules async) but namespace.coffee is a nano-lib to (just) make modules. By the other side does we require a load functionality such as Require.js?

Okay, we need only four magic locs to create namespace name with values...

# *Export the specified value(s) to the specified package name.*
window.namespace = ( name, values ) ->
  # Export to `exports` for node.js or `window` for the browser.
  target = window
  # Nested packages may be specified using dot-notation, and are automatically created as needed.
  target = target[ subpackage ] ||= {} for subpackage in name.split( '.' )
  # Export each value in the specified values Object to the specified package name by the value's key.
  target[ key ] = value for key, value of values
@kristianmandrup

Like I said, I think it is much better to use RequireJS for modules in case it is pure javascript. But please focus on the Coffeescript functionality, and leave it to others as an exercise if they want to use pure js.

But maybe your simple Namespace JS "hack" is enough for our needs?

Focus on the ideas I sent you for the stateful widgets and dynamic widget tree ;) Much more important IMO.

Cheers!!

@kuraga

My hack is a copy of namespace.coffee (not Namespace.js which is much bigger, 500+ locs). But it can be rewritten in JavaScript. There are fifteen locs but not five :) https://github.com/CodeCatalyst/namespace.coffee/blob/master/build/namespace.js. Yes, they're enough - these five lines.

@kuraga

Tests are passed but I don't know if every thing is tested.

@kuraga

And I don't like names of options: --js and --style. I want to make it Rails-style.

P.S. And I don't understand why Apotomo isn't connected with haml-rails etc and make these options defaults right...

@kristianmandrup

Yeah, make haml-rails or even slim the default ;) PS: I also like the new "curly templates" ;)

@kuraga

The next thing that I'll do: #2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment