Skip to content

Commit

Permalink
initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
harthur committed Feb 29, 2012
0 parents commit 4134e2f
Show file tree
Hide file tree
Showing 10 changed files with 2,281 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apis.js
@@ -0,0 +1,20 @@
function getMeetupStuff(method, params, callback) {
var url = "http://api.meetup.com/2/" + method + "/?callback=?";
params = $.extend({
key: "29363e123f3a52532a7b306b95b4d",
group_urlname: "Women-Who-Code-SF"
}, params);

$.getJSON(url, params, callback);
}

function searchTwitter(term, callback) {
var url = "http://search.twitter.com/search.json?callback=?";
var params = {
q: term,
rpp: 5,
result_type: "recent"
};

$.getJSON(url, params, callback);
}
1,493 changes: 1,493 additions & 0 deletions handlebars.js

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions index.html
@@ -0,0 +1,61 @@
<html>
<head>
<link rel="stylesheet" href="normalize.css"/>
<link rel="stylesheet" href="wwcode.css"/>

<script src="jquery.js"></script>
<script src="jquery.timeago.js"></script>
<script src="handlebars.js"></script>
<script src="wwcode.js"></script>
<script src="apis.js"></script>

<script id="event-template" type="text/html">
<a href="{{event_url}}" class="event {{status}}">
<div class="event-date">
{{date time}}
</div>
<div class="event-name">
{{name}}
</div>
</a>
</script>

<script id="tweet-template" type="text/html">
<div class="tweet">
<img class="tweet-image" src="{{profile_image_url}}">
</img>
<div class="tweet-info">
<div class="tweet-title">
<a href="http://twitter.com/{{from_user}}" class="tweet-link">
<span class="tweet-name">
{{from_user_name}}
</span>
<span class="tweet-username">
@{{from_user}}
</span>
</a>
<span class="tweet-time">
{{timeago created_at}}
</span>
</div>
<div class="tweet-body">
{{text}}
</div>
</div>
</div>
</script>

</head>
<body>
<img id="title-image" src="wwcode.png"></img>
<div id="title">
Women Who Code SF
</div>
<div id="content">
<section id="events">
</section>
<section id="tweets">
</section>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions jquery.js

Large diffs are not rendered by default.

146 changes: 146 additions & 0 deletions jquery.timeago.js
@@ -0,0 +1,146 @@
/*
* timeago: a jQuery plugin, version: 0.9.3 (2011-01-21)
* @requires jQuery v1.2.3 or later
*
* Timeago is a jQuery plugin that makes it easy to support automatically
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
*
* For usage and examples, visit:
* http://timeago.yarp.com/
*
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
*/
(function($) {
$.timeago = function(timestamp) {
if (timestamp instanceof Date) {
return inWords(timestamp);
} else if (typeof timestamp === "string") {
return inWords($.timeago.parse(timestamp));
} else {
return inWords($.timeago.datetime(timestamp));
}
};
var $t = $.timeago;

$.extend($.timeago, {
settings: {
refreshMillis: 60000,
allowFuture: false,
strings: {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "ago",
suffixFromNow: "from now",
seconds: "less than a minute",
minute: "a minute",
minutes: "%d minutes",
hour: "1 hour",
hours: "%d hours",
day: "a day",
days: "%d days",
month: "one month",
months: "%d months",
year: "a year",
years: "%d years",
numbers: []
}
},
inWords: function(distanceMillis) {
var $l = this.settings.strings;
var prefix = $l.prefixAgo;
var suffix = $l.suffixAgo;
if (this.settings.allowFuture) {
if (distanceMillis < 0) {
prefix = $l.prefixFromNow;
suffix = $l.suffixFromNow;
}
distanceMillis = Math.abs(distanceMillis);
}

var seconds = distanceMillis / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
var years = days / 365;

function substitute(stringOrFunction, number) {
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
var value = ($l.numbers && $l.numbers[number]) || number;
return string.replace(/%d/i, value);
}

var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
seconds < 90 && substitute($l.minute, 1) ||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && substitute($l.hour, 1) ||
hours < 36 && substitute($l.hours, Math.round(hours)) ||
days < 30 && substitute($l.days, Math.round(days)) ||
days < 60 && substitute($l.month, 1) ||
days < 365 && substitute($l.months, Math.floor(days / 30)) ||
years < 2 && substitute($l.year, 1) ||
substitute($l.years, Math.floor(years));

return $.trim([prefix, words, suffix].join(" "));
},
parse: function(iso8601) {
var s = $.trim(iso8601);
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
s = s.replace(/T/," ").replace(/Z/," UTC");
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
return new Date(s);
},
datetime: function(elem) {
// jQuery's `is()` doesn't play well with HTML5 in IE
var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
return $t.parse(iso8601);
}
});

$.fn.timeago = function() {
var self = this;
self.each(refresh);

var $s = $t.settings;
if ($s.refreshMillis > 0) {
setInterval(function() { self.each(refresh); }, $s.refreshMillis);
}
return self;
};

function refresh() {
var data = prepareData(this);
if (!isNaN(data.datetime)) {
$(this).text(inWords(data.datetime));
}
return this;
}

function prepareData(element) {
element = $(element);
if (!element.data("timeago")) {
element.data("timeago", { datetime: $t.datetime(element) });
var text = $.trim(element.text());
if (text.length > 0) {
element.attr("title", text);
}
}
return element.data("timeago");
}

function inWords(date) {
return $t.inWords(distance(date));
}

function distance(date) {
return (new Date().getTime() - date.getTime());
}

// fix for IE6 suckage
document.createElement("abbr");
document.createElement("time");
}(jQuery));

0 comments on commit 4134e2f

Please sign in to comment.