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

[WIP] Feature/Tags #83

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions client/app/events/eventList.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<div layout="column" layout-fill ng-show="tag">
<meta view-head property="og:type" content="website">
<meta view-head property="og:description" content="{{tag.description}}">
<meta view-head property="og:title" content="{{tag.title}}">
<view-title>{{tag.title}}</view-title>

<event-map position="geo" tag="{{tag._id}}"></event-map>

<div layout layout-margin layout-wrap layout-align="center start" id="card-box">

<md-card flex-sm="100" flex-gt-sm="45">
<md-card-content>
<h3 class="md-title">About {{tag.title}}</h3>
<p>{{tag.description}}</p>
</md-card-content>
</md-card>

<md-card flex-sm="100" flex-gt-sm="45">
<md-card-content>
<h3 class="md-title">
{{tag.title}} Events near you
</h3>
<md-list ng-if="geo.latitude">
<md-list-item class="md-2-line" ng-repeat="event in allEvents | orderBy:distanceFromHere"
ng-click="openEvent(event._id)">
<div class="md-list-item-text">
<h3 style="color: {{ tag.color }}">{{ event.title }}</h3>
<p>{{event.start | date : 'medium' : event.timezone}}</p>
</div>
</md-list-item>
</md-list>
<md-list class="md-2-line" ng-if="!geo.latitude">
Waiting for location...
</md-list>
</md-card-content>
</md-card>

<md-card flex-sm="100" flex-gt-sm="45">
<md-card-content>
<h3 class="md-title">
Upcoming {{tag.title}} Events
</h3>
<md-list ng-if="nextEvent">
<md-list-item class="md-2-line" ng-repeat="event in allEvents | orderBy:'start'"
ng-click="openEvent(event._id)">
<div class="md-list-item-text">
<h3 style="color: {{ tag.color }}">{{ event.title }}</h3>
<p>{{event.start | date : 'medium' : event.timezone}}</p>
</div>
</md-list-item>
</md-list>
<md-list class="md-2-line" ng-if="!nextEvent">
No upcoming events in this series.
</md-list>
</md-card-content>
</md-card>

</div>
</div>
11 changes: 11 additions & 0 deletions client/app/events/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

angular.module('fireflyApp')
.config(function ($routeProvider) {
$routeProvider
.when('/:tag/events', {
templateUrl: 'app/events/eventList.html',
controller: 'MainCtrl',
controllerAs: 'vm'
});
});
17 changes: 15 additions & 2 deletions client/app/main/main.controller.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
'use strict';

