[tor-commits] [compass/master] Fixed display of links when grouping by country or AS.
karsten at torproject.org
karsten at torproject.org
Mon Jan 7 07:09:40 UTC 2013
commit 6a4763db641317b30acfc3ea919f49fad3df427b
Author: Chris Wacek <cwacek at cs.georgetown.edu>
Date: Thu Dec 27 18:08:04 2012 -0500
Fixed display of links when grouping by country or AS.
---
compass.py | 6 +++++-
static/js/angularize.js | 2 +-
static/js/directives.js | 37 +++++++++++++++++++++++++++++++++++++
static/js/filters.js | 26 ++++++++++++++++++++++++++
static/js/sortable.js | 37 -------------------------------------
templates/index.html | 8 ++++++--
util.py | 2 +-
7 files changed, 76 insertions(+), 42 deletions(-)
diff --git a/compass.py b/compass.py
index b83ee5f..7987e49 100755
--- a/compass.py
+++ b/compass.py
@@ -328,6 +328,10 @@ class RelayStats(object):
# Add selected relays to the result set
for i,relay in enumerate(relay_set):
+ # We have no links if we're grouping
+ if options.by_country or options.by_as:
+ relay.link = False
+
if i < options.top:
relay.index = i + 1
output_relays.append(relay)
@@ -381,8 +385,8 @@ class RelayStats(object):
group_weights[weight] += relay.get(weight, 0)
result.nick = relay['nickname']
- result.link = options.links
result.fp = relay['fingerprint']
+ result.link = options.links
if 'Exit' in set(relay['flags']) and not 'BadExit' in set(relay['flags']):
result.exit = 'Exit'
diff --git a/static/js/angularize.js b/static/js/angularize.js
index 9c6614e..35c7f5e 100644
--- a/static/js/angularize.js
+++ b/static/js/angularize.js
@@ -1,4 +1,4 @@
-var compassModule = angular.module("Compass", ['ui','oblique.directives'])
+var compassModule = angular.module("Compass", ['ui','oblique.directives','oblique.filters'])
compassModule.value('ui.config', {
select2: {
diff --git a/static/js/directives.js b/static/js/directives.js
new file mode 100644
index 0000000..04c10a9
--- /dev/null
+++ b/static/js/directives.js
@@ -0,0 +1,37 @@
+// Generated by CoffeeScript 1.4.0
+
+/*
+This is part of the Oblique AngularJS components
+available at http://github.com/cwacek/Oblique
+*/
+
+
+(function() {
+ var module;
+
+ module = angular.module('oblique.directives', []);
+
+ module.directive('sortable', function() {
+ var linkFn;
+ linkFn = function(scope, element, attrs) {
+ return element.bind('click', function(event) {
+ var callback;
+ element.css('background-image', 'url("' + attrs.icon + '")');
+ ' Call the requested function ';
+
+ callback = scope.$eval(attrs.sortable);
+ callback(attrs.sortBy, attrs.invert, function() {
+ return element.css('background-image', "");
+ });
+ return attrs.invert = !attrs.invert;
+ });
+ };
+ return {
+ link: linkFn,
+ restrict: 'A',
+ link: linkFn,
+ scope: true
+ };
+ });
+
+}).call(this);
diff --git a/static/js/filters.js b/static/js/filters.js
new file mode 100644
index 0000000..4d8cc68
--- /dev/null
+++ b/static/js/filters.js
@@ -0,0 +1,26 @@
+// Generated by CoffeeScript 1.4.0
+
+/*
+This is part of the Oblique AngularJS components
+available at http://github.com/cwacek/Oblique
+*/
+
+
+(function() {
+ var module;
+
+ module = angular.module('oblique.filters', []);
+
+ module.filter('truncate', function() {
+ return function(input, limit, threshold) {
+ var out;
+ if (!limit || !threshold || input.length > threshold) {
+ out =input.substring(0, limit);
+ } else {
+ out = input;
+ }
+ return out;
+ };
+ });
+
+}).call(this);
diff --git a/static/js/sortable.js b/static/js/sortable.js
deleted file mode 100644
index 04c10a9..0000000
--- a/static/js/sortable.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Generated by CoffeeScript 1.4.0
-
-/*
-This is part of the Oblique AngularJS components
-available at http://github.com/cwacek/Oblique
-*/
-
-
-(function() {
- var module;
-
- module = angular.module('oblique.directives', []);
-
- module.directive('sortable', function() {
- var linkFn;
- linkFn = function(scope, element, attrs) {
- return element.bind('click', function(event) {
- var callback;
- element.css('background-image', 'url("' + attrs.icon + '")');
- ' Call the requested function ';
-
- callback = scope.$eval(attrs.sortable);
- callback(attrs.sortBy, attrs.invert, function() {
- return element.css('background-image', "");
- });
- return attrs.invert = !attrs.invert;
- });
- };
- return {
- link: linkFn,
- restrict: 'A',
- link: linkFn,
- scope: true
- };
- });
-
-}).call(this);
diff --git a/templates/index.html b/templates/index.html
index 02aa99e..5105d28 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -249,7 +249,10 @@
<td>{{ relay.p_exit | number:4 }}%</td>
<td>{{ relay.nick }}</td>
<td>
- <a href="https://atlas.torproject.org/#details/{{relay.fp}}" >{{relay.fp.substring(0,8)}}</a>
+ <span ng-show="relay.link">
+ <a href="https://atlas.torproject.org/#details/{{relay.fp}}" >{{relay.fp | truncate:8:30}}</a>
+ </span>
+ <span ng-show="!relay.link">{{relay.fp | truncate:8:30}}</span>
</td>
<td>{{ relay.exit }}</td>
<td>{{ relay.guard }}</td>
@@ -280,7 +283,8 @@
<script src="static/lib/select2/select2.js" type="text/javascript"></script>
<script src="static/js/angular/angular.js"> </script>
<script src="static/lib/angular-ui/angular-ui.js"></script>
- <script src="static/js/sortable.js"></script>
+ <script src="static/js/directives.js"></script>
+ <script src="static/js/filters.js"></script>
<script src="static/js/angularize.js"></script>
</body>
</html>
diff --git a/util.py b/util.py
index 893abcc..7dfc543 100644
--- a/util.py
+++ b/util.py
@@ -41,7 +41,7 @@ class Result():
self.p_middle = 0.0 if zero_probs else None
self.nick = ""
self.fp = ""
- self.link = ""
+ self.link = True
self.exit = ""
self.guard = ""
self.cc = ""
More information about the tor-commits
mailing list