Open samc5 opened 1 year ago
I was also confused by your slugs feature. Also, I would like to complement you on your help page feature. It was very thoughtful and unique.
I understand the idea of slugs: turning the entire title into a single word. I understand it's use: to have have that title become part of the path. It is a great way of organizing your site and connecting the site to the database. However, I am curious about the construction because you do not seem to call make_slug in yout init.py. So are slugs only made by and for the database? But, that means it wouldn't connect to the website. And if that was the case, you could just use the title alone in lieu of creating slugs. Did you find a way to use make_slug in the HTML? That would defeat the point of flask itself, so it is doubtful. I get what slugs are, but how are they implemented into the init.py.?
I was very impressed with the original blog post showing up in the input instead of copy/paste requirement. You mentioned that you slugs to make this happen. What still confused me a bit is
- How exactly do you turn the slug into the text of the post?
- Why is it named a slug and who made that decision? (I could easily find this online but I choose to leave it here)
Thank you so much for your compliments and for your questions @samc5 ! I'll also try to answer your questions one by one.
For example, in the URL https://www.stuyspec.com/news/campaign-coverage/freshman-caucus-2022-vanna-lei-and-cayla-chew
, freshman-caucus-2022-vanna-lei-and-cayla-chew
would be the unique identifier that allows the backend to fetch the article and to pass it to the frontend for rendering. Things like news
and campaign-coverage
are simply things that serve to make the URL more human friendly.
I understand the idea of slugs: turning the entire title into a single word. I understand it's use: to have have that title become part of the path. It is a great way of organizing your site and connecting the site to the database. However, I am curious about the construction because you do not seem to call make_slug in yout init.py. So are slugs only made by and for the database? But, that means it wouldn't connect to the website. And if that was the case, you could just use the title alone in lieu of creating slugs. Did you find a way to use make_slug in the HTML? That would defeat the point of flask itself, so it is doubtful. I get what slugs are, but how are they implemented into the init.py.?
@SNirloy Thanks for your insightful comments and questions. In our blog, the make slug function is only called in our database script. The slug produced would then be stored in a column dedicated to slugs. When we fetch all blogs from the database, the slug is also returned and incorporated in the client-side website, thus connecting the backend and frontend with a common unique identifier that refers to some blog. In short, the client side does not make any use of slugs except as a way for the server to return the correct blog. When the user creates a blog, the title is sent to the server through an HTML form, and the slug processing is all done on the server.
I was very impressed with the original blog post showing up in the input instead of copy/paste requirement. You mentioned that you slugs to make this happen. What still confused me a bit is