Commit b6548e0c19f4c43589d95d663f6e0c991b5a92a8

Authored by Macartur Sousa
1 parent 9df183c3

Added test and refactored gitlab_view

fixtures: add fixtures to use colab_association
views: change some names
tests: added tests to gitlab_activities view

Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
src/colab-spb-plugin/src/colab_spb/fixtures/__init__.py 0 → 100644
src/colab-spb-plugin/src/colab_spb/fixtures/colab_spb.json
... ... @@ -379,5 +379,35 @@
379 379 },
380 380 "model": "super_archives.emailaddress",
381 381 "pk": 1
  382 +},
  383 +{
  384 + "fields": {
  385 + "description": null,
  386 + "created_at": "2015-09-29T14:36:58Z",
  387 + "user": null,
  388 + "identifier": "example_community",
  389 + "categories": [],
  390 + "name": "example_community"
  391 + },
  392 + "model": "colab_noosfero.noosferocommunity",
  393 + "pk": 69
  394 +},
  395 +{
  396 + "fields": {
  397 + "path": "example_community",
  398 + "name": "example_community",
  399 + "owner_id": null
  400 + },
  401 + "model": "colab_gitlab.gitlabgroup",
  402 + "pk": 23
  403 +},
  404 +{
  405 + "fields": {
  406 + "mail_list": 1,
  407 + "group": 23,
  408 + "community": 69
  409 + },
  410 + "model": "colab_spb.communityassociations",
  411 + "pk": 2
382 412 }
383 413 ]
... ...
src/colab-spb-plugin/src/colab_spb/static/spb/js/jquery.timeago.js 0 → 100644
... ... @@ -0,0 +1,223 @@
  1 +/**
  2 + * Timeago is a jQuery plugin that makes it easy to support automatically
  3 + * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
  4 + *
  5 + * @name timeago
  6 + * @version 1.4.2
  7 + * @requires jQuery v1.2.3+
  8 + * @author Ryan McGeary
  9 + * @license MIT License - http://www.opensource.org/licenses/mit-license.php
  10 + *
  11 + * For usage and examples, visit:
  12 + * http://timeago.yarp.com/
  13 + *
  14 + * Copyright (c) 2008-2015, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
  15 + */
  16 +
  17 +(function (factory) {
  18 + if (typeof define === 'function' && define.amd) {
  19 + // AMD. Register as an anonymous module.
  20 + define(['jquery'], factory);
  21 + } if (typeof module === 'object' && typeof module.exports === 'object') {
  22 + factory(require('jquery'));
  23 + } else {
  24 + // Browser globals
  25 + factory(jQuery);
  26 + }
  27 +}(function ($) {
  28 + $.timeago = function(timestamp) {
  29 + if (timestamp instanceof Date) {
  30 + return inWords(timestamp);
  31 + } else if (typeof timestamp === "string") {
  32 + return inWords($.timeago.parse(timestamp));
  33 + } else if (typeof timestamp === "number") {
  34 + return inWords(new Date(timestamp));
  35 + } else {
  36 + return inWords($.timeago.datetime(timestamp));
  37 + }
  38 + };
  39 + var $t = $.timeago;
  40 +
  41 + $.extend($.timeago, {
  42 + settings: {
  43 + refreshMillis: 60000,
  44 + allowPast: true,
  45 + allowFuture: false,
  46 + localeTitle: false,
  47 + cutoff: 0,
  48 + strings: {
  49 + prefixAgo: null,
  50 + prefixFromNow: null,
  51 + suffixAgo: "ago",
  52 + suffixFromNow: "from now",
  53 + inPast: 'any moment now',
  54 + seconds: "less than a minute",
  55 + minute: "about a minute",
  56 + minutes: "%d minutes",
  57 + hour: "about an hour",
  58 + hours: "about %d hours",
  59 + day: "a day",
  60 + days: "%d days",
  61 + month: "about a month",
  62 + months: "%d months",
  63 + year: "about a year",
  64 + years: "%d years",
  65 + wordSeparator: " ",
  66 + numbers: []
  67 + }
  68 + },
  69 +
  70 + inWords: function(distanceMillis) {
  71 + if(!this.settings.allowPast && ! this.settings.allowFuture) {
  72 + throw 'timeago allowPast and allowFuture settings can not both be set to false.';
  73 + }
  74 +
  75 + var $l = this.settings.strings;
  76 + var prefix = $l.prefixAgo;
  77 + var suffix = $l.suffixAgo;
  78 + if (this.settings.allowFuture) {
  79 + if (distanceMillis < 0) {
  80 + prefix = $l.prefixFromNow;
  81 + suffix = $l.suffixFromNow;
  82 + }
  83 + }
  84 +
  85 + if(!this.settings.allowPast && distanceMillis >= 0) {
  86 + return this.settings.strings.inPast;
  87 + }
  88 +
  89 + var seconds = Math.abs(distanceMillis) / 1000;
  90 + var minutes = seconds / 60;
  91 + var hours = minutes / 60;
  92 + var days = hours / 24;
  93 + var years = days / 365;
  94 +
  95 + function substitute(stringOrFunction, number) {
  96 + var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
  97 + var value = ($l.numbers && $l.numbers[number]) || number;
  98 + return string.replace(/%d/i, value);
  99 + }
  100 +
  101 + var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
  102 + seconds < 90 && substitute($l.minute, 1) ||
  103 + minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
  104 + minutes < 90 && substitute($l.hour, 1) ||
  105 + hours < 24 && substitute($l.hours, Math.round(hours)) ||
  106 + hours < 42 && substitute($l.day, 1) ||
  107 + days < 30 && substitute($l.days, Math.round(days)) ||
  108 + days < 45 && substitute($l.month, 1) ||
  109 + days < 365 && substitute($l.months, Math.round(days / 30)) ||
  110 + years < 1.5 && substitute($l.year, 1) ||
  111 + substitute($l.years, Math.round(years));
  112 +
  113 + var separator = $l.wordSeparator || "";
  114 + if ($l.wordSeparator === undefined) { separator = " "; }
  115 + return $.trim([prefix, words, suffix].join(separator));
  116 + },
  117 +
  118 + parse: function(iso8601) {
  119 + var s = $.trim(iso8601);
  120 + s = s.replace(/\.\d+/,""); // remove milliseconds
  121 + s = s.replace(/-/,"/").replace(/-/,"/");
  122 + s = s.replace(/T/," ").replace(/Z/," UTC");
  123 + s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
  124 + s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
  125 + return new Date(s);
  126 + },
  127 + datetime: function(elem) {
  128 + var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
  129 + return $t.parse(iso8601);
  130 + },
  131 + isTime: function(elem) {
  132 + // jQuery's `is()` doesn't play well with HTML5 in IE
  133 + return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
  134 + }
  135 + });
  136 +
  137 + // functions that can be called via $(el).timeago('action')
  138 + // init is default when no action is given
  139 + // functions are called with context of a single element
  140 + var functions = {
  141 + init: function(){
  142 + var refresh_el = $.proxy(refresh, this);
  143 + refresh_el();
  144 + var $s = $t.settings;
  145 + if ($s.refreshMillis > 0) {
  146 + this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
  147 + }
  148 + },
  149 + update: function(time){
  150 + var parsedTime = $t.parse(time);
  151 + $(this).data('timeago', { datetime: parsedTime });
  152 + if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString());
  153 + refresh.apply(this);
  154 + },
  155 + updateFromDOM: function(){
  156 + $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
  157 + refresh.apply(this);
  158 + },
  159 + dispose: function () {
  160 + if (this._timeagoInterval) {
  161 + window.clearInterval(this._timeagoInterval);
  162 + this._timeagoInterval = null;
  163 + }
  164 + }
  165 + };
  166 +
  167 + $.fn.timeago = function(action, options) {
  168 + var fn = action ? functions[action] : functions.init;
  169 + if(!fn){
  170 + throw new Error("Unknown function name '"+ action +"' for timeago");
  171 + }
  172 + // each over objects here and call the requested function
  173 + this.each(function(){
  174 + fn.call(this, options);
  175 + });
  176 + return this;
  177 + };
  178 +
  179 + function refresh() {
  180 + //check if it's still visible
  181 + if(!$.contains(document.documentElement,this)){
  182 + //stop if it has been removed
  183 + $(this).timeago("dispose");
  184 + return this;
  185 + }
  186 +
  187 + var data = prepareData(this);
  188 + var $s = $t.settings;
  189 +
  190 + if (!isNaN(data.datetime)) {
  191 + if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
  192 + $(this).text(inWords(data.datetime));
  193 + }
  194 + }
  195 + return this;
  196 + }
  197 +
  198 + function prepareData(element) {
  199 + element = $(element);
  200 + if (!element.data("timeago")) {
  201 + element.data("timeago", { datetime: $t.datetime(element) });
  202 + var text = $.trim(element.text());
  203 + if ($t.settings.localeTitle) {
  204 + element.attr("title", element.data('timeago').datetime.toLocaleString());
  205 + } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
  206 + element.attr("title", text);
  207 + }
  208 + }
  209 + return element.data("timeago");
  210 + }
  211 +
  212 + function inWords(date) {
  213 + return $t.inWords(distance(date));
  214 + }
  215 +
  216 + function distance(date) {
  217 + return (new Date().getTime() - date.getTime());
  218 + }
  219 +
  220 + // fix for IE6 suckage
  221 + document.createElement("abbr");
  222 + document.createElement("time");
  223 +}));
