Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DasBlog - Have code but don't know how to edit 2

Status
Not open for further replies.

dwest100

Technical User
Aug 9, 2003
59
US
Hi,
I have the source code for DasBlog and I also have the source code for a patch I need to implement in DasBlog.

Problem is I'm NOT a programmer and I don't have a clue where to start.

Here is the patch with some instructions:
---
metaWeblog.newMediaObject
Hi.
Don't know where to post this patch.
I use dasBlog, and I was trying to create a post with
an image using an external software with the
metaWeblog API.

As for uploading an image you can only use the method
newMediaObject, and as it doesn't exist on the last
version of dasBlog, I'd quickly made one.

So, here's my code, working with the first try I made.
(For a better view I deleted comments)

On the project "newtelligence.DasBlog.Web.Services",
in the file "MetaWeblog.cs", added the code in the
namespace :
public struct MediaType
{
public string name;
public string type;
public byte[] bits;
}

In the IMetaWeblog interface, added :
[XmlRpcMethod("metaWeblog.newMediaObject",
Description="Upload a new file to the binary
content. Returns url as a string")]
string metaweblog_newMediaObject (string
blogid, string username, string password, MediaType
enc);


Then, on the file BloggerAPI.cs in the "BloggerAPI"
class, added the code :
string IMetaWeblog.metaweblog_newMediaObject(string
blogid, string username, string password, MediaType
enc)
{
if ( !siteConfig.EnableBloggerApi )
{
throw new ServiceDisabledException();
}
UserToken token = SiteSecurity.Login
(username, password);
if (token == null)
{
throw new
System.Security.SecurityException();
}
string strPath =
SiteConfig.GetBinariesPathFromCurrentContext() +
enc.name;
FileStream fs = new FileStream(strPath,
FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(enc.bits);
bw.Close();
fs.Close();
return siteConfig.BinariesDirRelative +
enc.name;
}

As I use a BinaryWriter, you have to add the
System.IO reference.

Hope it's ok,
Xas.
---
Cansomeone tell me the easiest way to get this incorporated into DasBlog?

Thanks!

 
dwest100,

If you're not a programmer then this is going to be a little difficult. Most of the instructions you need are provided in what you posted here. You'll need to modify MetaWeblog.cs (which is a file in the source code of dasBlog - located similar to C:\Dasblog\src\newtelligence.DasBlog.Web.Services\MetaWeblog.cs). Open that file up and add the following...

Code:
public struct MediaType
{
public string name;
public string type;
public byte[] bits;
}

...right below where it says...

Code:
namespace newtelligence.DasBlog.Web.Services.MetaWeblog
{
    /// <summary>
    /// 
    /// </summary>

Next you'll need to look for the portion of the code where it says...
Code:
    public interface IMetaWeblog
    {
        /// <summary>
        /// Updates an existing post to a designated blog using the metaWeblog API. Returns true if completed.
        /// </summary>
        /// <param name="postid"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="post"></param>
        /// <param name="publish"></param>
        /// <returns>true if successful, false otherwise</returns>
... and add the following right below that:
Code:
[XmlRpcMethod("metaWeblog.newMediaObject",
Description="Upload a new file to the binary 
content. Returns url as a string")]
string metaweblog_newMediaObject (string 
blogid, string username, string password, MediaType 
enc);

Then in the BloggerAPI.cs file it is more of the same (C:\Dasblog\src\newtelligence.DasBlog.Web.Services\BloggerAPI.cs). Look in that source file for the following...
Code:
	[XmlRpcService(Name="DasBlog Blogger Access Point", Description="Implementation of Blogger XML-RPC Api")]
	public class BloggerAPI : XmlRpcService, IBlogger, IMovableType, IMetaWeblog
	{
		SiteConfig siteConfig;
        IBlogDataService dataService;
		ILoggingDataService logService;

        public BloggerAPI()
		{
            this.siteConfig = SiteConfig.GetSiteConfig();
			this.logService = LoggingDataServiceFactory.GetService(HttpContext.Current.Server.MapPath(siteConfig.LogDir));
            this.dataService = BlogDataServiceFactory.GetService(HttpContext.Current.Server.MapPath(siteConfig.ContentDir), logService );
       	}

Then add all that source code that the patch tells you to add right below that.

Then finally at the top of the BloggerAPI.cs you'll see a bunch of using statements...
Code:
using System;
using CookComputing.XmlRpc;
using newtelligence.DasBlog.Runtime;
using newtelligence.DasBlog.Web.Services.Blogger;
using newtelligence.DasBlog.Web.Services.MovableType;
using newtelligence.DasBlog.Web.Services.MetaWeblog;
using System.Reflection;
using System.Collections;
using System.Web;
using newtelligence.DasBlog.Web.Core;
...and right below them add in a line that reads:
Code:
using System.IO;

Then build the newtelligence.DasBlog.Web.Services. There are plenty of online tutorials that you can find via a Google search that will explain how to build a C# assembly. If you had Visual Studio 2005 this whole process would be much easier. In any event, the instructions I've given you aren't much different that what you already had, but maybe some of the paths and the code to look for helps you to do this. You could always hire a programmer to do this for you... it wouldn't take more than an hour for them to provide you with the patch from start to finish.

boyd.gif

SweetPotato Software Website
My Blog
 
it wouldn't take more than an hour for them to provide you with the patch from start to finish.

True. Once they were familiar with how DasBlog works, which might take a day or more.

When looking for someone to do this work, dwest100 ought to specify that experience with DasBlog is needed.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks Gentlemen!
That's what I needed to know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top