aboutsummaryrefslogtreecommitdiffstats
path: root/syte/static/js/components/twitter.js
diff options
context:
space:
mode:
authorArnaud Bos <arnaud.bos@aeon-consulting.fr>2012-10-20 02:52:02 +0200
committerArnaud Bos <arnaud.bos@aeon-consulting.fr>2012-10-20 02:52:02 +0200
commit3ffd14fa4da0ca71e1f97a070973e4994bae8f61 (patch)
treedd7fea1a54417fc5df25eb559870c6ad06019ef1 /syte/static/js/components/twitter.js
parent01a8792a5116a305368d9d98fa366923086e0633 (diff)
downloadpelican-themes-3ffd14fa4da0ca71e1f97a070973e4994bae8f61.tar.gz
add client side social integration, use webassets
Diffstat (limited to 'syte/static/js/components/twitter.js')
-rw-r--r--syte/static/js/components/twitter.js82
1 files changed, 0 insertions, 82 deletions
diff --git a/syte/static/js/components/twitter.js b/syte/static/js/components/twitter.js
deleted file mode 100644
index 4a8bb30..0000000
--- a/syte/static/js/components/twitter.js
+++ /dev/null
@@ -1,82 +0,0 @@
-
-function setupTwitter(url, el) {
- var href = el.href;
-
- if ($('#twitter-profile').length > 0) {
- window.location = href;
- return;
- }
-
- var params = url.attr('path').split('/').filter(function(w) {
- if (w.length)
- return true;
- return false;
- })
-
- if (params.length == 1) {
- var username = params[0];
-
- var spinner = new Spinner(spin_opts).spin();
- $('#twitter-link').append(spinner.el);
-
- require(["json!/twitter/" + username, "text!templates/twitter-view.html"],
- function(twitter_data, twitter_view) {
- if (twitter_data.error || twitter_data.length == 0) {
- window.location = href;
- return;
- }
-
- var template = Handlebars.compile(twitter_view);
-
- var tweets = [];
- $.each(twitter_data, function(i, t) {
- if (i > 3)
- return;
-
- //'ddd MMM DD HH:mm:ss ZZ YYYY'
- t.formated_date = moment(t.created_at).fromNow();
- t.f_text = twitterLinkify(t.text);
- tweets.push(t);
- });
-
- var user = twitter_data[0].user;
- user.statuses_count = numberWithCommas(user.statuses_count);
- user.friends_count = numberWithCommas(user.friends_count);
- user.followers_count = numberWithCommas(user.followers_count);
- user.f_description = twitterLinkify(user.description);
-
- var template_data = {
- "user": user,
- "tweets": tweets
- }
-
- $(template(template_data)).modal().on('hidden', function () {
- $(this).remove();
- adjustSelection('home-link');
- })
-
- spinner.stop();
- });
-
- return;
- }
-
- window.location = href;
-}
-
-function twitterLinkify(text) {
- text = text.replace(/(https?:\/\/\S+)/gi, function (s) {
- return '<a href="' + s + '">' + s + '</a>';
- });
-
- text = text.replace(/(^|) @(\w+)/gi, function (s) {
- return '<a href="http://twitter.com/' + s + '">' + s + '</a>';
- });
-
- text = text.replace(/(^|) #(\w+)/gi, function (s) {
- return '<a href="http://search.twitter.com/search?q=' + s.replace(/#/,'%23') + '">' + s + '</a>';
- });
-
- return text;
-}
-