Embed Google Drive in Google Site - html

I am developing a Google Site that display different kinds of Data and soon integrating with files that is connected in Google Drive and this is where my question goes. As far as I know to import a Google Drive by doing this.
Selected Google Site > Edit > Insert > Then Select a Folder
and by that a list of files in my selected folder will display in my site in List View
Thats one solution for me. However I want also to integrate search function like a textbox below that gadget and when i search on that list of files will also show. How can I achieved that?
and also in addition how can I embed the search fucntion of Google search on that? For example I search test it will just not display the file that has a name of test but also files that contains test
any means of help is highly appreciated. TYSM

Try using Apps Script and deploying it as a web app then embedding it in your Google Site. According to the document:
Web apps can also be embedded in Google Sites. (These embedded web apps are sometimes called Google Sites Gadgets.)
To create a script that is bound to Google Sites, visit your site, click the gear icon, then select Manage site. Click Google Apps Scripts, then Add new script. After that, the process is the same as for creating and deploying a web app as above.
For the searching purposes use the field fullText which will check the Full text of the file including name, description, content, and indexable text. See Search for Files documents for further information
folder.searchFiles('fullText contains "' + search + '"')
Useful reference:
Search Google Drive folder from Google Site using Apps Script
Hope this helps.

Related

One question survey app Google Apps Script and Google Sheets with user management

I have to do a little bit of "crowdsourcing" for my work and it would consist in a very simple web app where a user can register/log in, and then be taken to a page where a picture is shown to a user and submit a number.
I'd like to be able to set up a few rules to choose which picture the user will see (so he won't have to answer twice the same question and also to allow some overlap between users to compare their answers).
We can assume that I have a google sheet with a list of images URLs that can be accessed and that I would like the answers to be populated there.
I figured that this tutorial would be a good start since it handles user creation and management and user can submit ideas :
Creating a CRUD Web App with Google Sheets
That being said I'm a bit clueless, I've tried to look for sample scripts deployed as web app but it's hard to know where to start.
I'll appreciate any help !
Google Apps Script is, basically, a javascript environment with a set of libraries that interact with the Google Apps. For instance, to read or store information from/to Google Sheets or Google Docs. If you know javascript, you can create simple applications there. In addition, you can create plugins for Google Applications if you are interested.
A very simple example
Suppose you wanna display an HTML page. You can create an stand-alone script (an script not-bound to a G suite application) and use the content or the HTML services.
You can create a function that sends a simple message to the browser using the ContentService:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
Or you can create a function that sends an HTML file in the same project using the HtmlService:
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index');
}
Once you have created the function, you must deploy the script as a web application.
Save the script as a new version doing File > Manage Versions and Save new version.
Then, publish the app using Publish > Deploy as web app and provinding information about the permissions for the application.
After Google publishes the application, it gives you an URL to access the application,
You may check more in a simple tutorial on producing content with Google Apps Script. In addition, you may check the google guide to use the HtmlService to provide templated content, i.e. where the HTML are templates which data is provided by javascript functions and variables.
Getting started with Google Apps Script
To start, you may check some tutorials in the internet:
Google has some tutorials and a series of Youtube videos.
In addition, you may find multiple resources for Google App Scripts that may help you:
Google has a list of sample projects
Tanakeich has a list of resources for taking advantage of Google Apps Script.
Oshliaer has another list of resources.
There are Google Codelab (tutorials) for Apps Scripts. They include a lab for using Google Sheets as a reporting tool and for creating a Hangouts Chat bot with Apps Script
Developing Google Apps Script projects locally
Although Google Apps Script provides a web interface to create your applications (your scripts), a better idea may be to create the software locally, using more-traditional tools for Javascript.
Clasp is a command-line tool to develop locally Google Apps Script projects.
Google has a codelab that teach you how to use clasp.

Google Site Script to dynamically add posts from Google Sheet

I have a Python cron job that pulls urls from sheet1 and populates sheet2 with scraped data from each url. Sheet 2 consists of [url, title, body, image urls]
I have an Old Google Site where I manually take sheet2's contents and create a new post. I want to automate this.
Structurally speaking would Google Scripts be able to pull and publish this dynamically? Lets say every time Sheet2 is updated (or a set interval).
I've worked with gscripts but never touched Google Sites before today.
The answer is probably yes. Apps script can do this. You have a couple of options.
Old Google sites
Option 1
Embed an apps script into the site as an iframe and stream you posts in that.
Option 2
Use either a standalone apps script or one attached to the google site and update the site using the Google Sites API.
New Google sites
Currently there is no apps script API for the new google sites. But you can embed JS HTML etc as a frame in the new sites. You can even use CDN libraries. Which means you can pull data from your sheet using something like AJAX.
Custom built option
The Google Sites API can be accessed anywhere you can handle Oauth. This means you can update Google Site from server-side code or from any client if you can handle Oauth.