... ...
src/colab-spb-plugin/src/colab_spb/templates/gitlab_activity.html 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +
  2 +{% load i18n %}
  3 +
  4 +<script type='text/javascript' src='/static/spb/js/jquery-2.0.3.min.js'></script>
  5 +<script type='text/javascript' src='/static/spb/js/jquery.timeago.js'></script>
  6 +
  7 +<div id='spb_content_gitlab_activity'>
  8 + {{message}}
  9 +</div>
  10 +
  11 +<script type='text/javascript'>
  12 + var $tag = $('#spb_content_gitlab_activity');
  13 +
  14 + {% if community_association %}
  15 +
  16 + $.getJSON("{{community_association.repository}}",{limit: {{community_association.limit}}, offset: {{community_association.offset}}},function(msg, e){
  17 + $tag.html(msg.html);
  18 + $tag.append("<div class=\"see-more-repository\">" +
  19 + "<a href={{community_association.repository}}>" +
  20 + "veja toda a atividade no repositório" +
  21 + "</a></div>");
  22 + });
  23 + {% endif %}
  24 +</script>
  25 +
... ...
src/colab-spb-plugin/src/colab_spb/views.py
... ... @@ -46,30 +46,38 @@ def mail_list(request):
46 46 message = ("Não foi possível encontrada lista de discussão"
47 47 " associada a está comunidade, para mais"
48 48 " detalhes contate o administrador.")
49   - return HttpResponse(message, status=404)
  49 + return HttpResponse(message, status=200)
