how to redirect a html page to another website which is hosted in google drive urlshorten by gdriv.es - google-drive-api

I am new to this.
Can any one tell me why my HTML page which is hosted in Google Drive, cannot redirect to a particular webpage while URL is shortened in GDRIV .
my html file content was
<html>
<body>
<p>you will be redirected soon.</p>
<meta http-equiv="refresh" content="0; url=http://examplesite.com">
</body>
</html>
I shared the Folder to the public and it was working fine, but the URL was bitty flabby like
https#://googledrive.com/host/0BXXXXXXXXXXXXXMGM/site.html
So I shortened the URL with the help of GDRIV
and i got a decent short URL something like
http#://gdriv.es/XXXX/site.html
But the redirecting function is no more working while using the shorten URL and work fine with that clumsy URL
Can any one tell me why this happen and well I think it is irrelevant to ask you tat ' Can i use PHP coding in Google drive hosted sites? '

It works. I did same thing in above example you provided and it did redirect my gdriv.es shortened address to redirected website.
Of course I assume you are aware of typo you made by adding # in your URL.
If it still doesn't work for you there is a "Send Feedback" link at the bottom of gdrive.es main page.
Fill that form and I'm sure they'll check that problem.
For your second question: No, you can not use PHP or any other server side scripting language on Google Drive Hosted Web Sites.
However you can use Google Apps Script which works under Google Drive and it uses Javascript language. You can do many things with GAS, one of them provides you a facility similar to PHP: HTML Service.
One caveat though: It has a javascript sanitization mechanism called CAJA. Meaning you can't just run any javascript code you like. Check last link for restrictions.

Related

How to deal with url for google while using ajax

My question is regarding URL on my site. I am wondering how to write usable URL for Google search engine while using AJAX on my site.
I'm using AJAX to minimize the resource usage on my site. It also prevent the page from flashing every time you hit a link.
But I also made a Rewrite rule to accept more common URL's. These URL's could be use to get to a document in my site.
Read it here
My URL's are as follow:
<a onClick="MyAjaxFunc()" href ="#">this is my link</a>
Its working great and fast just the way I like it. But what will happen when Google try to index my site?
Is there a way to make my URL work with AJAX on my site but render a more Google friendly URL.
Any ideas?
Thank you.

Use custom url for HtmlService webapp

Is there a way to use a specific cname to run a Htmlservice webapp ?
I would like to user something like app.domain.com to run the htmlservice app.
I see that this works inside a Google Site but the Google site doesn't manage correctly the tags
Not possible. At most you can use your custom url and program it to redirect to your apps script webapp. That way its easy to type and remember.
The solution posted by #Karl_S works with the published /exec urls but not with the /dev ones. Furthermore the responsive design is lost because the frame redirect skips the viewport setting in the html wrapper. An alternative would be to host the wrapping html page on your domain and add the viewport setting in the head while keeping the rest what the frame redirect does. For example the following worked for me:
<html><head>
<title>My App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<frameset rows="100%">
<frame src="https://script.google.com/a/.../exec"
title="My App"
frameborder="0"
noresize="noresize">
</frameset>
</html>
Also make sure to publish your script with cross domain restriction disabled, i.e. In your script ensure you call
HtmlService.createTemplateFromFile(...)
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
Hope it helps someone.
I have published web apps working via a Forwarded subdomain with masking. The URL does not change and client side interaction works and is posted back to my files as well. So instead of https://script.google.com/a/bondwood.net/d/1y3iLTLT.... I have mysubdomain.bondwood.net If I want to pass parameters I do have to throw a dummy character is, so mysubdomain.bondwood.net/n?arg1=xyz&arg3=abc
Note that currently any responsive design is being lost via the subdomain but is working via the raw url. This is the only thing I have found to not work at this time.
A CNAME record is an abbreviation for Canonical Name record and is a type of resource record in the Domain Name System (DNS) used to specify that a domain name is an alias for another domain, the "canonical" domain. All information, including subdomains, IP addresses, etc, are defined by the canonical domain. CNAME
But the HTML service lets you serve web pages that can interact with server-side Apps Script functions. HTML Service: Create and Serve HTML
It's a dubious advantage for public pages (not for internal apps).
If you really want to have Google Apps Script Server you need publish a page on a web-server and interact by REST.
Yes, you'll lost Client-side API. Do you really need it?
For an example you can publish a GihHib page Setting up a custom domain with GitHub Pages
Look at my simple app which deploeded on Google Drive Host
Cheers!

How to add a redirect to a web page where you have limited user priveledges

