Skip to content

Commit be11853

Browse files
committed
Load dashboard newsfeed from project site
1 parent 1930161 commit be11853

File tree

6 files changed

+51
-58
lines changed

6 files changed

+51
-58
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using BlogEngine.Core.Data.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ServiceModel.Syndication;
5+
using System.Web.Http;
6+
using System.Xml;
7+
8+
public class NewsFeedController : ApiController
9+
{
10+
public List<SelectOption> Get()
11+
{
12+
var items = new List<SelectOption>();
13+
string url = "http://dotnetblogengine.net/syndication.axd";
14+
try
15+
{
16+
var cnt = 0;
17+
var reader = XmlReader.Create(url);
18+
var feed = SyndicationFeed.Load(reader);
19+
reader.Close();
20+
21+
foreach (SyndicationItem item in feed.Items)
22+
{
23+
var option = new SelectOption();
24+
option.OptionName = item.Title.Text;
25+
option.OptionValue = item.Id;
26+
items.Add(option);
27+
cnt++;
28+
if (cnt > 2) break;
29+
}
30+
}
31+
catch (Exception) { }
32+
return items;
33+
}
34+
}

BlogEngine/BlogEngine.NET/AppCode/Api/QuickNotesController.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

BlogEngine/BlogEngine.NET/AppCode/Api/StatsController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using BlogEngine.Core.Data.Contracts;
22
using BlogEngine.Core.Data.Models;
3-
using System;
4-
using System.Net;
53
using System.Web.Http;
64

75
public class StatsController : ApiController

BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<Reference Include="System.Net.Http.Formatting">
6868
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
6969
</Reference>
70+
<Reference Include="System.ServiceModel" />
7071
<Reference Include="System.Web.DynamicData" />
7172
<Reference Include="System.Web.Entity" />
7273
<Reference Include="System.Web.ApplicationServices" />
@@ -1956,14 +1957,14 @@
19561957
<Compile Include="AppCode\Api\LookupsController.cs" />
19571958
<Compile Include="AppCode\Api\PackageExtraController.cs" />
19581959
<Compile Include="AppCode\Api\PackagesController.cs" />
1959-
<Compile Include="AppCode\Api\QuickNotesController.cs" />
19601960
<Compile Include="AppCode\Api\SetupController.cs" />
19611961
<Compile Include="AppCode\Api\PagerController.cs" />
19621962
<Compile Include="AppCode\Api\PagesController.cs" />
19631963
<Compile Include="AppCode\Api\PingServicesController.cs" />
19641964
<Compile Include="AppCode\Api\PostsController.cs" />
19651965
<Compile Include="AppCode\Api\RolesController.cs" />
19661966
<Compile Include="AppCode\Api\SettingsController.cs" />
1967+
<Compile Include="AppCode\Api\NewsFeedController.cs" />
19671968
<Compile Include="AppCode\Api\StatsController.cs" />
19681969
<Compile Include="AppCode\Api\TagsController.cs" />
19691970
<Compile Include="AppCode\Api\TrashController.cs" />

BlogEngine/BlogEngine.NET/admin/app/dashboard/dashboardController.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
angular.module('blogAdmin').controller('DashboardController', ["$rootScope", "$scope", "$location", "$log", "$filter", "dataService", function ($rootScope, $scope, $location, $log, $filter, dataService) {
22
$scope.vm = {};
33
$scope.itemToPurge = {};
4+
$scope.news = [];
45
$scope.security = $rootScope.security;
56
$scope.focusInput = false;
67
$scope.qd = angular.copy(newDraft);
@@ -120,6 +121,7 @@
120121
spinOn();
121122

122123
$scope.loadPackages();
124+
$scope.loadNewsFeed();
123125

124126
dataService.getItems('/api/dashboard')
125127
.success(function (data) {
@@ -149,6 +151,15 @@
149151
toastr.error($rootScope.lbl.errorLoadingPackages);
150152
});
151153
}
154+
$scope.loadNewsFeed = function () {
155+
dataService.getItems('/api/newsfeed', { take: 5, skip: 0 })
156+
.success(function (data) {
157+
angular.copy(data, $scope.news);
158+
})
159+
.error(function () {
160+
toastr.error($rootScope.lbl.errorLoadingPackages);
161+
});
162+
}
152163
$scope.checkNewVersion = function () {
153164
if (!$scope.security.showTabCustom) {
154165
return;

BlogEngine/BlogEngine.NET/admin/app/dashboard/dashboardView.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ <h4 class="modal-title">{{lbl.trash}}</h4>
149149
<div class="panel-title">Latest News</div>
150150
</div>
151151
<ul class="list-group list-group">
152-
<li class="list-group-item"><a href="#">BlogEngine.NET 4.0 Released</a> <span>New</span></li>
153-
<li class="list-group-item"><a href="#">BlogEngine.NET 3.0 Released</a></li>
154-
<li class="list-group-item"><a href="#">BlogEngine.NET 3.0 Released</a></li>
152+
<li class="list-group-item" data-ng-repeat="n in news">
153+
<a href="{{n.OptionValue}}.aspx" target="_blank">{{n.OptionName}}</a>
154+
</li>
155+
<li ng-if="news.length == 0" class="list-group-item item-empty">{{lbl.empty}}</li>
155156
</ul>
156157
</div>
157158
</div>

0 commit comments

Comments
 (0)