Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10 from friedger/shorturl-event
Browse files Browse the repository at this point in the history
add event page for short urls
  • Loading branch information
friedger committed Sep 29, 2014
2 parents ded7b13 + 40d4d6b commit c6163d2
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 5 deletions.
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"angular-google-maps": "~1.2.1",
"font-awesome": ">=4.1.0",
"ngGeolocation": ">=0.0.2",
"lodash": "~2.4.1"
"lodash": "~2.4.1",
"moment": ">=2.8.3",
"moment-timezone": ">=0.2.2",
"angular-linkify": ">=0.3.0"
},
"devDependencies": {
"angular-mocks": ">=1.2.*",
Expand Down
3 changes: 2 additions & 1 deletion client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ angular.module('fireflyApp', [
'ui.bootstrap',
'googlechart',
'google-maps',
'ngGeolocation'
'ngGeolocation',
'linkify'
])
.config(function ($routeProvider, $locationProvider) {
$routeProvider
Expand Down
2 changes: 1 addition & 1 deletion client/app/event-map/event-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<window ng-repeat="marker in markers" coords="marker.coordinates" show="marker.show">
<div>

<b><a href="http://gdg.events/{{marker.id}}">{{marker.title}}</a></b>
<b><a href="/{{marker.id}}/">{{marker.title}}</a></b>
</div>
</window>
</markers>
Expand Down
4 changes: 2 additions & 2 deletions client/app/main/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h3><i class="fa fa-map-marker"></i> {{tag.title}} Event near you</h3>
<div class="col-md-9">
<div ng-repeat="event in allEvents | orderBy:distanceFromHere | limitTo:5">
<p>
<a href="http://gdg.events/{{event._id}}">{{event.title}}</a><br/>
<a href="/{{event._id}}/">{{event.title}}</a><br/>
{{event.start | date : 'medium' : event.timezone}}
</p>
</div>
Expand All @@ -74,7 +74,7 @@ <h3><i class="fa fa-clock-o"></i> Next {{tag.title}} Events</h3>
<div class="col-md-9">
<div ng-repeat="event in allEvents | orderBy:'start' | limitTo:5">
<p>
<a href="http://gdg.events/{{event._id}}">{{event.title}}</a><br/>
<a href="/{{event._id}}/">{{event.title}}</a><br/>
{{event.start | date : 'medium' : event.timezone}}
</p>
</div>
Expand Down
11 changes: 11 additions & 0 deletions client/app/moments/moment-timezone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

angular.module('moment-timezone', [])
.service('MomentTimezone', ['$http', function ($http) {
var promise = $http.get("/bower_components/moment-timezone/moment-timezone.json").success(function(resp) {
moment.tz.add(resp);
});
return {
promise: promise
}
}]);
95 changes: 95 additions & 0 deletions client/app/moments/moments.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
'use strict';

angular.module('fireflyApp')
.directive('timeTimezone', ['$http', function($http) {
return {
restrict: 'E',
template: '{{formatDate}}',
scope: {
date: "=",
timezone: "="
},
link: function(scope, element, attrs) {

var update = function upd() {
if(scope.timezone && scope.date) {
scope.formatDate = moment(scope.date).tz(scope.timezone).format('llll');
}
};

scope.$watch('date', function(oldVal, newVal) {
update();
});

scope.$watch('timezone', function(oldVal, newVal) {
update();
});
}
};
}])
.directive('timeAgo', ['$timeout', function($timeout) {
return {
restrict: 'E',
template: '{{formatDate}}',
scope: {
date: "="
},
link: function(scope, element, attrs) {
var promise = null;

var update = function() {
if(scope.date) {
scope.formatDate = moment(scope.date).fromNow();
promise = $timeout(update, 60000, false);
}
};

scope.$watch('date', function(oldVal, newVal) {
if(promise) {
$timeout.cancel(promise);
}
update();
});
}
};
}])
.directive('localTime', [function() {
return {
restrict: 'E',
template: '{{formatDate}}',
scope: {
date: "="
},
link: function(scope, element, attrs) {
var promise = promise;

var update = function upd() {
scope.formatDate = moment(scope.date).format('llll');
};

scope.$watch('date', function(oldVal, newVal) {
update();
});
}
};
}])
.directive('time', [function() {
return {
restrict: 'E',
template: '{{formatDate}}',
scope: {
date: "="
},
link: function(scope, element, attrs) {
var promise = promise;

var update = function upd() {
scope.formatDate = moment(scope.date).utc().format('llll');
};

scope.$watch('date', function(oldVal, newVal) {
update();
});
}
};
}]);
33 changes: 33 additions & 0 deletions client/app/shorturl/shorturl.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

angular.module('fireflyApp')
.controller('ShorturlEventCtrl', function ($scope, $http, $routeParams) {

var processEventData = function (data, status, headers, config) {
if (data.geo) {
data.geo.latitude = data.geo.lat;
data.geo.longitude = data.geo.lng;
data.geo.zoom = 11;
data.geo.center = {
latitude: data.geo.latitude,
longitude: data.geo.longitude
};
delete data.geo.lat;
delete data.geo.lng;
}
$scope.event = data;

$http.get("https://www.googleapis.com/plus/v1/people/" + $scope.event.chapter + "?fields=image&key=AIzaSyD7v04m_bTu-rcWtuaN3fTP9NBmjhB7lXg").success(function (data) {
$scope.image = data.image.url.replace("sz=50", "sz=70");
});

$http.jsonp("https://hub.gdgx.io/api/v1/chapters/" + $scope.event.chapter+"?callback=JSON_CALLBACK").success(function (data, status, headers, config) {
if (data.geo) {
data.geo.latitude = data.geo.lat;
data.geo.longitude = data.geo.lng;
delete data.geo.lat;
delete data.geo.lng;
}
$scope.chapter = data;
});
};
$http.get("/api/shorturl/"+$routeParams['hash']).success(function(data) {
$scope.shorturl = data;
$http.jsonp("https://hub.gdgx.io/api/v1/events/" + data.event_id+"?callback=JSON_CALLBACK").success(processEventData);
});
})
.controller('ShorturlAnalyticsCtrl', function ($scope, $http, $routeParams) {
$scope.referrers = {
Expand Down
110 changes: 110 additions & 0 deletions client/app/shorturl/shorturl.event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<div ng-include="'components/navbar/navbar.html'"></div>

<div class="container">
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<h3>{{event.title}} <small><time-ago date="event.start"></time-ago></small></h3>
<div class="card">
<div class="card-body">
<p>
<div ng-bind-html="event.about | linkify"></div>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h3><i class="fa fa-clock-o"></i> Your Time</h3>
<p>
<b>Begins:</b> <span><local-time date="event.start"></local-time></span><br/>
<b>Ends:</b> <span><local-time date="event.end"></local-time></span>
</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h3><i class="fa fa-clock-o"></i> Event Time</h3>
<p>
<b>Begins:</b> <span><time-timezone date="event.start" timezone="event.timezone"></time-timezone></span><br/>
<b>Ends:</b> <span><time-timezone date="event.end" timezone="event.timezone"></time-timezone></span><br/>
<b>Timezone:</b> {{event.timezone}}
</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h3><i class="fa fa-map-marker"></i> Location</h3>
<p>
{{event.location}}<br/><br/>
<a ng-href="https://maps.google.com/maps?daddr={{event.location}}">Get directions</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="row">
<div class="col-md-12">
<h3>Hosted by</h3>
<div class="card">
<div class="card-body">
<p>
<img ng-show="chapter._id != undefined" class="pull-right" style="margin-top: 11px;" ng-src="{{image}}"/>
<h3><a ng-href="http://developers.google.com/groups/chapter/{{chapter._id}}/">{{chapter.name}}</a></h3>
<span>{{chapter.city}}, {{chapter.country.name}}</span>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Event sites</h3>
<div class="card">
<div class="card-body">
<p>
<div ng-switch on="!!event.eventUrl">
<div ng-switch-when="true">
<a ng-href="{{event.eventUrl}}">Google+ event page</a>
</div>
<div ng-switch-default>...</div>
</div>
<a ng-href="http://developers.google.com/events/{{event._id}}/">Google Developers' event page</a>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<p>
<div ng-switch on="!!event.geo">
<div ng-switch-when="true">
<google-map center="event.geo.center" zoom="event.geo.zoom">
<marker coords='event.geo'>

</marker>
</google-map>
</div>
<div ng-switch-default>...</div>
</div>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<script src="bower_components/angular-google-maps/dist/angular-google-maps.js"></script>
<script src="bower_components/ngGeolocation/ngGeolocation.js"></script>
<script src="bower_components/ngGeolocation/ngGeolocation.min.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.js"></script>
<script src="bower_components/angular-linkify/angular-linkify.js"></script>
<!-- endbower -->
<!-- endbuild -->

Expand All @@ -75,6 +78,8 @@
<script src="app/event-map/event-map.directive.js"></script>
<script src="app/main/main.controller.js"></script>
<script src="app/main/main.js"></script>
<script src="app/moments/moment-timezone.js"></script>
<script src="app/moments/moments.directive.js"></script>
<script src="app/shorturl/shorturl.controller.js"></script>
<script src="app/shorturl/shorturl.js"></script>
<script src="components/footer/footer.controller.js"></script>
Expand Down

0 comments on commit c6163d2

Please # to comment.