Import local CSS file into a procedure - css

I got a PL/SQL Web Toolkit project not online (url : http://127.0.0.1:8080/dad/my_procedure).
And I just want to know how to import a local CSS file into this procedure...
I tried to do something like this :
htp.print('<link href="'C:/Users/Me/Desktop/css/filecss.css" rel="stylesheet" type="text/css" />');
or even
htp.print('<link href="/css/filecss.css" rel="stylesheet" type="text/css" />');
with no success...
In reality I don't know what's the root directory for a project like this.

The CSS file has to be within the HEAD area of the webpage. You should have your htp.print statement between the htp.headopen and htp.headclose calls.
Also, the CSS file path is relative to the web server processing the request, so the path should be to the directory on the web server that the CSS file resides.

Related

Apps Script External Stylesheet

I am trying to use a single HTML stylesheet that I've created between multiple apps script web app projects. I have the HTML stylesheet hosted on an external site but cannot figure out the code to include that external stylesheet into my apps script projects.
I've currently got it working with the following code in my Index.html file:
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<?!= include('stylesheet') ?>
The include function calls:
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
And my stylesheet is a separate HTML file in my Apps Script.
This all works well, but I'd like to have a central repository elsewhere (I've read that I cannot link to an Apps Script file in another project) for my stylesheet so that whatever changes I make will update to all of my Apps Script projects automatically.
To do this, I've uploaded my stylesheet.html to a website and have taken the link that points to the file (i.e. http://www.test.com/stylesheet.html) and tried to do the following without success:
<link rel="stylesheet" href="http://www.test.com/stylesheet.html">
I've placed this in the head element of my Index.html file, and I also tried it above the head element. Neither worked.
I've also tried to just use the include function that worked as mentioned above and modify my stylesheet.html to be blank except for:
<link rel="stylesheet" href="http://www.test.com/stylesheet.html">
None of this seems to work, wondering if anyone else has any thoughts on how this might be possible.
Host CSS file in Google Drive
Create a .css stylesheet file and host it on Google Drive.
Change the uploaded file permissions to publish it on the Web.
Now copy the published file ID and use it to build the following URL:
https://drive.google.com/uc?export=view&id=FILE-ID-GOES-HERE
Now include the generated URL to your HTML page using the <link/> tag in this way:
<link rel="stylesheet" href="google_drive_link_goes_here">
Reference
Host CSS or JS file on Google Drive

Why can't Node.js server read CSS if it is located on the higher lever than HTML?

For some reason, I can only access my CSS files in my Node.js app if they are located in the same folder or deeper than HTML.
Folder structure that works:
I can assess CSS here using the css/style.css path as it is located in the sub-folder of the HTML folder. It also works for the nested sub-folders.
Folder structure that doesn't work:
But when I try to move CSS on the level higher, it can't be accesses using ../css/style.css, an error message about the incorrect MIME type (text/html) appears and the style doesn't apply.
Am I missing something or this is intended?
The issue might be with path, it must be
<link rel="stylesheet" type="text/css" href="../css/style.css">

Spring Boot MVC with angular app static content behavior?

I am not sure what is happening with that behavior but when :
i include the following script link in the HTML
<link href='./css/style.css' rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="./js/app.js"></script>
the page is not applying css or js if I just open the HTML page in any browser directly, but it runs on the server and apply the links
when i include the following instead of the pervious link
<link href='../static/css/style.css' rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../static/js/app.js"></script>
it Runs when open the Page in browser directly , but it is not applying when run on server
i can not figure out why this happening
The reason behind this is because when you run on the server, Spring boot maps the src/main/resources/static folder to your context root (usually /).
That means that if you have the following structure:
src/
main/
resources/
static/
myStyle.css
templates/
index.html
Both the src/main/resources/static/myStyle.css and the src/main/resources/templates/index.html will be available as /myStyle.css and /index.html.
If you're using Spring boot you should never include the static/ (or templates/) part in your links/references. You should never open the HTML page directly in your browser since this does not reflect any real environment.
To make it work locally you should run the Spring boot application and open the application through your browser, not just some HTML file in the project itself.

how to link css file from outside web application

Simple as title says, how do I include a css file that is found two parent folders up from the actual web application itself?
I have tried adding the file as a link to the web project and then referencing it like that and it dose not work
<link rel="stylesheet" href="../../mystyle.css" /> would literally move up two folders on your server. You may be better off with using the full path: <linke rel="stylesheet" href="/folder1/folder2/mystyle.css" /> - which all assumes that the path you need to get to is accessible to the web server.
Since the page comes from the server I would read the physical file and stuff that onto the page as part of the server script such as:
<style>
<?= css_file_content ?>
</style>
If in a parent folder, it may be outside the hosted path making it inaccessible to the client. But it is not inaccessible to the server-side script.
Visit: http://www.w3schools.com/css/css_howto.asp
You can add inline css if external doesn't work

Reffering to a css stylesheet from an unknown, higher directory

I'm currently in the process of building my first PHP-based website. The entire website is located in the main directory: example.com
I want users to find different pages of my website by going to links like example.com/page, example.com/another_page, example.com/directory/some_page, etc. etc.
To do this, I make these directories, and add the following php-code in an index.php:
<?php
include("/home/user/domains/example.com/public_html/index.php");
?>
This works fine, the page is being included. The problem is that the stylesheet isn't. It only works in the main folder. I tried both these HTML-snippets:
<link href="Stylesheet.css" rel="stylesheet" type="text/css" />
<link href="/home/user/domains/example.com/public_html/Stylesheet.css" rel="stylesheet" type="text/css" />
But they both don't work.
How does this work in HTML, how to access the home directory?
Thanks in advance
The css file is downloaded and included on the client side, as opposed to the php include statement which includes the file on the server side.
The path for the css should therefor "make sense" from the clients perspective and probably be specified relative to the public_html directory. That is, if it resides directly in the public_html directory the line should read
<link href="/Stylesheet.css" rel="stylesheet" type="text/css" />
The browser can't see all the directories under your public_html. Web servers present the browser with a document root. You need to refer to it with a / only:
<link href="/Stylesheet.css" rel="stylesheet" type="text/css" />
Also consider using mod_rewrite instead of creating directories and PHP files everywhere. I think you would find that much more maintainable.
This is your absolute path for Server-Side access:
<?php
include("/home/user/domains/example.com/public_html/myDirectory/Stylesheet.css");
?>
However, you want access from your Web Server for this. The absolute path for the Web Server is as follows, where / is the root of your web server and myDirectory is a directory location off the root:
<link href="/myDirectory/Stylesheet.css" rel="stylesheet" type="text/css" />

Resources