Synchronizing data between Google Sheets and MS Excel using Google Drive API

I open MS-Word file in Google Document and edit it. But changes wasn't reflected to original MS-Word file. Please tell me how to fix this. Is there any way through API?
I really liked your question, see if this helps :
you need to edit the file using the following two options
Edit the file using Office Compatibility Mode (OCM)
Convert the file to Google Docs, Sheets, or Slides.
For using the Office Compatibility Mode (OCM), do the following
Go to :
https://chrome.google.com/webstore/category/apps
Go to the Extensions "Menu"
Search for --> Office
Install the " Office Editing for Docs, Sheets & Slides" extension
Now go to Google Drive, there go to the settings
and uncheck the Convert Upload option
(Convert uploaded files to Google Docs editor format)
However if the doc is heavily formated, this may not be
a good way to edit it.
Ref: See the link below
https://www.youtube.com/watch?v=odjJBYpJmxs
I am sorry i didn't see the last part of your question where you have asked for API. I have not done this before ...
however ever when i check in the web,,i didn;t see any API like Google Docs API, I can see the Google Sheets and Google Slides API though in the RESTful APIs that Google is providing.
So Maybe can redesigning you app a little using Google Picker of Google Drive API, may help OR use the paid Google Apps for work https://apps.google.com/products/docs/
Some one else , in this forum may reply with better answer.

Google Realtime API with Google Docs

I would like to build an application on a webpage, that does as google docs:
I want to build an app that allow people to work on a document in collaboration
I start with this: https://developers.google.com/drive/realtime/realtime-quickstart
But the problem is that it creates a file with the mimetype is "application/vnd.google-apps.drive-sdk".
I would like to work with google docs format, so people can open them with their google drive and edit their later.
The file created is not the proper format, and find it me impossible to open it.
( I try to edit the mimetype with "application/vnd.google-apps.document", however it creates the file in the google drive but it can't find the file when it try to load it).
How to create a google doc in realtime ? (If you can post the code here, it would help me a lot)
Then, it want to add the toolbar for editing(bold, italic,...).
After that, it would like to add the google picker to select the file to load.

How to add Google Drive Scripts project into Google Sites?

I want to embed Google Drive Scripts/ project from Google Sites but I can not.
Google Sites alert me with a message
This url is not recognised as a valid Apps Script
after I
created project-script from Google Drive,
added a function function doget(e) { code; code; code; ... },
published the script ("Deploy as web app"),
retrieved the link link (e.g: https://script.google.com…1DkWAQ/exec), and
in the Google Sites page,
I edited page and inserted a script from menu: Insert > Apps Script Gadget.
In the next page I enter script's link but a message box shows up: "This url is not recognised as a valid Apps Script"
Where I am wrong?
My question is: Can I execute Google Drive Script without adding code in site's page? Is it possible to execute from several Google Sites' pages a Google Drive Script with different parameters?
Thanks,
Michele
The url is different when embedded in a Google site, here is an example that can be inserted :
`https://sites.google.com/macros/exec?service=keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
You can pick the key in the standalone url.
I must admit that the interface is not really clear about that, nor is the documentation
EDIT : since some people seems to be sceptic ;-) here is an example with a shared script written as a script file :
the url given for a standalone app is :
https://script.google.com/macros/s/AKfycbxlPTVLSLfO3d1w2vSrMzzh57p9DJM6ivCIHiIfTB2AKqubSs1L/exec
The same script in the site page is :
https://sites.google.com/macros/exec?service=AKfycbxlPTVLSLfO3d1w2vSrMzzh57p9DJM6ivCIHiIfTB2AKqubSs1L
feel free to check ;-)
in the gadget properties it shows up like this :
I believe this summarizes the correct format for URLs of scripts saved on Drive for inserting with a Script Gadget on Google Sites:
Regular Google user:
https://sites.google.com/macros/exec?service=KEY
Google Apps domain:
https://sites.google.com/a/macros/MYDOMAIN/exec?service=KEY
Note the domain part is 'sites.google.com' not 'script.google.com'
As my experiences, you can't create an Apps script in Google Drive and then embed it in Sites.
To do that, log into your site's dashboard. You can do that by selecting menu item More > Manage site from your site (with logged in account). Then select tab Apps Scripts, hit the button Add new script. From there you can code your script. When you're done, come back to your site, edit a page and insert that script into your page.