Saying goodbye to the Twitter Search API :-(
authorveltr
Thu, 13 Jun 2013 14:31:35 +0200
changeset 192 47aa37d3e750
parent 191 0aa26796c69c
child 193 7d95ace8c08f
Saying goodbye to the Twitter Search API :-(
client/css/renkan.css
client/js/i18n.js
client/js/space-editor.js
client/js/twitter-bin.js
client/render-test.html
client/space-editor.html
server/src/main/webapp/WEB-INF/templates/renkanProjectEdit.html
--- a/client/css/renkan.css	Thu Jun 06 18:48:57 2013 +0200
+++ b/client/css/renkan.css	Thu Jun 13 14:31:35 2013 +0200
@@ -611,30 +611,6 @@
     color: #303080;
 }
 
-.Rk-Twitter-Icon {
-    background-image: url(../img/search-logos.png); background-position: 0 -80px;
-}
-
-.Rk-Twitter-Title-Icon {
-    height: 20px; background: url(../img/search-logos.png); background-position: 0 -80px;
-}
-
-.Rk-Twitter-TwImage {
-    float: left; width: 48px; height: 48px; margin: 2px 0;
-}
-
-.Rk-Twitter-TwTitle, .Rk-Twitter-TwDate, .Rk-Twitter-TwText, .Rk-Twitter-TwActions {
-    margin: 2px 0 2px 50px;
-}
-
-p.Rk-Twitter-TwDate {
-    font-size: 11px; font-style: italic;
-}
-
-p.Rk-Twitter-TwActions {
-    font-size: 11px;
-}
-
 .Rk-Bin-Main .searchmatch {
     background: #ffff80;
 }
--- a/client/js/i18n.js	Thu Jun 06 18:48:57 2013 +0200
+++ b/client/js/i18n.js	Thu Jun 13 14:31:35 2013 +0200
@@ -29,7 +29,6 @@
         "Click on the background canvas to add a node": "Cliquer sur le fond du graphe pour rajouter un nœud",
         "Click on a first node to start the edge": "Cliquer sur un premier nœud pour commencer le lien",
         "Click on a second node to complete the edge": "Cliquer sur un second nœud pour terminer le lien",
-        "Twitter": "Twitter",
         "Wikipedia": "Wikipédia",
         "Wikipedia in ": "Wikipédia en ",
         "French": "Français",
--- a/client/js/space-editor.js	Thu Jun 06 18:48:57 2013 +0200
+++ b/client/js/space-editor.js	Thu Jun 13 14:31:35 2013 +0200
@@ -174,7 +174,7 @@
                 ldtsection.hide();
             }
             
