Hi!
I found a way to embed a gist into tiddler without a motify to $:/core
First, creat a file named "*gist.html"* with the following content and put
it anywhere(local or web server):
<html>
<body>
<script language="javascript">
function GetRequest() {
var url = location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
var Request = new Object();
Request = GetRequest();
var id=Request["id"];
var user=Request["user"];
var usel = '<script
src="'+"https://gist.github.com/"+user+"/"+id+".js"+'"><\/script>';
document.write(usel);
</script>
</body>
</html>
Then, creat a template tiddler "*T/Gist"* with the following content,
remember to replace the path/to/your/gist.html to the url or local path of
yourself:
<$set name="q"
value={{{[[path/to/your/gist.html?user=]addsuffix{!!gist_user}addsuffix[&id=]addsuffix{!!gist_id}]}}}>
<$set name="myVariable" value="Some text">
<html><div align="center"><iframe src=<<q>> frameborder="0" width="100%"
height="600"></iframe></div></html>
</$set>
It will use the field "gist_id" and "gist_user" and embed gist in tiddlers
like this:
{{||T/Gist}}.
在2021年2月24日星期三 UTC+8 上午5:39:13<[email protected]> 写道:
> From a previous thread where I was having the same problem:
>
> SOLUTION/WORKAROUND
> WARNING: this requires changing a core tiddler. The code is there for a
> reason. My use case is very specific in that I will only be doing this on
> a wiki that runs just to render static tiddlers.
>
> I noticed that the rendering process for the <script> tag renders as
> <safe-script>. So I just searched and found the tiddler responsible for
> the modification and commented out the code.
>
> The tiddler is $:/core/modules/widgets/element.js and the code to comment
> out is
>
> if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1)
> { tag = "safe-" + tag;
> }
>
> <https://tiddlywiki.com/#>Again this would I imagine create a very
> serious security risk in wikis open to the internet.
>
> I cannot stress enough that this could cause serious issues. Since it is
> a gist it may just be better to just copy/paste and avoid the potential for
> problems.
> On Friday, February 19, 2021 at 4:57:18 PM UTC-5 [email protected]
> wrote:
>
>>
>> Hi TW users,
>>
>> Does anyone know why the embed code for a gist doesn't display in a
>> tiddler? I get an empty box returned. I tried wrapping in an <iframe> also.
>>
>> This is the code I am trying to add:
>> <script src="https://gist.github.com/protrolium/e0dbd4bb0f1a396fcb55.js
>> "></script>
>>
>> macOS 10.13.6
>> Firefox 85.0.2
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/6bc0bc92-e11c-4567-ae4a-508096ddafdbn%40googlegroups.com.