-
Notifications
You must be signed in to change notification settings - Fork 168
/
Meetups.cshtml
77 lines (68 loc) · 2.78 KB
/
Meetups.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@using OurUmbraco.Community.People
@using Skybrud.Essentials.Maps
@using Skybrud.Essentials.Maps.Geometry
@using Skybrud.Essentials.Security
@inherits UmbracoViewPage<List<OurUmbraco.Community.Meetup.Models.OurMeetupGroup>>
@{
// Get a reference to the current member
IPublishedContent member = Members.GetCurrentMember();
// Get the location of the current member (if logged in and a location is present)
Point memberLocation = null;
if (member != null && member.HasValue("latitude") && member.HasValue("longitude")) {
memberLocation = new Point(
member.GetPropertyValue<double>("latitude"),
member.GetPropertyValue<double>("longitude")
);
}
var upcomingEvents = Model.Where(x => x.Events.Any()).OrderBy(x => x.Events.OrderBy(y => y.DateTime).First().DateTime).ToList();
}
@foreach (var group in upcomingEvents) {
double distance = -1;
var upcomingEvent = group.Events.OrderBy(x => x.DateTime).FirstOrDefault();
if (upcomingEvent == null)
{
return;
}
if (memberLocation != null)
{
{
var venueLocation = new Point(upcomingEvent.Latitude, upcomingEvent.Longitude);
distance = memberLocation.GetDistance(venueLocation);
}
}
<a href="@upcomingEvent.Url" class="forum-thread" target="_blank" rel="noreferrer noopener">
@if (string.IsNullOrWhiteSpace(group.LogoBaseUrl) == false)
{
<div class="avatar">
<img src="@(group.LogoBaseUrl)/80x80.png" alt="" />
</div>
}
else
{
var fakeHash = SecurityUtils.GetMd5Hash(group.Id + "");
var avatarService = new AvatarService();
var avatarPath = avatarService.GetFakeAvatar(fakeHash);
var img = avatarService.GetImgWithSrcSet(avatarPath, group.Name, 100);
<div class="avatar">
@Html.Raw(img)
</div>
}
<div class="meta">
<div class="forum-thread-text">
@if (distance >= 0 && distance <= 50000) {
//<span style="float: right; color: red;">@String.Format("~{0:N0}", distance / 1000) km</span>
<span style="float: right; color: red; font-weight: bold;" title="Distance: @string.Format("~{0:N0}", distance / 1000) km">NEAR YOU</span>
}
<h3>@group.Name</h3>
<p>@upcomingEvent.DateTime.ToString("MMM d, yyyy") by @group.Name</p>
</div>
</div>
</a>
}
@if (upcomingEvents.Count % 2 == 1) {
// If there is an odd amount of events, we add a invisible div so the last event doesn't take up the full width
<div class="forum-thread" style="visibility: hidden;"></div>
}
@if (upcomingEvents.Any() == false) {
<h2>Could not load upcoming meetups.</h2>
}