As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label Google Docs. Show all posts

A while ago, I was learning how to write a custom function in Google Docs Spreadsheet, even wrote a wiki page to note about input and output of custom function. I picked timeago function as an exercise.

I submitted the finished script to gallery, you could find it by searching timeago:

http://4.bp.blogspot.com/-d_GEU-_TPU8/T9lYasFsvQI/AAAAAAAADZc/uOHWTK1Rnpg/s1600/timeago+in+Google+Docs+Spreadsheet.png

Here is the test spreadsheet.

For the source code, I think you can view it in that test spreadsheet or after you install the script, not really sure. I lost my interest in writing custom function since I dont need any for practical uses.

Note

Google Docs Viewer is gone, therefore nothing here will work. (2015-12-10T03:08:02Z)

More than a year ago, I wrote a post about how to view local PDF file. To be honest, I never actually used that script, I have a bookmark for viewing PDF online for very long time even before I wrote that script. I dont download PDF when I need to open a PDF file, just directly view it using Google Docs Viewer.

If you are a Firefox user, itd be great to know the keyword and %s in bookmarks. Keyword of bookmark allows you to access the bookmark by just typing it in address bar, %s in bookmark URL will be replaced with the string you put after the keyword when you open a bookmark using address bar.

To show you how to use bookmark, first, create a bookmark with URL as follows:

https://docs.google.com/viewer?url=%s

and set keyword to gdv.

Next, find a random PDF link online and type in the following text in address bar:

gdv[Space]http://example.com/foobar.pdf[Enter]

Google Docs Viewer will show you the document if its not get blocked. I have seen one or two websites actually blocks Google Docs Viewer.

You can have embedded version with the following URL, which has less controls:

https://docs.google.com/viewer?embedded=true&url=%s

For me, as a fan of Pentadactyl, after I yank a URL of PDF, I just type in:

[o]gdv[Space]http://example.com/foobar.pdf[Enter]

If you are smart, you should have learned you can set some keywords for your most visited bookmarks with single letter or two. You dont need to go through your bookmark bar, you just type the keyword and press enter.

Note

Thanks azuwis for the great tip of using hints in the comment below, here is the embedded code. (2012-06-26T09:38:22Z)

Press ;d to get the hints if links are PDF, DOC, etc.

A twitter asked:

Anyone have a way to validate the Links / URLs in a Google Docs (docs.google.com) document? (not http://validator.w3.org/che...)
and he bookmarked W3C Link Checker and commented eariler:

For documents at docs.google.com, getting: Error: 403 Forbidden by robots.txt
The first question poped out of my brain is why does W3C Link Checker comply with robots.txt, is it a robot? The answer is yes, even it wasn't, it is still not allowed to access because it's a script and the Terms from Google.



The robotstxt.org defines:

A robot is a program that automatically traverses the Web's hypertext structure by retrieving a document, and recursively retrieving all documents that are referenced.
The W3C Link Checker identifies all links from the link you specify and checks them one by one, which is an act of traverse. Although, I don't seem that it meets the later prerequisite. I would still say: yes, it's a robot, therefore it complies with the robots.txt on Google Docs, whose content is:

User-agent: *
Allow: /$
Allow: /support/
Allow: /a/
Disallow: /
Last line denies all robots to access published documents on Google Docs. robots.txt is not only a standard to Google, but also a part of their Terms of Service. You, developers or users of apps, can't say I just don't follow the standard. In section 5.3:

5. Use of the Services by you



[snip]



5.3 You agree not to access (or attempt to access) any of the Services by any means other than through the interface that is provided by Google, unless you have been specifically allowed to do so in a separate agreement with Google. You specifically agree not to access (or attempt to access) any of the Services through any automated means (including use of scripts or web crawlers) and shall ensure that you comply with the instructions set out in any robots.txt file present on the Services.


Robots (including scripts) must not access. The future possible automatic way to access is to depend on Google Docs API (the full name is Google Documents List Data API). Right now, I see no interface allowing you to retrieve a Google Docs Document. Manually downloading and checking is only way without violating something.