Added a new section to the "Community" page listing Umbraco events from Meetup.com

This commit is contained in:
Anders Bjerner
2017-06-04 17:02:41 +02:00
parent 2fcd7f3911
commit c6de48c8e2
10 changed files with 213 additions and 0 deletions
+14
View File
@@ -224,6 +224,18 @@
<HintPath>..\packages\semver.1.1.2\lib\net451\Semver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Skybrud.Essentials, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Skybrud.Essentials.1.0.8\lib\net45\Skybrud.Essentials.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Skybrud.Social.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Skybrud.Social.Core.1.0.0-beta9\lib\net45\Skybrud.Social.Core.dll</HintPath>
<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>
<Private>True</Private>
</Reference>
<Reference Include="SQLCE4Umbraco, Version=1.0.6274.27357, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UmbracoCms.Core.7.5.11\lib\SQLCE4Umbraco.dll</HintPath>
<Private>True</Private>
@@ -485,6 +497,7 @@
<Content Include="config\Lang\sv-SE.user.xml" />
<Content Include="config\Lang\zh-CN.user.xml" />
<Content Include="config\log4net.config" />
<Content Include="config\MeetupUmbracoGroups.txt" />
<Content Include="config\Notification.config" />
<Content Include="config\restExtensions.config" />
<Content Include="config\Skinning.config" />
@@ -4330,6 +4343,7 @@
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
<Content Include="Views\Partials\Grid\Bootstrap2.cshtml" />
<Content Include="Views\Partials\Grid\Bootstrap2-Fluid.cshtml" />
<Content Include="Views\Partials\Home\Meetups.cshtml" />
<None Include="web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
@@ -1,4 +1,5 @@
@using OurUmbraco.Our.Models
@using Skybrud.Social.Meetup.Models.Events
@inherits OurUmbracoTemplatePage
@{
var homeNotificationText = Model.Content.GetPropertyValue<string>("homeOnlyBanner");
@@ -59,6 +60,7 @@
@if (Members.IsLoggedIn())
{
@ForumActivity()
@Meetups()
@TwitterSearch()
@Html.Partial("home/documentation")
}
@@ -66,6 +68,7 @@ else
{
@Html.Partial("home/documentation")
@ForumActivity()
@Meetups()
@TwitterSearch()
}
@@ -125,4 +128,25 @@ else
</div>
</div>
</section>
}
@helper Meetups() {
<section class="forum">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">Meetups</h1>
<p>
Upcoming meetups organized by the Umbraco community.
</p>
</div>
<div class="col-md-12">
<small>Upcoming meetups</small>
</div>
<div class="col-md-12 flex" id="meetups">
<h2>Loading meetups...</h2>
</div>
</div>
</div>
</section>
}
@@ -7,6 +7,15 @@
console.log("Couldn't load Twitter feed", errTwitter.message);
}
try {
console.log("@Url.Action("GetEvents", "Meetups")");
$("#meetups").load("@Url.Action("GetEvents", "Meetups", new { numberOfResults = 6 })");
console.log('yay');
}
catch (errTwitter) {
console.log("Couldn't load meetups", errTwitter.message);
}
try {
$("#forum-activity").load("@Url.Action("LatestActivity", "LatestActivity", new { numberOfTopics = 6 })");
}
@@ -0,0 +1,51 @@
@using Skybrud.Essentials.Locations
@using Skybrud.Essentials.Locations.Extensions
@using Skybrud.Social.Meetup.Models.Events
@inherits UmbracoViewPage<OurUmbraco.Community.Models.MeetupEventsModel>
@{
// 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)
EssentialsLocation memberLocation = null;
if (member != null && member.HasValue("latitude") && member.HasValue("longitude")) {
memberLocation = new EssentialsLocation(
member.GetPropertyValue<double>("latitude"),
member.GetPropertyValue<double>("longitude")
);
}
}
@foreach (MeetupEvent ev in Model.Events) {
double distance = -1;
if (memberLocation != null) {
if (ev.HasVenue) {
distance = memberLocation.GetDistance(ev.Venue);
}
}
<a href="@ev.Link" class="forum-thread">
@*<div class="avatar">
<img src="@tweet.CreatedBy.ProfileImageUrl400x400.Replace("http://", "https://")" />
</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>
}
<h3>@ev.Name</h3>
<p>@ev.Time.DateTime.ToString("MMM d, yyyy") by @ev.Group.Name</p>
</div>
</div>
</a>
}
@if (Model.Events.Any() == false) {
<h2>Could not load recent meetups.</h2>
}
@@ -0,0 +1,7 @@
umbracodk
Dutch-Umbraco-User-Group
Australian-Umbraco-Meetups
Kent-Umbraco-Meetup
Sydney-Umbraco-Meetup
Umbraco-Meetup-RheinMain
The-London-Umbraco-Meetup
+3
View File
@@ -56,6 +56,9 @@
<package id="RestSharp" version="104.1" targetFramework="net4" />
<package id="semver" version="1.1.2" targetFramework="net452" />
<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="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" />
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using OurUmbraco.Community.Models;
using Skybrud.Social.Meetup;
using Skybrud.Social.Meetup.Models.Events;
using Skybrud.Social.Meetup.Responses.Events;
using Umbraco.Core.Logging;
using Umbraco.Web.Mvc;
using Umbraco.Core.Cache;
namespace OurUmbraco.Community.Controllers {
public class MeetupsController : SurfaceController {
public ActionResult GetEvents() {
MeetupEventsModel model = new MeetupEventsModel {
Events = new MeetupEvent[0]
};
try {
string configPath = Server.MapPath("~/config/MeetupUmbracoGroups.txt");
if (!System.IO.File.Exists(configPath)) {
LogHelper.Debug<MeetupsController>("Config file was not found: " + configPath);
return PartialView("~/Views/Partials/Home/Meetups.cshtml", model);
}
// 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",
() => {
// 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>();
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)
// Append the events from the reasponse to the aggregated list
aggregated.AddRange(res.Body);
} catch (Exception ex) {
LogHelper.Error<MeetupsController>("Could not get events from meetup.com for group with alias: " + alias, ex);
}
}
return aggregated.OrderBy(x => x.Time).ToArray();
}, TimeSpan.FromMinutes(30));
} catch (Exception ex) {
LogHelper.Error<MeetupsController>("Could not get events from meetup.com", ex);
}
return PartialView("~/Views/Partials/Home/Meetups.cshtml", model);
}
}
}
@@ -0,0 +1,11 @@
using Skybrud.Social.Meetup.Models.Events;
namespace OurUmbraco.Community.Models {
public class MeetupEventsModel {
public MeetupEvent[] Events { get; set; }
}
}
+14
View File
@@ -241,6 +241,18 @@
<HintPath>..\packages\semver.1.1.2\lib\net451\Semver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Skybrud.Essentials, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Skybrud.Essentials.1.0.8\lib\net45\Skybrud.Essentials.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Skybrud.Social.Core">
<HintPath>..\packages\Skybrud.Social.Core.1.0.0-beta9\lib\net45\Skybrud.Social.Core.dll</HintPath>
<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>
<Private>True</Private>
</Reference>
<Reference Include="SQLCE4Umbraco, Version=1.0.6261.14294, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UmbracoCms.Core.7.5.10\lib\SQLCE4Umbraco.dll</HintPath>
<Private>True</Private>
@@ -391,7 +403,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CamelCaseFormatter.cs" />
<Compile Include="Community\Controllers\MeetupsController.cs" />
<Compile Include="Community\Controllers\TwitterSearchController.cs" />
<Compile Include="Community\Models\MeetupEventsModel.cs" />
<Compile Include="Community\Models\TweetsModel.cs" />
<Compile Include="CustomDateTimeConvertor.cs" />
<Compile Include="Documentation\Busineslogic\ConventionExtensions.cs" />
+3
View File
@@ -55,6 +55,9 @@
<package id="RestSharp" version="104.1" targetFramework="net451" />
<package id="semver" version="1.1.2" targetFramework="net452" />
<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="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" />