Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add opml subscription list for all the feeds within a blog + add char…

…acters counter in blog
  • Loading branch information...
commit c58205a1eab019daf963da0baaaedd5659df8484 1 parent b409d94
@dodyg authored
View
46 HobiHobi.Core/Blogging/Blog.cs
@@ -1,9 +1,11 @@
using HobiHobi.Core.Framework;
+using HobiHobi.Core.Subscriptions;
using HobiHobi.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Web;
namespace HobiHobi.Core.Blogging
{
@@ -59,6 +61,50 @@ public BlogFeed CreateFeed(string title, string description, string newId = null
return feed;
}
+ public List<BlogFeed> GetFeeds(Raven.Client.IDocumentSession session)
+ {
+ if (Id.IsNullOrWhiteSpace())
+ throw new ApplicationException("This blog must have an id before performing GetFeeds operations");
+
+ var feeds = session.Query<BlogFeed>().Where(x => x.BlogId == this.Id).ToList();
+
+ return feeds;
+ }
+
+ public Opml GetFeedsOpml(List<BlogFeed> feeds, HttpRequestBase request)
+ {
+ if (Id.IsNullOrWhiteSpace())
+ throw new ApplicationException("This blog must have an id before performing GetFeedsOpml operations");
+
+ var opml = new Opml
+ {
+ Title = Title,
+ DateCreated = DateCreated,
+ };
+
+
+ foreach (var i in feeds.Select(
+ x =>
+ {
+ var item = new Outline();
+ item.Attributes["text"] = x.Title;
+ item.Attributes["type"] = "rss";
+ item.Attributes["name"] = Texts.ConvertTitleToName(x.Title);
+ if (!string.IsNullOrWhiteSpace(x.Description))
+ item.Attributes["description"] = x.Description;
+ item.Attributes["htmlUrl"] = x.GetHtmlLink(request);
+ item.Attributes["xmlUrl"] = x.GetRssLink(request);
+
+ return item;
+ }))
+ {
+ opml.Outlines.Add(i);
+ }
+
+
+ return opml;
+ }
+
/// <summary>
/// Use this method to convert a given feed title to a url
/// </summary>
View
14 HobiHobi.Core/HobiHobi.Core.csproj
@@ -51,15 +51,16 @@
<Reference Include="CoffeeSharp">
<HintPath>..\packages\CoffeeSharp.0.5\lib\CoffeeSharp.dll</HintPath>
</Reference>
- <Reference Include="dotless.Core">
- <HintPath>..\packages\dotless.1.3.0.5\lib\dotless.Core.dll</HintPath>
+ <Reference Include="dotless.Core, Version=1.3.1.0, Culture=neutral, PublicKeyToken=96b446c9e63eae34, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\dotless.1.3.1.0\lib\dotless.Core.dll</HintPath>
</Reference>
<Reference Include="DotLiquid">
<HintPath>..\packages\DotLiquid.1.7.0\lib\NET40\DotLiquid.dll</HintPath>
</Reference>
- <Reference Include="FluentValidation, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="FluentValidation, Version=3.4.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\FluentValidation.3.4.0.0\lib\Net40\FluentValidation.dll</HintPath>
+ <HintPath>..\packages\FluentValidation.3.4.6.0\lib\Net40\FluentValidation.dll</HintPath>
</Reference>
<Reference Include="Jurassic">
<HintPath>..\packages\CoffeeSharp.0.5\lib\Jurassic.dll</HintPath>
@@ -79,8 +80,9 @@
<Reference Include="Raven.Client.Lightweight">
<HintPath>..\packages\RavenDB.Client.1.0.972\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
- <Reference Include="RestSharp">
- <HintPath>..\packages\RestSharp.103.4\lib\net4\RestSharp.dll</HintPath>
+ <Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
View
6 HobiHobi.Core/packages.config
@@ -3,13 +3,13 @@
<package id="Autofac" version="2.6.3.862" />
<package id="BCrypt-Official" version="0.1.107" />
<package id="CoffeeSharp" version="0.5" targetFramework="net40" />
- <package id="dotless" version="1.3.0.5" targetFramework="net40" />
+ <package id="dotless" version="1.3.1.0" targetFramework="net40" />
<package id="DotLiquid" version="1.7.0" />
- <package id="FluentValidation" version="3.4.0.0" targetFramework="net40" />
+ <package id="FluentValidation" version="3.4.6.0" targetFramework="net40" />
<package id="MarkdownDeep.NET" version="1.5" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.7" />
<package id="NLog" version="2.0.0.2000" />
<package id="RavenDB.Client" version="1.0.972" />
- <package id="RestSharp" version="103.4" />
+ <package id="RestSharp" version="104.1" targetFramework="net40" />
</packages>
View
5 HobiHobi.Tests/HobiHobi.Tests.csproj
@@ -38,8 +38,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="dotless.Core">
- <HintPath>..\packages\dotless.1.3.0.5\lib\dotless.Core.dll</HintPath>
+ <Reference Include="dotless.Core, Version=1.3.1.0, Culture=neutral, PublicKeyToken=96b446c9e63eae34, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\dotless.1.3.1.0\lib\dotless.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
2  HobiHobi.Tests/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="dotless" version="1.3.0.5" targetFramework="net45" />
+ <package id="dotless" version="1.3.1.0" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.7" targetFramework="net45" />
<package id="NLog" version="2.0.0.2000" targetFramework="net45" />
View
BIN  HobiHobi.Web.v11.suo
Binary file not shown
View
17 HobiHobi.Web/Areas/Manage/Views/Blog/Index.cshtml
@@ -20,7 +20,8 @@
<div id="message"></div>
<form id="new_post">
- <textarea class="input-xxlarge" id="post_content" name="content"></textarea>
+ <span id="post_content_count">280</span><br />
+ <textarea class="input-xxlarge" id="post_content" name="content" onkeyup="countChar(this)"></textarea>
<br />
<input type="url" id="post_link" class="input-xxlarge" name="link" placeholder="Link"/>
<br />
@@ -54,6 +55,20 @@
@section JsInline{
<script type="text/javascript">
+ function countChar(val) {
+ var len = val.value.length;
+ if (len >= 280) {
+ val.value = val.value.substring(0, 280);
+ }
+ else if (len >= 140) {
+ $('#post_content_count').text("* " + (279 - len));//max size - 1 to make sure the remaining character count makes sense
+
+ }
+ else {
+ $('#post_content_count').text(280 - len);
+ }
+ };
+
$(function () {
var firstTab = $('#feed_tabs li:first');
View
22 HobiHobi.Web/Controllers/BlogController.cs
@@ -12,6 +12,7 @@
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Converters;
using HobiHobi.Core;
+using HobiHobi.Core.Framework;
namespace HobiHobi.Web.Controllers
{
@@ -37,10 +38,26 @@ public ActionResult Index(string name)
ViewBag.Title = blog.Title;
ViewBag.Description = blog.Description;
ViewBag.Keywords = blog.Keywords;
-
+ ViewBag.OpmlUrl = "/b/opml/" + blog.Name;
return View();
}
+
+ public ActionResult BlogOpmlSubscriptionList(string name)
+ {
+ var blog = RavenSession.Query<Blog>().Where(x => x.Name == name).FirstOrDefault();
+
+ if (blog == null)
+ return HttpNotFound();
+
+ var feeds = blog.GetFeeds(RavenSession);
+ var opml = blog.GetFeedsOpml(feeds, Request);
+ var xml = opml.ToXML();
+
+ this.Compress();
+ return Content(xml.ToString(), "text/xml");
+ }
+
/// <summary>
/// There are three types of feed. Render as HTML or RSS or RSSJS
/// </summary>
@@ -102,6 +119,7 @@ public ActionResult FeedRss(string slug, int page = SiteConstants.INITIAL_PAGE,
return Content(payload, "application/rss+xml");
}
+
public ActionResult FeedItem(string feedSlug, string postSlug)
{
var feed = BlogFeed.FindByUrl(RavenSession, feedSlug);
@@ -120,5 +138,7 @@ public ActionResult FeedItem(string feedSlug, string postSlug)
return View();
}
+
+
}
}
View
8 HobiHobi.Web/Global.asax.cs
@@ -91,6 +91,14 @@ public static void RegisterRoutes(RouteCollection routes)
);
routes.MapRoute(
+ "BlogSubscriptionFeedList", // Route name
+ "b/opml/{name}", // URL with parameters
+ new { controller = "Blog", action = "BlogOpmlSubscriptionList" }, // Parameter defaults
+ new string[] { "HobiHobi.Web.Controllers" }
+ );
+
+
+ routes.MapRoute(
"Blog", // Route name
"b/{name}", // URL with parameters
new { controller = "Blog", action = "Index" }, // Parameter defaults
View
19 HobiHobi.Web/HobiHobi.Web.csproj
@@ -58,18 +58,20 @@
<Reference Include="Autofac.Integration.Mvc">
<HintPath>..\packages\Autofac.Mvc3.2.6.3.862\lib\NET40\Autofac.Integration.Mvc.dll</HintPath>
</Reference>
- <Reference Include="dotless.Core">
- <HintPath>..\packages\dotless.1.3.0.5\lib\dotless.Core.dll</HintPath>
+ <Reference Include="dotless.Core, Version=1.3.1.0, Culture=neutral, PublicKeyToken=96b446c9e63eae34, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\dotless.1.3.1.0\lib\dotless.Core.dll</HintPath>
</Reference>
<Reference Include="DotLiquid">
<HintPath>..\packages\DotLiquid.1.7.0\lib\NET40\DotLiquid.dll</HintPath>
</Reference>
- <Reference Include="FluentValidation, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="FluentValidation, Version=3.4.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\FluentValidation.3.4.0.0\lib\Net40\FluentValidation.dll</HintPath>
+ <HintPath>..\packages\FluentValidation.3.4.6.0\lib\Net40\FluentValidation.dll</HintPath>
</Reference>
- <Reference Include="FluentValidation.Mvc">
- <HintPath>..\packages\FluentValidation.MVC3.3.4.0.0\lib\Net40\FluentValidation.Mvc.dll</HintPath>
+ <Reference Include="FluentValidation.Mvc, Version=3.4.6.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\FluentValidation.MVC3.3.4.6.0\lib\Net40\FluentValidation.Mvc.dll</HintPath>
</Reference>
<Reference Include="MarkdownDeep">
<HintPath>..\packages\MarkdownDeep.NET.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll</HintPath>
@@ -86,8 +88,9 @@
<Reference Include="Raven.Client.Lightweight">
<HintPath>..\packages\RavenDB.Client.1.0.972\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
- <Reference Include="RestSharp">
- <HintPath>..\packages\RestSharp.103.4\lib\net4\RestSharp.dll</HintPath>
+ <Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data.DataSetExtensions" />
View
4 HobiHobi.Web/Views/Blog/Index.cshtml
@@ -23,7 +23,9 @@
{
<div id="edit_this_blog"><a href="@ViewBag.EditLink">Edit <i class="icon-edit"></i></a></div>
}
-
+ <br />
+ <a href="@ViewBag.OpmlUrl"><img src="/Images/opml-icon-128x128.png" width="32" /></a>
+ <br /><br />
@Html.Raw(ViewBag.Body)
@Html.Raw(ViewBag.BodyInline)
View
58 HobiHobi.Web/Web.config
@@ -1,66 +1,66 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
- <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core"/>
+ <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
</configSections>
<appSettings>
- <add key="webpages:Version" value="1.0.0.0"/>
- <add key="ClientValidationEnabled" value="true"/>
- <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
- <add key="Site.CssTag" value="molify"/>
- <add key="Site.JsTag" value="rotator"/>
+ <add key="webpages:Version" value="1.0.0.0" />
+ <add key="ClientValidationEnabled" value="true" />
+ <add key="UnobtrusiveJavaScriptEnabled" value="true" />
+ <add key="Site.CssTag" value="molify" />
+ <add key="Site.JsTag" value="rotator" />
</appSettings>
<connectionStrings>
- <add name="RavenDB" connectionString="Url=http://localhost:8080"/>
+ <add name="RavenDB" connectionString="Url=http://localhost:8080" />
</connectionStrings>
<system.web>
- <customErrors mode="Off"/>
+ <customErrors mode="Off" />
<!--trigger rebuild 2-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
- <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
- <forms loginUrl="/" timeout="2880"/>
+ <forms loginUrl="/" timeout="2880" />
</authentication>
<pages controlRenderingCompatibilityVersion="4.0">
<namespaces>
- <add namespace="System.Web.Helpers"/>
- <add namespace="System.Web.Mvc"/>
- <add namespace="System.Web.Mvc.Ajax"/>
- <add namespace="System.Web.Mvc.Html"/>
- <add namespace="System.Web.Routing"/>
- <add namespace="System.Web.WebPages"/>
- <add namespace="HobiHobi.Core.Framework"/>
+ <add namespace="System.Web.Helpers" />
+ <add namespace="System.Web.Mvc" />
+ <add namespace="System.Web.Mvc.Ajax" />
+ <add namespace="System.Web.Mvc.Html" />
+ <add namespace="System.Web.Routing" />
+ <add namespace="System.Web.WebPages" />
+ <add namespace="HobiHobi.Core.Framework" />
</namespaces>
</pages>
<httpHandlers>
- <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core"/>
+ <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
</system.web>
<system.webServer>
- <validation validateIntegratedModeConfiguration="false"/>
- <modules runAllManagedModulesForAllRequests="true"/>
+ <validation validateIntegratedModeConfiguration="false" />
+ <modules runAllManagedModulesForAllRequests="true" />
<handlers>
- <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition=""/>
+ <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
- <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
- <dotless minifyCss="false" cache="true" web="false"/>
+ <dotless minifyCss="false" cache="true" web="false" />
</configuration>
View
9 HobiHobi.Web/packages.config
@@ -2,12 +2,11 @@
<packages>
<package id="Autofac" version="2.6.3.862" />
<package id="Autofac.Mvc3" version="2.6.3.862" />
- <package id="dotless" version="1.3.0.5" targetFramework="net40" />
+ <package id="dotless" version="1.3.1.0" targetFramework="net40" />
<package id="DotLiquid" version="1.7.0" />
- <package id="FluentValidation" version="3.4.0.0" targetFramework="net40" />
- <package id="FluentValidation.MVC3" version="3.4.0.0" targetFramework="net40" />
+ <package id="FluentValidation" version="3.4.6.0" targetFramework="net40" />
+ <package id="FluentValidation.MVC3" version="3.4.6.0" targetFramework="net40" />
<package id="jQuery" version="1.8.0" targetFramework="net40" />
- <package id="jQuery.UI.Combined" version="1.8.11" />
<package id="jQuery.Validation" version="1.9.0.1" targetFramework="net40" />
<package id="MarkdownDeep.NET" version="1.5" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
@@ -15,5 +14,5 @@
<package id="Newtonsoft.Json" version="4.5.7" />
<package id="NLog" version="2.0.0.2000" />
<package id="RavenDB.Client" version="1.0.972" />
- <package id="RestSharp" version="103.4" />
+ <package id="RestSharp" version="104.1" targetFramework="net40" />
</packages>
Please sign in to comment.
Something went wrong with that request. Please try again.