50 50  
51 51 return render(request, 'discussion.html', context)
52 52  
53 53  
54 54 def gitlab_activity(request):
55 55 community = request.GET.get('community', "")
  56 + limit = request.GET.get('limit',7)
  57 + offset = request.GET.get('offset',0)
56 58  
57 59 context = {}
58 60 context['message'] = ("Esta comunidade não está associada a"
59   - " nenhum repositório no momento, para mais"
60   - " detalhes contate o administrador")
61   - context['community_association'] = get_community_association(community)
  61 + " nenhum repositório no momento, para mais"
  62 + " detalhes contate o administrador.")
  63 +
  64 + association = get_community_association(community, limit, offset)
  65 + context['community_association'] = association
  66 +
62 67 return render(request, 'gitlab_activity.html', context)
63 68  
64   -def get_community_association(community):
65   - if community:
66   - associations = CommunityAssociations.objects.all()
67   - for community_association in associations:
68   - if community_association.community.name in community:
69   - return { 'community': community_association.community.name,
70   - 'repository': community_association.group.url,
71   - 'mailman_list': community_association.mail_list.name,
72   - 'activities_limit': 7,
73   - 'offset': 0,
74   - }
75   - return {}
  69 +def get_community_association(community,limit=7,offset=0):
  70 + if not community:
  71 + return {}
  72 +
  73 + associations = CommunityAssociations.objects.all()
  74 + for community_association in associations:
  75 + if community_association.community.name in community:
  76 + return { 'community': community_association.community.name,
  77 + 'repository': community_association.group.url,
  78 + 'mailman_list': community_association.mail_list.name,
  79 + 'limit': limit,
  80 + 'offset': offset,
  81 + }
  82 +
  83 + return {}
