diff --git a/djangoproject/sandbox/views.py b/djangoproject/sandbox/views.py index c6143215..2112a250 100644 --- a/djangoproject/sandbox/views.py +++ b/djangoproject/sandbox/views.py @@ -114,6 +114,7 @@ def project(request): u'Coloque 200 ml de água em uma panela, adicione o miojo, deixe\n' u'ferver por 3 minutos. Adicione o tempero e pronto!', 'get_image3x1': '/static/img2/fs_logo.png', + 'get_tags': ['tag1', 'tag2'] } _stats = { 'issues_open': 2, diff --git a/djangoproject/statfiles/static/js/so/soapi.js b/djangoproject/statfiles/static/js/so/soapi.js new file mode 100644 index 00000000..30c6384f --- /dev/null +++ b/djangoproject/statfiles/static/js/so/soapi.js @@ -0,0 +1,23 @@ +var mod = angular.module('soapi', []); + +mod.factory('SOApi', function($http){ + var get_tags = "https://api.stackexchange.com/2.1/tags"; + + + function getTags(s){ + return $http({ + url: get_tags, + method: "GET", + params: { + order: 'desc', + sort: 'popular', + inname: s, + site: 'stackoverflow' + } + }); + } + + return { + getTags: getTags + }; +}) diff --git a/djangoproject/statfiles/static/js/tags/taglist.html b/djangoproject/statfiles/static/js/tags/taglist.html new file mode 100644 index 00000000..a25cce2b --- /dev/null +++ b/djangoproject/statfiles/static/js/tags/taglist.html @@ -0,0 +1,12 @@ +
+ {[{tag}]} +
+ +
+
    +
  • {{ poptag.name }}
  • +
+
+ +
+
\ No newline at end of file diff --git a/djangoproject/statfiles/static/js/tags/taglist.js b/djangoproject/statfiles/static/js/tags/taglist.js new file mode 100644 index 00000000..6c80336c --- /dev/null +++ b/djangoproject/statfiles/static/js/tags/taglist.js @@ -0,0 +1,64 @@ +/** + * + Copyright (C) 2013 FreedomSponsors + + The JavaScript code in this page is free software: you can + redistribute it and/or modify it under the terms of the GNU + AFFERO GENERAL PUBLIC LICENSE (GNU AGPL) as published by the Free Software + Foundation, either version 3 of the License, or (at your option) + any later version. The code is distributed WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. + + As additional permission under GNU GPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + For more information, refer to + https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt + */ + +var mod = angular.module('taglist', ['soapi' /*'tagsapi'*/]); +mod.directive('taglist', function() { + return { + restrict: 'E', + replace: true, + scope:{ + type: "@", + objid: "@" + }, + templateUrl: '/static/js/tags/taglist.html', + controller: function ($scope, $timeout, SOApi /*, TagApi, SOApi*/) { + $scope.tags = ["java", "python"]; + $scope.poptags = []; + + var timer = undefined; + + function restartTimer(){ + if(timer){ + $timeout.cancel(timer); + } + timer = $timeout(getTags, 200); + } + + function getTags(){ + $scope.loading = true; + SOApi.getTags($scope.newtag).success(function(result){ + $scope.loading = false; + $scope.poptags = result.items; + }) + } + + $scope.keypress = function(){ + restartTimer(); + }; + + $scope.addTag = function(t){ + $scope.tags.push(t.name); + $scope.poptags = []; + } + } + } +}); diff --git a/djangoproject/templates/core2/project.html b/djangoproject/templates/core2/project.html index 0f674229..6b737ee8 100644 --- a/djangoproject/templates/core2/project.html +++ b/djangoproject/templates/core2/project.html @@ -4,8 +4,31 @@ {% load l10n %} +{% block head %} + + + + + + +{% endblock %} + + {% block mainContent%} -
+
@@ -72,8 +95,9 @@

{{ project.name }}

{% for tag in project.get_tags %} - {{ tag.name }} + {{ tag }} {% endfor %} +