Attach to Process

writeas

In my last DevLog, I mentioned that I took down apps.dinobansigan.com, and with it, the Write.as Archive Page Generator. I said I was letting it go. Well, that lasted about two months.

So, I went to update one of my other blogs recently, and realized the archive page on it was way out of date. The tool I used to update it was gone. Turns out I still needed it after all.

Why it can't just be a website

The old version was a Blazor WASM app. Since it ran in the browser, it couldn't call the Write.as API directly because of CORS. My workaround was to write my own API for the Blazor app to call, running as an Azure App Service. That API ran on free Azure credits that I've since lost access to.

I didn't want to host something again, since that means paying for it. And I didn't want to fight CORS again either. So this time around, the answer was an app that runs locally on my own machine. CORS only applies to browsers, so a regular app can call the Write.as API just fine.

Rebuilding it with Claude Code

I rebuilt this one with Claude Code. I treated it like pairing with another developer. Claude wrote most of the code, and I reviewed every change before it went in. Good news was, I still had the source code for both the old Blazor app and the API on my machine, so we had something to work off of. We ended up with a simple .NET console app. You run it with your blog's alias, and it spits out the HTML for your archive page. Same output as before, same CSS classes, so if you customized the look of your archive page, it should still work.

It still uses my WriteAs.NET library to talk to the Write.as API. But we swapped out CommonMark.NET and HtmlAgilityPack for Markdig, which turns the Markdown of untitled posts into plain text in a single line of code. CommonMark.NET hasn't been updated in years, so it was time anyway. Going through my old code also turned up a few bugs, like the app crashing on short untitled posts. Oops.

From reading through the old code to having a working app up on GitHub, the whole thing took one afternoon.

Rate limiting

The biggest surprise was that Write.as now heavily rate limits calls to its API. And because of how I wrote WriteAs.NET, a rate limited call just comes back empty instead of throwing an error. So the first test run fetched 20 out of 55 posts, and would have happily given me an incomplete archive page without me knowing.

The fix was to slow things down. The app now waits 10 seconds between each page of posts, retries if it still gets rate limited, and checks the number of posts it got against what the blog says it has. It's slow, but it gets all of them. Funny enough, that's an improvement over the old version, which used to time out on blogs with a lot of posts. An API key would probably help with the rate limiting, but I don't have one set up right now.

There was also a bug in the new version where some emojis in post titles showed up as code instead of the actual emoji. That one got fixed real quick.

It's on GitHub

Back in 2022, I said I'd share the source code for the WPF version of this tool if there was enough interest. This time around, I'm just putting it out there: writeas-archive-generator. It's a console app, so no pretty UI, but it does the job. You'll need the .NET 10 SDK to run it, and the README has all the details.

Eventually, I want to build a Windows desktop app with a UI for it. But for now, this works, and my archive page is up to date again. Thanks for reading, and I'll catch you in the next DevLog.

Tags: #DevLog #ClaudeCode #DotNet #CSharp #WriteAs #WriteAsNet

Discuss... or leave a comment below.

I've had a personal Claude Pro subscription for a few months now. I've used it to build a few apps that my kids and I use at home. Most recently, I rebuilt my personal homepage with the help of Claude Code.

Choosing a tech stack

Part of my discussion with Claude was what tech stack to build the new site on. I considered React, ASP.NET, or even a popular static site generator like Eleventy. But at the end of the day, those all felt like overkill for a static site with at most 2-3 pages. I decided to just have Claude build it with plain HTML and CSS. Any future updates I can handle myself by editing those files directly, and with continuous deployment from GitHub to Netlify, shipping a new build is quick and easy.

That continuous deployment pipeline turned out to be one of the real benefits of using Claude to help build websites. It knows GitHub, and it knows Netlify. I had no idea how to set up a pipeline that deploys automatically from GitHub to Netlify, and researching it myself probably would've taken a few hours. With Claude, I had step-by-step instructions and a working pipeline in under 10 minutes.

Read more...

So, for awhile now, the Write.as Archive Page Generator on my hobby site wasn't working anymore. For some reason, calls to the Write.as api just started failing. The error I was getting back was “The response ended prematurely.”

Took me awhile, but I finally found a fix for the error. Turns out, I now need to add a “user-agent” default header value to my requests, to allow the api call to go through. This seems to be an issue affecting Web APIs written using C#/.NET starting June 2024. Credit goes to this answer from StackOverflow.

Tags: #DevLog#ASPNETCore #WebDevelopment #WriteAs

Discuss... or leave a comment below.

