6 Replies Latest reply on Jun 24, 2013 1:35 AM by Bart Fukkink

    Create custom routings like *.erb.bb

    Bart Fukkink

      Hello,

       

      I did a quick search trough the documentation but I can't find any information on this. Is it posible to create custom routings like the way the specific blackberry pages are implemented?

      If this is possible, is this also possible to supply the information of wich files to target during runtime?

       

      This would be really usefull in the situation we are going to have in the near future.

       

      Our current application is created for Tablets now. We currently target some Android tablets and some iPads. Customers asked questions if this could also be run on smartphones. So in an ideal world, we do not want to change our controllers and model, but just create a new view which is completely targgeted for smartphones only. Could we add some kind of mechanism that targets *.erb.sp files when we are on a smartphone, and *.erb files when we are on a tablet?

       

      Kind regards,

       

      Bart Fukkink

        • Re: Create custom routings like *.erb.bb
          Robert Galvin

          Hi Bart

           

          Currently we support 4 different per platform files (works on more than just .erb files)

           

          http://docs.rhomobile.com/rhodes/application#per-platform-files

           

            index.android.erb

            index.iphone.erb (which is really iOS not just iPhone)

            index.wm.erb

            index.bb.erb

          1 of 1 people found this helpful
            • Re: Create custom routings like *.erb.bb
              Bart Fukkink

              Hello Robert,

               

              I have seen those indeed, but is it also possible to create custom ones for these? Or is this fixed within the Rhodes part of the application? Would we for example be able to create index.ipad.erb and make a our own platform file definition?

                • Re: Create custom routings like *.erb.bb
                  Robert Galvin

                  Not that I know of, would probably require modifying the Rhodes source. I am not sure where the code is that handles that. Have you looked into another approach using CSS Media queries?

                  1 of 1 people found this helpful
                    • Re: Create custom routings like *.erb.bb
                      Bart Fukkink

                      We have, but since the screen size is so much more limited, we are looking for alternatives that are easier to maintain when we keep on updating our application. Our current media query's that work to target the portrait and landscape mode work great, but if we also add smartphone portrait and smartphone landscape to this, we would have a terrible job of maintaining this.

                       

                      Thank you for the information tho! We`ll be on the lookout for a diffrent system then.

                        • Re: Create custom routings like *.erb.bb
                          Kutir Mobility

                          Your initial approach may not be as hard as it initially seems, right now the process of choosing which platform files to use (.andoid.erb, .wm.erb, etc) is done at build time. Depending on the platform you are compiling your application for, the build process chooses one file and discards the rest.

                           

                          Inside the rhodes Rakefile (within the gem), look for common_bundle_start (around line 1307), then scroll down until you find an assignment to replace_platform, it will look like this:

                           

                            replace_platform = $config['platform']
                            replace_platform = "bb6"if$bb6
                          

                           

                          a few lines below you will see that this replace_platform variable is what decides which files to use:

                           

                                Dir.glob("**/*.#{replace_platform}.*").each do |file|
                                  oldfile = file.gsub(Regexp.new(Regexp.escape('.') + replace_platform + Regexp.escape('.')),'.')
                                  rm oldfile if File.exists? oldfile
                                  mv file,oldfile
                               end
                          

                           

                          if you change replace_platform you can create any number of new "platforms" you need. If you do so, make sure to also update the code found later that cleans up unnecessary files from the build. One disadvantage is that this trick does not seem to work for RhoSimulator, it is possible that the simulator has the platform routing hardcoded.

                           

                          Another alternative would be to use something like SASS or LESS to parameterize your css and compile different variations at build time

                           

                          Thanks,

                          Javier

                          Kutir Mobility