faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
_whitelogger has joined #amber
<FromGitter> <damianham> sure go ahead
<FromGitter> <eliasjpr> I was wondering how did you managed modularizing amber
<FromGitter> <eliasjpr> ?
<FromGitter> <damianham> it is simple - all you have to do is load the modules in the application startup file
<FromGitter> <damianham> see how it works in the modular recipe
<FromGitter> <damianham> to modularise a standard amber app you also need to include 'amber_render_module' shard
<FromGitter> <eliasjpr> I managed to create a directory under src with controllers models and views and require those and run the module as part of the same app
<FromGitter> <eliasjpr> I was able to do it all manually using the built in render
<FromGitter> <eliasjpr> Later on I’ll put it on a repo so you can give me you thoughts
<FromGitter> <damianham> that's interesting - how did you do that ? I found I had to create a new render macro so the views could be found
<FromGitter> <damianham> OK
<FromGitter> <eliasjpr> The current render macro takes a path
<FromGitter> <eliasjpr> I’ll have to publish
<FromGitter> <eliasjpr> In a few hours I’ll send you the link to the repo
<FromGitter> <damianham> ah yes but that means you have to modify all the controllers - admittedly not too problematic but I wanted it to work without changing the controller
<FromGitter> <eliasjpr> I tried to create a macro to inject the modules like rails does it using a ‘mount’ macro but I found that hard since it is compile
<FromGitter> <eliasjpr> Well I wrapped the controller in a module
<FromGitter> <eliasjpr> We can build a generator to easy the dev workflow
<FromGitter> <eliasjpr> What I think it would be great is to be able to create modules as shard lib than can be dropped in to a current amber project
<FromGitter> <damianham> YES!! that is exactly my thinking and that is why I submitted a PR to allow modular route definition
<FromGitter> <damianham> the amber_render_module macro uses the path of the controller to find the views so it can be anywhere within the project
<FromGitter> <damianham> if we amend my PR to also search for route files in lib then that would allow us to drop in modules as shards
feepbot has quit [Ping timeout: 272 seconds]
feepbot has joined #amber
<FromGitter> <eliasjpr> I don’t think it has to search for routes
<FromGitter> <eliasjpr> I’ll have to show you
vivus has joined #amber
vivus has quit [Remote host closed the connection]
<FromGitter> <drujensen> That would be great to drop in a shard and mount it in the routes.
<FromGitter> <drujensen> Even better if I can keep the MVC pattern in the shard. ;-)
<FromGitter> <eliasjpr> yes
<FromGitter> <damianham> No
<FromGitter> <eliasjpr> thats definitely possible
<FromGitter> <eliasjpr> lol
<FromGitter> <eliasjpr> okay
<FromGitter> <damianham> MVC pattern is broken
<FromGitter> <drujensen> No it’s not
<FromGitter> <damianham> :)
<FromGitter> <damianham> OK - I will accept it is OK for small projects
<FromGitter> <damianham> not suitable for larger projects
<FromGitter> <eliasjpr> okay let's not cry over spilled guineas
<FromGitter> <eliasjpr> https://youtu.be/7-Id3k6OE_k
<FromGitter> <drujensen> it all depends on the project imo
<FromGitter> <eliasjpr> They compliment eachother
<FromGitter> <damianham> if you guys could see the issues I have at the moment with a Rails MVC project with files for 1 feature spread all over the place you would quickly begin to realise modules make more sense
<FromGitter> <eliasjpr> Modules + MVC = 💓
<FromGitter> <eliasjpr> @damianham I could say we have the same issue at work
<FromGitter> <damianham> app/controllers, app/models, app/views, app/assets/javascripts, app/assets/javascripts/backbone/views etc. etc. files in many many places for a singel feature
<FromGitter> <eliasjpr> @drujensen I have a suprised for the Amber afficionados in regards to params
<FromGitter> <eliasjpr> PR is comming for 👇 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b97d69ea04db554a70dc8f0]
<FromGitter> <drujensen> wow. awesome!
<FromGitter> <drujensen> @damianham ctrl+p and alt file plugin for vim ;-)
<FromGitter> <drujensen> I prefer seeing all the controllers together myself but this is just bike shedding IMO
<FromGitter> <damianham> I don't use vim
<FromGitter> <eliasjpr> Tabs or Spaces?
<FromGitter> <drujensen> lol
<FromGitter> <damianham> Dru try building a project wit modules and you will soon see it makes more sense
<FromGitter> <damianham> spaces always
<FromGitter> <drujensen> been there done that
<FromGitter> <eliasjpr> 😅 you got me worried for a minute there
<FromGitter> <eliasjpr> :P
<FromGitter> <drujensen> thats how all apps used to be built before mvc
<FromGitter> <drujensen> you just stick the sql right in the view
<FromGitter> <drujensen> remember? lol
<FromGitter> <damianham> no I don't do that
<FromGitter> <eliasjpr> @damianham ☝️
<FromGitter> <eliasjpr> Look for modular app
<FromGitter> <eliasjpr> Main app routes file ☝️
<FromGitter> <drujensen> that is sortof modular but not what @damianham is envistioning
<FromGitter> <damianham> nah... you were thinking about rails engines
<FromGitter> <eliasjpr> is modular enough no?
<FromGitter> <drujensen> nope
<FromGitter> <drujensen> he wants features together
<FromGitter> <damianham> not the way to go - Dru is right - it is not the way I was envisioning
<FromGitter> <eliasjpr> features can be together
<FromGitter> <drujensen> models, views, controllers in the same directory
<FromGitter> <damianham> duplication of layouts for s start
<FromGitter> <drujensen> like react modules
<FromGitter> <damianham> like MEAN.js modules but a bit less verbose
<FromGitter> <eliasjpr> Modular `app.cr`
<FromGitter> <drujensen> MEAN is js which doesn’t support inheritance
<FromGitter> <drujensen> its not an OO language
<FromGitter> <damianham> I am only referring to the code organisation
<FromGitter> <drujensen> right
<FromGitter> <drujensen> my point is in an OO language its more common to share a base class
<FromGitter> <drujensen> that avoids duplicate code
<FromGitter> <eliasjpr> you cannot get more modular than that. I mean the boundries are clear for the example above
<FromGitter> <drujensen> the layout kinda follows
<FromGitter> <eliasjpr> the modular app can be mounted on a main app or be used in isolation
<FromGitter> <damianham> here is something from a conversation I had with Paul Smith - it is a directory listing of one of the features in my Amber app ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b97d92f45318b2dfe9342b4]
<FromGitter> <eliasjpr> You can do that as well
<FromGitter> <eliasjpr> ignore the MVC structure
<FromGitter> <drujensen> i think the render looks in the views directory
<FromGitter> <eliasjpr> but you can accomplish the same with the example above I just choose to split it
<FromGitter> <damianham> so in that folder for the Alarm feature I have alarm.cr (model), *alarm*lib.cr (business logic) and everything else should be self explanatory
<FromGitter> <eliasjpr> Modular APP controller ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b97d9b0cddb292dff5a0b5a]
<FromGitter> <damianham> in other modules I also have e.g. src/modules/ais/js/ais.js and all the other javascript code that belongs to the ais module
<FromGitter> <eliasjpr> @damianham agree, the fact that someone chooses to have sub directory or not is not relevant that a preference
<FromGitter> <drujensen> I agree as well
<FromGitter> <damianham> yes Elias you can do that - but with my amber_render_module shard you can skip the path parameter
<FromGitter> <drujensen> we should see if we can support it
<FromGitter> <eliasjpr> but what I was trying to demonstrate is that you can accomplish both
<FromGitter> <damianham> yes I agree you is isn't hard to get what you want from Amber - it was super easy for me to create a modular app
<FromGitter> <drujensen> can we set some sort of amber setting that allows you to provide the prefix path to the render method?
<FromGitter> <damianham> no that won't work Dru
<FromGitter> <drujensen> so if you want mvc, it would be `../views`
<FromGitter> <eliasjpr> > yes Elias you can do that - but with my amber_render_module shard you can skip the path parameter ⏎ ⏎ Yes. I do prefer not adding another layer if the render method already supports it
<FromGitter> <drujensen> in the modular it would be `.`
<FromGitter> <drujensen> why?
<FromGitter> <damianham> yes OK if you supply a path to every render call - I meant without the path argument
<FromGitter> <damianham> so controllers as they are
<FromGitter> <drujensen> this wouldn’t work? `Amber::View.prefix = "."` vs `Amber::View.prefix = "../views"`
<FromGitter> <drujensen> or instead of project based, what if you just set this in the controller once?
<FromGitter> <damianham> I don't think that will work for controllers in src/controllers with views in src/views
<FromGitter> <drujensen> in the base controller for the whole project?
<FromGitter> <damianham> you still have them in a modular app - e.g home page, signin/signup etc.
<FromGitter> <drujensen> if you set this per controller, then you can
<FromGitter> <damianham> src/views/layouts is still the location of the app layout
<FromGitter> <damianham> as it applies to all modules
<FromGitter> <drujensen> right, but i’m not following why it wouldn’t work
<FromGitter> <drujensen> i guess i will try it out when i get a chance
<FromGitter> <drujensen> see if we can do something to avoid the hard coded path
<FromGitter> <damianham> yeah that would be great
<FromGitter> <drujensen> that way we can keep those modular guys happy. ;-)
<FromGitter> <damianham> :) LOL
<FromGitter> <drujensen> and the old rails guys will still feel at home
<FromGitter> <drujensen> lol
<FromGitter> <damianham> hey if we can add a shard to the shards.yml file and then get a whole new set of routes for our app that will be the most awesome thing
<FromGitter> <drujensen> yes, totally agree here
<FromGitter> <drujensen> mount point a shard
<FromGitter> <eliasjpr> You can do that with the example above
<FromGitter> <drujensen> great!
<FromGitter> <eliasjpr> routes can be modular ⏎ ⏎ ```# example main routes.cr ⏎ module ExampleMainApp ⏎ include Alarm ⏎ end``` [https://gitter.im/amberframework/amber?at=5b97dd4045318b2dfe93604b]
<FromGitter> <eliasjpr> just need to install the shard and load it in `application.cr`
feepbot has quit [Ping timeout: 246 seconds]
feepbot has joined #amber
wontruefree has joined #amber
wontruefree has quit [Quit: this is not the client you are looking for]
wontruefree has joined #amber
wontruefree has quit [Quit: bye]
wontruefree has joined #amber