Cleaning House!

Cleaning House!

I've been with my web host for about 8 years.  They handle my mail too.  They absolutely rock! That said I'm a pack rat and after a long time my site has collected much "stuff".  So I had the directory whacked and recreated so I could start off fresh.  This was a good time to rethink my url rewriting strategy.

I have several urls that all resolve to the same directory.  Previously to handle this I would look at the requested url and redirect to the appropriate directory set up with content for that site.  so if you asked for panteravb.com you were redirected to panteravb.com/pvb or something like that, and if you asked for carterfamilytree.com you got redirected to carterfamilytree.com/cft.  Tacking on the directory always bugged me.

I have since implemented an HttpModule to handle the url rewrites and just got it working with my fresh new directory.  Url rewriting is a way cool way of keeping your web "interface" clean while doing the dirty stuff in the background.  I plan on posting info on what I've implemented on this site so stay tuned.

Uploading to remote site you don't own...

I develop features for my sites locally and then upload the files.  The stuff I develop locally is not part of  a site, for example this blog engine I'm messing around with, really is not part of anything.  If I use Visual Studio 2005 I don't know(probably have not looked enough or at all) of a way that I can develop locally and just deploy bits of disconnected projects to a remote site(that I don't own).  Right now when I update MyBlogEngine, I run a build script to compile everything, if good, I open Internet Explorer to my ftp site, copy and paste the new assembly to the bin directory.  This is pretty annoying if I need to do that often.  I'll be changing this code probably, but .NET 2.0 has made FTP'ing pretty simple.  Here's the code I run in a console app to upload my newly compiled assemblies:


public static void UploadBinaryFile(string destinationFile,
        			string localFile, string userName, string password){
    FtpWebRequest request = FtpWebRequest.Create(destinationFile) as FtpWebRequest;
    request.UseBinary = true;
    request.Method = WebRequestMethods.Ftp.UploadFile;
    request.Credentials = new NetworkCredential(userName, password);
    using (FileStream fileStream = new FileStream(localFile, FileMode.Open))
    using (BinaryReader reader = new BinaryReader(fileStream))
    using (BinaryWriter writer = new BinaryWriter(request.GetRequestStream())){
        byte[] buffer = new byte[2047];
        int read = 0;
        do{
        	read = reader.Read(buffer, 0, buffer.Length);
        	writer.Write(buffer, 0, read);

        } while (read != 0);
        writer.Flush();
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Rss feed is built, but...

Ok, I am definitely green in the RSS department, it's simple so long as your blog engine doesn't suck like mine does.  I have not built in any way to get to a single post, so setting the guid is difficult, so just so I can get my RSS feed to validate against FEED Validator I'm creating a new System.Guid every request :)

More on TextCommands ...

These are turning out to be more like macros than anything.  Check this out, many times I need to reference documentation on microsoft, mostly in reference to the .NET Library Class reference.  Well now that they have the cool hackable url scheme set up, I created a MSClassTextCommand that looks like [$MSClass=System.Data.DataTable$] Which renders this:
 System.Data.DataTable
The MSClassTextCommand looks like this:

public class MSClassTextCommand : ITextCommand{
  public string Execute(string arg){
    string result = "";
    result += String.Format("{0}", arg);
  }
}

I still don't like this parser but I do like some simple macros to let me do stuff like the MSClassTextCommand.  I see a need for a more dynamic nature to these TextCommands as I'd rather not have to maintain a separate class for every little "macro" I want or need...

Here's number 2 ...

Ok, so my parser sucks.  Granted, it's the first one I've written but it's already annoying.  For example, I implemented FreeTextBox for my post editor.  Great tool.  There's probably a way of changing this behavior but tonight's plan wasn't to investigate how to use FreeTextBox.  Here's the problem.  My original tag system consisted of tags.  That's great but FreeTextBox's default behavior is to convert the less than symbol to it's html encoded entity representation(<), thus my parser broke.  Luckily, I can switch out the characters easy enough so I switched to brackets instead.  Super.  But now I need the ability to show those tags like this without the tags being parsed [$Code=1$].  To handle this, i created a SnippetLiteralTextCommand, that let's me do this [$SnippetLiteral=Code=1$] which gets rendered like this: [$Code=1$].  The only cool thing about this usage is the ease to which it was added.
I have an ITextCommand interface that looks like this:

public interface ITextCommand{
  string Execute(string arg);
}

The SnippetLiteralTextCommand implements that interface like this:

public class SnippetLiteralTextCommand : ITextCommand{
  public string Execute(string arg){
    return String.Format("[${0}$]", arg);
  }
}

Then I modified the TextCommandFactory to handle the new command like this:

public class TextCommandFactory{
  public ITextCommand Create(string commandName){
    switch (commandName.ToLower()){
      case "snippetliteral": return new SnippetLiteralTextCommand();      			
      case "code":
      default: return new CodeTextCommand();
    }
  }
}


I also need to mention Castle Project ActiveRecord again, this thing rocks.  I'm still way new at  it but I haven't written any sql code yet to run MyBlogEngine which kicks ass.

Post Numero Uno

Welcome to the first posting using MyBlogEngine. This is no more than a app to excercise some ideas I have. I've been trying to find a way to implement Castle ActiveRecord and NHibernate, so that's what MyBlogEngine is using for it's persistence mechanism. I want to build a user interface for managing content that does not suck, one that alternatively uses a Smart Client app. The plan is to have this entire blog tool zipped up and ready for install and inspection for anyone who feels like poking around.

The first fiew posts will focus on the creation of the blogging tool, I have great ideas on a user interface for the content. Since I host a couple of other urls I would like to entertain blog content for those as well.

I am currently editing this content in a plain ol' TextArea html tag. It really sucks and is not productive. My only goal for today was to get the basic tools in place for editing online content and that is done, I think my next order of business will be upgrading to FreeTextBox to make editing not painful.

Other items on my ToDo list include adding comments along with an implementation of CAPTCHA.

I've implemented a very crude tag parser that lets me reference my own code snippets like this: [$Code=1$]. I implemented a simple parser that parses a command like Code=1 into a TextCommand, and basically acts exactly like asp.net tags behave. It executes the TextCommand and inserts the results where the tags were, simple concept, just something I have not done before. The Code=1 would produce the following:

public string GetName(){
  return "name";
}

 

 

 

[$Code=1$]

 
Author: , 0000-00-00