Skip to content

Instantly share code, notes, and snippets.

@mariemosley
Last active November 5, 2016 09:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariemosley/f3bb583947d8cd04d3ad to your computer and use it in GitHub Desktop.
Save mariemosley/f3bb583947d8cd04d3ad to your computer and use it in GitHub Desktop.
A Pinterest gallery designed for use in an HTML/JavaScript gadget on Blogger. Blogger installation tutorial at: http://www.codeitpretty.com/2015/01/a-pinterest-gadget-for-blogger-updated.html Unminified version at: https://gist.github.com/mariemosley/27fdb7e8a171eec16dae
<!-- BEGIN CODE IT PRETTY PINTEREST GALLERY -->
<style>
#pinterest-gallery {
overflow: auto;
width: 210px;
list-style: none;
}
#pinterest-gallery li {
float: left;
width: 100px;
height: 100px;
background-size: cover;
margin: .1em;
padding: 0;
border: none;
}
#pinterest-gallery img { border: none; }
.pinterest-link {
display: block;
overflow: hidden;
text-indent: 100%;
height: 100%;
white-space: nowrap;
}
/* Internet Explorer correction */
#pinterest-gallery li a {
color: transparent;
line-height: 1px;
font-size: 0px;
}
</style>
<div id="pinterest-gallery"></div>
<!-- If you already have jQuery installed in your template, remove the next line -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- end jQuery link -->
<script type="text/javascript">
$( document ).ready(function() {
//GALLERY SETTINGS
var thumbnailCount = 6;
var username = '';
var profile = true;
var board = false;
var boardname = '';
var newWindow = false;
//END GALLERY SETTINGS. DO NOT EDIT BELOW THIS LINE
var url;var urlPrefix="https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=https://www.pinterest.com/";if(board===true&&profile===true||board===false&&profile===false){$("#pinterest-gallery").append("<p>Error: please choose a profile gallery or board gallery.</p>")}else{if(profile===true){url=urlPrefix+username+"/feed.rss&num="+thumbnailCount}else{if(board===true&&boardname===""){$("#pinterest-gallery").append("<p>Error: Please specify a boardname.</p>")}url=urlPrefix+username+"/"+boardname+".rss&num="+thumbnailCount}}$.ajax({url:url,dataType:"jsonp",success:function(e){$.each(e.responseData.feed.entries,function(t){var n=e.responseData.feed.entries;var r=n[t].title;var i=n[t].link;var s=n[t].content;var o=s.indexOf("http");var u=s.indexOf('"></a>');var a=s.substring(o,u);var f=$('<li><a class="pinterest-link" href="'+i+'">'+r+"</a></li>");if(newWindow===true){$(".pinterest-link").attr("target","_blank")}f.appendTo("#pinterest-gallery").css("background-image","url("+a+")")})}})
});
</script>
<!-- END CODE IT PRETTY PINTEREST GALLERY-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment