How to start using a downloaded plugin? - ruby-on-rails-4

I recently downloaded two plugins, https://github.com/harvesthq/chosen and https://github.com/fredwu/jquery-endless-scroll. I extracted the files. Now what? I'm guessing for a start I have to move the files somewhere. I'm just trying to figure out how to 'install' them into my app. There are tutorials for how to use the plugins after they're installed, but none on the actual installation.
I have a rails 4.0.10 app, if that matters.

The Rails way of doing it would be to put any 3rd party lib under vendor/assets. JS files in the javascripts directory and CSS files in the stylesheets. The you need to require the files in either the application.js or application.css files. Doing this will ensure that the files get compiled and minified within the Asset Pipeline of your application.
EDIT #1:
Information about organizing application assets http://guides.rubyonrails.org/asset_pipeline.html#asset-organization
EDIT #2:
I highly recommend using the Rails Assets framework when using 3rd party libs. Makes managing assets much easier.

Related

Can I download A-frame library offline and host on my server?

As A-frame is a opensource framework, is it possible to download the A-Frame libraries offline and setup in own server?
Yes, the JS files can be downloaded: https://github.com/aframevr/aframe/tree/master/dist
The instructions there explain which to file use; you probably only need one of those files. The copies of the library hosted on a CDN are just there as a convenience, downloading the file is perfectly fine.

Should I use a fontawesome cdn or include the css file in my react project?

I was going to add fontawesome to a project I am working with (using Microsoft's MVC spa services and VS2017) but a coworker told me to include it in the build. Is this supposed to be better? if so, how do I do that? Just copy the css file somewhere and webpack will take care of it?
I would be using the CDN version as it is always upto date and the load in minimal. No point using server space really is there?

Include only part of ember addon in ember app

Currently I'm working on a project which uses Ember and requirejs. My plan is to migrate the project to ember-cli, but I'm facing some problems.
My app consists of multiple apps and one shared folder in which I put shared code of all other apps (like models, adapters, serializers, helpers, routes etc.). Not all of this code is used by every app, they only require what they need.
My plan is to create multiple ember apps of the apps mentioned above and move the shared code to an ember addon. Now I am wondering if it is possible to only include a part of this ember addon into the applications (only what they need). I did not find any relevant information in the docs for this use case.
Any ideas would be appreciated.
I ended up using the addon folder within my addon to share most of the files. This files can be imported from all apps and when building only the imported files are included into the final build file.

ember-cli project within Django application

Up till now I was using ember by including all required vendor files in Django static folders. With the rise of ember-cli more and more ember related files are not available in stand-alone version. They require using npm and/or ember-cli.
Ember-cli uses npm, and it creates and manages its own files, create all project files and manages loading them... so now how can I integrate than withing a Django application. Like:
I want to hook up an ember application on a given page in Django. ember-cli doesn't seems to cover such scenarios?
all vendor files (JS and other) must be served by Django / found by staticfiles finders. npm won't install to Django project staticfiles directory.
and it would be good to be able to collect files/make apps withing separate subfolders so that older apps won't break when newer app pulls newer vendor files etc.
So is that somewhat doable with ember-cli and Django? What is the best way to handle such projects?
You are going to need to set up a build and deployment process in order to deploy the assets built by Ember so that they can be served by your Django application.
I want to hook up an ember application on a given page in Django.
ember-cli doesn't seems to cover such scenarios?
You can most definitely have an Ember application live within a Django page. Set up your appplication outlet within the page served by Django.
all vendor files (JS and other) must be served by Django / found by
staticfiles finders. npm won't install to Django project staticfiles
directory.
Set up a process that copies the dependencies downloaded by npm to the static files
directory as part of your deployment.
and it would be good to be able to collect files/make apps withing
separate subfolders so that older apps won't break when newer app
pulls newer vendor files etc.
It would seem an equaly bad idea to have multiple copies of the same dependency floating around -- especially if a single user will navigate to multiple ember applications hosted on various pages of your Django app which rely on the same libraries. You will have to make a choice of whether to try to maintain the depencies for each of your Ember applications individually or to ugrade depencies across each of them at the same time. This will depend on your needs and how tightly coupled the functionality in each of your apps is.

Is everytime need to precompile the asset when we change the css or js file?

I have a basic question in asset.
1. Is everytime need to precompile the asset when we change the css or js file.
2. When pre-compiling old css and js files servered or not?
i have checked the local when pre-compiling no css loaded.
3.Is it necessary to precompile the asset in development mode to work in local.
I have some problems understanding your english, but maybe I understand what you are asking for.
It works like this:
When you are working in development mode on your local machine and edit stylesheets or javascripts, Rails and the Asset-Pipeline take care of reloading the relevant files. No Precompilation will happen.
When you deploy to a server in production, the rake assets:precompile task will create all the asset-files for you, so that you can serve them via a webserver like apache or something and rails does not need to handle it.
I think that with Rails4 the pre-compilation-process is much quicker, because it does not compile files that did not change, but I am not 100% sure about that.