... ...
src/colab-spb-plugin/tests/test_colab_integration.py 0 → 100644
... ... @@ -0,0 +1,81 @@
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +from django.test import TestCase, Client
  4 +
  5 +
  6 +class SPBTest(TestCase):
  7 +
  8 + fixtures = ['colab_spb.json']
  9 +
  10 + def setUp(self):
  11 + super(SPBTest, self).setUp()
  12 + self.client = Client()
  13 +
  14 + def tearDown(self):
  15 + pass
  16 +
  17 + def test_mail_list_without_list(self):
  18 + response = self.client.get("/spb/mail_list/?community=")
  19 + message = ("Não foi possível encontrada lista de discussão"
  20 + " associada a está comunidade, para mais"
  21 + " detalhes contate o administrador.")
  22 + self.assertEqual(message, response.content)
  23 + self.assertEqual(200, response.status_code)
  24 +
  25 + def test_mail_list_with_list(self):
  26 + response = self.client.get("/spb/mail_list/"
  27 + "?community=example_community&MAX=5")
  28 + self.assertEqual(5, len(response.context[1]['latest']))
  29 +
  30 + def test_mail_list_default_MAX(self):
  31 + response = self.client.get("/spb/mail_list/"
  32 + "?community=example_community")
  33 + self.assertEqual(7, len(response.context[1]['latest']))
  34 +
  35 + def test_mail_list_invalid_MAX(self):
  36 + response = self.client.get("/spb/mail_list/"
  37 + "?community=example_community&MAX=")
  38 + self.assertEqual(7, len(response.context[1]['latest']))
  39 +
  40 + def test_gitlab_community_association_with_invalid_community(self):
  41 + response = self.client.get("/spb/gitlab_activity/?community=")
  42 + message = ("Esta comunidade não está associada a"
  43 + " nenhum repositório no momento, para mais"
  44 + " detalhes contate o administrador.")
  45 + self.assertIn(message, response.content)
  46 + self.assertEqual(dict() ,response.context['community_association'])
  47 + self.assertEqual(200, response.status_code)
  48 +
  49 + def test_gitlab_community_association_with_valid_community(self):
  50 + response = self.client.get("/spb/gitlab_activity/"
  51 + "?community=example_community")
  52 +
  53 + result = response.context['community_association']
  54 +
  55 + self.assertEqual(type(result), dict)
  56 + self.assertEqual(result['community'], 'example_community')
  57 + self.assertEqual(result['limit'], 7)
  58 + self.assertEqual(result['offset'], 0)
  59 + self.assertEqual(result['repository'],
  60 + '/gitlab/groups/example_community')
  61 + self.assertEqual(result['mailman_list'], 'ListA')
  62 +
  63 + def test_gitlab_community_association_with_no_default_limit(self):
  64 + response = self.client.get("/spb/gitlab_activity/"
  65 + "?community=example_community"
  66 + "&limit=5")
  67 +
  68 + result = response.context['community_association']
  69 +
  70 + self.assertEqual(type(result), dict)
  71 + self.assertEqual(result['limit'], "5")
  72 +
  73 +
  74 + def test_gitlab_community_association_with_no_default_offset(self):
  75 + response = self.client.get("/spb/gitlab_activity/"
  76 + "?community=example_community"
  77 + "&offset=5")
  78 +
  79 + result = response.context['community_association']
  80 +
  81 + self.assertEqual(result['offset'],"5")