The company I work for has replaced our previously very flexible website with a much more restrictive "website in a box" technology. I have my web pages hosted on Google Sites and would like to redirect people to those pages. When I attempt to do this via javascript it gets stripped from the page when its saved. I do not have access to the section to attempt the depreciated method of redirecting.
Is there another method available to automatically redirect a customer other than just posting a link in a restricted environment like this?
If you're limited to using HTML to do the redirect, you can use a meta redirect:
<meta http-equiv="refresh" content="0; url=http://example.com/">
Though note that its use is deprecated because it may be disorienting to the user. In addition to the <meta> tag, you can add <link rel="canonical" href="http://example.com/"> to let search engines know that the targeted page is the canonical one.
Edit: if Google Sites won't allow you to change the <head> HTML, the Javascript, or the PHP, then it's time to go searching for solutions within Google Sites itself. One solution that pops up pretty frequently in searches seems to be using a URL Redirect Gadget.
On the page you want to redirect from, click the Edit Page button, then Insert Menu, then More Gadgets. Once there, search for "redirect gadgets" and some widgets that should help will show up.
These instructions are based on advice given in the Google Products forums. I don't have a Google Site myself, so I can't verify that they work.

How to make google index my custom domain instead of the github pages domain?

I have a splash page hosted in github pages for a client while we finish their official site.
Until a few days everything was ok but I now realized that google is indexing the github url instead of the custom domain.
I followed github instructions, i used the CNAME file in my repo, I setup the A domain for the top-level domain and the CNAME for the www.
I looked all over the internet without luck. I tried using google webmaster tools, and I can't really use robots.txt because that would affect both.
I think I found the solution. Leaving it since it might be helpful to others.
I need to wait now for google to re-index, but it should do it.
According to this question and this google article a canonical link tag in the head should fix it.
<link rel="canonical" href="http://www.[website-url]"/>
I also added a js redirect trick to redirect the people coming from google.
if ( window.self === window.top ) {
// console.log("not in a frame")
window.location.href = 'http://www.[website-url]';
}

opening html from google drive

I have made a page in html5 with css3. It works fine on local (I dont use any server, just doubleclick in the index to open it).
I want to put it in google drive. I have load all the documents needed, but when I try to open the html, I can only see the text (I mean, it is not being executing, I can see just the source code).
Any suggestion?
Not available any more, https://support.google.com/drive/answer/2881970?hl=en
Host web pages with Google Drive
Note: This feature will not be available after August 31, 2016.
I highly recommend https://www.heroku.com/ and https://www.netlify.com/
EDIT: As of August 2016 Google Drive can no longer be used to host static web pages, so this solution no longer works.
Create a new folder in Drive and share it as "Public on the web."
Upload your content files to this folder.
Right click on your folder and click on Details.
Copy Hosting URL and paste it on your browser.(e.g. https://googledrive.com/host/0B716ywBKT84AcHZfMWgtNk5aeXM)
It will launch index.html if it exist in your folder other wise list all files in your folder.
I don't think it is necessary to "host" the content using the way from the accepted answer. It is too complicated for a normal user with limited developing skills.
Google actually has provided hosting feature without using Drive SDK/API, what you need is just few clicks. Check this out:
http://support.google.com/drive/bin/answer.py?hl=en&answer=2881970
It is the same to the answer of user1557669. However, in step 4, the URL is not correct, it is like:
https://drive.google.com/#folders/...
To get the correct host URL. Right click on the html file (you have to finish 1-3 steps first and put the html in the public shared folder), and select "Details" from the context menu. You will find the hosting URL right close to the bottom of the details panel. It should look like:
https://googledrive.com/host/.../abc.html
Then you can share the link to anyone. Happy sharing.
Now you can use
https://sites.google.com
Build internal project hubs, team sites, public-facing websites, and moreā€”all without designer, programmer, or IT help. With the new Google Sites, building websites is easy. Just drag content where you need it.
While drive allows you to edit plain text and HTML files I don't believe they allow the HTML to actually be displayed. I don't think they want people hosting websites from their drive space.
A lot of the solutions offered here do not seem to work anymore. I'm currently on a chromebook and wanted to view an HTML5 banner. This seems impossible now through Google Drive or other apps (as mentioned in previous comments).
The method I ended up using to view the HTML5 was the following:
Open Google Adwords (create a free account if you dont have one)
Click on Ads in the top panel
Click on "+AD" and choose image ad
Choose "upload an ad"
Drag and drop your zip file into the area
Click on Preview
Voila, you will see your HTML5 banners in their full beauty
There may well an easier way, but this way is pretty good too. Hope it helps and worked well for me.
Create a new folder in Drive and share it as "Public on the web."
Upload your HTML, JS & CSS files to this folder.
Open the HTML file & you will see "Preview" button in the toolbar.
Share the URL that looks like www.googledrive.com/host/... from the preview window and anyone can view your web page.
Found method to see your own html file (from here (scroll down to answer from prac): https://productforums.google.com/forum/#!topic/drive/YY_fou2vo0A)
-- use Get Link to get URL with id=... substring
-- put uc instead of open in URL