-            if (data.type === "Wikipedia" || data.type === "Twitter" || (data.type === "Ldt" && data.ldt_type === "Results")) {
+            if (data.type === "Wikipedia" || (data.type === "Ldt" && data.ldt_type === "Results")) {
                 data.search = kwfield.val();
                 kwdisplay.text(data.search);
                 kwsection.show();
@@ -286,7 +286,7 @@
             
         }
         
-        if (data.type === "Wikipedia" || data.type === "Twitter" || (data.type === "Ldt" && data.ldt_type === "Results")) {
+        if (data.type === "Wikipedia" || (data.type === "Ldt" && data.ldt_type === "Results")) {
             kwfield.val(data.search || "");
         }
         
@@ -326,14 +326,16 @@
     
     $(".add-search-engine").click(function() {
         addSearchEngine({
-            type:"Twitter"
+            type: "Wikipedia",
+            lang: "en"
         }, true);
         return false;
     });
     
     $(".add-bin").click(function() {
         addBin({
-            type:"Twitter",
+            type: "Wikipedia",
+            lang: "en",
             search: ""
         }, true);
         return false;
--- a/client/js/twitter-bin.js	Thu Jun 06 18:48:57 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-Rkns.Twitter = {
-};
-
-Rkns.Twitter.Search = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.opts = _opts;
-};
-
-Rkns.Twitter.Search.prototype.getBgClass = function() {
-    return "Rk-Twitter-Icon";
-};
-
-Rkns.Twitter.Search.prototype.getSearchTitle = function() {
-    return this.renkan.translate("Twitter");
-};
-
-Rkns.Twitter.Search.prototype.search = function(_q) {
-    this.renkan.tabs.push(
-        new Rkns.Twitter.Bin(this.renkan, {
-            search: _q
-        })
-    );
-};
-
-Rkns.Twitter.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-Rkns.Twitter.Bin.prototype.tweetTemplate = Rkns._.template(
-    '<li class="Rk-Twitter-Tweet Rk-Bin-Item" draggable="true" data-uri="http://twitter.com/<%=tweet.from_user%>/status/<%=tweet.id_str%>" '
-    + 'data-title="Tweet by @<%- tweet.from_user %>" data-description="<%-tweet.text%>" data-image="<%- tweet.profile_image_url %>">'
-    + '<img class="Rk-Twitter-TwImage" src="<%=tweet.profile_image_url%>" />'
-    + '<h4 class="Rk-Twitter-TwTitle"><a href="http://twitter.com/<%=tweet.from_user%>" target="_blank">@<%=tweet.from_user%></a> (<%=tweet.from_user_name%>)</h4>'
-    + '<p class="Rk-Twitter-TwDate"><%=date%></p>'
-    + '<p class="Rk-Twitter-TwText"><%=text%></p>'
-    + '<p class="Rk-Twitter-TwActions"><a class="Rk-Twitter-TwAction" href="http://twitter.com/<%=tweet.from_user%>/status/<%=tweet.id_str%>" target="_blank">show original</a> · '
-    + '<a href="http://twitter.com/intent/tweet?in_reply_to=<%=tweet.id_str%>" target="_blank">reply</a> · '
-    + '<a href="http://twitter.com/intent/retweet?tweet_id=<%=tweet.id_str%>" target="_blank">retweet</a> · '
-    + '<a href="http://twitter.com/intent/favorite?tweet_id=<%=tweet.id_str%>" target="_blank">favorite</a></p></li>'
-);
-
-Rkns.Twitter.Bin.prototype._init = function(_renkan, _opts) {
-    this.renkan = _renkan;
-    this.search = _opts.search;
-    this.title_icon_$.addClass('Rk-Twitter-Title-Icon');
-    this.title_$.html(this.search).addClass("Rk-Twitter-Title");
-    this.refresh();
-};
-
-Rkns.Twitter.Bin.prototype.render = function(searchstr) {
-    var _rgxp = new RegExp('('+(searchstr || this.search).replace(/(\W)/g,'\\$1')+')','gi');
-    if (searchstr) {
-        var rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i');
-    }
-    function highlight(_text) {
-        return _text.replace(_rgxp, "<span class='searchmatch'>$1</span>");
-    }
-    var _html = "",
-        _this = this,
-        count = 0;
-    Rkns._(this.data.results).each(function(_result) {
-        if (searchstr && !rxtest.test(_result.text)) {
-            return;
-        }
-        count++;
-        var _entities = [],
-            _users = _result.text.match(/@[\w_]+/gm),
-            _lastpos = 0;
-        if (_users) {
-            for (var _i = 0; _i < _users.length; _i++) {
-                var _m = _users[_i],
-                    _start = _lastpos + _result.text.substr(_lastpos).search(_m),
-                    _lastpos = _start + _m.length;
-                _entities.push({
-                    "text" : _m,
-                    "start" : _start,
-                    "end" : _lastpos,
-                    "link" :'<a href="http://twitter.com/' + _m.substr(1) + '" onclick="filtrerTexte(\'' + _m + '\'); return false;" target="_blank">',
-                });
-            }
-        }
-        var _hashes = _result.text.match(/([^&]|^)#[^\s,.!?=#@&;()]+/gm),
-            _lastpos = 0;
-        if (_hashes) {
-            for (var _i = 0; _i < _hashes.length; _i++) {
-                var _m = _hashes[_i],
-                    _h = ( _m[0] == '#' ? _m : _m.substr(1) ),
-                    _start = _lastpos + _result.text.substr(_lastpos).search(_h),
-                    _lastpos = _start + _h.length;
-                _entities.push({
-                    "text" : _h,
-                    "start" : _start,
-                    "end" : _lastpos,
-                    "link" :'<a href="http://twitter.com/search?q=' + encodeURIComponent(_h) + '" onclick="filtrerTexte(\'' + _.escape(_h) + '\'); return false;" target="_blank">',
-                });
-            }
-        }
-        
-        var _urls = _result.text.match(/(www\.|https?:\/\/)[\w.\/_\-]+/gim),
-            _lastpos = 0;
-        if (_urls) {
-            for (var _i = 0; _i < _urls.length; _i++) {
-                var _m = _urls[_i],
-                    _start = _lastpos + _result.text.substr(_lastpos).search(_m),
-                    _lastpos = _start + _m.length;
-                _entities.push({
-                    "text" : _m,
-                    "start" : _start,
-                    "end" : _lastpos,
-                    "link" :'<a href="' + _m + '" target="_blank">',
-                });
-            }
-        }
-        _entities = Rkns._(_entities).sortBy(function(a) { return a.start; });
-        var _lastend = 0,
-            _text = Rkns._(_entities).map(function(_e) {
-                var _txt = highlight(_result.text.substring(_lastend, _e.start)) + _e.link + highlight(_e.text) + '</a>';
-                _lastend = _e.end;
-                return _txt;
-            }).join("") + highlight(_result.text.substring(_lastend));
-        
-        _html += _this.tweetTemplate({
-            tweet: _result,
-            date: new Date(_result.created_at.replace(/(\+|-)/,'UTC$1')).toLocaleString(),
-            text: _text
-        });
-    });
-    this.main_$.html(_html);
-    if (searchstr && count) {
-        this.count_$.text(count).show();
-    } else {
-        this.count_$.hide();
-    }
-    if (searchstr && !count) {
-        this.$.hide();
-    } else {
-        this.$.show();
-    }
-    this.renkan.resizeBins();
-};
-
-Rkns.Twitter.Bin.prototype.refresh = function() {
-    var _this = this;
-    Rkns.$.ajax({
-        url: "http://search.twitter.com/search.json",
-        dataType: "jsonp",
-        data: {
-            q: this.search,
-            rpp: 100
-        },
-        success: function(_data) {
-            _this.data = _data;
-            _this.render();
-        }
-    });
-};
--- a/client/render-test.html	Thu Jun 06 18:48:57 2013 +0200
+++ b/client/render-test.html	Thu Jun 13 14:31:35 2013 +0200
@@ -19,7 +19,6 @@
         <script src="js/full-json.js"></script>
         <script src="js/list-bin.js"></script>
         <script src="js/ldtjson-bin.js"></script>
-        <script src="js/twitter-bin.js"></script>
         <script src="js/wikipedia-bin.js"></script>
         <script src="js/paper-renderer.js"></script>
         <script type="text/javascript">
@@ -59,9 +58,6 @@
                         {
                             type: "Wikipedia",
                             lang: "fr"
-                        }, 
-                        {
-                            type: "Twitter"
                         }
                     ],
                     property_files: [ "data/properties.json" ],
--- a/client/space-editor.html	Thu Jun 06 18:48:57 2013 +0200
+++ b/client/space-editor.html	Thu Jun 13 14:31:35 2013 +0200
@@ -19,7 +19,6 @@
         <script src="js/models.js"></script>
         <script src="js/list-bin.js"></script>
         <script src="js/ldtjson-bin.js"></script>
-        <script src="js/twitter-bin.js"></script>
         <script src="js/wikipedia-bin.js"></script>
         <script src="js/space-editor.js"></script>
         
@@ -44,7 +43,6 @@
                         <label>Type:</label>
                         <span class="display-value"></span>
                         <select class="edit-value">
-                            <option value="Twitter">Twitter</option>
                             <option value="Wikipedia">Wikipedia</option>
                             <option value="Ldt">Lignes de Temps</option>
                         </select>
@@ -81,7 +79,6 @@
                         <span class="display-value"></span>
                         <select class="edit-value">
                             <option value="ResourceList">Resource List</option>
-                            <option value="Twitter">Twitter Search Results</option>
                             <option value="Wikipedia">Wikipedia Search Results</option>
                             <option value="Ldt">Lignes de Temps</option>
                         </select>
--- a/server/src/main/webapp/WEB-INF/templates/renkanProjectEdit.html	Thu Jun 06 18:48:57 2013 +0200
+++ b/server/src/main/webapp/WEB-INF/templates/renkanProjectEdit.html	Thu Jun 13 14:31:35 2013 +0200
@@ -19,7 +19,6 @@
         <script src="js/defaults.js" th:src="@{/static/js/defaults.js}"></script>
         <script src="js/i18n.js" th:src="@{/static/js/i18n.js}"></script>
         <script src="js/models.js" th:src="@{/static/js/models.js}"></script>
-        <script src="js/twitter-bin.js" th:src="@{/static/js/twitter-bin.js}"></script>
         <script src="js/wikipedia-bin.js" th:src="@{/static/js/wikipedia-bin.js}"></script>
         <script src="js/ldtjson-bin.js" th:src="@{/static/js/ldtjson-bin.js}"></script>
         <script src="js/list-bin.js" th:src="@{/static/js/list-bin.js}"></script>
@@ -51,10 +50,6 @@
                             search: "Digital Humanities"
                         },
                         {
-                            type: "Twitter",
-                            search: "Digital Humanities"
-                        },
-                        {
                             title: "LDT Project",
                             type: "Ldt",
                             ldt_type: "Project",
@@ -74,9 +69,6 @@
                         {
                             type: "Wikipedia",
                             lang: "ja"
-                        },
-                        {
-                            type: "Twitter"
                         }
                     ],
                     property_files: [