Drupal: The easiest way to create HTML page without usage of drupal - html

How can I make Drupal "print" the .html file which is stored inside Drupal directory (e.g. in drupal root directory, or in sites/all/files/)?
I want to get that .html file by simple path like http://www.mydomain.com/thatfile.html, without theming, etc.
P.S. to explain the motivation: I want users to be able to print the location map from the site (pressing "Print map" link). I could do it not redirecting the user to new tab (I want them to be redirected to new tab :)). But what if user will accidentally press "Cancel"? (User can become confused)
Thanks in advance.

If Drupal is hosted on http://example.com/, and there is a file named results.html, visiting http://example.com/results.html you will get the content of that HTML file.
One of the rewrite rules included in the .htaccess file Drupal comes with says to the web server to serve a file that exists.

Related

Host files locally with predictable/controllable URL on Synology NAS

I am trying to find the best way to host a bunch of pdfs(and other files potentially) on my synology DS1821+ that can be accessed by a URL so employees can access them by scanning a QR code. The files should be available to any device connected to our WiFi.
I was able to achieve this quite easily using WordPress and simply uploading the files to the "Media Library" And converting the URL to QR code using my web browser.
Here is an example of one of the URLs provided:
http://10-0-1-128.synologynas.direct.quickconnect.to/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf
this also works:
http://10.0.1.128/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf
However, since we would be printing potentially thousands of QR codes to be used around the factory for years to come I need the URL to be something I can control manually, without stuff like "2022" in it so that if someday we switch to different software/hardware we can replicate the same structure so as not to need to reprint and redistribute thousands of QR codes.
I see the application "File Station" on my NAS and this is close to what I want but not quite. There I can right click a file -> share ->QR code and it returns something like this:
http://gofile.me/73nWA/C8AYNuBpv
Pretty cool, but again the URL is not something I can control, and also it uses some advanced voodoo to make the link work anywhere on the internet and these need to only work on our local network.
Any thoughts on the simplest way to achieve wat I'm looking for?
-Thanks
Edit -
I see now that I can add a folder to the "web" directory using File Station, and then add files to that folder and access them in my web browser by going to:
/folder/filename.pdf - (although if I right click it and say open in new tab it access it through a long and convoluted url???)
which is basically what I wanted
however, I would like to be able to also go to:
/folder
and see a selectable list of all the files as well
I know I can create I link by adding something like
<a href="file.pdf" etc etc etc
to the .html file, but I'm working with about potentially thousands of files.
Is there a way to just generate one for every file in the folder.
as I'm sure you can tell I'm a noob at this.
Figured it out.
As long as you have some web server SW up and running you should be able to acces files placed in the /web folder of the "file station." for example if there is a pdf in the web folder named document.pdf you can access it by going to /document.pdf in your browser on local network.
If there is a folder name named pdf with files in it in the /web folder
you can add index.php to that folder with the following code in it to see a list of links to the files in it in your web browser.
<?php
$dir = "/volume1/web/pdf";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
echo " <a href=./$file>$file</a><br>";
}
closedir($dh);
}
}
?>

Vs code live server Cannot get error message

I'm currently developing a simple static web page with only HTML.
I'm using tags with href to link to different pages and the VS code live server used to work when I inserted a link like page1.html it would send the browser to this page.
But I prefer to have just the page without the .html.
When I remove the .html from the link the live server gives an error: Cannot GET /page1
But when I deploy my site on Netlify it does, however, find the page, but this breaks the development process for me.
How can I fix the live server so it also gets sent to the correct page?
Thank you in advance,
Timo
This is a common server behaviour. The server tries to find a file or folder name page1 but doesn't find it. Nothing wrong with live server. I guess Netlify is the one doing extra magic.
However if you want to remove the .html in page1 you could create a folder name page1 and put inside a index.html with the content. This way the server will find the folder named page1 and return the index.html. This will also work with live server and any standard server.
This is how your folder structure could look like:
Cannot GET /source/gfdfghdgh/A/1&2.html
This is the error I get because of the '&' symbol.
Make sure your file name is browser friendly.
VS CODE LIVE SERVER CANNOT GET ERROR MESSAGE
Restart VSCode
Sometimes the best you can do is start VSCode from scratch. First, save all of your work. Then close VSCode, which will also stop all of the extensions you've installed. Then, reopen VSCode and try again – go to the HTML file you want to view, right-click## Heading ##, and select "Open with Live Server".

HTML - How to run a file from the user pc?

I'm creating a little project in HTML and there's something that I would like to do.
Imagine that my HTML page is hosted, and you can download there some .ppt and .exe files and place to a specific folder.
Now, that's the problem. Considering that the files are in the right folder, I would like to run these files when the user select their respective options at the HTML page.
Does anyone know how to do it? Thanks :)
This isn't directly possible, for security reasons.
If you control that application or can install something on the user's system, you can associate a file type or URI handler with the application you wish to launch.

Have Domain Open HTML File?