... ...
src/colab_spb/static/spb/js/jquery.timeago.js
... ... @@ -1,223 +0,0 @@
1   -/**
2   - * Timeago is a jQuery plugin that makes it easy to support automatically
3   - * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
4   - *
5   - * @name timeago
6   - * @version 1.4.2
7   - * @requires jQuery v1.2.3+
8   - * @author Ryan McGeary
9   - * @license MIT License - http://www.opensource.org/licenses/mit-license.php
10   - *
11   - * For usage and examples, visit:
12   - * http://timeago.yarp.com/
13   - *
14   - * Copyright (c) 2008-2015, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
15   - */
16   -
17   -(function (factory) {
18   - if (typeof define === 'function' && define.amd) {
19   - // AMD. Register as an anonymous module.
20   - define(['jquery'], factory);
21   - } if (typeof module === 'object' && typeof module.exports === 'object') {
22   - factory(require('jquery'));
23   - } else {
24   - // Browser globals
25   - factory(jQuery);
26   - }
27   -}(function ($) {
28   - $.timeago = function(timestamp) {
29   - if (timestamp instanceof Date) {
30   - return inWords(timestamp);
31   - } else if (typeof timestamp === "string") {
32   - return inWords($.timeago.parse(timestamp));
33   - } else if (typeof timestamp === "number") {
34   - return inWords(new Date(timestamp));
35   - } else {
36   - return inWords($.timeago.datetime(timestamp));
37   - }
38   - };
39   - var $t = $.timeago;
40   -
41   - $.extend($.timeago, {
42   - settings: {
43   - refreshMillis: 60000,
44   - allowPast: true,
45   - allowFuture: false,
46   - localeTitle: false,
47   - cutoff: 0,
48   - strings: {
49   - prefixAgo: null,
50   - prefixFromNow: null,
51   - suffixAgo: "ago",
52   - suffixFromNow: "from now",
53   - inPast: 'any moment now',
54   - seconds: "less than a minute",
55   - minute: "about a minute",
56   - minutes: "%d minutes",
57   - hour: "about an hour",
58   - hours: "about %d hours",
59   - day: "a day",
60   - days: "%d days",
61   - month: "about a month",
62   - months: "%d months",
63   - year: "about a year",
64   - years: "%d years",
65   - wordSeparator: " ",
66   - numbers: []
67   - }
68   - },
69   -
70   - inWords: function(distanceMillis) {
71   - if(!this.settings.allowPast && ! this.settings.allowFuture) {
72   - throw 'timeago allowPast and allowFuture settings can not both be set to false.';
73   - }
74   -
75   - var $l = this.settings.strings;
76   - var prefix = $l.prefixAgo;
77   - var suffix = $l.suffixAgo;
78   - if (this.settings.allowFuture) {
79   - if (distanceMillis < 0) {
80   - prefix = $l.prefixFromNow;
81   - suffix = $l.suffixFromNow;
82   - }
83   - }
84   -
85   - if(!this.settings.allowPast && distanceMillis >= 0) {
86   - return this.settings.strings.inPast;
87   - }
88   -
89   - var seconds = Math.abs(distanceMillis) / 1000;
90   - var minutes = seconds / 60;
91   - var hours = minutes / 60;
92   - var days = hours / 24;
93   - var years = days / 365;
94   -
95   - function substitute(stringOrFunction, number) {
96   - var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
97   - var value = ($l.numbers && $l.numbers[number]) || number;
98   - return string.replace(/%d/i, value);
99   - }
100   -
101   - var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
102   - seconds < 90 && substitute($l.minute, 1) ||
103   - minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
104   - minutes < 90 && substitute($l.hour, 1) ||
105   - hours < 24 && substitute($l.hours, Math.round(hours)) ||
106   - hours < 42 && substitute($l.day, 1) ||
107   - days < 30 && substitute($l.days, Math.round(days)) ||
108   - days < 45 && substitute($l.month, 1) ||
109   - days < 365 && substitute($l.months, Math.round(days / 30)) ||
110   - years < 1.5 && substitute($l.year, 1) ||
111   - substitute($l.years, Math.round(years));
112   -
113   - var separator = $l.wordSeparator || "";
114   - if ($l.wordSeparator === undefined) { separator = " "; }
115   - return $.trim([prefix, words, suffix].join(separator));
116   - },
117   -
118   - parse: function(iso8601) {
119   - var s = $.trim(iso8601);
120   - s = s.replace(/\.\d+/,""); // remove milliseconds
121   - s = s.replace(/-/,"/").replace(/-/,"/");
122   - s = s.replace(/T/," ").replace(/Z/," UTC");
123   - s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
124   - s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
125   - return new Date(s);
126   - },
127   - datetime: function(elem) {
128   - var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
129   - return $t.parse(iso8601);
130   - },
131   - isTime: function(elem) {
132   - // jQuery's `is()` doesn't play well with HTML5 in IE
133   - return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
134   - }
135   - });
136   -
137   - // functions that can be called via $(el).timeago('action')
138   - // init is default when no action is given
139   - // functions are called with context of a single element
140   - var functions = {
141   - init: function(){
142   - var refresh_el = $.proxy(refresh, this);
143   - refresh_el();
144   - var $s = $t.settings;
145   - if ($s.refreshMillis > 0) {
146   - this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
147   - }
148   - },
149   - update: function(time){
150   - var parsedTime = $t.parse(time);
151   - $(this).data('timeago', { datetime: parsedTime });
152   - if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString());
153   - refresh.apply(this);
154   - },
155   - updateFromDOM: function(){
156   - $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
157   - refresh.apply(this);
158   - },
159   - dispose: function () {
160   - if (this._timeagoInterval) {
161   - window.clearInterval(this._timeagoInterval);
162   - this._timeagoInterval = null;
163   - }
164   - }
165   - };
166   -
167   - $.fn.timeago = function(action, options) {
168   - var fn = action ? functions[action] : functions.init;
169   - if(!fn){
170   - throw new Error("Unknown function name '"+ action +"' for timeago");
171   - }
172   - // each over objects here and call the requested function
173   - this.each(function(){
174   - fn.call(this, options);
175   - });
176   - return this;
177   - };
178   -
179   - function refresh() {
180   - //check if it's still visible
181   - if(!$.contains(document.documentElement,this)){
182   - //stop if it has been removed
183   - $(this).timeago("dispose");
184   - return this;
185   - }
186   -
187   - var data = prepareData(this);
188   - var $s = $t.settings;
189   -
190   - if (!isNaN(data.datetime)) {
191   - if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
192   - $(this).text(inWords(data.datetime));
193   - }
194   - }
195   - return this;
196   - }
197   -
198   - function prepareData(element) {
199   - element = $(element);
200   - if (!element.data("timeago")) {
201   - element.data("timeago", { datetime: $t.datetime(element) });
202   - var text = $.trim(element.text());
203   - if ($t.settings.localeTitle) {
204   - element.attr("title", element.data('timeago').datetime.toLocaleString());
205   - } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
206   - element.attr("title", text);
207   - }
208   - }
209   - return element.data("timeago");
210   - }
211   -
212   - function inWords(date) {
213   - return $t.inWords(distance(date));
214   - }
215   -
216   - function distance(date) {
217   - return (new Date().getTime() - date.getTime());
218   - }
219   -
220   - // fix for IE6 suckage
221   - document.createElement("abbr");
222   - document.createElement("time");
223   -}));
src/colab_spb/templates/gitlab_activity.html
... ... @@ -1,25 +0,0 @@
1   -
2   -{% load i18n %}
3   -
4   -<script type='text/javascript' src='/static/spb/js/jquery-2.0.3.min.js'></script>
5   -<script type='text/javascript' src='/static/spb/js/jquery.timeago.js'></script>
6   -
7   -<div id='spb_content_gitlab_activity'>
8   - {{message}}
9   -</div>
10   -
11   -<script type='text/javascript'>
12   - var $tag = $('#spb_content_gitlab_activity');
13   -
14   - {% if community_association %}
15   -
16   - $.getJSON("{{community_association.repository}}",{limit: {{community_association.activities_limit}}, offset: {{community_association.offset}}},function(msg, e){
17   - $tag.html(msg.html);
18   - $tag.append("<div class=\"see-more-repository\">" +
19   - "<a href={{community_association.repository}}>" +
20   - "veja toda a atividade no repositório" +
21   - "</a></div>");
22   - });
23   - {% endif %}
24   -</script>
25   -