Reference JavaScript file in other project - aptana

In an Aptana Studio 3 web project, is it possible to use JS libraries located in a different project?
I'm trying to create a JavaScript library and put it under source control, then create an example project that uses APIs in my library. As far as I can tell, there doesn't seem to be a way to do this. It appears to me that all of my HTML/CSS/JS files need to be located in the same project.
Am I missing something obvious?
EDIT
To clarify: if I have everything in 1 project, my folder structure looks like this
- Project\
- index.html
- JS/
- myAwesomeLibrary.js
- script.js
And I would reference my JS files like this
<script src="JS/myAwesomeLibrary.js"></script>
<script src="JS/script.js"></script>
What I want to do is move myAwesomeLibrary into its own Aptana project:
- Library\
- JS\
-myAwesomeLibrary.js
- Project\
- index.html
- JS\
- script.js
How do I make this work in HTML?

It depends on where your Library project is located relative to your Project project. If they are both in the same parent folder, the src for your js could be as simple as
<script src="../Library/JS/myAwesomeLibrary.js"></script>
Meaning, go up one folder past where my current file is and then look for a folder called 'Library'. You can also use an absolute path using the address the internal browser uses - though you will have to change this for the final server. The absolute path would look something like:
<script src="http://127.0.0.1:8020/Library/JS/myAwesomeLibrary.js"></script>
Keep in mind, this may work in Aptana's internal browser, but your paths may change once you get the final server if the Library, for instance, is located in a different virtual host than the Project.

For future reference: there is a way to make Aptana synchronize files between two projects by setting up a new connection with the source set to project 'Library' and destination project 'Project'.
I might actually use this method instead as it allows greater control over which project gets library updates and when, while also removing the need to set different script tags on the development server.

Related

Basics of importing scripts in angular2 using nodejs and npm with ASp.net Core 1

Hi i just finished installing asp.net core1 so got introduced to npm , bower and nodejs after researching a lot i chose to go with angular2 .
now my problem is that i have never used gulp, grunt etc even though i know how it works and why to use it. there are lots of instructions on web to setup angular2 project with mvc6 but not explaining the thing which is new with mvc6.
anyways i dont want to get myself confused with gulp/grunt etc right now so i am just copying files from node_modules to my script folder and giving it path but it works almost for everything related to angular.
for eg.
import {anything} from 'angular2/core' or from RXjs etc(this import is from node_modules) and i have to give a path in my index files where i have copied all the files.
but when i try to include some plugins like ng2-select, ng2-bootstrap or toastr etc it doesnt work the way it should it throws errors.
my question is do i need to copy whole folder from node_modules to my script folder and then linq it or what , how it works?
Do I need to copy whole folder from node_modules to my script folder and then link it or what, how does this work?
I have an example in my blog post of what you should be doing in this situation. Ideally, you will use a gulpfile.js to orchestrate your desired file needs. For example, if you're looking for Angular2 it is rather simple. You create a gulpfile.js by adding a new item to your project. In that file you write some simple "tasks" that automate this move for you. You look in node_modules and move over anything that you need. For Angular2 I move over the following .js files (in this example):
var angularJs = [
'./node_modules/angular2/bundles/angular2.js',
'./node_modules/angular2/bundles/router.js',
'./node_modules/angular2/bundles/angular2-polyfills.js',
'./node_modules/angular2/bundles/http.js'
];
So to answer your question more directly, no. You do not need to copy the entire folder -- just the files that your application needs.

how to add third party angular directives to meteor application

I'm using angular-meteor library to develop a meteor application with angular as a front-end.
I need to add an angular directive called angular-file-upload.
When I use this directive in my node/angular app, it is installed via bower, and has this folder structure:
angular-file-upload folder contains
angular-file-upload.js
as well as a sub-folder named src,
which contains 3 files:
intro.js, module.js and outro.js
What is the process of installing such third party angular directives?
Is this done with meteor add command, or by placing these files manually into specific directories?
Check out this link, if those are the actual packages which serve your purpose then you can directly add them to you Meteor app by using meteor add <package-name> command in the terminal.
While the alternate way to do this is by adding these .js files manually to public or lib folder and link them to your corresponding HTML pages. But I would personally prefer the 1st way to do this.
You can create the library by yourself. There are few alternatives to do that.
Basically it goes down to these steps:
add package.js in root directory
meteor publish --create
The complete details how to do that can be found here: http://angular-meteor.com/tutorial/step_19

ASP.NET 5 MVC6 Custom CSS & Javascript placing convention

