How to optimize calling Trix library in RoR - ruby-on-rails-6

I'm new to webpacker. After include Trix on my RoR project based in documentation , my views are calling it when they are uploaded and seems that Trix is too heavy despite of using javascript_packs_with_chunks_tag and just having application.js in my javascript/pack folder. is there a way to optimize Trix or a better way to manage it. I just need it for a view, and I'd like to be able to call it just for that view if this is the only option.

Related

Best practices approach to multiple views in meteor?

Every tutorial/example i can find for meteor shows a single view application. I would like to build something a little more complex. I'm unclear how to approach multiple views...preferably in a way that's somewhat scalable?
The iron-router package lets you access different views (layouts) by nice, REST-ful human-friendly clean URLs. It supports parameters in the URL, "loading" templates, waiting for subscriptions to finish loading, before and after hooks etc.
At this point you can only create Single Page applications with Meteor. Note that Single Page, doesn't mean you can't have several views - use iron-router for that.
But by design, Meteor serves a big fat unique JavaScript/HTML/CSS application down to the browser, though there's a feature request to allow incremental loading. It is then up to the application (or more precisely, the JavaScript framework), to dynamically render its views in order to display different "pages".
I was wondering the same thing and it took me way too much time getting something started. I finally got a paged app working solidly by using Backbone views and routes, so I created a simple boilerplate project to make setting up an app like this easier in the future.
Live demo here: backbone-boilerplate.meteor.com
Source code here: github.com/justinmc/meteor-backbone-boilerplate
Have you looked at madewith.meteor.com?
A bunch of apps there have multiple views using Backbone also Jonathan Kingston who created britto has started simple meteor framework called Stellar
At this stage of the game not sure if there really are best practices. But these two seem to be the current flow.
You can also make a tabbed interface for multiple views. There is a package project "Smart package for generating a tabbed interface with pushState" github project here: https://github.com/possibilities/meteor-tabs
The best solution right now is using a routing package (router is basic but works). The workflow is something like this:
declare routes; return a template name for each route
place the reactive helper provided by the package in your body tag
the reactive helper will return the template associated to that route
you create a template for each route and optionally set custom publish functions
Router will give you browser history (client side).
Note that at this time there are some limitation on the way Meteor handles html/js. They are load all at the same time. The bright side is that once the app is loaded, page transitions will be instant.

Why do index.php files for CMS's like wordpress & drupal contain little other than an include/require statement?

