Gist in blogger's dynamic views

I want to embed my gists ( gist.github ) in my blogger blog. But as explained in this question, dynamic views do not directly support javascript.

From moski's post (as mentioned in the answer) it can be embedded in the gist.

What if I only want to insert only one file from my text?

For example:

<script src="https://gist.github.com/3975635.js?file=regcomp.c"></script> 
+8
javascript syntax-highlighting gist blogger blogger-dynamic-views
source share
1 answer

Looking at the moski blog, its description and gist snippets ( gistLoader.js and gistBlogger.js ), I can assume that to achieve your goal you need to modify this code a bit.

Currently, when you add

 <script src="https://raw.github.com/moski/gist-Blogger/master/public/gistLoader.js" type="text/javascript"></script> 

at the bottom of your posts, that this script is looking for this other code added to your blog

 <div class="gistLoad" data-id="GistID" id="gist-GistID">Loading ....</div> 

extracts the data-id attribute and enters the required code to load the script with src set to

 'https://gist.github.com/' + id + '.js' 

Now, if I understood correctly what the code is doing, by editing the second moski HTML code this way:

 <div class="gistLoad" data-id="GistID" data-file="GistFile" id="gist-GistID">Loading ....</div> 

and a function in moski gistBlogger.js to get (if defined) a new data-file attribute, you can generate a new src for input, for example:

 'https://gist.github.com/' + id + '.js?file=' + file 

It should work.

+2
source share

All Articles