angular.module('fireflyApp')
.controller('MainCtrl', function ($rootScope, $scope, $http, $location, $window, config) {
.controller('MainCtrl', function ($rootScope, $routeParams, $scope, $http, $location, $window, config) {
$scope.domain = config.DOMAIN;
$scope.nearEvent = undefined;

if ($routeParams.tag) {
$scope.prefix = $routeParams.tag;
$scope.all = false;
$http.jsonp(config.HUB_IP + 'api/v1/tags/' + $routeParams.tag + '?callback=JSON_CALLBACK')
.success(function (data) {
$scope.tag = data;
});
}

$http.jsonp(config.HUB_IP + 'api/v1/events/stats?callback=JSON_CALLBACK')
.success(function(data) {
$scope.tags = data.upcoming_top_tags; // jshint ignore:line
}
);

$scope.openEvent = function (eventId) {
$location.path('/' + eventId);
$location.path('/event/' + eventId);
};

$scope.openTag = function (path) {
$window.location.href = 'http://' + path;
};

$scope.openTagList = function () {
$window.location.href = 'http://' + config.DOMAIN + '/tags/active';
};

$scope.distanceFromHere = function (_item, _startPoint) {
var start = null;

Expand Down
7 changes: 7 additions & 0 deletions client/app/main/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ <h3 style="color: {{ tag.color }}">{{ key }}</h3>
<p>{{ value }} events</p>
</div>
</md-list-item>
<md-list-item class="md-2-line" ng-click="openTagList()"
style="display: inline-block;" >
<div class="md-list-item-text">
<h3 style="color: {{ tag.color }}">All topics</h3>
<p> more ...</p>
</div>
</md-list-item>
</md-list>
</md-card-content>
</md-card>
Expand Down
5 changes: 5 additions & 0 deletions client/app/shorturl/shorturl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ angular.module('fireflyApp')
controller: 'ShorturlAnalyticsCtrl',
controllerAs: 'vm'
})
.when('/event/:hash', {
templateUrl: 'app/shorturl/shorturlEvent.html',
controller: 'ShorturlEventCtrl',
controllerAs: 'vm'
})
.when('/:hash/', {
templateUrl: 'app/shorturl/shorturlEvent.html',
controller: 'ShorturlEventCtrl',
Expand Down
14 changes: 14 additions & 0 deletions client/app/tags/tagList.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
angular.module('fireflyApp')
.controller('TagsCtrl', function ($rootScope, $scope, $http, $location, $window, config) {
$scope.domain = config.DOMAIN;

$http.jsonp(config.HUB_IP + 'api/v1/tags/active?callback=JSON_CALLBACK').then(function(data){
$scope.allTags=data;
}, function(err){
$scope.error = err;
});

$scope.openTag = function (path) {
$window.location.href = 'http://' + config.DOMAIN + '/' + tag + '/events';
};
});
17 changes: 17 additions & 0 deletions client/app/tags/tagList.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div layout="column" layout-fill ng-show="tag">
<meta view-head property="og:type" content="website">
<meta view-head property="og:description" content="List of tags">
<meta view-head property="og:title" content="GDG Topics">
<view-title>GDG Topics</view-title>

<div layout layout-margin layout-wrap layout-align="center start" id="card-box">

<md-card flex-sm="100" flex-gt-sm="45" ng-repeat="tag in allTags | orderBy:name" ng-click="openTag(tag)">
<md-card-content>
<h3 class="md-title">{{tag}}</h3>
<h3 style="color: {{ tag.color }}" class="md-title">About {{tag.title}}</h3>
<p>{{tag.description}}</p>
</md-card-content>
</md-card>
</div>
</div>
11 changes: 11 additions & 0 deletions client/app/tags/tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

angular.module('fireflyApp')
.config(function ($routeProvider) {
$routeProvider
.when('/tags/active', {
templateUrl: 'app/tags/tagList.html',
controller: 'TagsCtrl',
controllerAs: 'vm'
});
});
3 changes: 3 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@
<script src="app/firefly.config.js"></script>
<!-- injector:js -->
<script src="app/event-map/event-map.directive.js"></script>
<script src="app/events/events.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.js"></script>
<script src="app/shorturl/shorturlAnalytics.controller.js"></script>
<script src="app/shorturl/shorturlEvent.controller.js"></script>
<script src="app/tags/tagList.controller.js"></script>
<script src="app/tags/tags.js"></script>
<script src="app/util/theme.service.js"></script>
<script src="components/footer/footer.directive.js"></script>
<script src="components/topNav/topNav.directive.js"></script>
Expand Down
21 changes: 17 additions & 4 deletions server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,29 @@ module.exports = function(app) {
function(err, shortUrl) {
var me = this;

function handleTagsResponse(err, tagsRes) {
if (err || !tagsRes || !tagsRes.body || !tagsRes.body._id) {
console.error(err);
// If there is an error looking up the shortUrl, just redirect to default prefix.
return res.redirect(301, 'http://' + DOMAIN);
}
res.redirect(301, 'http://' + DOMAIN + '/' + tagsRes.body._id + '/events');
}
/**
* @param err
* @param eventsRes
* @returns {*}
*/
function handleEventsResponse(err, eventsRes) {
if (err || !eventsRes || !eventsRes.body || !eventsRes.body._id) {
console.error(err);
// If there is an error looking up the shortUrl, just redirect to default prefix.
return res.redirect(301, 'http://' + DOMAIN);
if (err && err.status == 404) {
request.get(HUB_IP + 'api/v1/tags/' + req.params.hash, handleTagsResponse);
return;
} else {
console.error(err);
// If there is an error looking up the shortUrl, just redirect to default prefix.
return res.redirect(301, 'http://' + DOMAIN);
}
}

// Create a new DB entry for this new event shortUrl
Expand Down Expand Up @@ -87,7 +100,7 @@ module.exports = function(app) {
*/
function redirect(me, req, res, shortUrl) {
if (shortUrl.event_id) {
res.redirect(301, 'http://' + DOMAIN + '/' + shortUrl.event_id + '/');
res.redirect(301, 'http://' + DOMAIN + '/event/' + shortUrl.event_id + '/');
} else {
res.redirect(301, shortUrl.url);
}
Expand Down