Laravel blade template view HTML::style not linking in sub folder - html

I have:
{{HTML::style('css/bootstrap/bootstrap.min.css')}}
Which in the source code comes out as:
http://www.view.local/laravel/css/bootstrap/bootstrap.min.css
Which is wrong.
It should be:
http://www.view.local/laravel/public/css/bootstrap/bootstrap.min.css
But of course I don't want it to show the laravel part of the source.
The project directory is:
http://www.view.local/laravel
Which is working fine for everything else.
How can I get this to work properly?

This works exactly as expected.
Public folder should be configured as root directory for laravel applications. You should set path_to/laravel/public as directory for your virtual host. That will solve the issue.
Making path_to/laravel as root directory will make your application vulnerable. Always make sure that you give web access only to public directory. If you are hosting on a linux based web server, the content of public folder should go to public_html folder.

Laravel links all the resources file to the public folder so you can use the asset() function in this way:
<link href="{{ asset('style.css') }}" rel="stylesheet" type="text/css">
where style.css must be in public/ folder

Related

hosting a github pages server with multiple html files

Im trying to host a github live server for a project that right now has a "index.html" main folder with 4 files inside that main folder named "forgot-pass.html" "home.html" "sign-in.html" "sign-up.html"
I know to host on github your html needs to be a index.html but my question is can you have a folder named index.html with html files inside that folder and it still work? or how can i host on github if i have multiple html files named various things.
Yes you can have more html files in the same folder or subfolders, but it's mandatory to have the "index.html" file. Also I think you can make that folder but will not work (I don't know if it works or not, but give it a shot).
Its required to have a "index.html" file located in the root directory. As far as having a main FOLDER named index.html with files inside of that as-well, did not work for me. but i did not try to have a index.html file in the root directory on its own ALONG with a separate folder containing the rest of the html files. So i don't know if that works or not. i just put all the html files in the root directory and made sure to have one named "index.html"

IIS not loading css file outside of website folder

I have an ASP 4.0 web site being served by IIS 8 that is in a folder outside of wwwroot. The site will load, but a css file that I am using is not being loaded (getting a 404 error).
Here's the folder path for the site:
C:/Sites/Test/"website I am using"
And the folder path for the css file:
C:/Sites/Test/sharedfiles/css/stylesheet.css
Here's the link I am using to connect to the css file (with spaces to get this to post)
< link href="~/../sharedfiles/css/stylesheet.css" rel="stylesheet" type="text/css" / >
This should load the css file, but it does not. I'd like to figure out how to get this working.
The Sites folder is shared for IIS_IUSRS and IUSR and permissions are passed down to the folders below, including the Test/sharedfiles/css folder.
The web site folder is what's selected by IIS for the website. I have Anonymous Authentication enabled for Application Pool identity and Static File serving is enabled.
I'd appreciate any other ideas on how to figure out the problem!
Make sharedfiles a virtual directory and establish a web site or a web application there and access your resources (css etc.) using a url. So in local host you would have http://localhost/sharedfiles/yourcss.css
Thats the correct way to do it - what you are trying to implement here is your own CDN.

404 page not found - Go rendering css file

I'm currently working in Go. I created a web server on my local machine. I followed the instruction on this page Rendering CSS in a Go Web Application
but I'm still getting the 404 error that the program can't seem to find where my css file is. My directory is as follows.
In src folder contains css/somefilename.css, src also contains server/server.go.
The code inside my server.go file is as follows.
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
When I go to localhost:8080/css/ I get 404 page not found. I'm also using templates to render the html code. The templates are in the folder
src/templates/layout.html
the html code is as follows:
<link rel="stylesheet" type="text/css" href="../css/css490.css" />
Since you don't specify full path for the css folder just a relative one, whether your css files are found depends on the folder you run your application from (the working directory, this is what relative paths are resolved to).
For example if you start your application from your src with go run server/server.go it will work. If you start it from your src/server folder with go run server.go, it will not work. Also if you create a native executable from your app which is put into the bin folder and you start that from the bin folder, this also won't work because the css folder is not in the bin folder.
Either start it with go run server/server.go from the src folder, or copy the css folder to your bin folder and start the executable from the bin folder and it should work (but in this case you also have to copy other static files like html templates).

