Permalink
Browse files

added api.js that has getPermalink(), make use of it in the current t…

…emplates
  • Loading branch information...
cpetzold committed Apr 13, 2011
1 parent 28a355d commit 4b587b6691f803ac439033ada2eb9bc63abc8657
Showing with 144 additions and 130 deletions.
  1. +14 −0 api.js
  2. +115 −117 kenburns/index.html
  3. +8 −4 slideshow/index.html
  4. +1 −4 slideshow/js/script.js
  5. +6 −5 snowstack/index.html
View
14 api.js
@@ -0,0 +1,14 @@
+function Storify() {}
+
+Storify.prototype = {
+ getPermalink: function() {
+ var permalink = null;
+
+ if (window.location.hash.match(/http\:\/\/.*storify\.com/)) {
+ permalink = window.location.hash.substr(1);
+ }
+
+ return permalink;
+ }
+
+};
View
@@ -44,137 +44,135 @@ <h3>Byline</h3>
</div>
+ <script src="../api.js"></script>
<script>
-var storyurl;
+ var storify = new Storify();
+ var storyurl = storify.getPermalink() || 'http://storify.com/storify/testimonials';
-if (window.location.hash && window.location.hash.match(/http:\/\/storify\.com\//)) storyurl = window.location.hash.substr(1);
-else storyurl = 'http://storify.com/nzherald/reaction-to-japanese-tsunami';
+ $.getJSON(storyurl + '.json?metadata=1&callback=?', function(json) {
+ renderStory(json);
+ });
+ $('#story').removeClass("hidden");
-$.getJSON(storyurl + '.json?metadata=1&callback=?', function(json) {
- renderStory(json);
-});
-$('#story').removeClass("hidden");
+ function renderStory(story) {
-function renderStory(story) {
+ // console.log("Story: ", story);
- console.log("Story: ", story);
+ $('#story #header h1').html(story.title);
+ $('#story #header h2').html(story.description);
+ $('#story #header h3').html('By ' + story.author.name);
+ $('#story #header img#byline').attr("src", story.author.avatar);
- $('#story #header h1').html(story.title);
- $('#story #header h2').html(story.description);
- $('#story #header h3').html('By ' + story.author.name);
- $('#story #header img#byline').attr("src", story.author.avatar);
+ var storyImages = [],
+ people = '';
+ people_array = [],
+ tweets = {};
- var storyImages = [],
- people = '';
- people_array = [],
- tweets = {};
+ for (var i in story.elements) {
+ var el = story.elements[i];
- for (var i in story.elements) {
- var el = story.elements[i];
+ if (el.image && el.image.src) {
+ storyImages.push(el.image.src);
+ }
- if (el.image && el.image.src) {
- storyImages.push(el.image.src);
- }
+ if (el.author.avatar) {
+ if (people_array.indexOf(el.author.avatar) == -1) {
+ people_array.push(el.author.avatar);
+ people += '<a href="#" title="' + addslashes(strip_tags(el.description)) + '" class="avatar"><img src="' + el.author.avatar + '" /><a>';
+ }
+ }
+ }
- if (el.author.avatar) {
- if (people_array.indexOf(el.author.avatar) == -1) {
- people_array.push(el.author.avatar);
- people += '<a href="#" title="' + addslashes(strip_tags(el.description)) + '" class="avatar"><img src="' + el.author.avatar + '" /><a>';
- }
- }
- }
+ $('#story #people').html(people);
- $('#story #people').html(people);
-
- $('a.avatar').poshytip({
- className: 'tip-twitter',
- showTimeout: 1,
- alignTo: 'target',
- alignX: 'center',
- offsetY: 40,
- allowTipHover: false,
- fade: true,
- slide: true
- });
- console.log("Images: ", storyImages);
+ $('a.avatar').poshytip({
+ className: 'tip-twitter',
+ showTimeout: 1,
+ alignTo: 'target',
+ alignX: 'center',
+ offsetY: 40,
+ allowTipHover: false,
+ fade: true,
+ slide: true
+ });
+ // console.log("Images: ", storyImages);
- $('#kenburns').kenburns({
- images: storyImages,
- frames_per_second: 30,
- display_time: 10000,
- fade_time: 1000,
- zoom: 1.5,
- width: 384,
- height:416,
- background_color: '#ffffff'
- });
-
-}
-
-function strip_tags (input, allowed) {
- // Strips HTML and PHP tags from a string
- //
- // version: 1103.1210
- // discuss at: http://phpjs.org/functions/strip_tags
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + improved by: Luke Godfrey
- // + input by: Pul
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + bugfixed by: Onno Marsman
- // + input by: Alex
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + input by: Marc Palau
- // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + input by: Brett Zamir (http://brett-zamir.me)
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + bugfixed by: Eric Nagel
- // + input by: Bobby Drake
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + bugfixed by: Tomasz Wesolowski
- // + input by: Evertjan Garretsen
- // + revised by: Rafał Kukawski (http://blog.kukawski.pl/)
- // * example 1: strip_tags('<p>Kevin</p> <b>van</b> <i>Zonneveld</i>', '<i><b>');
- // * returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
- // * example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
- // * returns 2: '<p>Kevin van Zonneveld</p>'
- // * example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
- // * returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
- // * example 4: strip_tags('1 < 5 5 > 1');
- // * returns 4: '1 < 5 5 > 1'
- // * example 5: strip_tags('1 <br/> 1');
- // * returns 5: '1 1'
- // * example 6: strip_tags('1 <br/> 1', '<br>');
- // * returns 6: '1 1'
- // * example 7: strip_tags('1 <br/> 1', '<br><br/>');
- // * returns 7: '1 <br/> 1'
- allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
- var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
- commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
- return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
- return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
- });
-}
-function addslashes (str) {
- // Escapes single quote, double quotes and backslash characters in a string with backslashes
- //
- // version: 1103.1210
- // discuss at: http://phpjs.org/functions/addslashes
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + improved by: Ates Goral (http://magnetiq.com)
- // + improved by: marrtins
- // + improved by: Nate
- // + improved by: Onno Marsman
- // + input by: Denny Wardhana
- // + improved by: Brett Zamir (http://brett-zamir.me)
- // + improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
- // * example 1: addslashes("kevin's birthday");
- // * returns 1: 'kevin\'s birthday'
- return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
-}
-</script>
-
+ $('#kenburns').kenburns({
+ images: storyImages,
+ frames_per_second: 30,
+ display_time: 10000,
+ fade_time: 1000,
+ zoom: 1.5,
+ width: 384,
+ height:416,
+ background_color: '#ffffff'
+ });
+
+ }
+
+ function strip_tags (input, allowed) {
+ // Strips HTML and PHP tags from a string
+ //
+ // version: 1103.1210
+ // discuss at: http://phpjs.org/functions/strip_tags
+ // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: Luke Godfrey
+ // + input by: Pul
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + bugfixed by: Onno Marsman
+ // + input by: Alex
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + input by: Marc Palau
+ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + input by: Brett Zamir (http://brett-zamir.me)
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + bugfixed by: Eric Nagel
+ // + input by: Bobby Drake
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + bugfixed by: Tomasz Wesolowski
+ // + input by: Evertjan Garretsen
+ // + revised by: Rafał Kukawski (http://blog.kukawski.pl/)
+ // * example 1: strip_tags('<p>Kevin</p> <b>van</b> <i>Zonneveld</i>', '<i><b>');
+ // * returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
+ // * example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
+ // * returns 2: '<p>Kevin van Zonneveld</p>'
+ // * example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
+ // * returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
+ // * example 4: strip_tags('1 < 5 5 > 1');
+ // * returns 4: '1 < 5 5 > 1'
+ // * example 5: strip_tags('1 <br/> 1');
+ // * returns 5: '1 1'
+ // * example 6: strip_tags('1 <br/> 1', '<br>');
+ // * returns 6: '1 1'
+ // * example 7: strip_tags('1 <br/> 1', '<br><br/>');
+ // * returns 7: '1 <br/> 1'
+ allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
+ var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
+ commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
+ return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
+ return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
+ });
+ }
+ function addslashes (str) {
+ // Escapes single quote, double quotes and backslash characters in a string with backslashes
+ //
+ // version: 1103.1210
+ // discuss at: http://phpjs.org/functions/addslashes
+ // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: Ates Goral (http://magnetiq.com)
+ // + improved by: marrtins
+ // + improved by: Nate
+ // + improved by: Onno Marsman
+ // + input by: Denny Wardhana
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
+ // * example 1: addslashes("kevin's birthday");
+ // * returns 1: 'kevin\'s birthday'
+ return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
+ }
+ </script>
</body>
</html>
View
@@ -20,13 +20,17 @@
<div id="twitterShow"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
+ <script src="../api.js"></script>
<script>
- STORIFY_JQUERY = jQuery;
+ STORIFY_JQUERY = jQuery;
+
+ var storify = new Storify();
+ STORIFY_PERMALINK = storify.getPermalink() || 'http://storify.com/storify/testimonials';
</script>
<script src="http://static.storify.com/js/utils.js"></script>
-
- <script src="js/plugins.js?v=1"></script>
- <script src="js/script.js?v=1"></script>
+
+ <script src="js/plugins.js"></script>
+ <script src="js/script.js"></script>
</body>
</html>
View
@@ -158,10 +158,7 @@ $(document).ready(function() {
}
function init() {
- var storyurl;
-
- if (window.location.hash && window.location.hash.match(/http\:\/\/.*storify\.com/)) storyurl = window.location.hash.substr(1);
- else storyurl = (typeof STORIFY_PERMALINK != 'undefined') ? STORIFY_PERMALINK : 'http://storify.com/storify/testimonials';
+ var storyurl = STORIFY_PERMALINK || 'http://storify.com/storify/testimonials';
$.getJSON(storyurl + '.json?metadata=1&callback=?', function(data) {
$('#title').append(getTitle(data.author));
View
@@ -21,14 +21,15 @@
<meta name="Description" content="Snow Stack is a demo of WebKit CSS 3D visual effects with latest WebKit nightly on Mac OS X Snow Leopard" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
-
+<script src="../api.js"></script>
<script>
+var storify_api = new Storify()
+ , storyurl = storify_api.getPermalink() || 'http://storify.com/storify/testimonials';
+
function storify(callback, page)
{
- var storyurl, page = page || 1;
- if (window.location.hash && window.location.hash.match(/http:\/\/storify\.com\//)) storyurl = window.location.hash.substr(1);
- else storyurl = 'http://storify.com/torontostar/online-reaction-to-libya-chaos';
-
+ var page = page || 1;
+
jQuery.getJSON(storyurl+'.json?page='+page+'&callback=?', function(story)
{
var images = [];

0 comments on commit 4b587b6

Please sign in to comment.