There was a bug on my Write.as Archive Page Generator web app. Instead of creating URLs with the correct alias in there, for instance https://write.as/dino/blog-post-title, it was hard-coding the word alias, like https://write.as/alias/blog-post-title.

It was an easy fix, though it wasn't the web app that was broken, but the API that it was calling. I mentioned in a previous post, that I was working on an API to power my Blazor WASM apps. The API is functional, it's out there on the internet, running as an Azure App Service. And it's the one with the bug that I just fixed a few hours ago.

So, the Write.as Archive Page Generator should be working correctly now. You no longer need to do a “search and replace” on the output to correct the URLs.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

My Write.as Archive Page Generator is back up and running. I've already updated the Archive pages for my other blogs. It seems to be working fine. Please give it a try and let me know if you run into any issues with it.

I did notice, during my testing, that it can fail on blogs with a huge number of posts. That's mainly because the API call times out at like the 1.7 minute mark. I'll see if I can fix that in the future. But for now, just getting the archive page generator working is a win. So I'll call it a day.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

Version 1.2.1 of WriteAs.Net has been released.

This very minor update adds an interface for the WriteAsClient class, which opens it up for use with dependency injection in ASP.NET Core. This allows you to create a single WriteAsClient instance and re-use it when needed, making the caching additions from Version 1.2.0 much more useful.

This also frees me up to make better use of it in the API I'm working on.

You can install it via nuget: Install-Package WriteAs.NET -Version 1.2.1

Or via the .NET Core command line interface: dotnet add package WriteAs.NET --version 1.2.1

If you find any bugs or issues with it, please let me know. Thanks and y'all have a good night.

Tags: #DotNet #WriteAs #WriteAsNet

Discuss... or leave a comment below.

A number of people have been asking me about why the WriteAs Archive Page generators I made no longer work. They no longer work because of CORS restrictions on the API server. I'm trying to see if I can work around the restrictions on my Blazor WASM apps by going the Web API route.

Started working on an API for my websites

Tags: #DevLog#ASPNETCore #WebAPI #WriteAs

Discuss... or leave a comment below.

It's been awhile since I updated the contents of the Archive page on my journal. I stopped updating when my Blazor apps stopped working. Archive Page - Dino's Journal - 20220625

I remember working on some update to my Blazor apps, but the limitation of Blazor WASM as a client-side application, plus the CORS restrictions I kept running into, made it a headache and so I stopped. I eventually created a WPF app just for my own use.

WriteFreely Archive Page Generator written in C# and WPF

This is what I used today to generate the contents for my archive page. Yes I know it is ugly. But I just need it to work, I don't need it to look pretty. And well, it does the job just fine, so I'm happy with it.

Since it is a WPF app, it will only run in Windows. So sorry folks, it's not something that everyone else can easily use. But if there's enough interest on it, I can share the source code in a public repo. Let me know in Remark.as or in the comments below.

Tags: #WriteAs #WPF

Discuss... or leave a comment below.

Version 1.2.0 of WriteAs.Net has been released.

This latest version now allows you to enter an API key when initializing a WriteAsClient instance. This API key will allow you to bypass the rate limiting checks on the Write.as API.

Some basic in-memory caching has also been added to the client. You can configure some of the cache settings when initializing a WriteAsClient instance. The new settings are described below:

  • cacheExpirationInSeconds determines how long data will stay in the cache before it expires. The default value for this setting is 300 seconds.
  • cacheSize determines how many objects it can store in the cache. Note that a collection of posts (List<Post>) and a single post each count as 1 item. The default value for this setting is 4.

You can install it via nuget: Install-Package WriteAs.NET -Version 1.2.0

Or via the .NET Core command line interface: dotnet add package WriteAs.NET --version 1.2.0

If you find any bugs or issues with it, please let me know. Thanks and y'all have a good weekend.

Tags: #DotNet #WriteAs #WriteAsNet

Discuss... or leave a comment below.

I'm working on an update to the WriteAs.Net client/wrapper library. In a previous post I talked about adding caching to it before I release a new version. I ran into some road-blocks that derailed me. I ended up pushing it off to the side to focus my time somewhere else.

The two issues that I ran into were: figuring out what the cache key was going to be for the cached object and removing the oldest object in the cache. I now have solutions for those issues.

For the cache keys, I figured I could use the method name plus the parameter values.

For clearing out the oldest cached object, I decided to make use of a generic Queue collection that could accept the cache key values. Then I could just pop-off the oldest value from the Queue and use that to remove the associated object in the cache.

And so anyway, I should have the updated version of the client/wrapper library out soon. I just need to do some more testing on it.

Tags: #DotNet #WriteAs #WriteAsNet

Discuss... or leave a comment below.