viewing site on http://localhost instead of file://, using node.js

I am learning to use node.js.
The site looks fine when run from file:///C:/.../myfolder/index.html
I have my jquery and bootstrap files in the directories myfolder/css/ and myfolder/js.
but when I run node index.js and go to localhost:3000, these css and js files cannot be found.
This is what is in my index.html file:
<link href="/css/bootstrap.min.css" rel="stylesheet">
<script src="/js/bootstrap.min.js"></script>
<script src="/js/jquery.js"></script>
<script src="/socket.io/socket.io.js"></script>
Is there some folder in nodejs that I'm supposed to store these files? Or do I have to put some code in index.js that imports all the css and js files?
You can simply follow the quick start instructions for Express.js here:
https://www.npmjs.org/package/express
Then browse to http://localhost:3000 to test
You can use the Atom text editor or Brackets and place your files under the public folder and reference them.
http://atom.io
http://brackets.io
By default Express uses a template engine called Jade. You can look here to work with that:
http://jade-lang.com/
Using HTML in Express instead of Jade
Node.js + Express without using Jade
Good luck!
Your localhost begins in a specific directory on you machine. If you use Xampp, you must put all your server files in C:\xampp\htdocs\ in order to acces these via your localhost URL. Some other servers use a folder called 'www'.
Find your server root path en put your files there. Or create a symlink from your server root to your files.
Did you require the path module?
var path = require('path');
It's best to create a public directory to store your files in.
public/index.html
public/css/style.css
public/js/scripts.js
The reason that you couldn't get access to localhost:3000/folder/file is that localhost:port is just a virtual port. There is no such directory called localhost:3000/css/ or localhost:3000/js.
To fix this, you need to use express module to configure the root directory from which to serve static assets.
Basically, you need to add the following code:
var express=require('express');
var app=express();
var path=require('path');
app.use(express.static(path.join(__dirname,'public')));
and your static files directory will be currentWorkingDirectory/public/, which contains all of your assets.
In your code, to link any source file,
href='/fileName.extention'
Here is the documentation link express-static-files

Aptana Studio 3 preview problems with absolute path

I have this structure for my project:
Root Directory
|-css folder
|-style.css
|
|-it folder
|-index.html
If I try to include css file with:
<link href="/css/style.css" rel="stylesheet" type="text/css"/>
from index.html, aptana preview and also internal server can not find style.css.
Why is this?
In my remote server it works perfectly and I do not want to use a relative path.
In terms of the "why", the problem you are having is related to how your development server is setup versus your production server.
Assuming a standard setup, your production server will receive requests for a domain (i.e., http://mysite.com) that is, for lack of a better word, mapped to a folder on your server (i.e, a request to http://mysite.com will be mapped to a folder, /var/www/mysite, on your server).
So, when you link to a style sheet with /css/style.css, your (production) sever immediately goes to the /var/www/mysite folder and starts looking for the css folder, file and so on. No problems with that, as you point out.
Your development machine, however, is serving up pages locally and has a different directory structure for mapping to files and folders.
When I open an HTML page in my Aptana project and hit the preview button, Studio loads http://127.0.0.1:8020/mysite/public/404.html (note how the first folder after the IP and port is mysite). To load the absolutely pathed CSS file, the local server is actually looking for http://127.0.0.1:8020/css/styles.css but it needs to get to http://127.0.0.1:8020/mysite/css/styles.css.
The initial "/" in your link (/css/styles.css) tells the server to go to the root directory of the server and start looking for the folder and files from that point ... but there is no css folder in the local server's root directory. It lives in /mysite/css/styles.css and that's why fskreuz suggests relative paths and using "../css/styles.css" instead.
Personally, I prefer absolute links (but that's just a personal preference and not in any way a challenge to or comment upon fskreuz's response). However, my local development setup is conducive to using them because I setup virtual hosts for the sites I work on. Using Apache, I setup a virtual host for each of my projects. With this, I can load something like http://dev.mysite.com in any browser on my computer and test my site/app in a way that makes it mirror my production setup.