Module 1 - Introduction
1. Welcome to the course2. Why Go3. Why start and build a blog?4. What about React/Vue/Angular?5. Getting setup and source filesModule 2 - Tech Stack Walkthrough
1. Introduction to Golang Part 12. Introduction to Golang Part 23. Introduction to Golang Part 34. Structuring Golang Applications5. Templating with Templ6. Just enough interactivity with HTMX7. Getting started with postgres8. Servers, routers and endpointsModule 3 - Creating the MVP
1. What are the minimal requirements?2. Doing some initial plumbing3. Embedding static assets4. Creating our first views5. Tailwind & Utility-first CSS6. Styling the Landing Page7. Styling the Article PageModule 4 - Managing Content
1. Choose your own adventure2. Writing in Markdown3. Parsing Markdown to HTML4. Frontmatter and Meta Information5. Making our code examples look nice6. Adding error pagesModule 5 - Adding the Database
1. What is a Migration?2. Our first migration: articles table3. Creating the Database Layer4. Showing the Latest Posts5. Slugs and Human Readable URLsModule 6 - Managing the Blog
1. What are the minimum requirements?2. A new layout approaches3. Introduction to authentication4. Our second migration: Users Table5. Storing passwords securely6. Authenticating users Part One7. Authenticating users Part Two8. Remember me/Forget me9. Managing posts using a hypermedia API - Part One10. Managing posts using a hypermedia API - Part Two11. Managing posts using a hypermedia API - Part Three12. Managing posts using a hypermedia API - Part Four13. Implementing CRUD For Articles - Part One14. Implementing CRUD For Articles - Part Two15. Implementing CRUD For Articles - Part Three16. Implementing CRUD For Articles - Part Four17. Flashing Ourselves/Providing Visual Feedback - Part One18. Flashing Ourselves/Providing Visual Feedback - Part Two19. Flashing Ourselves/Providing Visual Feedback - Part ThreeModule 7 - Adding Subscribers
1. What are the minimum requirements?2. Expanding the database: Tokens & Subscribers3. Creating the token and subscriber models - Part One4. Creating the token and subscriber models - Part Two5. Creating the subscription form6. Saving and verifying subscribers - Part One7. Saving and verifying subscribers - Part Two8. Saving and verifying subscribers - Part Three9. Emails and Clients - Part One10. Emails and Clients - Part Two11. Emails and Clients - Part Three12. Our fifth migration: Tokens Table13. Email validation view14. Email validation tokens15. Sending validation emails with SES16. Making it all come togetherManaging the Blog
Flashing Ourselves/Providing Visual Feedback - Part One
Summary
Coming soon.
Transcript
So we can now manage our block. However, we don't have the visual feedback whenever we do an action like creating, updating, and deleting. So the final episode of this module is going to be doing exactly that, adding these flash messages to our web app, our dashboard, so that we can see if something succeeded or something failed. And the way to do this is actually going to be very straightforward. We need to do very similar to what we did with our app context. So we can go into routes, context, and instead of going into one of the existing ones, let's create a new one here called toast.go, package context. And here we will do very similar to what we had in here. So I can actually just copy-paste it. And then we are going to say flash key. Let's just say flash key here. And we're going to be having another type here called flash type string. There's going to be a bunch of consts. There's going to be flash success. There's a flash type equal to success. We have three more. We have error. It's going to be error. Warning. Warning. Finally, we have info. Info. Great. And then the actual flash message. We're going to still be having an echo context. Let's just also give it an ID. UI ID. Type of flash type. Create it at time.time. And message is going to be a string. There we go. Then we can go into our controllers and we need to add another middleware. So just as we had this register app context, we need one to register the flash messages so that we check every time our request is made. So register flash message context. And we actually need to skip this if the request will path as slash static in it. So let's say strings. Hash prefix. And the C request URL path. Static. So if this is the case, then just return next. There we go. Just return next. If not, then we're going to get flash session. Say flash. Oh, what did I do? Flash session name. Let's add this to our const here. So flash session. All right. Let me pull out all of our flash messages from the session storage. Then we can remove this and say flash messages equals to context. Flash message or slice of context flash messages. And then say if flashes. S dot flashes. And we have the flash session name. And if len flashes, so if we actually have any flashes, then we are going to be saying for flash in range flashes. And we need to convert it to a context flash message. If flashes and then we have like this. Right. Right. Let me just remove this and remove this. All right. So we have if we have any flashes. Right. And like this. And of course, it's going to be a slice of flash messages that it's complaining about. So what are we doing wrong here? Of course, we loop over the flashes and then we say if message OK. Flash context. Flash message. And OK. Then we can add the message to our flash messages slice. So append. And this is a little fiddly, but get there. ID. Type. Message created at. Finally, message message with that one. Right. This result is never used. It will be used in just a second. We then say if error is safe, because now we have pulled out all of the all of the flash messages from the context and we don't want to them to exist after this after this request. So response. Error does not equal nil. I don't really want to block anything here. So we're just going to return it. We could say slug error context here. Pass the context. Say could not save session or flash session. Error being error. At least we have some some notification. Right. Finally, set the flash key string to the flash messages. And then we're just going to call return xc. Final thing. We do this whole registering the we register the app context on on our on our request cycle. Right. So we also need to do that with with the flash messages. So we can say app ctx ctx context with value. And in here we're going to say ctx request context as the parent and then app ctx for key and then app ctx for the app context. All right. Let me say flash ctx key. Context flash key. And then flash ctx. ctx get flash ctx key and string. Finally, we can say here. Return. Let's get rid of that one. And we're going to have the parent context be with ctx. Then flash ctx key. Finally, flash. So now we must register in routes our new middleware. Register flash message context. So it gets called. So again, this is just the order that our middleware gets called in. The session new cookie store creation first and the app context and then finally the flash message context.