I am currently making a website, and have a folder containing CSS3 and HTML5 code in it. When I click on the index.html file, it opens up a local file and I can see my design and text in it. However, I am not sure how to have my website "point" to the index.html file, so it shows the content that is in the file. (I bought the domain with GoDaddy).
Thanks for the help!
Make Sure the directory does not have any other default files like default.php,default,html,etc and also there should be only one index file. if there is any index.php it will overtake index.html. Please make your question more clear and tell use which hosting are you using.....
Check documentation of the company that provides you hosting - the server has a list of files it looks for on disk in a given order. Only thing you need to do is to rename you file to match server's "lookup table".
Relevant part of configuration of the most popular web servers:
apache: https://httpd.apache.org/docs/current/mod/mod_dir.html
nginx: http://nginx.org/en/docs/http/ngx_http_index_module.html

Do I need to specify a webpage's url?

I've uploaded several files to my server and it's really quite baffling. The home page is saved as index.html, and when I type in the URL of said page it miraculously, and quite successfully shows the right page. What about my other pages? I have linked to them from the home page with the following code:
About Us
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"? I am dubbing this "The Unanswered Question" because I have looked at numerous examples of metadata and there is nothing about specifying the URL of a page.
It depends on what type of server you are running.
Static web servers
If it is the simplest kind of static file server with no URL aliasing or rewriting then URLs will map directly to files:
If your "web root" was /home/youruser/www/, then that means:
http://www.example.com -> /home/youruser/www/
And any paths (everything after the domain name) translate directly to paths under that web root:
http://www.example.com/about.html -> /home/youruser/www/about.html
Usually web servers will look automatically for an "index.html" file if no file is specified (i.e. the URL ends in a /):
http://www.example.com/ -> /home/youruser/www/index.html
http://www.example.com/about/ -> /home/youruser/www/about/index.html
In Apache, the filename searched for is configurable with the DirectoryIndex directive:
DirectoryIndex index.html index.txt /cgi-bin/index.pl
That means that every request to a path that ends in a / (and to add yet another rule, under some common settings it will automatically append a / if the path is the name of a directory, for example 'about'):
http://www.example.com/ -> /home/youruser/www/index.html
-> or /home/youruser/www/index.txt
-> or /home/youruser/www/cgi-bin/index.pl
Web servers with path interpretation
There are too many different types of servers which perform this functionality to list them all, but the basic idea is that a request to the server is captured by a program and then the program decides what to output based on the path.
For example, a program might perform different routes for basic matching rules:
*.(gif|jpg|css|js) -> look for and return the file from /home/user/static
blog/* -> send to a "blog" program to generate the resulting page
using a combination of templates and database resources
Examples include:
Python
Java Servlets
Apache mod_rewrites (used by Wordpress, etc.)
Links in HTML pages
Finally, the links in the HTML pages just change the URL of the location bar. The behavior of an HTML link is the same regardless of what exists on the server. And the server, in turn, only responds to HTTP requests and only produces resources (HTML, images, CSS, JavaScript, etc.), which your browser consumes. The server only serves those resources and does not have any special behavioral link with them.
Absolute URLs are those that start with a scheme (such as http: as you have done). The whole content of the location bar will be replaced with this when the user clicks the link.
Domain relative URLs are those that start with a forward slash (/). Everything after the domain name will be replaced with the contents of this link.
Relative URLs are everything else. Everything after the last directory (/) in the URL will be replaced with the contents of this link.
Examples:
My page on "mydomain.com" can link to your site using the Example.com about just as you have done.
If I change my links to about then it will link to mydomain.com instead.
An answer your question
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"?
First, the file itself has no idea what its URL is. Unless:
the HTML was dynamically generated using a program. Most server-side languages provide a way to get this.
after the page is served, client-side scripts can also detect the current URL
Second, if the URL is /about and the file is actually about.html then you probably have some kind of rewriting going on. Remember that paths, in their simplest, are literal translations and /about is not the same as about.html.
Just use /about.html to link to the page
Theoretically, it's better for URLs in your documents to be relative, so that you don't have to change them in the event you change the domain or the files location.
For example, if you move it from localhost to your hosted server.
In your example, instead of www.example.com/about.html use /about.html.
Given the link above you would need a about page named index.html located in a directory named about for your example to work. That is however not common practice.
I'm a bit confused, but here is some information. Any file named "index" is the default display page for any directory(folder) when trying to view that directory.
All files in a folder are always relative to that directory. So if your link is in a file, within a different directory, then you must type in that directory along with the file. If it is the same directory, then there is no need to type in that directory, just the file name.
about.html doesn't know what it's URL is, its the index.html file that calls your about.html file.
When you're in any given directory, linking to other pages within that directory is done via a simple relative link:
About Us
Moving up a directory, assuming you're in a sub folder (users) perhaps you can use the .. operator to navigate up one directory:
About Us
In your case your about page is in the same directory as the page you're linking from so it just goes to the right page.
Additionally (and I think this may be what you're asking) if you have:
about.html
about.php
about.phtml
about.jpg
for example, and you visit http://www.yoursite.com/about it will automatically bring up the html page and the other pages should be referenced explicitly somewhere if you want them to be used.