Updated the implementation
- We can now show logo (or image really) of the group responsible for each event - Only the first event of each group are shown in the list - A "NEAR YOU" label is now shown instead of the distance (the location of the group is used as fallback if no venue is specified)
This commit is contained in:
@@ -233,7 +233,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Skybrud.Social.Meetup, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Skybrud.Social.Meetup.1.0.0-beta001\lib\net45\Skybrud.Social.Meetup.dll</HintPath>
|
||||
<HintPath>..\packages\Skybrud.Social.Meetup.1.0.0-beta002\lib\net45\Skybrud.Social.Meetup.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLCE4Umbraco, Version=1.0.6274.27357, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
try {
|
||||
console.log("@Url.Action("GetEvents", "Meetups")");
|
||||
$("#meetups").load("@Url.Action("GetEvents", "Meetups", new { numberOfResults = 6 })");
|
||||
$("#meetups").load("@Url.Action("GetEvents", "Meetups")");
|
||||
console.log('yay');
|
||||
}
|
||||
catch (errTwitter) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
@using Skybrud.Essentials.Locations
|
||||
@using OurUmbraco.Community.Models
|
||||
@using Skybrud.Essentials.Locations
|
||||
@using Skybrud.Essentials.Locations.Extensions
|
||||
@using Skybrud.Social.Meetup.Models.Events
|
||||
@using Skybrud.Essentials.Security
|
||||
|
||||
@inherits UmbracoViewPage<OurUmbraco.Community.Models.MeetupEventsModel>
|
||||
@inherits UmbracoViewPage<MeetupEventsModel>
|
||||
|
||||
@{
|
||||
|
||||
@@ -20,32 +21,46 @@
|
||||
|
||||
}
|
||||
|
||||
@foreach (MeetupEvent ev in Model.Events) {
|
||||
@foreach (MeetupItem item in Model.Items) {
|
||||
|
||||
double distance = -1;
|
||||
|
||||
if (memberLocation != null) {
|
||||
if (ev.HasVenue) {
|
||||
distance = memberLocation.GetDistance(ev.Venue);
|
||||
if (item.Event.HasVenue) {
|
||||
distance = memberLocation.GetDistance(item.Event.Venue);
|
||||
} else {
|
||||
distance = memberLocation.GetDistance(item.Group);
|
||||
}
|
||||
}
|
||||
|
||||
<a href="@ev.Link" class="forum-thread">
|
||||
@*<div class="avatar">
|
||||
<img src="@tweet.CreatedBy.ProfileImageUrl400x400.Replace("http://", "https://")" />
|
||||
</div>*@
|
||||
<a href="@item.Event.Link" class="forum-thread">
|
||||
@if (item.Group.GroupPhoto != null)
|
||||
{
|
||||
<div class="avatar">
|
||||
<img src="@item.Group.GroupPhoto.ThumbLink" alt="" />
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
string fakeHash = SecurityUtils.GetMd5Hash(item.Group.Id + "");
|
||||
<div class="avatar">
|
||||
<img src="https://www.gravatar.com/avatar/@fakeHash?s=100&d=mm&r=g&d=retro" alt="" />
|
||||
</div>
|
||||
|
||||
}
|
||||
<div class="meta">
|
||||
<div class="forum-thread-text">
|
||||
@if (distance >= 0) {
|
||||
<span style="float: right; color: red;">@String.Format("~{0:N0}", distance / 1000) km</span>
|
||||
@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>@ev.Name</h3>
|
||||
<p>@ev.Time.DateTime.ToString("MMM d, yyyy") by @ev.Group.Name</p>
|
||||
<h3>@item.Event.Name</h3>
|
||||
<p>@item.Event.Time.DateTime.ToString("MMM d, yyyy") by @item.Group.Name</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (Model.Events.Any() == false) {
|
||||
<h2>Could not load recent meetups.</h2>
|
||||
@if (Model.Items.Any() == false) {
|
||||
<h2>Could not load upcoming meetups.</h2>
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net452" />
|
||||
<package id="Skybrud.Essentials" version="1.0.8" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Core" version="1.0.0-beta9" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Meetup" version="1.0.0-beta001" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Meetup" version="1.0.0-beta002" targetFramework="net452" />
|
||||
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net452" />
|
||||
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="net452" />
|
||||
<package id="TweetinviAPI" version="1.2.0" targetFramework="net452" />
|
||||
|
||||
@@ -3,9 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using OurUmbraco.Community.Models;
|
||||
using Skybrud.Essentials.Json.Extensions;
|
||||
using Skybrud.Social.Meetup;
|
||||
using Skybrud.Social.Meetup.Models.Events;
|
||||
using Skybrud.Social.Meetup.Models.Groups;
|
||||
using Skybrud.Social.Meetup.Responses.Events;
|
||||
using Skybrud.Social.Meetup.Responses.Groups;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Core.Cache;
|
||||
@@ -17,7 +20,7 @@ namespace OurUmbraco.Community.Controllers {
|
||||
public ActionResult GetEvents() {
|
||||
|
||||
MeetupEventsModel model = new MeetupEventsModel {
|
||||
Events = new MeetupEvent[0]
|
||||
Items = new MeetupItem[0]
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -31,27 +34,36 @@ namespace OurUmbraco.Community.Controllers {
|
||||
// Get the alias (urlname) of each group from the config file
|
||||
string[] aliases = System.IO.File.ReadAllLines(configPath);
|
||||
|
||||
model.Events =
|
||||
ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem<MeetupEvent[]>("UmbracoSearchedMeetups",
|
||||
model.Items =
|
||||
ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem<MeetupItem[]>("UmbracoSearchedMeetups",
|
||||
() => {
|
||||
|
||||
// Initialize a new service instance (we don't specify an API key since we're accessing public data)
|
||||
MeetupService service = new MeetupService();
|
||||
|
||||
List<MeetupEvent> aggregated = new List<MeetupEvent>();
|
||||
List<MeetupItem> items = new List<MeetupItem>();
|
||||
|
||||
foreach (string alias in aliases) {
|
||||
|
||||
try {
|
||||
|
||||
// Make the call to the meetup.com API to get upcoming events
|
||||
MeetupGetEventsResponse res = service.Events.GetEvents(alias);
|
||||
|
||||
// TODO: We should probably have some pagination, as the API only returns the first 20 events for a group (none of the groups currently have that much)
|
||||
// Get information about the group
|
||||
MeetupGroup group = service.Groups.GetGroup(alias).Body;
|
||||
|
||||
// Append the events from the reasponse to the aggregated list
|
||||
aggregated.AddRange(res.Body);
|
||||
if (group.JObject.HasValue("next_event")) {
|
||||
|
||||
string nextEventId = group.JObject.GetString("next_event.id");
|
||||
|
||||
// Make the call to the Meetup.com API to get upcoming events
|
||||
MeetupGetEventsResponse res = service.Events.GetEvents(alias);
|
||||
|
||||
// Get the next event(s)
|
||||
MeetupEvent nextEvent = res.Body.FirstOrDefault(x => x.Id == nextEventId);
|
||||
|
||||
// Append the first event of the group
|
||||
if (nextEvent != null) items.Add(new MeetupItem(group, nextEvent));
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
LogHelper.Error<MeetupsController>("Could not get events from meetup.com for group with alias: " + alias, ex);
|
||||
@@ -59,7 +71,7 @@ namespace OurUmbraco.Community.Controllers {
|
||||
|
||||
}
|
||||
|
||||
return aggregated.OrderBy(x => x.Time).ToArray();
|
||||
return items.OrderBy(x => x.Event.Time).ToArray();
|
||||
|
||||
}, TimeSpan.FromMinutes(30));
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Skybrud.Social.Meetup.Models.Events;
|
||||
|
||||
namespace OurUmbraco.Community.Models {
|
||||
namespace OurUmbraco.Community.Models {
|
||||
|
||||
public class MeetupEventsModel {
|
||||
|
||||
public MeetupEvent[] Events { get; set; }
|
||||
public MeetupItem[] Items { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Skybrud.Essentials.Locations;
|
||||
using Skybrud.Social.Meetup.Models.Events;
|
||||
using Skybrud.Social.Meetup.Models.Groups;
|
||||
|
||||
namespace OurUmbraco.Community.Models {
|
||||
|
||||
public class MeetupItem {
|
||||
|
||||
public MeetupGroup Group { get; set; }
|
||||
|
||||
public MeetupEvent Event { get; set; }
|
||||
|
||||
public ILocation Location {
|
||||
get { return Event.HasVenue ? (ILocation) Event.Venue : Group; }
|
||||
}
|
||||
|
||||
public MeetupItem(MeetupGroup group, MeetupEvent ev) {
|
||||
Group = group;
|
||||
Event = ev;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -250,7 +250,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Skybrud.Social.Meetup, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Skybrud.Social.Meetup.1.0.0-beta001\lib\net45\Skybrud.Social.Meetup.dll</HintPath>
|
||||
<HintPath>..\packages\Skybrud.Social.Meetup.1.0.0-beta002\lib\net45\Skybrud.Social.Meetup.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLCE4Umbraco, Version=1.0.6261.14294, Culture=neutral, processorArchitecture=MSIL">
|
||||
@@ -406,6 +406,7 @@
|
||||
<Compile Include="Community\Controllers\MeetupsController.cs" />
|
||||
<Compile Include="Community\Controllers\TwitterSearchController.cs" />
|
||||
<Compile Include="Community\Models\MeetupEventsModel.cs" />
|
||||
<Compile Include="Community\Models\MeetupItem.cs" />
|
||||
<Compile Include="Community\Models\TweetsModel.cs" />
|
||||
<Compile Include="CustomDateTimeConvertor.cs" />
|
||||
<Compile Include="Documentation\Busineslogic\ConventionExtensions.cs" />
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net452" />
|
||||
<package id="Skybrud.Essentials" version="1.0.8" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Core" version="1.0.0-beta9" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Meetup" version="1.0.0-beta001" targetFramework="net452" />
|
||||
<package id="Skybrud.Social.Meetup" version="1.0.0-beta002" targetFramework="net452" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
|
||||
|
||||
Reference in New Issue
Block a user