BrandGhost

LIVE CODING - WordPress Migration to Blazor - PART 4

It's time! WordPress on AWS LightSail has been non-stop problems for nearly 2 years now. Time for a change. I'll be looking into using LinkDotNet.Blog by Steven Giesel as my blog engine of choice. But migrations are never easy, so this will be the first of many sessions trying to figure out how I can get my blog setup before going live. Remember -- I need to keep as many links active as possible so I don't ruin my SEO!
View Transcript
all right I think this is going um this is a bit hectic to get started here my camera wasn't coming through uh even though I was streaming last night and everything was fine so it just like stopped working so I was like oh no um and of course it's like right as I want to start streaming so that's perfect um but I think it's working now um I can see myself on the interwebs I'm just going to get this uh launched on Tik Tok as well so I need one moment and that's just because I was panicking because this thing wasn't going but um so just got to Wordpress migration to laser cool so just launching that and I need one more second thanks folks I appreciate the patience okay so we are going to be doing some coding today which is sweet um so this stream at this time slot what I've been trying to do is migrate my WordPress blog which has been a total pain in the butt uh migrate my WordPress blog over to Blazer so Steven gel has a uh Blazer uh blog engine so I should actually get the link to that ready um it's early here so I'm still kind of falling apart hello good to see you I'm doing well this morning thank you for asking I hope you're doing great um I'm just I flustered myself because my camera wasn't working as I was coming on here so now I'm like oh no Everything feels like it's off but it's actually fine um so I'm just going to put the link to uh the repository that I am using from Steven gizel so give me one sec this is going into the chat um if you're on LinkedIn you should be able to see the uh um The Links come through in the chat but they won't show up in the comments just a heads up it's kind of kind of silly how this platform Works uh technically only only the uh I think it's twitch Facebook and YouTube get the chat messages that I'm sending directly into their chat so um that's kind of a limitation of restream IO so thanks for understanding that if I ever send a link like uh in the chat and it's not something that you can type and it's a pain in the butt like let me know and I'll I'll send it on the platform itself and that way you don't feel like left out because you can't actually navigate and you have to type out like a full goid or something ridiculous just ask and I'll I'll put it there but um so I put the link to Steven's Blazer engine there uh awesome Stephen is here in the chat so great to see you Stephen um so I want to give you a little bit of background for where things are at and what we're going to try to accomplish today so uh full closure I don't think I'm going to finish today still but I'm I actually think that we'll be in a really good spot to uh to basically press the press the hammer and have it all migrated uh effectively so um what we had done before was we took the perspective of migrating a single post and I don't mean actually migrating it to like put it into the database I just mean migrating the format of it so we started playing around with that and what I was doing was taking the HTML body of the post because on WordPress for me all of my posts are saved as HTML and in Steven's uh engine we're able to use markdown and and I learned this from Stephen I didn't actually know this ahead of time but markdown technically fully supports HTML which is sweet um so it meant that I didn't have to do full migration of my existing post like I mean that a lot of the post itself already would render properly in the Blazer blog engine so that's that's really good news because otherwise there is a lot more work to do but um what we were able to do was take a single post and start looking at the pieces of that post that do not translate properly so for example um all of my uh existing uploads all of my existing uploads when I go to migrate to the new blog engine they're going to break in terms of like the picture references and stuff and that's because when I go to take down my old WordPress site all of those pictures are currently on the WordPress site I need them somewhere so there's things like this there's some stuff that's uh like uh I I needed to ask Stephen for like member only post because I need to flag some of my stuff that's paywalled so my newsletter that I have is the archive of it is paywalled so that was something uh there's something called short codes this concept where you can basically take a little tag that has an identifier and have the the blog engine itself replace that tag uh when it goes to display it with some other HTML or markdown and this way for example if um I have courses on like reflection or refactoring what I'd be able to do is write the blog article and I could put a short code in the middle somewhere and then I could reuse like a template for a little course advertisement to say hey by the way like I have a course on this if you're reading this article and you're interested in the information you could check out this course so just little things like this um that would make the quality of life for me uh significantly better in terms of migration so uh Stephen has done just an incredible job uh in terms of uh supporting me it's been super cool because like I said he's he's in the chat right now uh I think he's still there uh but he's been joining the live streams and and and seeing where I have some pain points and we've had good discussions offline and stuff so um yeah I guess what I'm trying to say is the support from Steph has been way more than I ever expected so I'm very thankful now that's kind of where we got to last time and what I wanted to show and get to is being able to actually put the posts onto the Blazer site um but one of the things I've still been nervous about from a live stream perspective is I didn't want to open up my Azure portal and then spend all the time on stream tweaking things because I think that there's a a higher likelihood that I'm accidentally going to show something like secrets and I really don't want to like you know be Hest stream have some Secrets exposed and number one not realize or number two like realize and then like have to shut down the stream and go panic and go reset everything and I just don't want to be in that kind of position so what I did over this weekend was I tried as best as I could to make sure all of my Azure resources are set up so um to go through the the list of things I had to set up a mySQL database in Azure so the blog is currently hooked up to that uh I actually have it deploying in Azure so that was I guess a big step too um there is the Azure blob storage is wired up so um what I also did was I took all of the picture uploads that I had on WordPress they're now in Azure blob storage I hooked up the CDN to that as well so that's the content delivery network if you're not familiar with that cdns are very important because when you have a website that's being accessed globally you want to make sure that people are able to pull resources like images very very quickly and if you're not totally familiar with this concept uh where you are geographically makes a big difference in terms of performance so cdns can be spread out across the world and that way when you're trying to retrieve information you can go to a closer uh CDN node to be able to pull content and ideally it's significantly faster than going to the origin server to pull that data so CDN is hooked up to Azure blob storage which has all of my uploads so this is good I have uh o hooked up to uh to Azure I think I have all of the pieces hooked up to Azure at this point and I ran a test over the weekend which I'm going to explain this part in just a second but uh I can have my I basically imported all of my blog posts uh into the new blog they're all busted but like they they work um so imported them all and then I can drop them again so in order to do that I made one more little tool we're going to merge this tool with the previous tool today and then we're actually in this position where we can press play in the console app blast in all of the posts or maybe we just limit it to a couple and then go look at how they're rendered literally online like other people that are on the stream you can go to the website you can check it out to and then we can say okay what's still busted here and then we can go back modify how it's being transformed drop the stuff rerun it and see how it looks so I think it's going to be a pretty cool exercise I'm excited because we are so close to getting it done um yes and then Stephen saying for your images you could name on your blob storage uh WordPress and put everything under upload with this every image URL should work with your WordPress blog so yeah thanks Stephen I think one thing that I realized because when I was asking Steph for some help around the Azure blob storage stuff um something I was worried about before was that I needed to maintain all of the the existing URLs for my my media and I actually think that that was an incorrect assumption on my part so just to explain um when we have the blog post on one site blog post can uh refer to each other right like it's actually a strategy with uh search engine optimiz ation that you want blog posts to link to each other and that way you can have this web of of links that make sure that your post seem relevant with each other it helps uh it helps the search engine believe uh or rank that your pages are actually valuable and can relate to each other that there's like some topical Authority on your site so if I were to migrate the post themselves and the posts didn't have uh consistent URLs like that would be a big problem for me because all of my internal links on my website would break not only that I've shared out links across all of social media platforms for like two years straight now any post like that would also break because the the post URL would just not be the same anymore so that's one part and I I knew I had to tackle this but I thought the images would be a problem too and I actually no longer think that the images maintaining their full URL will be a problem because as I import posts what I'm hoping what I'm hoping that I can do is replace every single upload URL cuz they'll look the same it will say like Dev leader.com storage and as long as I replace the prefix with the CDN prefix I should be good to go um otherwise what I would need to do is just replace the full URL so I only have to change the prefix we will see that today uh fortunately because I think I coded that but like I said the posts aren't going to be perfect yet but this is going to hopefully illustrate to folks like this is the iterative process I need to go through to be able to do the migration at this point so I think we're left I hope with the interesting Parts uh because in my opinion configuring things in Azure is like kind of a it's not like Azure specific I don't like configuring stuff like whether it's AWS or Azure it's a pain in the butt I don't like having to go through and be like why like why can't I access this oh it's because I didn't you know like forward something or I didn't have oth for it like just a pain in the butt so I'd rather just code stuff to be honest so I need to go pull something from my other machine cuz I was developing on my laptop to get this other piece working so I'm just going to grab that um by the way when I go through this stuff uh the stream that I do in the evening so for me it's uh quarter after 7 a.m. right now I do a stream the night before at 700 p.m. my time and I always remind people on that stream if you have any questions about like it doesn't have to be about what we're going through right now if you have any questions at all please just ask uh I'd rather you know make sure that I can spend some time answering questions um if they're helpful my answers are helpful I mean okay so I pulled that project over give me one moment I will open it and then I'm probably going to use this one as the no I'll use the other one as the Baseline but I need to I need to show you both of them in action so let's get this guy opened up and we will use we use the old the old Visual Studio not the preview one for this uh okay and let me switch over to full screen here we go um give me one more second actually because I want to make sure that I get my app settings kind of hidden like I said it's only going to take one of these silly situations where I'm like oops there's the password everything um so this is a pretty gross uh little program but I'm going to explain what it does um oh and and Stephen has a question so maybe it's only me but it would be interesting to know how life is at Microsoft how does Microsoft tackle projects products Etc sure um I can let me spend a couple minutes talking about this before I into some of the code um because we're about if you look on my screen we're about to see this super gross query but we'll come back to just a moment spoiler alert um yeah so to Steph's question like life at Microsoft um I think this is an interesting question to answer because it I can guarantee that it will look different depending on who you're asking and what part of Microsoft they're in so for me I'm on the side of Microsoft that's called substrate and substrate is the plat platform that supports all of The Office 365 products so uh like I don't work on Azure I don't work on Windows Xbox and more joins that's right there's a lot of joins in there um so there's all these different areas of Microsoft and because Microsoft is so huge I can I don't I can basically guarantee that those feel like different companies entirely just because of the scale of things so with within substrate there's hundreds of teams already like it's it's a it's a big space so so substrate like I said is the platform for all of Office 365 services so um what is life like for us even within substrate I would say it probably looks different in terms of how teams tackle projects I can elaborate at least on how we approach things um and maybe some high level things so um because of the scale and how many team and stuff are involved there is generally planning that's done uh at a high level so it will be done for like high level months at a time so you might have like a uh either for a quarter or for like a whole half of the year you would project out the things that you're hoping to accomplish and then this type of stuff it's it's not carved in stone but it's basically your opportunity as a team to say like here are the things that we plan on focusing on and where we plan to drive like improvements and things like that and then you communicate this up through like leadership levels it doesn't like go up to like SAA because that wouldn't make sense but it does get commun communicated up through some senior leadership within our organization and this way they have a holistic view of the areas that teams plan to invest in and that doesn't mean that when it gets up to like the uh the senior leadership level we're not talking like Hey we're going to modify this class and we're going to add unit tests like definitely not they don't care uh and it wouldn't make sense to communicate that but we want to talk about the areas of investment so that we can make sure that we are both aligned from like business objectives like say for example Microsoft uh Microsoft is always focused on security but if Microsoft is saying hey for this period of time like we want teams to make sure that they are investing more into security and maybe the uh next period it's like you know this is the the number one top priority like basically the focus areas can can shift as a business uh but there's always going to be things like security trust at the top obviously co-pilot's a huge factor for us so the business kind of sets these like highlevel goals like these are where we want Investments and then the teams basically come up with how are we contributing to that and how are we contributing to like literally our team's uh like Mission St statement right so for example I was on the deployment team before for substrate so the deployment team would be responsible for making sure that all of the uh substrate services are deployed um as you might have expected so that will mean that we want to focus on like how can we deploy things faster how can we make sure that uh teams have visibility into their deployments how can we make sure that uh if something has gone wrong with a deployment that teams understand that that they can mitigate it faster like they can selfservice is necessary so these are types of things that our team would want to do and then we would go look at business priorities as well and then we'd say okay if security is a priority how do we make sure that what we're deploying is like literally signed it's guaranteed to be what the developers signed off on that like that there's like a uh like a chain of Trust basically that's maintained so like we would have to factor in these goals in our planning as well but this happens at like a long-term scale like on the order of like quarters uh so like you know 3 months at a time to 6 months at a time uh sometimes even like very high level we would say like next year we really want to make sure we're focused on whatever but obviously the longer you project out the higher likelihood that like you're not doing exactly that it's just inevitable so once we have that kind of stuff laid out then it comes down to like more execution so that's where like I work with PMS to make sure that we're like strategically aligned with the business business initiatives and then within that like you know we'll have uh different Engineers of different levels picking up different size projects within that uh and my team currently which is responsible for routing so I'm not no longer on the deployment team I uh work on a team that does uh dos protection and routing for all of the traffic uh for substrate um so like engineers to pick up different projects for this kind of stuff and uh our team is pretty heavy on uh design documents so people would pick that kind of work up make sure that they are prepping design docs and they don't like it's not like uh document every possible thing it's more like they're actually it's a tool just for communicating and uh making sure that people are aligned before building stuff so when I say that we're heavy on design docs I mean that's the mechanism of Comm communication we've selected but we're big on communication I guess is the The Meta point there but yeah Engineers would pick up work uh as necessary for larger projects and stuff uh come up with design docs and then we kind of have this iterative process of like make sure people are signing off on the design doc uh once they have start developing the work if you need to go back to the design because things aren't panning out you know you can go back to the design make sure that you're bringing in the subject matter expert that we're helping review um that kind of thing so uh overall like um it's like it's definitely not like like agile by any traditional sense I would say but I do think that we we adapt like all of the time there's always going to be stuff that comes up and I think that's the thing that really matters is like when we need to Pivot we're having conversations like hey like this is important for the business right like we need to shift gears on this okay like let's have a conversation about what's most important make sure people can wrap up work and if we need to Pivot then we do so uh I don't know if that helps um so another angle how does your team surrounding deal with removing old features for example Google apps or sorry Google Apple are somewhat quick to scrap whole products um yeah um I'm trying to think from just like so it's it's a little bit unique because the teams that I've been on and had exposure to at Microsoft are very much like platform teams so just for perspective like as Stephen's question like if you're a quick to scrap hole products like uh we don't have we almost don't have that luxury on some of the teams that I've been on because the whole product would be like the deployment platform or like the routing architecture so um we don't we don't have that same kind of like hey let's uh we're we're iterating with like customers trying to get because I think if you're doing a lot more like either a website development app development like even mobile whatever and you're you have like more end user like literally external users um you might find this feedback loop a lot more familiar where it's like hey we're trying something out we're kind of getting a market fit getting the user feedback building iterating and if it's not resonating and the product is like not going to pan out the way that people expect it especially as a business then you would say look we got to pull the plug on this and get people focused on something else that we think is going to be successful um we don't really have that type of thing with the platform teams I've been on and that's because uh we don't we can't just like turn off the platform we can't say oh yeah nope like just turn it off so for us it's always like migration paths so um we will try things out and scale them up um and for us to answer Stephen from my perspective I think the best way to answer this is like there are absolutely pieces of technology that we deprecate and uh I I really appreciate my manager's perspective on this because I'm not a huge fan of like of just like rewriting stuff and being like like hey we think that if we were to just rewrite it tomorrow we could solve all the problems um but I think he takes a pretty interesting approach that I appreciate which is like if we have been iterating on something for years so say we've had a product or service in place for like five years or something and we've been iterating and optimizing and making it better and better he does like to entertain like what does what does the next generation of this look like and I think it's really cool because it gets us to ask these questions of like is the architecture what we have in place holding us back and that means if we're like yeah like the way we've designed this is just like it's not going to continue to scale do we go back to the drawing board and make the next generation of it is it something that we can refactor slowly pull apart and build up the new pieces but it's almost like this I feel like it's a cool philosophy of getting us to question like we're not just stuck with some 15year old thing where we're like this is the thing like we can't move away from it it's constantly like like evaluating it which I think is cool um and then Stephen saying from personal experience remove features is rare moving products are more often than not just rewrites and migrations to newer Tech yeah exactly so that's kind of been you know my experience I know like within within the routing area of substrate we have pieces that are like you know call them like Legacy there's Legacy code everywhere um and there's stuff that we're migrating there's even stuff across the entire platform where we'll have like other platform teams that have pieces of infrastructure or like sdks the teams are building on top of and they'll say hey like we're we're deprecating this and then it's like a almost like a multi-year effort to phase this stuff out um and migrate to the new thing because when you when you have this many teams building on top of stuff it's like you can't just flip a switch and say okay everyone's on the new stuff it's like go coordinate with like hundreds of teams across you know uh literally hundreds of services and it's not not going to be trivial so definitely interesting uh I hope that helps from uh perspective upgrade to Silver light yeah uh silver light too soon um yeah I hope that helps but I I enjoy it I think it's cool um yeah I love the people I work with and I think that makes a big difference too so thanks for the question um if there's any other aspects of that you're interested in I'm happy to share um but with that said we can jump back to um this very beautiful join sorry for your eyes everyone I understand that this uh this query is about to be painful but let me explain what this codee's doing um I want to emphasize that this code does not have to be good this code doesn't have to be good because it just has to get my stuff migrated and then I never need to use it ever again so I want to clarify that um that's why there's going to be stuff in here where you might be like why would you do that I'm like it's just because it's quick um and that's exactly what this is so let me explain um how this beautiful query Works uh this is a SQL query and it's terrible but what it does is it's going to be pulling the information that I need um from my existing WordPress site and it's going to be pulling that stuff into these WordPress post records so I'm going to have a collection of these and this is all of the data I think that I need to take a post from WordPress and then operate on it to translate it into what going into the Blazer blog so I'm going to explain the pieces of this I do apologize in advance I didn't come up with the schema um for the WordPress site it's just how it is so there's a bunch of garbage right here in the middle and just to Briefly summarize what all of this terribleness is uh WordPress post can have categories and tags and you might ask well what's the difference it's a great question I think categories are just like a higher level of organization and tags you might argue are like closer to something like a hashtag now in the new world where we're going in Steven's blog there aren't categories and there's just tags the other thing to consider is that my WordPress site probably has a bunch of Legacy stuff that's kind of trash um in terms of categories and tags like they're probably all over the place I'm not going to use this migration opportunity to try and like perfect them by any means that would be nice I guess but I'd rather just get off of Wordpress so basically these two things right here line 40 and 41 and then mixed with all this stuff in here all these left joins um this is going to allow us to get the categories and tags just to explain what that is so little bit later we'll see but I'm going to basically merge these things together and that way I have and I and I'll make sure that they're distinct in case I had repeated uh categories and tags but this way in the final result I will just have a set of tags for the new blog post so that's the majority of the query is just to get these two things right here so it's not that bad um the rest of this stuff obviously nothing too fancy up here you might say well what the heck is this then um basically if I have a blog post that has been published because I'm going to pull in a lot of draft posts as well there's probably I don't know if it's quite a 100 but there's probably like I don't know like 50 or so draft posts I have that I kind of just put like the shell of a post and then I've never gone back and like actually finished it and it's just so that I could get the ideas written down so I may never post them I may scrap them but I don't want to lose them from the WordPress site so I am going to migrate them but all of the ones that are published need to make sure that they have have um the the peral link set up so if they're not published they they've never had a link to the internet but if they have been published I want to make sure that I have this link formatted properly and it doesn't fit on the screen so let me just show you what it looks like um so you can see but basically it's just to get the date segment written up here so hopefully this becomes a little bit more readable so Dev leader.com the post postore name is uh the identifier used inside of the database it's not the title of the post like that's friendly but this together should give me a URL that links to my current website and that way when it comes time to uh operate on these things I have the original URL if it's been published hopefully that makes sense so far um Steven saying I don't want to see the PHP code behind that WordPress plugin I don't want to see any PHP code sorry anyone that loves PHP but um not for me personally um yeah so it's it is a little bit of a mess this is the first query um I'm going to explain the second one and I want to also mention that I did try to merge even more so this query I tried to merge into the previous one and it became so slow that it just wouldn't finish like like I even up the the timeout and it basically just felt like everything was frozen this query is responsible for getting the images of blog posts and the way that that's done requires basically uh two levels of indirection it's a bit of a pain in the butt um because the attachments this is kind of confusing I just want to explain it briefly the picture that you're putting onto a blog post becomes an attachment post I don't know why and then you need to reference that attachment post as the image so it's kind of silly but you need to have this this extra join in here to get things done properly um all that I'm doing is I'm pulling that in for all of the posts so this will basically give me a uh a dictionary so if we look down here I say two dictionary and it's going to have the post ID and then I'm formatting this looks pretty gross but this is the uh CDN link so anything that comes out of here will technically be an image and we should be able to access it already on the Azure CDN and how is that possible because I mentioned at the beginning of the stream I uploaded all of my WordPress pictures already so this means that we'll now have a dictionary that we can have mapped to the uh to the post ID and we can get where the new featured image for the blog post will be so now the next step that we want to be able to do because we have all of the information necessary for a given blog post from WordPress and again this code not a huge fan does it work yes it does that's what matters for now so then we have this for each Loop that's going to go across all of the blog posts um there's a few hundred of them so it's not like I've pulled in you know like a gigabyte or gigabytes of data or something like that there's a bunch of posts it's all manageable but what we want to do is transform them into a Blazer post because that's going going to be the new format based on Steven's blog engine so this part looks kind of gross um sorry I realized my head's cutting off some of it uh hopefully if I zoom out a little bit that's better let me make this a little smaller um what this part does is like I said earlier I'm just merging categories and tags and that's because in the new world we will not have both I don't I never really understood why WordPress needed both um but whatever we're just going down to one and all that I'm doing is I'm using a hash set to DD these things so again like is this the most effective way to do this like absolutely not but it's going to work and it's not many of them so who cares um I needed to calculate the reading time so I just copied and pasted Steven's code to calculate the reading time this is going to be a little bit unique because I think his was operating on markdown now with all of the HTML and how this calculate reading time is done my reading times are probably going to be inflated I don't think it's the end of the world I'm not going to try and make it more accurate um uh stepen saying if schedule publish date is from uh the blog you don't have to set this it's only used if you write a blog post now I want to publish it automatically um not that it does something wrong I guess okay want to publish it automatically later so okay so I don't need to set it so and maybe Stephen just to clarify if I if I wanted to uh mimic the behavior of like a posted date is it updated date or the scheduled publish date because guess I see a potential for for multiple things here it's probably good to clarify because you're in the chat I would this is my speculation updated date is purely tracking the last time a change was made to the the blog post record scheduled publish date I felt because there was only two dates I felt like it was multi-purpose which was either you are using it to look up when to schedule and it would also be if you've already posted something like that was the date that it was posted um so yeah maybe I don't know if the all all of that together if you can explain that a little further um so I basically just have them set to be the same thing because I wasn't sure oh there is no publish date itself interesting okay um I am currently how am I doing that oh I think I'm hijacking the because I for explanation uh some another feature that I was uh once it's getting published it'll be set to all interesting okay good to know um okay so for extra Clarity on this um Let me let me pull up the the blog engine just to explain there we go um one sec I want to navigate to the site so this is the live site it's on it's on the internet for real so staging um what I was able to do was take um oh I don't have any blogs so Stephen's um typical path for blogs I think it's like blog post and then the ID of the blog goes up top okay and that's how he's looking them up and and I think you can even have a slug at the end the way that I need to do it to maintain all of my links we had to go add support for something like this where I could put a date in and then a month and then sorry a year a month and a day and then the slug goes here so this is the and I realize that text is small I apologize but um I need this format in order for my post to maintain their uh I don't know like to not break any links I guess so I need some type of date and I guess I was oh did we we already changed the code for this and it probably is the updated date okay I was trying to figure out what code is going to break but we already used updated date because I remember talking to Stephen about this over the weekend so so it should actually be okay um so your use case set upd date and you're good to go yeah so as I'm I'm realizing I'm highlighting Steven's messages in the chat you can't see what I'm highlighting so so he's saying this is effectively the publish date for all sense and purposes so that's that's perfect um okay so that means if I go back to this code I actually don't want to do this I want to set this to null it seems like um and I need to make this a nullable so let me go back okay so that should address this part or these two lines updated date is effectively going to be the public date um a quick question then Stephen now that I'm thinking about this if I were to update a blog post um so say I found a typo in a blog post and I saved it is that going to change the effective publish date now so say I have a post that I made on uh July 13th 2024 and I was reading it today and I was like oh crap there's a typo if I went and saved it again is it going to change the public uh the effective publish date now if so I I will probably have to go make a tweak which is fine um I just need to plan for that I guess oh cool okay so Steph saying if you update you can define whether or not you want to update the updated date or not there's a toggle perfect problem solved excellent okay thank you so much for the clarification this is why it's so awesome to have steveen here and I appreciate it so I was the last part I was leaving off on was the reading time uh if that's not accurate I don't care too much it'll be more accurate going forward uh I have a typo that's supposed to say featured image so the featured image URL um I don't know if Steven's blog engine will get mad if I don't have a featured image I know that when we're creating the post in the the user interface it does require that you set a URL some of mine from WordPress that are old just don't so I was thinking like I'm if I don't have one I'm just going to set it to be um basically this placeholder it's like a a square Banner image that says Dev leader on it and that way everything's populated at least we should be okay um let's see and anything else in here I don't have any uh fallback URLs um one could argue maybe I could put this guy into the fallback as well maybe um whether or not something's published I'm just mapping the WordPress status which is published to uh to this Boolean uh and I could put a million likes in here for every post but I'm only lying to myself if I do that so I think for the most part this is a pretty straightforward mapping so I'm not sure if anyone has questions about what they're seeing obviously just put it into the chat um cool okay and stea was just saying it might break if I don't have a URL so I might as well just set it so that's cool okay next part um again there's probably a way better way to do this um I'm just doing a whole bunch of inserts in a loop in a transaction I don't care if it's not effective because it works uh it took me I think a couple of seconds to go migrate my entire WordPress site running this uh um this looks pretty gnarly I don't know why but Dapper wasn't allowing me to just put the Blazer post into here and I feel like normally I'm able to do that so if you're I know a lot of people use Entity framework core I like using Dapper um and I like using Dapper because I like seeing the sequel right in front of me and I realize that's probably really weird for a lot of people and that's okay um I I am not here to say that dapper is better or worse than Entity framework core I know Entity framework is heavily used by everyone I need to and I'm hoping actually that using Steven's blog engine because it uses Entity framework I'm hoping that I just get forced to use it more so I'm more comfortable but I I have always liked having the sequel in front of me um but usually what I've noticed with Dapper is that I'm able to um maybe if use a yeah I thought it was a record maybe it's not um yeah I think they all are records though so anyway um yeah usually like what I've expected to do in the past is like let me just cut this out like I believe that I was able to do like Blazer blog post just like this and because all of the properties on this are these right are these uh parameters in the SQL query I thought that this just worked and I feel like I've used used this before in many other places and it just wasn't working so I remapped them all out by hand and now it looks pretty terrible so whatever like I said we just need to get this to to work like this is not going to be production code that's running all the time uh it's only going to be getting multiple runs because the conversion is not going to be perfect that's it so what I want to do is cu I wasted a lot of time just explaining what all this does but I hope it's helpful um I'm going to run this and I just want to run it and make sure that it's not going to uh fail to connect and put my password up so I'm going to move it off the screen while I run it I'm just going to press play I'm not cheating or anything so we'll go to the homepage here I'm going to press the Run button which I've just done right now and what we should see is that all of my blog posts get migrated over hopefully I've never run it on this machine it shouldn't be any different okay so it hit a break point it's about to go do all of the inserts now let you see the top of the the bar here so you can see that it's it's running so when we go to iteratively do this we might just do a few blog posts at a time because the insert is going to be the slowest part to read it and transform it took like two seconds but I'm not doing like a bulk insert I'm just being kind of stupid with it but we could just do like 10 blog posts at a time and it would be done okay so that that migrated my entire WordPress site it's really not that long okay so if I go back home let me go to post I guess there's all of my blog posts which is super cool um let's go back home oh this is probably cached right so let me log in and I think that there's an admin setting right so if I go to show settings invalidate the cache now look look at that it's my WordPress site but way better um and for reference all of these things are in Azure CDN right so if we just open up one of these again it's not going to be correct yet just as a heads up okay so there's a bunch of parts in here that we know are not going to map properly for example one of the things that has to get addressed is I like having um basically a table of contents directly on the article itself um oh and sorry I missed Steven's comment for the Dapper thing yeah it's a runtime issue it's not a compile time thing which is uh even more weird but yeah I like I said I've been able to use Rec I feel like I've been able to use records like that before and it's been no issue so I don't know what I'm missing so you can see that we didn't do any transformation at all that's not fair to say we did extremely minimal translation right like this is just an HTML article dropped in from my WordPress site um this is okay this is a link I wanted to see if there was a link to another article or something but that one's on substack directly um pictures like most of these I'll probably want to Center so little things like that oh uh we talked about this on the previous stream we actually have a fix for it but these YouTube uh links are supposed to be embedded so oh see what's currently not showing up is related blog post that only runs if you publish something via the blog okay good to know that's good to know um so for folks that attended some of the previous live streams we we will literally remigrate this today um and we should be able to have these uh video embeds working so the whole point of this is now we can see what it looks like and then we can go figure out what to address and what's broken so we have code that addresses this that's great um there was no pictures embedded in this one let's go over to posts let's jump back because I haven't been writing blog posts since I've been working on brand ghost um can I can I pull up my GitHub one sec it's kind of funny um yeah there's if you can see when I started working on brand ghost uh right around here basically like this April time frame frame forward um this is if you were to look at when I started publishing or stopped publishing blog posts it's basically like right around April I just stopped publishing blogs because I couldn't keep up with writing blogs and uh and working on brand ghost I I said one of these things has to go and I want brand ghost to succeed so um sorry so anyway kind of funny um which if you look at my my blog post they're basically all um they're basically all what's the word I'm looking for uh newsletter articles this one is weird oh no did I I actually had a I did write a blog post in May perfect so one of the things we were looking at before is like yes the code blocks still work which is cool um this is I'm referencing some stuff from Andrew Lock who's an excellent net Creator by the way Steven who's in the chat that made the this blog engine is an excellent net Creator uh this is the entire reason I was able to find his blog engine so like you can see like these blog posts actually look pretty decent in terms of formatting and stuff um I just I'm trying to look for okay here's an example of a short code right let me zoom in here I already lost it there it is so you can see ocean WordPress this is a a plugin I was using and this is an example of a short code so I will need to go back and figure out what short codes I need um to make things work so um we can write a red Jax parser that looks for ocean WP library with a square bracket and then and I maybe I make a list of them and then I have to go back and migrate them I'm not exactly sure um oh stepen saying interesting some of the messages sometimes get lost I've noticed too like um right now just just for reference for folks if I've been missing your messages I just want to call this out uh restream is showing me that all six platforms are connected to the chat but the there's an order of magnitude more people on Twitter right now and I've not seen one Twitter message come in in fact I only see them from Steven which maybe that is the reality um so I'm just just refreshing the chat on my side I don't know if that will so I I pressed refresh I lost every single message that's come through so that's perfect um I I had to share on Twitter yesterday like I think restream has a bit of a glitch going on um using tags leads to an except an exception okay uh is Stephen is that on my end like I messed something up or there's uh a bug in the the blog engine um boy I can't write awesome yeah no it's all good another thing I want to call out so like this is a short code I will have to map these um something else this is an SEO thing oh interesting invalid Json yeah so let's go back to I just don't want to lose this train of thought so the tags um interesting it does put it should never be um null so I would think that like based on this logic here that this should never be null um or or even like empty uh Json because if it was if it was so like basically merged tags here should never be null which means it must be at least an empty collection which means when we to array it because it's a hash set when we two arrayed it should just give us an empty array which I'm hoping if my logic is sound that we're always at least serializing an empty array and and Stephen saying empty should be fine so I don't know but uh I can also like poke through the database and see what's there too so um jumping back to this this is one of the things that I will need to find out how to migrate I want to explain this very briefly um this one isn't populated so it's a bad example I'm going to jump back to an earlier blog post this one still has a TBD I never went back and did it this is an SEO optimization and I'm going to explain it briefly because some people I don't know you might be like hey I'm here for the C and Blazer stuff and that's cool but I want to take the opportunity to explain a couple of things that I'm not an expert by any means but I've been trying to learn along the way so if we jump back to an earlier blog post um like this one for example you can see another short code up at the top um these links are still going to my old site so that's cool uh Dave Callin shout out to Dave but what I want to show you hopefully this one has it at the end see how there's an a frequently Asked question section um this is an SEO optimization that tells the the Google bot and other search engines like you've probably done a search before on Google and you'll see I mean a page of ads first because it's Google uh how the mighty have fallen and so you'll get a page of ads and then beyond that you'll get like one search result which to Google's uh credit is usually like probably what you want after the page of ads and then you'll see like a section that's just like questions and then you expand the question and you get an answer and stuff and that's like what this information is so there are sections that you can put on with special tags that allow uh search engines to figure out if you have like like formatted frequently asked questions um this one looks like it's okay but um that's not always the case like I already saw from the weekend maybe maybe I got unlucky but some of them from the weekend when I was running this you would see like basically some of the HTML stuff bleeding through um kind of like it was almost like meta tags that were added on by the plugin that in in the WordPress plugin it's able to strip out properly but the mark down was like I don't know what to do with this so you would see above all of these titles you would see like a crazy block of text and you're like what the heck am I supposed to do with this uh but it looks like these are coming through okay so I'm interested if I press F12 if we go look at this for example okay you might S I realize a text is probably microscopic so I apologize but you see here you can see that this is AI o SEO so this is Allin one SEO that's the plugin I was using as an FAQ block question so what I was observing over the weekend was that these were it says H3 with this class like this was basically just showing up where the title was so something was incorrectly formatted um but uh something interesting here is like I don't know like I basically when I do this migration I might accidentally break all of the SEO effort that was done to put FAQs in so what I will need to do is go look at an actual web page so if we went to um the same link on my actual live website and we looked at the FAQ section it might be formatted differently in fact I suspect it is and it probably meets the uh the standard spec that Google's looking for for FAQs so I will likely and we're probably not getting to it on this stream but I will likely need to go rewrite these sections uh as we import but it's okay because I can drop all of these blog posts again and just reimport I have an entire copy of my website right now so I could turn off WordPress and I'm not going to lose the post because I have a copy of them um so yeah we're in good shape there so I will have to address that but I think the first thing that I want to do is um yeah I'm giving stepen all my my SEO Secrets he said I wasn't didn't know there was a Structure for this yeah this is uh one of the things like um there's a whole bunch of stuff like this and I'm like I said I'm not an expert but um you can there's basically a bunch of meta tags for all sorts of like especially Google features like I don't have a recipe website but you could do that the same type of thing for recipes um that's actually one of the reasons why like there's a ton of effort that goes into recipe websites because if you have a website with recipes and say you're writing an article and you're you know doing a food blog or something you can put the recipe in there and literally when someone searches for like what's the like healthy chicken recipe like if Google has picked up your website you might even have like a recipe on your page show up in the search results directly and people don't even have to navigate to your page yet so it's just this really good opportunity to get more visibility so you can do this with books you can do this with people um there's a whole bunch of different things so I was trying to spend a lot of time every time I would make a blog post being like do I have all of these boxes checked and one of them in particular was um for the FAQ section and the other one I'm pretty sure uh this is not quite the same but I'm pretty sure table of contents does help with um with SEO that might be bull crap at this point um I was trying to do a lot of reading and I believe that I read that having a table of contents does help but maybe I'm making that up now okay enough blabbing this is pretty cool um this is like I said at the top here the tags might like I might spend some time trying to clean these up I don't know maybe these don't work anymore oh yeah Stephen I don't know like did I need to like do the tags not work because it hasn't been posted through the site maybe maybe I should mention too I was doing some other stuff on the weekend so I was nervous that I have these landing pages on my existing site so here's my existing site it's awful um every time I show this I feel sick to my stomach like The Styling and stuff in the top like this is not what it's supposed to look like but it's like all all the uh the caching and minimization to try and make it faster and it's still not fast um makes it look like trash but um so I have like these these coar landing pages so I wanted to make sure that I could not lose like Dev leader. courses so if we go back to here I have like a courses section and it's Dev leader. courses obviously the staging part will go away um so the only things like I I had like a fancy button on the other one right if I jump back over like it's a ooh it's this button that I can hover um but oops wrong one sorry but like I can always replace this that's fine but all of these should work um so I got my course landing page um I had like a section for my newsletter so if people were interested in subscribing to that like there's a whole landing page for it um products is just an external link so it's just like gumroad stuff that has a couple of things um but yeah I was able to just drop these in super easily which is cool yeah and then so Steven saying um okay a couple things so the tags uh might just have to wait a bit or hard reload okay good to know so it's good to know that it's ju it doesn't have to be posted through the site to pick it up um SEO is really difficult to find real evidence online is there's so much contradictory information yeah and it's always changing too but it's a I don't want to I don't want to speak ill of anyone because I'm sure people are doing it with the best intentions but there are like as a software development content creator like I focus on creating content for software but there are content creators for all sorts of other uh niches and one of them is for SEO and like the amount of information that gets published is like insane and one of the tricks and like one of the meta points is like if you notice how much people are publishing like there's the secret right there how do you get good at SEO you post all of the fraking time non-stop about everything that you possibly can related to it it's really hard to to not get picked up if you have like information on every possible aspect even if you've repeated it and you're saying it in different ways you know you search an SEO topic you're going to end up seeing the same people that talk about it it's just that it's a pretty crowded space but you could argue that about a lot of niches but anyway yeah it's you have some people that say like oh like this this doesn't matter and then other people saying like oh you're missing out on you're missing gains on your SEO by not doing this and it's like who's right I don't know like you know learn about the stuff and then try implementing it and see what sticks um and see saying as the blog uses bootstrap you can use bootstrap 5 HTML for your buttons to have the same style that's great except I don't know anything about HTML so I'm going to have to learn some front end stuff unfortunately if it was some backend SHP stuff we'd be laughing but um I'm going to be doing a lot of crying I think okay so I think what I want to do is short codes will park for a second I want to get the videos uh like this is a a video in bed it should be let's do a quick check let me pull this back over so you can see it WP block embed wrapper right this block here with this figure class whatever WP block embed a line Center so I'm going to have to and I think we did this on the previous um live stream which is what I want to integrate right now we're going to take that code we're going to drop it into this blog migration I'm going to uh limit the migration to like 10 posts or something just so it's faster and we should be able to see that my newsletter articles because they have videos they actually embed properly now so this is like a small little optimization we can make and I think it's going to make things a lot better um yeah and stepen saying so like we were chatting about this uh slug right so basically this part that you see up here in the browser tab like the part after the post ID um like there is conflicting information about whether this matters or not arguably you could say that hey look what key wordss do we have in here Blazer we have render mode dependency injection right that's like three different key phrases that maybe would be helpful for search engines someone might say like that literally doesn't matter there's no evidence that proves that that's helpful and other people will say well those are literally keywords so they're going to show up how can you say it's not helpful so in my my opinion a lot of this stuff if it ends up being trivial to do and there's a chance it will help with SEO I'll do it like for example the FAQ sections are very simple to generate it's a going to be a pain in the butt now that I have to migrate them but that's a one-time thing um yeah and Stephen saying to be honest it doesn't hurt so I see more benefits than downsides exactly if you were like hey to go make this slug is going to take me twice as long than it would take to go write the post then yeah it's probably not worth it you might as well go write two more posts like and not you know do better on your SEO than than focusing on that so anyway little optimizations but um let's go get this part working to get the videos embedded I think that's a good Next Step so I need to first I'm going to open up the other project I had so let me do that right now should be this one I think it is okay so I had this article converter uh I want to move this stuff over what's a good way to do this what is a good way to do this I know what I'll do sorry this is a little bit all over the place I'm going to take the projects that are in here and I'm going to go drop them into this other uh solution folder so give me one sec um sorry for kind of finagling stuff on the Fly here but I just need one moment this is what you get for watching a live stream and not like a a heavily edited YouTube tutorial because I end up doing this stuff when I'm making the YouTube videos but get someone to edit it all out for me so it doesn't look so trashy okay so I have those projects in the folder I'm just going to add existing project oh no what happened there am I being silly add existing project oh yeah sorry it's the different folder so I'm going to pull in this one and then um I'm going to pull in the other one this is the test one so again for folks that weren't on the previous stream um this is the previous like migrator code that we started with and all that we did was we got to replacing um I think this was uh oh we were replacing um we're replacing the HTML headers with markdown so that they get picked up properly we actually didn't we didn't make a Rex replacement for the videos I forgot we we proved that we could do the replacement and they would embed properly and in fact now I forget what what we settled on for it um but I'm going to go ahead and uh I'm G to this isn't how I want to do it but I'm going to basically make this a console application and then we're going to reference it so this is again not my recommendation um oh console app 3 the software developers new folder too yeah um yeah and the amount of console apps that are just sitting on my other computer I'm surprised it was only three I think it's uh it reset the counter um because I moved some stuff around but it was definitely like in the 20s so oops um we're going to go over to here uh yeah output type I don't want to be executable I'm just going to make this a class Library just as a heads up and then we're going to add a dependency to it in here again this is like it's an extra project totally unnecessary totally unnecessary I just don't want to copy and paste stuff around because I want to keep the test working um now what I want to be able to do is basically this is the part that does the insert we are going to just do this part for now we're going to take 10 blog posts okay so this is not going to stick around this is just for for playing around today and what I need to be able to do is make a uh what did we call it an article migrator article converter my naming is just all over the place so article converter so we'll make a new one of those and that way we can do this content part so we can do our um migrated and I'm not using a cancellation token because whatever um let me just spread this out so we will take the migrated content and put it into here simple okay so that means we can now iterate on not that uh on this part and I broke some stuff there we go so what we can do is iterate on what's happening with the replacement uh this part is okay I literally wrote the to-do list here so we still have to do the video embeds um we have to do images to update them to the CDN that's actually a pretty that should be a simple one uh and this one will do the the markdown so if we go run this again and clear the cache what we should see is that we only have 10 posts and if we double check the uh the table of contents that's built in it should do the right thing so let's just go run this it's going to be sad because there's going to be fewer posts but that's okay should go pretty quick okay so that's done we will go back up to the top in Min panel uh settings invalidate cache oo so these are the oldest this blog post I I want to I need the opposite order uh this is the first blog post that survived um this is from so this is real by the way I just want to show you because this is kind of crazy in 2013 that was my not my first blog post the first one that survived my first host migration and I was running my blog on a Raspberry Pi because in typical developer fashion I'm not paying anyone for anything I'm going to do it myself um spoiler alert it was not a good idea to do it all myself I learned a bunch so uh okay so the migration is kind of not what I want so give me one sec I want to uh reverse this so let's do um order by descending posted date okay so this should give us the latest ones sorry about that but what I want to show you is that the table of contents is working properly so there we go I didn't even change the cache a hiccup that's weird um so here we go right this is uh not my latest new newsletter article it's I guess I have to migrate more stuff from uh I lied earlier I said when I turn off my WordPress site I have everything I'm a couple weeks behind I have to migrate again but table of contents should now work right this should now work because we changed all of these headers to be markdown so just approve it maybe I didn't oh no sorry this is I'm being dumb this is this is literally HTML now because it's in the browser um we were looking at this before uh over here I think so see how these now just have random markdown this is what that regular expression was doing in the the migration code just as a heads up so the migrator is doing what it needs to so far now what I want to do is the video stuff so let's go have a look because there should be some videos at the bottom here sorry there's two scroll bars so it's a pain in the butt uh okay so here's an example so likely what I will need to do is have a regular expression that looks for this but I'm trying to remember what we settled on because there was a couple ways we could do this I think it was was it just a video HTML video because there were two things we tried and one of them did not work I think it was just video so let me just try this we're going to put this in here and I think I usually do like um I think usually like that but I had to use this is the trick I actually had to use the um the YouTube embed give me one sec I have to pull up this video you don't have to watch it but on YouTube there is a share button and it gives you the URL in this format sorry I lied it's um it's this format so I think I need to yeah so that's what Stephen saying there's something with the embed path segment right so we basically we don't need this part at the end the ID is the same but instead of this watch it's embed but I think if I were to put this into this part down here I think it works and if it's not this there was some other it wasn't a video tag it was something else but for the life of me I'm not going to remember um so which article was this this was destroying momentum so if we go save this one uh this is the update publish date stepen was talking about we're not going to press that we're going to make it visible immediately So This Will Blow The cach away I believe so that's what we want and submit okay so that's over here 64 do we get a video hey we do I didn't remove the other part right we will have to do that but this is kind of odd maybe it's not video that we want it's uh the player doesn't actually work come on come on uh is it just in bed let me pull this one up we did this before so I apologize um I have it on my clipboard so one sec double scroll bar Fiasco okay so here's the other one yeah Stephen saying maybe in the network tab or console you can find the issue you're probably 100% accurate and I probably should do that but here I am um if this doesn't work I will I will absolutely go check uh we don't want HTML we want uh MP4 I think because that's what I would expect I think this might work but let's find out it was one or the other this is kind of like the typical like if I just read the read me I would probably be okay but no not this guy oh yeah these aren't going to work oh no one sec sorry I forgot the table of contents that's on the page will not work currently okay so it is the embed one that's what we want so if I were to click this now you will see my beautiful face talking so um and there's another thumbnail with my stupid face on it so it is the um the embed tag that we want good news okay so if we go back to edit let's have a little look um maybe I think I I did this last time I'm going to show I'm going to show using AI to like to go solve this for us so one sec I think this is kind of fun so okay I'm going to end up typing some stuff into here I just need to figure out how to get my windows positioned properly um and this is because regular expressions are pain in the butt to write so we could say we know that we have we don't want this video one this is wrong but we have some structure that looks like this okay so I'm going to basically ask chat gbt to go write a regular expression that does replacement for us so I have HTML that embeds a YouTube video and it follows the following I shouldn't say follows has the following structure then I'm going to paste in this uh I need to use a Rex in C to replace this HTML with the following and then I'm going to give it this one sec um this will need to work across videos of different URL so that it doesn't just like hardcode the URL I want that to be variable please create the C function and I bet you it's going to work almost perfectly so I'm just I'm just to try it just to try it we're just going to copy and paste directly into the code and I lost everything one sec there we go we're back um so if we go to the migrator um let's see this is migr sync so I should I think I mentioned this before but this code is going to be extremely slow um with a whole bunch of regular expressions and stuff like this is not going to be an optimal way to do things but it really doesn't matter because we just have to do the migration once um sorry once I shouldn't say once it's probably going to take multiple attempts but I mean it's not like production code that has to keep running that's my point so we should be able to say um what do we call it output HTML and this pattern is not quite right um I can already tell because or maybe it'll work I don't know if it's planning to match the whole string but anyway we'll find out let's just go run it and see yeah uh Stephen saying there's also libraries that translate HTML to markdown yeah and I think uh you have uh I think you're using Mark dig in inside of yours I think that can actually do a bunch of it but I'm actually more nervous that I'm more nervous that it's going to cause like there's going to be things that it does well and then there's going to be situations where like it doesn't work and then I'm going to have to deal with like I don't know like this layer of Magic on top where I'm like I don't know what I actually need to do here um because like it's doing some of it and I have to do other parts so uh that's why I opted to kind of just like do it the hard way I guess but so let's go see if this worked at all no and I think it's because um the redx is basically looking for let's jump back to the code I think the Rex is not factoring in that there's other um text in the HTML so if we go back to chat GPT and we say um this does not work the HTML for the source video embed can be inside of other HTML on a page uh this needs to be able to operate on all instances of this text within the HTML and by the way I should mention this um I've been using chat gbt like this a lot more because I'm finding that like I don't I don't think that this is the answer with single line to be honest um I've been using chat GPT like this a lot more because there's some stuff that like I know how to do and I'm like it's just going to be faster if I don't have to think about it and that way when it doesn't work I can troubleshoot it a little bit easier but I I still don't think that this is going to work it's saying to you single line now um hey used single line before what did it change explanation of changes pattern adjustment captures a YouTube video after this it's saying that that should do it but I'd have to compare them side by side trying to do this comparison for me is not going to help my eyes at all so let's so drop it in what did it oh it did change the it changed it for sure I was expecting to see differences um at the beginning of the pattern though oh Stephen saying I really like the vs code plugin where you can add more context especially because you can drag in Project files give it context that's super cool um I almost don't use Visual Studio code for anything except front end development and if you're familiar with uh the stuff I build then uh front end development is certainly something I don't spend a lot of time doing I probably should spend more time on it but um so yeah I like I do like using chat GPT for this kind of stuff um the sequel query that I showed at the beginning of this for the migration that was another one where I'm like I know I can go figure this out but like I just don't want to have to think about it and when I go to use it I can see what it's done and it's done like 90% of the work and for me to do the other 10% I'm like it's way more effective now I don't do that for everything because there's some stuff where I'm like it's just absolutely not helping and that's okay um and sometimes even like for more advanced SQL queries there's times where I'm talking to chat GPT being like hey like this isn't working and I'm telling it why like you can't do this like that doesn't doesn't work and then it's like oh sorry I misunderstood and then like gives me the same query back and I'm like H you still don't get it so it's not perfect but I think you know at least for my development the stuff I'm doing at home it is absolutely speeding up a ton of stuff um so I will continue to use it but let's see how we did still so I I genuinely don't think that it um we should do this instead Let's uh let's grab some of the text out of here because I think when you give it more context it will do a better job so let's pick uh here how do I get more of this uh let's no let's not do that let's go to the article itself sorry for jumping around but this is how my brain's working right now so let's see um I'm just going to give it this block of HTML I'm just going to say hey it's still not working of HTML input that it will need to operate on what does it mean it has to handle a variety of different structures I'm still not sold on this it's saying like it's pretty confident but I I honestly don't think it will and even says like that's the output I I disagree I don't think that's going to do it but let's let's see this is the third time chat GPT at this point I might as well have written it myself let's put them can we put them side by side here let's see um I just want to see this part so let me pull that back up right this pattern I don't think that it's changing this pattern sufficiently it put a question mark in that's the change I honestly don't think that that's it but okay chat gbt you get one more one more shot oops and then you're fired Stephen for next stream how about doing JavaScript and PHP in the back end how does that sound sounds I think I'm I'm sick that day I will be uh I'll be in bed uh for storage at X5 would you just fine I mean it might it might do just [Laughter] fine that sounds that sounds like a lot of fun I think is how I would phrase that okay let's go back we're going to uh once again invalidate the cash jump back over check to see if Chad GPT knows what it's talking about I still think no and no it doesn't okay now we have to we have to think about things which means I need to go back to chat GPT I need to see what I gave it as an input so specifically I think it's trying to match on too much stuff um like we actually don't care about this um I care about this part so if we I realize my head is covering some of the regular expression patterns sorry it's a it's a nasty one um so what is going on here actually there's another website I like using Rex storm I'm not sure if people have used this it's one of my favorites personally so this is oh no chat gbt go away um this is one that I really like to use and what we can do is I'm just going to take the text out of chat [Music] GPT um so this is going to be the text we want to match against I know that you are prob thinking hey I'm going to go watch the stream and learn about Blazer and now you're watching me write regular Expressions um everyone's nightmare so just to kind of see I don't think this is matching at all right zero matches um let's kind of strip some things down right oh did it put slashes in there okay one sec can already see like it's not okay so and anytime we have white space like I don't just want to put a space in so but we're going to do it for now right so I actually don't care about literally sorry this is that grammarly yeah grammarly you're ruining everything go away um I only care like about this URL here so there's a lot of stuff in the middle I just don't care about so can we do something that's literally like I don't know like dot plus to um oh there's a line break okay I think that's you know what I think that's why it was trying to do single line that's why the single line thing is not right um so then we have some white space um just want to check this yeah so again I'm going to replace this with a a white space specific match I just don't know my regular expression stuff off the top of my head have to open the reference and in fact I just want to get over to this so see how now we're matching all this stuff we just don't care about then I need a group that I'm going to say starts with https col slash has some stuff um why doesn't that work oh new line Sorry okay um right so we need that which is fine um and then it will have this really it doesn't cuz I missed this part okay so just to kind if you haven't used this tool I love it because it the visual um there's probably plenty of other tools that do a a better job or you're more familiar with them whatever I like this one I just one I found a while ago and I've stuck with it but um this is going to do mostly the trick for us see how it it's pulling the actual URL that we care about outside right like it's matching all this garbage here we don't care about literally any of it but we care about this and then I have to get all the way to the end here so I need to be able to do [Music] um some more white space basically but I need to get to the point where I can do I don't want to necessarily have to do this part so not even on a new line This is why like I can't really tell so there it matches the whole block to do a replacement now um the the point that I want to get across here is anytime we have a new line it's a little sketchy because you can like technically you could have multiple new lines anytime we have a space technically like this could happen in the HTML um still valid I guess because I have a DOT plus there so that's cool um but there could be something where like like this is still valid HTML right for me to have a new line here see how it all falls apart like not cool um so I could do like this kind of thing wherever I have a new line I could say well you can support multiple new lines um that way this still works uh I don't like using new lines specifically like this I'd rather match on just white space but this is this is probably okay it's probably okay thanks for nothing chat gbt embarrassing me on my stream I thought we were friends um no single line we're taking this ra out I am quite confident that that's the source of all evil [Music] um oh interesting this replacement is uh I've never seen that before I don't I've never I've never seen this so it has the dollar sign one that's supposed to be putting the group in there but I've never actually used a Rex replace like this so I wonder what would be hilarious if this whole time it was working but the actual string that it was dropping in was it was still garbage okay thanks Steve I appreciate it let's um I'm G to I'm going to run it one more time if this doesn't work with the new stuff uh I'm going to put a break point in there which is what we probably should have done from the beginning oops and we'll have a look at what it's saying okay back to this we go to the admin panel we go clear the cache we go back to the article I think we're still screwed okay it's not matching it so is that because one sec I have one more thought I know I said i' go to theb Bugger I know I said that but I have one more thought um okay it's not because there's extra text here so let's go see um we should do um is it called match let me do this far I want to see if we get any matches we'll start with that the nice thing is the first post that we hit is the the one that we're interested in so do we get any matches we do not get any matches with this regular expression crazy crazy crazy how is that possible the HTML is what we expect the pattern so just for context too I dropped it into these uh these quotes but it has the at symbol out the front so regular Expressions get super stupid because there's like multiple levels of escaping that need to occur so when you have a string that looks like of our XXX equals like if you were to put just as an example if you put a slash in here like a backslash it it doesn't work because it's escaping this quote so you would have to do this so this gives you one single backs slash but if you put an at sign out the front you don't have to escape the back slashes anymore so that's important to note um I don't know why this doesn't work so maybe what I'll do is a new conversation with chat GPT and what I'm going to do is I'm going to tell it I have this C function that replaces text using a Rex um however is not matching as expected here is the method I need to spell method properly too um and then I want to explain to it what it's not doing so I probably need to give it more context in that but I just want to be able to kind of see if it tells me why if it says single line I'm going to lose my mind okay it did not say single line the pattern has been modified to capture the video ID within the URL non-g greedy matching optional carriage return for new line variations this is what I was saying where like if we scroll back up to here um I was putting like this part is definitely different which I think could be a source of error for sure non- greedy matching is used to account for varying amounts of text within the tags and attributes like that's a thing that like I wouldn't do that properly uh it's being more specific about the video ID which is pretty cool I think that should be okay uh I think those are all the valid characters an ID can be but basically it was trying to make it more flexible so I'm still not thinking that this is going to be the the thing but I think what we can do I think I can rewind this nice okay cool we will try to see we still get no matches um can we do ignore case maybe still no matches oh man I thought this was going to be an easy one to do but um this is a total pain in the butt this is why we don't like using regular expressions for anything so it's funny because if you're watching this you might have already said well why are you doing this like why don't you just go walk through the text go find a location of this like we could liter go WR logic to go um like parse this out and split the string up and join it back in like we probably could have done that faster than this but I'm being a little bit um picky about the fact that I want to see this part work because I feel like it should um something else that it did that I'm not a fan of I'm just realizing this now let me pull um my original code back one sec it's pulling the URL out of a spot that I don't want it to because I don't care it's pulling it out of the comment so this is my original one I'm just going to put them side by side so you can see what it's doing in mine I was saying like I don't care about all this stuff just get me to the part inside of the HTML element and it's saying we're still in the comment and they happens to be a URL like let's go use that like I don't want that I don't want that at all I want to pull it from inside uh neither are working though so who am I to say I don't know this is probably a really simple thing and unfortunately with regular expressions like if you have one character off it can break the whole thing so um probably not going to be super effective to go waste more time on this right now but this is the idea um the same thing that we'll want to do for uh for images right so do I have yeah we should have an image on the blog post one sec okay so this one here um open image a new tab you can see that this is on see how it says like www instead of staging um it's not coming off of the current site being served from Blazer this is on my old WordPress site and even when it's on Blazer it will not be served from staging it's going to be served from the Azure CDN so we could go write a regular expression again to go do this replacement and basically look for um let me just kind of show you quickly let's do another tab so if we have this input okay and then some other stuff the idea is that we want to make sure that we can pull off uh everything after uploads so we want to match this entire thing but we want a grouping that's after uploads because what I can do is take the Azure CDN prefix and replace the whole beginning part so I need to look for this right and then something like dot Plus and then um I think how is this going to look like webp or PNG I am not a regular expression expert by any means um this isn't the right thing I need um these guys I think I need parentheses so to explain what I'm trying to do is I'm trying to make a regular expression that's going to match just the part after uploads in a group and this way I can refer to it and you can see in this tool it's telling me I'll scroll down a little bit there um it's telling me that this is the piece that I'm going to be pulling out and that means if I had um this and then I had uh a PNG they both get matched there is going to be jpeg there is going to be jpg right these ones don't work so we can go say cool no problem let's go tack those on right so this is a way easier regular expression fortunately and I think man I think even on this one it makes me no never mind I'm I'm getting nervous about the beginning and end matching but it doesn't matter we don't want to match the whole string forget forget that train of thought I think we can go write this one and we can prove that um going back to here I think we should be able to prove that uh where was the article what oh man I'm in the middle of running it and debug and it hasn't imported all the Articles again but anyway I think there's an article that we were just looking at that had um the course advertisement and we should be able to prove that we have we can put the CDN prefix in front so I think that's an easy one to do I said that last time though right so who am I to say so let's go do same type of thing convert um image links or let's call them URLs and we can basically I don't I don't know why I copied and paste all that we certainly don't need all that the replacement again I've never seen this syntax with the Dollar on so I'm very curious about how that works um dollar one I'm going to keep the matches in here just for testing when we go through this but we should be able to do basically the exact same thing I'm going to update the regular expression here right so again we have the at symbol out the front so I don't need to escape my backs slashes The Backs slash that's here is to escape in the regular expression the period because the period character will match on any character and I'm trying to say don't match on any character match on a period so now in group one according to this group one should give us this part so far so good which means that I want the replacement to be where did I have this part I want the replacement to be this because this is the Azure CDN and then if we put dollar one after just to pull this back up on the screen one more time um if you imagine after Azure CDN media then we have the link to the picture that should be the blob ID that we have should be so I think that should work famous last words though right let's go see I'm basically like zero for 100 on red Jack's attempts so far matches we have zero matches come on man what am I doing wrong here some someone who's smarter than me tell me this is nuts um do I have these P don't tell me that I have these out of order because that would be super embarrassing input and then the pattern yeah that's right okay so let's try this just to prove a theory so if I said html. index of this we should absolutely see that there is something in here really so in all of the HTML you're telling me that sounds made up um I know this is really difficult to read through so I apologize I'm not not expecting you to to know um but I found it so what am I doing wrong here I have it highlighted so let's see hopefully you can see that on my screen right um I just want to move this window around so we can see it at the same time https col slash oh I found the issue it's right here that's not https why isn't it https that's so dumb okay just to make sure I don't miss any other stupid stuff let's go back I'm going to put this right in front let's look at these side by side right so basically if I can check for an s or not the whole beginning of that looks right so that's so upsetting uh https question mark I think actually fixes it just to prove it so we do get the index of match we do get one match because there's only one picture embedded in here just to show you I realized the text is super small I'm sorry but it gets the whole match if we look at the groups on it it should have three because the extension was the third one uh the zero group is just the whole match for those that aren't familiar and the one group is going to be the part that's inside our parentheses on the outside so that means if we go to do this it should actually work and I'm going to take off this break point uh this part we know still isn't working that's okay that's an exercise for another day because the entire process is going to be iterative like this so now if we go home there's no post because we have to clear the cache I will invalidate it we go back here now Moment of Truth ready so the picture still works if I go to open image a new tab where is it located Azure so one of the regular Expressions worked yay um there's got to be something really stupid with the other one so I apologize for wasting so much time on that but uh I'm going to wrap up the stream here folks because hopefully you can see that this is the iterative approach that's going to be happening the one final thing that I'll mention is that uh what I should do is basically rerun the tests and prove that uh like now I have the feature that should transform uh my uploads into Azure CDN references so I should update this one and go look for any uploads and basically map the thing over so now I have a test that I can do a regression against and that ways I'm adding more functionality I don't end up like stomping other Replacements that I'm doing so I should be able to catch it early but I think that it I do appreciate you tuning in it's uh probably more redx than anyone wanted to see at this time of day so I'm sorry but um it's got to happen so thanks uh the blog should get migrated uh relatively soon so I'm I'm very excited about that I appreciate you being here I will be doing the same thing next week at the same time and uh Mondays at 7 pm Pacific so basically the evening before I do a live stream on General software engineering topics so uh if you're interested in that check it out uh wherever you're watching this right now is exactly where I'll be uh if you didn't enjoy the platform you were on uh you can watch it on YouTube kick twitch Tik Tok Twitter LinkedIn Facebook uh not Instagram for the coding ones because it's vertical and you would be very upset but for the um the Monday night ones I do them on Instagram as well so wherever you want to watch just just tune in there but I appreciate you being here thanks for hanging out for some regular expression

Frequently Asked Questions

What challenges are you facing while migrating your WordPress blog to Blazor?

Migrating my WordPress blog to Blazor has been quite a challenge, especially with the formatting of posts. Since my WordPress posts are saved as HTML, I need to ensure that they translate properly into the markdown format that Blazor uses. Additionally, I have to address issues like broken image references and member-only posts, which complicate the migration process.

How are you handling the migration of images from WordPress to Azure?

For the migration of images, I've uploaded all my WordPress images to Azure Blob Storage and set up a CDN for them. This way, when I migrate my posts, I can replace the image URLs with the new CDN URLs, ensuring that all my images are accessible without breaking any links.

What tools or methods are you using to facilitate the migration process?

I'm using a combination of custom SQL queries and regular expressions to extract and transform the data from my WordPress database into the format required by Blazor. I've also developed a console application to handle the migration process iteratively, allowing me to test and refine the migration as I go along.

These FAQs were generated by AI from the video transcript.
An error has occurred. This application may no longer respond until reloaded. Reload