So I'm playing around with MVC6, and I've added bower.json & grunt.json, I've created my grunt tasks for generating my jQuery & bootstrap.css and its all sitting in the wwwroot folder as i expected.
But what about things like my site.css & my main.js files, the files that I will add to for the project over time.
What convention are people using when choosing a directory for this stuff?
Are we to add a Content folder and drop it in?
Is there something I'm missing, that i should also be using Grunt / bower for?
I do have app and vendor folders outside wwwroot.
In vendor, I customize libraries like bootstrap, themes.
In app I have my own css, less and js files for the application.
I also have an asset path inside app for anything that needs to be copied (folder font shown in the screenshot)
Then I use the opinionated really easy to use and way better than grunt or gulp tool: brunch.
With this simple config, I get sourcemaps, concat, jshint, and with --production also uglify, minify, csso.
Adding anything else to the pipeline is simple as installing a brunch-plugin, so I recommend to also check http://brunch.io/ out.
Any static files (.css, .js) should be added directly into the wwwroot path (e.g. wwwroot/scripts, wwwroot/css). Anything that will be compiled into static files (.ts, .less) should be put into an Assets directory (or whatever name you like) in your project and output into the wwwroot path during compilation (generally configured through grunt compilation tasks).

Where does javafx.scene.image.Image("flower.png") look for flower.png?

I would like to know what the JavaFX Image constructor's relative path resolution algorithm is for:
Stand-alone apps.
Browser deployed apps.
Webstart deployed apps.
If the algorithm may look in multiple locations, I'd like to know what they are for each of the above deployment scenarios.
If the behaviour for stand-alone apps is different when the app is placed in a jar, I'd like to know that too.
Then user provides relative path to new Image(String url) it will be relative against workdir of the app aka System.getProperty("user.dir")
For stand-alone app it's a folder you started an application from
For web-start app being run from command line (javaws myfxapp.jnlp) it works the same way as with standalone app
For plugin start or webstart app loaded from browser you can't reliably be sure about workdir location. It depends on browser and even on installed plugins for that browser.
So general direction is: for standalone apps use url same way as you'll use it in new File(String url). For jnlp/plugin use full url with protocol or Class.getResource() approach.
Update: Please, note, this behavior is going to be clarified and changed in 2.2. See http://javafx-jira.kenai.com/browse/RT-18291
The following comment is from RT-18291 and outlines the intended changes for 2.2:
Martin Sladecek added a comment - May, 15 2012 10:53 AM
After discussion with Richard Bair, we decided to change the current (undocumented) behavior for paths. Currently, they are treated as user.dir relative. All path, with or without leading slash will be now resolved as relative to classpath, which will be consistent with CSS and more corresponds to what might users expect.
For user.dir relative paths, "file:" URL can be still used.
The answer is "/" if case you are using getClass().getResourceAsStream(), i.e. the root of your jar file (inside it). Not user.dir nor where the package is hosted
search directory where class files( name of class getClass().getName().toString() ) related to your .java file are present, copy and paste your image there
Image image=new Image(getClass().getResourceAsStream("yourImageName.jpg")); is must.
In NetBeans the directory where classes are present NetBeansProjects/JavaFXProjectName/build/classes/packageName/

How to specify linked resource folder in mxmlc compiler arguments?

I've got external folder with resources (graphics, movies, etc) which is shared between a couple of projects. I'm able to link this resource folder in FlashBuilder (as described in http://livedocs.adobe.com/flex/3/html/help.html?content=projects_5.html#155069). After that all the pathes to embeds are relative to the project, and that's the behaviour I want.
This linked resource appears in .project file as follows:
<linkedResources>
<link>
<name>resources</name>
<type>2</type>
<locationURI>DOCUMENTS/Shared/resources</locationURI>
</link>
</linkedResources>
Note, that it isn't source folder and it is not included in compilerSourcePath tag.
The question is how can I specify resource linked folder in mxmlc command line arguments?
-source-path is not working here, relative pathes to embeds can not be resolved.
Seems like it's not possible and there's no such option. FlashBuilder somehow passes all the workaround to mxmlc java wrapper, therefore it knows where to search resources.
In my project I used another method to achieve proper sharing of resources:
Autobuild step, which copies images and extractes fla files to resource folder in each project form the source directory.
All css files I moved to shared source folder (e.g. Common/css/main.css) - they are under source control. I added link to it via -source-path option.
After that all relative pathes in css started to look like ../../resources/image.png in both projects.
Maybe someone will find my experience helpful.

Resources