Possibilities of using Google Apps Scripts?

313 views
Skip to first unread message

CHUN LI

unread,
Feb 12, 2019, 8:13:37 PM2/12/19
to TiddlyWiki
Hello,

As I have been using Google Apps Scripts (GAS) and knowing TiddlyWiki for about 1 year, I am trying to find out the possibilities of (re) writing TiddlyWiki in GAS. The HTML services in GAS allows client side javascript, CSS and HTML (https://developers.google.com/apps-script/guides/html). Google Sheets might be a place to store (or keep a copy of) tiddlers, or be used to produce a data tiddler. Google also has this (https://developers.google.com/apps-script/api/quickstart/nodejs) to make node.js commands to GAS API.  
 
Did I misunderstand anything? Or this sounds like a plan? Sorry if I overlooked the Copyright of Tiddlywiki as I don't intend to do so. 

Thanks!

Chun 

TonyM

unread,
Feb 12, 2019, 10:10:05 PM2/12/19
to TiddlyWiki
Chun,

Thanks for your suggestion, I look forward to the feedback from other community members. 

Perhaps what is needed is not so much a rewrite of tiddlywiki but integration with such Google Apps Scripts. 

For example
  • The ability to include them in TiddlyWiki
  • Save Tiddlers/whole wikis to a Google App Storage
    • I believe there has being an application in the past of saving in Sheets
    • There are some people using TiddlyWiki on top of google drive
  • host tiddlywikis or databases of tiddlers on Google Platform
  • Include tiddlers that translate to standalone apps, or scripts provided by GAS that interact with a Wiki
  • Adding Open ID to TiddlyWikis for Authorisation and user credentials
  • Perhaps adding such services into NodeJS for interaction with the server implementations of TiddlyWiki
  • See also the Proposed Innerwiki plugin or the use of iFrames for integration at arms length.
Regards
Tony

CHUN LI

unread,
Feb 19, 2019, 5:42:08 AM2/19/19
to TiddlyWiki
Thanks Tony. Where can I find the "application in the past of saving in Sheets"? Is it in Google Sheets?

Jeremy Ruston

unread,
Feb 19, 2019, 6:25:32 AM2/19/19
to tiddl...@googlegroups.com
Hi Chun

As I have been using Google Apps Scripts (GAS) and knowing TiddlyWiki for about 1 year, I am trying to find out the possibilities of (re) writing TiddlyWiki in GAS. The HTML services in GAS allows client side javascript, CSS and HTML (https://developers.google.com/apps-script/guides/html). Google Sheets might be a place to store (or keep a copy of) tiddlers, or be used to produce a data tiddler. Google also has this (https://developers.google.com/apps-script/api/quickstart/nodejs) to make node.js commands to GAS API.  

Thanks! I think you are correct, there is a fascinating opportunity to make an adaptation of TW that is served by GAS and can save changes back to it. It would be a nice straightforward user experience too.

I think the easiest way to get started would be to create a new syncadaptor that loads and saves tiddlers via the GAS APIs. Then one could serve a blank TW file that includes that plugin, and at startup it would load the required tiddlers from the server. The next step might be to bake tiddlers into the HTML file when it is first served.

I'm not sure that I will personally have time to investigate this opportunity in the near future, but I'd be very happy to help guide other developers who might want to take up the challenge...

Best wishes

Jeremy




 
Did I misunderstand anything? Or this sounds like a plan? Sorry if I overlooked the Copyright of Tiddlywiki as I don't intend to do so. 

Thanks!

Chun 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/97145418-d172-42b5-aaff-c6b170c7d4ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

CHUN LI

unread,
Feb 20, 2019, 4:38:37 AM2/20/19
to TiddlyWiki
Hi Jeremy,

Thanks for the guide and I will see how far I can go.

May I ask a further question? Can a blank TW file also be created by publishing a Google web app? I guess it is about the fundamental requirements of creating a TW file vs. the limitation of GAS? 

(I read about Web app on GAS from https://developers.google.com/apps-script/guides/web)

So I am thinking, 
  1. Create a Google spreadsheet on my Google drive.
  2. Open Script Editor from the 'Tools' tab in the Google spreadsheet.
  3. Add (write) all the necessary .js, .html, .css code in my TW.html file. Please see a screenshot attached below. GAS use .html file to store all these three types of files. 
  4. Use a .gs file, e.g. getData.gs, to read all the data from the Google spreadsheet. The data can be used to create a .json tiddler, and create tiddlers.
  5. Publish as a web app.
  6. The Google spreadsheet can be updated using a Google form. The form can also be a tiddler and be used to edit (add) tiddlers. 
  7. Multiple users can work on the Google spreadsheet. Their Google logins will be collected and used as tiddler authors.
Screen Shot 2019-02-20 at 10.12.53 PM.png






















Thanks,

Chun

Siniy-Kit

unread,
Mar 8, 2019, 6:43:56 AM3/8/19
to tiddl...@googlegroups.com

Jeremy Ruston

unread,
Mar 8, 2019, 6:59:57 AM3/8/19
to tiddl...@googlegroups.com
Hi Siniy-Kit

What you've built is incredibly impressive. I would love to get the techniques you are using written up so that it's easier for others to follow. Do you have any idea of the traffic volumes you're seeing? Can you talk about the number of successfully completed transactions per day/week etc?

here is google table shop demo with 14000+ ITEMS  http://heeg.ru/shop_test29.htm

This URL didn't work for me.

Best wishes

Jeremy.

Siniy-Kit

unread,
Mar 8, 2019, 8:50:11 AM3/8/19
to TiddlyWiki
All my javascript I put to one tiddler http://novye-podarki.ru/6_7_0/heeg.html#%24%3A%2Fboot%2Fbootprefix1.js  I know, that it is not correct, but my project heeg.ru is not professional. it has only  30-40 unique users per day (both with shop users and their shops).
I don't see transactions of shops on my site (this information is private), but i think it is about 0 :)

test project http://heeg.ru/shop_test29.html use  gviz google api. so it loads not whole table at start (as my standard shop), but only necessary part of it. So this APi use google table as database all code is


var part='';


function drawVisualization(dataURL,queryString,part) {

    var opts = {
        sendMethod: 'auto'
    };
    var query = new google.visualization.Query(dataURL, opts);
    query.setQuery(queryString);
    query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
    var data = JSON.parse(response.getDataTable().toJSON());



 
for (var ik=0, lenk=data.rows.length; ik<lenk; ik++) {
  var fields = Object.create(null);
for (var i=0, len=data.cols.length; i<len; i++) {
if(data.cols[i].label=='id'){new_keya='title'}else if(data.cols[i].label=='name'){new_keya='caption'}else{
new_keya=data.cols[i].label};



if(data.rows[ik].c[i] == null || data.rows[ik].c[i].v=="" || data.rows[ik].c[i].v==undefined){}else if(new_keya=="tags"){
fields[new_keya]=data.rows[ik].c[i].v+" $:/Note"+" "+search_text;}else{fields[new_keya]=data.rows[ik].c[i].v+""};

 };
$tw.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getModificationFields(),fields,$tw.wiki.getCreationFields()));


};

if (part=="limit 1"){
var story = new $tw.Story();
story.navigateTiddler(search_text);
}


}





function summaryVisualTitle(title, col, par){
if(title.length>2){
    querySummary = 'select * Where ' +col +' like '+title+' ' +par;
part=par;
search_text=title;
    drawVisualization(dataURL,querySummary,part);



}
}

 

пятница, 8 марта 2019 г., 14:59:57 UTC+3 пользователь Jeremy Ruston написал:

CHUN LI

unread,
Mar 8, 2019, 10:00:33 PM3/8/19
to TiddlyWiki
Hi Siniy-Kit,

Thank you! This is incredible! Thanks for sharing! 

Kind regards,

Chun

CHUN LI

unread,
Mar 10, 2019, 5:33:04 AM3/10/19
to TiddlyWiki
Hi Siniy-Kit,

May I suggest you to announce this great work as a plugin? I think it is a really creative way to use TW5 and Google API. 

Jeremy, do you think this will be appropriate and beneficial?

Kind regards,

Chun

Mohammad

unread,
Mar 10, 2019, 8:45:17 AM3/10/19
to TiddlyWiki
Added to TW-Scripts

CHUN LI

unread,
Mar 12, 2019, 6:41:33 AM3/12/19
to TiddlyWiki
Hi Siniy-Kit,

Thanks again for sharing this.

I tried to figure out the necessary tiddlers / system tiddlers to get my Google table data into my blank TiddlyWiki 5.1.19 on node.js, but it seems like only the boot.js, bootprefix.js and bootprefix1.js are not enough. Could you suggest which tiddlers are also need to be included?

Kind regards,

Chun

On Saturday, March 9, 2019 at 2:50:11 AM UTC+13, Siniy-Kit wrote:

CHUN LI

unread,
Mar 13, 2019, 4:38:51 PM3/13/19
to TiddlyWiki
I am trying to make a simple version of the test project. It will use data from Google table to make tiddlers in a blank TiddlyWIki 5.1.19. What I did are,

  • Save http://heeg.ru/shop_test29.html a HTML file. 
  • Use my Google Table URL for the dataURL in the boot.js tiddler, save a copy.
  • Run a blank TiddlyWiki 5.1.19 on node.
  • Import the HTML file I saved as tiddlers, included all the tiddlers from the HTML file.
  • Received error message on the running TiddlyWiki webpage.
  • Shut down the node server, try to start again, but got error message. TypeError: $tw.Syncer is not a constructor at ..
I am trying to figure out why. Maybe I am missing a syncadaptor, or it is because the Tiddlywiki version differences (the version in step 1 is 5.1.14)?

Cheers,

Chun


Siniy-Kit

unread,
Mar 16, 2019, 10:05:04 AM3/16/19
to TiddlyWiki
look here  http://heeg.ru/shop_test29.html#%24%3A%2Fcore%2Fmodules%2Fwidgets%2Faddup.js   I put this macros to every tiddler 
<$list filter="[is[current]addprefix[']addsuffix[%']]">
<$addup val1=<<currentTiddler>>  val2="B" val3="limit 300"/>
</$list>

by this http://heeg.ru/shop_test29.html#%24%3A%2F_show_podrazdel

so this macros takes tiddler  title and  search it in a "B" column of the table, then loads this lines from table.


среда, 13 марта 2019 г., 23:38:51 UTC+3 пользователь CHUN LI написал:

CHUN LI

unread,
Mar 21, 2019, 5:14:00 AM3/21/19
to TiddlyWiki
Thanks Siniy-Kit. I managed to include bootprefix1.js in the TiddlyWIki5.html tiddler to call all the functions then added the "Google table" tiddler to click on the button to add all the tiddlers by reading the rows in my google spreadsheet. So the Google spreadsheet data finally are loaded to create tiddlers. 

I will try more on the way to search column B. It is an amazing way to use Google spreadsheets as a backend database.
Reply all
Reply to author
Forward
0 new messages