Skip to content

Commit

Permalink
adding command to dump categories as json, fixing wordpress category …
Browse files Browse the repository at this point in the history
…mapping to allow long integers
  • Loading branch information
fschwiet committed Mar 24, 2012
1 parent c7158e4 commit 98f13a2
Show file tree
Hide file tree
Showing 24 changed files with 40,953 additions and 5 deletions.
31 changes: 31 additions & 0 deletions JoeBlogs.Console/DumpCategories.cs
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ManyConsole;
using Newtonsoft.Json;

namespace JoeBlogs.Console
{
public class DumpCategories : ConsoleCommand
{
public DumpCategories()
{
this.IsCommand("dump-categories", "Writes categories in JSON.");
LoginInfo.AddXmlRpcLogin(this);
}

public LoginInfo LoginInfo = new LoginInfo();

public override int Run(string[] remainingArguments)
{
var client = LoginInfo.GetWordPressClient();

var results = client.GetCategories();

System.Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(results,Formatting.Indented));

return 0;
}
}
}
4 changes: 4 additions & 0 deletions JoeBlogs.Console/JoeBlogs.Console.csproj
Expand Up @@ -41,6 +41,9 @@
<Reference Include="NDesk.Options">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -50,6 +53,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DumpCategories.cs" />
<Compile Include="LoadCommentsForPost.cs" />
<Compile Include="LoginInfo.cs" />
<Compile Include="Program.cs" />
Expand Down
1 change: 1 addition & 0 deletions JoeBlogs.Console/packages.config
Expand Up @@ -2,4 +2,5 @@
<packages>
<package id="ManyConsole" version="0.4.2.0" />
<package id="NDesk.Options" version="0.2.1" />
<package id="Newtonsoft.Json" version="4.0.8" />
</packages>
4 changes: 2 additions & 2 deletions JoeBlogs/Mapper.cs
Expand Up @@ -300,14 +300,14 @@ internal static Category Category(XmlRpcCategory input)
{
var result = new Category
{
ParentCategoryID = Convert.ToInt16(input.parentId),
ParentCategoryID = Convert.ToInt32(input.parentId),
Name = input.categoryName,
Description = input.description,
HtmlUrl = input.htmlUrl,
RSSUrl = input.rssUrl,
};

SetPrivateFieldValue("_categoryID", Convert.ToInt16(input.categoryId), result);
SetPrivateFieldValue("_categoryID", Convert.ToInt32(input.categoryId), result);

return result;
}
Expand Down
6 changes: 3 additions & 3 deletions JoeBlogs/classes/Category.cs
Expand Up @@ -11,9 +11,9 @@ public class CategoryMin

public class Category
{
private int _categoryID;
public int CategoryID { get { return _categoryID; } }
public int ParentCategoryID { get; set; }
private long _categoryID;
public long CategoryID { get { return _categoryID; } }
public long ParentCategoryID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string HtmlUrl { get; set; }
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 98f13a2

Please sign in to comment.