First sails didn't create .tmp/public, so i did it manually. But it also doesn't copy stuff from my assets folder to my public folder. Can someone explain why that is?
#
At that time, the answers i got weren't helping,
I've updated to 9.8 now, and i don't seem to have any problem.
#
I had this same issue. When running sails lift the .tmp folder wasn't created. What finally worked for me was installing Grunt locally in the root folder of my sails app. So just run npm install grunt in your sails app folder. Having Grunt installed globally with the -g flag was apparently not enough. After the local installation, you can run sails lift again, and the .tmp folder will be created.
Hope this helps!
Where do I put my css and javascript assets in sails?
Sails uses grunt to manage assets. Some of this "management" involves syncing files between your project folder structure and the server's public folder, but as always, I'm getting ahead of myself.
The configuration of grunt is based upon the Gruntfile.js file found in the root of your sails project. There’s a lot going on in this file, however, I’m going to concentrate on the javascript and css assets.
Your Project's Assets
When you first create a project, you have the option of using the --linker flag. An example of using the flag would be sails new projectName --linker. Here’s the directory structure of the /assets folder under both scenarios:
USING the --linker flag
/assets
/images
/linker
/js
/styles
/templates
NOT USING the --linker flag
/assets
/images
/js
/styles
Note, you can “upgrade” a project that wasn't created with the --linker flag by manually creating the /linker folder and inserting it into your /assets path. You can then add /js, /styles, and /templates under /linker.
The Server's Public Folder
When starting the sails server via sails lift the following folder structure is created/sync'd via grunt within the .tmp folder:
.tmp
/public
If any of the other project folders (e.g. /images, /js, /styles, /templates) contain content they are copied/sync'd to the .tmp/publicfolder. The distinction being that if a /linker folder exists, the /js, /styles, and an additional /templates folder is created under /linker.
What happens to my layout.ejs file?
If you use the /linker folder, sails will alter your layout.ejs file to include links to your javascript and css files. Therefore, any page served from the project's /views folder will have access to the javascript and css contained in these files.
Grunt uses commented tags in layout.ejs to as placehodler for these links. For example, anything placed in the /style folder will automatically be linked in layout.ejs between these two tags:
<!--STYLES-->
<!--STYLES END-->
Anything in the /js folder will be linked between these two tags:
<!--SCRIPTS-->
<!--SCRIPTS END-->
Anyting in the /templates folder will be linked between these two tags:
<!--TEMPLATES-->
<!--TEMPLATES END-->
Accessing Sail's Assets
Here's how you access the assets under either scenario:
USING the /linker folder
/js --> /linker/js/yourFile.js
/styles --> /linker/styles/yourCSS.css
NOT USING the /linker folder
/js --> /js/yourFile.js
/styles --> /styles/yourCSS.css
It didn't appear that Grunt was doing anything on my installation including copying the assets folder. I found this post on the Google Group by Rob Wormald that finally got it working for me:
In your .sailsrc file, in the root of your project, remove the line that says "grunt" : false. That should get things working.
This was an issue with one of the generators that I believe should be corrected in the next release.
You will need to check Gruntfile.js in your sails project root directory and everything will be much easier to understand. Here is some short explanation:
Sails 'magic' during lift process are hidden in Grunt tasks.
If Sails not create .tmp/public directories in your project, it can be because permissions or something similar (its happen on Windows as I know, I not have it on Linux). Solution is to create manually .tmp/public directories and to be sure that is writable.
To get your assets copied to .tmp/public you will need to keep it inside assets/linker directory, or to update Gruntfile.js based on your specific need.
I hope this help :).
Related
By default following directories are created in netbeans:
nbproject
src
build
manifest.mf
Suppose I want to add image and database directory to store images and database. Should these directories be under src? Let me know what is the correct directory architecture of any project in netbeans ?
Thats a too philosophical question under developers. Be more specific for which kind of project.
For web i reccomend something like this:
Src - all your own code
Libraries - all external code
Public - mostly url reachable files and htaccess
Assets - images, media
Styles - the name says it
In your case i would add another folder database
I am new in ionic. I found in some ionic project, there is no src(app & pages) folder, but only is www folder.
After checking some sample ionic projects, it seems the src folder contents the similar components as www folder.
Could you please explain the differences between these folders, are they can be used together? If there is some detailed introduction for ionic framework architecture, it will be really appreciated.
The src folder contains your raw, uncompiled code, the files you need to edit in order to build your app. It'll hold all your pages, components, pipes, services, themes, assets, images.
The www is simply your compiled code, every time you build your project the www content is erased and built again, so there's no need to change anything in this folder. If you want to deploy for web one of the ways is using the code that's inside www folder.
The project you've found with no src folder must be an early version of ionic 2, i remember ionic 2 rc6 was already using src folder, so this project is using a version released before November 2016.
You can learn more about the structure here.
Hope this helps.
Always I store an all my front-end sources in Site Root Folder.
But today I update netbeans to 8.1 and I notice the Source Folder in the project properties.
What this folder for?
It is good explained in NetBeans Help -> Project Properties Window: Sources
Site Root Folder
The contents of this folder will be available through the web server on the production site. It contains the HTML, CSS and JS files that are publicly accessible/visible. This folder typically contains the index.html file.
Source Folder
The folder in the project that serves for server-side sources (typically node.js JS files). If the project is a JS library, JavaScript files should be placed in this folder (not in the Site Root Folder).
When you use Grunt or Gulp you should store sources and final site and different folders.
I have the following site directory structure (on a shared hosting):
/home/username/
public_html/
index.html
resources/
config.php
I am trying to set up a new project using the remote deployment in PhpStorm. I'd like to have both public_html and resources folders accessible, since both contain PHP files. I am confused by what should be the Project Root. Logic suggests that my project root is the top level directory containing all my files, i.e. /home/username/.
However if I mark it such in PhpStorm, the next screen (Specify Web Path) automatically maps my web root folder to the project root.
As the result, if I run /home/username/public_html/index.html from PhpStorm, it tries browsing to https://webroot/public_html/index.html. This is wrong. The web root should be mapped to /home/username/public_html. Actually, the very question ("Web path for project root '/home/username'") is invalid, since there is no web path to folders above public_html, that's the whole point of putting resources there. How should I properly configure folders in PhpStorm?
Such setup is definitely possible -- its very common to have website root folder as a sub-folder of the actual project.
As far as I'm aware it is not possible to create such setup right from New Project Wizard -- it has to be done at later stage when project creation was completed.
You need to go into Settings/Preferences | Build, Execution, Deployment | Deployment and add new mapping. Here is an example:
Here my website root is located in web folder -- you will have to change that to yours public_html. This way when you use Open in Browser on file inside your web root folder it will be opened with correct URL.
I'm creating a new dynamic web project in Eclipse and was wondering what best practices are for folder taxonomy. Here's what I believe it is <> are folders. Can someone please verify?
<Eclipse project name>
<src>
-- .java files
<WebContent>
-- .html pages
<images>
<css>
<js>
<META-INF>
MANIFEST.MF
<WEB-INF>
web.xml
<app name>
-- .jsp pages
Here is a sample folder structure of a dynamic web project:
As you can see all static files are placed as sub-folders under the WebContent folder. By naming conventions .css files are places in the css sub-folder. JavaScript .js files are placed under the js sub-folder and any image files such as .jpeg or .png are placed in the images sub-folder. I also have an extra lib sub-folder where I placed an angularjs library to be used.
By default after creation of a dynamic web project your web.xml file looks like so:
`<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>`
meaning it will first call the listed default name files when you run your application. This is why most projects will name the files as index.html or index.jsp. NOTE: that my index.html file is directly below the WebContent folder and not in a sub-folder
Finally you can call/include your static files (.css .js and image files) from your 'index' file like so:
<link rel="stylesheet" href=css/bootstrap.min.css>
<link rel="stylesheet" href=css/bootstrap-theme.min.css>
<script type="text/javascript" src="lib/angular.min.js"></script>
<script src="js/contactsApp.js"></script>
Also your .java files will properly go in the Java Resources -> src -> {place java files here}
Put your pages under WEB-INF folder, in that way they cannot be accessed directly.
Also look at maven directory layout http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html.
To what Aleksandr M said,
WebContent folder:
The mandatory location of all web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory(or in a sub directory structure under this directory), the files will not be available when the application is executed on the server.
WEB-INF
Based on the Sun Microsystems Java Servlet 2.3 Specification, this directory contains the supporting Web resources for a Web application, including the web.xml file and the classes and lib directories.
Source: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Fccwebprj.html
I am not sure why having an app-name directory under WebContent would be considered a "best practice".
Other than that, one primary rule you should be following when coming up with a directory structure is to have all static resources under one directory. In your example, I would have a subdirectory called static under WebContent, and place the js, css and images directories under it.
That way, it'd be easier for you to (later on) configure your HTTP server to pick static resources directly from the file system rather than route requests for static resources through the servlet container.
I had this question too and can't comment yet, but Upendra Bittu's answer helped me.
http://help.eclipse.org/neon/index.jsp
Search 'jsp', click on "Creating JavaServer Pages (JSP) files"
Create a dynamic Web project if you have not already done so.
In the Project Explorer, expand your project and right click on your WebContent folder or on a subfolder under WebContent. Note that
if you choose any other folder in which to create the JSP, then it
will not be included in the WAR file that is deployed to the server.
In addition, link validation will not encompass files that are not
under the WebContent folder.
From the context menu, select New > JSP. The New Java Server Page window appears with your folder selected
I'm trying out tutorials and get lost when people don't say where they create their files, and this helped me understand what's going on, so I'm just passing it on.