Skip to content

Commit

Permalink
Add Mobile Basic for Google Docs (#3)
Browse files Browse the repository at this point in the history
* Update Code.gs

Add /mobilebasic option for 'Docs'

* Update test_docs.gs

* Update README.md

* Update README.md
  • Loading branch information
techstreams authored Mar 19, 2021
1 parent 356f48f commit 44edb34
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See the following blog posts for more information and getting started guides:
| Copy | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: `*` |
| Copy w/ Comments | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
| Template | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: `*` |
| MobileBasic | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: |
| PDF (Portable Document Format) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
| JPEG (Joint Photographic Experts Group Image) | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_check_mark: | :heavy_minus_sign: |
| PNG (Portable Graphics Format Image) | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_check_mark: | :heavy_minus_sign: |
Expand Down Expand Up @@ -152,6 +153,15 @@ To perform **TSDynamicUrls** for Google Forms unit tests:

---

## Change Log

* 2021-03-19 - Added **/mobilebasic** option for Google Docs. To test:
* Make a copy of this [Google Form](https://techstreams.page.link/TSDynamicUrlsForm).
* Add a **MobileBasic** option to the **Google Docs URL Modification Type?** section.
* Replace the [Code.gs](./form/Code.gs) in the copied form.

---

## License

**TSDynamicUrls License**
Expand Down
11 changes: 11 additions & 0 deletions form/Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ function processResponses(e) {
throw new Error('TSDynamicUrls.convertUrl(): Invalid document type.');
}
break;
// MobileBasic 'docs' type
case 'mobilebasic':
self.url = itemResponses.shift().getResponse();
switch (self.doct) {
case 'docs':
self.url = self.url.replace(self.getUrlSuffix_(),"/mobilebasic");
break;
default:
throw new Error('TSDynamicUrls.convertUrl(): Invalid document type.');
}
break;
// PDF all doctypes except 'forms'
case 'pdf':
switch (self.doct) {
Expand Down
8 changes: 8 additions & 0 deletions form/tests/test_docs.gs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var cases_ = function() {
copy: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/copy',
copycomments: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/copy?copyComments=true',
template: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/template/preview',
mobilebasic: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/mobilebasic',
pdf: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/export?format=pdf',
rtf: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/export?format=rtf',
txt: 'https://docs.google.com/document/d/1wtrYEY4vgVTMhnuBtYGebJqlIRD4eNTpWwk8fixnkFE/export?format=txt',
Expand Down Expand Up @@ -112,6 +113,13 @@ var cases_ = function() {
response = responses[responses.length-1];
tsdu = new TSDynamicUrls(form, response).convertUrl();
equal(tsdu.getUrl(), docs.template, 'TSDynamicUrls successfully creates Docs Template URL');

// Test Docs MobileBasic
TestUtil.createDocResponse(form, ['Docs', 'MobileBasic', docs.input]);
responses = form.getResponses();
response = responses[responses.length-1];
tsdu = new TSDynamicUrls(form, response).convertUrl();
equal(tsdu.getUrl(), docs.copy, 'TSDynamicUrls successfully creates Docs MobileBasic URL');

// Test Docs PDF
TestUtil.createDocResponse(form, ['Docs', 'PDF (Portable Document Format)', docs.input]);
Expand Down

0 comments on commit 44edb34

Please sign in to comment.