Embedding Java Script

154 views
Skip to first unread message

TonyM

unread,
Jun 14, 2018, 10:36:48 PM6/14/18
to TiddlyWikiDev
Hi Folks,

I am trying to determine how to make the following work in TiddlyWiki, It allows a user to embed a Yammer conversation into a TiddlyWiki.

<div id="embedded-feed" style="height:800px;width:100%;"></div>
<script type="text/javascript" src="https://s0.assets-yammer.com/assets/platform_embed.js"></script>
<script type="text/javascript">
yam
.connect.embedFeed({
  container
: "#embedded-feed",
  network
: "tiddlywiki",
  feedType
: "group",
  feedId
: "15224909"
});
</script>

Of Course in the above, the display occurs with
<div id="embedded-feed" style="height:800px;width:100%;"></div>

It will make discussing a specific wiki simple. I can past this into Raw HTML on a website, or in a WordPress Post and it works. It uses external script code, So I imagine it would be easy to implement.

However imbeding java script is out side my skills in TiddlWiki so far.

I have tried placing the contents of 
then
yam.connect.embedFeed({
  container
: "#embedded-feed",
  network
: "tiddlywiki",
  feedType
: "group",
  feedId
: "15224909"
});

in a tiddler of type application, to no effect

Thanks in advance
Tony

Jed Carty

unread,
Jun 15, 2018, 5:57:43 AM6/15/18
to TiddlyWikiDev
From my experiments with similar things before, I think in order to use that unmodified you will have to put everything in your first code block inside a tiddler tagged with $:/tags/RawMarkup and then it will only show up under the story river.

To make it more useful in a tiddlywiki context I think it would need a widget that contains the yam.connect.embedFeed part so that it would get loaded each time the widget is rendered. Otherwise the feed would only appear if the tiddler that contains it is open when the wiki is loaded and never closed.

This is the same problem that almost all of the commenting systems that I played with have and unless yammer has a built-in refresh mechanism you can call it isn't a simple fix.

BJ

unread,
Jun 15, 2018, 5:22:13 PM6/15/18
to TiddlyWikiDev
you can use a js macro (set module-type to macro, and type to application/javascript):

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports
.name = "yam";

exports
.params = [{name: "container"},{name: "id"}
];
/*
Run the macro
*/


exports
.run = function(container,id) {
yam
.connect.embedFeed({
 container
: "#"+container,

 network
: "tiddlywiki",
 feedType
: "group",

 feedId
: id
});
return "";
}

and as Jed said put

<script type="text/javascript" src="https://s0.assets-yammer.com/assets/platform_embed.js"></script>


in a tid tagged with

$:/tags/RawMarkup

then call it from a tid:

<div id="embedded-feed" style="height:800px;width:100%;"></div>

<
<yam  """embedded-feed"""   "15224909">>

all the best
BJ

TonyM

unread,
Jun 15, 2018, 6:20:42 PM6/15/18
to TiddlyWikiDev
Bj et al, thanks for your support,

I will be testing this after the week end.

Regards
Tony

TonyM

unread,
Jun 17, 2018, 8:08:33 PM6/17/18
to TiddlyWikiDev
Bj, et al..

I have followed your instructions and built the three tiddlers and reading through I kind of follow what is happening, however I am only getting a multi-row blank tiddler.

If you join yammer https://www.yammer.com/tiddlywiki you could see the conversion as well, in yammer, and I would love your review of Yammer as well.

I have attached the three tiddlers in a JSON file, The $:/PSaT/yammer/embed tiddler should be displaying the view.

Further assistance would be appreciated.

Regards
Tony

On Saturday, June 16, 2018 at 7:22:13 AM UTC+10, BJ wrote:
YammerEmbed.bundle.json

BJ

unread,
Jun 18, 2018, 6:42:44 AM6/18/18
to TiddlyWikiDev
the tid $:/PSaT/yammer/embed.js needs to be type "application/javascript" not json

TonyM

unread,
Jun 19, 2018, 7:47:05 PM6/19/18
to TiddlyWikiDev
Bj,

That "obvious mistake was fixed but still no result.
I am not sure how to "debug" this, but I will try inspect.

Regards
Tony

BJ

unread,
Jun 20, 2018, 1:04:11 AM6/20/18
to TiddlyWikiDev
you also need a 'module-type' field on the macro and set the value to 'macro'

TonyM

unread,
Jun 20, 2018, 7:58:32 PM6/20/18
to TiddlyWikiDev
Bj,

Thanks so much that is working now. I can embed in a TiddlyWiki the yammer thread and thus allow conversations about the Wiki to take place in Yammer.

This is something I have long being after and it means I can open up the TiddlyWiki Yammer network to others wanting to allow conversations/discussion/feedback about their website (tiddlyWiki focus).

I will endeavour to make the solution a little more friendly perhaps with a macro that is supplied the feedID and then "publish it".

I wonder is a json bundle fine or should I package it as a plugin?

Semi-related idea:
Some tiddlers in a NoteSelf wiki could include a link to conversions, and also external resources such that even once a user makes the wiki their own (saving Changes to PouchDB) they can access changing resources, even updates to the NoteSelf implementation itself. In someways we can use federation type tools on top of NoteSelf so that each use of NoteSelf is not a total "fork" (if you know what I am talking about?)


Thanks once again for this critical assistence
Regards
Tony
Reply all
Reply to author
Forward
0 new messages