Several popular CMS's such as Drupal, Wordpress, etc. have an index.php file that is pretty much empty except for a include/require statement that includes some other PHP file (as in one file) containing all of the bootstrap code for the CMS. What is the rationale for this? Why not just move all of the bootstrapping code into index.php if it is doing nothing other than including the bootstrapping code anyway?
I'm trying to build a CMS as an example project to improve my PHP skills, and I'd like to understand what design considerations led them to do it this way. I understand the benefit of breaking up applications into multiple files, but I've never heard of making a file that does nothing but include another one. Obviously there is some benefit, since several major CMS projects designed it this way, but I just can't figure out what it is.
Can someone explain to me the reasoning for this?
In Drupal's case, there are other files that do a similar bootstrap. These typically aren't normal pages, but do serve important purposes. Off the top of my head cron.php, update.php, and install.php do this. I use the bootstrap process at the beginning of custom import scripts, as well as scripts that get called by cron that I don't want to use a hook_cron for.
I can think of two reasons:
When using a product like Wordpress, you sometimes end up adding user hacks to the front controller - say, setting custom constants, specific redirects, or an additional layer of access control, or whatever. An empty index file allows you to add that kind of stuff without disturbing the product's original code.
Having everything in a separate bootstrap creates the possibility of moving all code (including the bootstrap) to a location outside the web root, and include it from there.
Aesthetics mostly. You can have a clean and neat directory structure (outside of webroot), in which bootstrapping files are separated from index.php file. There are probably several of them (vs. one index.php file) and they are doing different things (db init, authorisation).
I also found one or two CMS which start in debug declaration (in order to switch display errors and warnings before including any files, so you can have your errors printed before php includes a file with syntax error, but that's not really a good practice).
I would say this is good design because you can easily change the path to the bootstrap, which makes it very easy to change location of the CMS, if ever necessary.
Another good reason is you could also be running a dev CMS while developing, and roll out new versions with one path change in the index.php.

Template system in CodeIgniter like wordpress?

I'm trying to build a template system in CodeIgniter like wordpress. Does anyone have some links or tips to share with me on this matter?
I would like to create several functions that I can call from those php template pages like in wordpress. For example to display the comments from an item or loop through something, or even a tag_could.
the views folder would containt the different template folders & files.
and yes there is smarty, but no I don't want to use it.
Have a look at my Template library. It supports modules, themes, partials and layouts so you can create one main layout for each theme then have modular views if you wish.
While you are not a fan of Smarty, you might be interested in trying Dwoo. They are both very similar but Dwoo has the advantage of not sucking major donkey balls, which is Smarty's main downfall. I have written an extension for the CodeIgniter Parser library to get it to use Dwoo, which integrates perfectly with my Template library.
Between the two you can make pretty powerful, theme-able MVC applications.
Check out
http://www.williamsconcepts.com/ci/codeigniter/libraries/template/index.html
Template is right for you if:
You feel like using views can be clunky, especially when "embedding" views.
You don't like calling header, footer, and other global views from every Controller method.
You prefer having one "master template" that can be changed for any controller in order to meet unique application design needs.
You don't want to drastically alter the way you interface controllers and views.
You like clear, thorough documentation on par with CodeIgniter's User Guide.

Create WebApplication with Drupal: development steps

I am new to Drupal and I am figuring out a set of steps for developing a Web Application. I planned:
1) Develop the application without any template or graphic effect. Just create your nodes, your views, integrate some plugins and so on. Goal: to have a website up and running from a functional point of view
2) Customize plugins: if some functionality is missing, customize plugins or develop on your own
3) Choose Theme and Customize it
4) Insert graphic effects (ex. JQuery)
5) Fine tuning
I am learning Drupal so I haven't any experience. Am I figuring out correctly ?
There are different approaches. This is how I work:
Define the goal of the site
Define functions
Define menu / pages
Deleveop theme / templates. Either from scratch or themes you downlowd.
Replace dummy text with Drupal code to show content. Here you functions comes in to place.
Remebmer that a node i Druapl, is basicalle your content / your text when you write articles.
When I tried to learn Drupal, I summarized some content here : http://stiengfoto.wordpress.com/category/development/drupal/
If you never have used CMS before, find some tutorials and start with the very most basic things.
Drupal i a great piece of machinery, but it might not be the best choice as a web app framework. It depends what you want to do really, but usually web apps is a lot of custom code / logic. Here Drupal's complexity might become a hindrance for you.
If I was going to build a site or application I would probably do something like this.
Find all the modules that I need. This can involve
Finding the contrib modules that I absolutely need.
Figuring out if I should use a contrib module + alterations or build my own module.
Searching for modules that can solve a problem, looking for solutions to problems that seem common etc.
Do the actual development, and create the features needed.
This include functional jQuery like AJAX.
Theming - this can in some extend be done while developing.
First step is usually to find a good base theme for your design, like Zen.
Then you need to implement the design.
Add jQuery where needed for flashy effects
Test and bugfix.
This should be done while developing, but when all looks good, be sure to give it all some good testing to make sure that it doesn't fail anywhere.

Multiple file uploader - looking at Google Docs implementation

I'm looking to implement a multiple file uploader in my ASP.NET 3.5 site.
Now, the Google Docs multi-file uploader is pretty awesome, and I'd like to create something like that. Correct me if I'm wrong, but Google Docs is not open source, so I can't get my hands on the source code for it.
Any ideas on how this is implemented, or the best way of creating a nice interactive multi-file uploader like it?
I strongly suggest you give this jquery file upload plugin a try: "uploadify". It makes it super easy to integrate such a feature.
Nice and interactive : you can build a Silverlight client to send your files to webserver. It allows to select multiple files at once.
I guess 'Zhaph - Ben Duguid' had the best answer for this one. Post it as an answer and I'll accept it!
GoogleDocs uses a combination of Flash and JS, with the bulk of the work happening in the Flash object, rather than the JS, and they heavily minify their JS to make it smaller to download, and also harder to read...

Resources