file structure of big node js projects - node.js

I am building a big blog application with express and my question is about how big blogs and big applications structure their files.
For my application, I am making a new ejs file for every blog article that I write. I am doing this because each blog article that I write has a different amount of pictures, different headings, etc. However, I am realizing that there are a lot of files building up.
Is there a better way of doing this?
I thought of storing the article contents in the database but due to the contents of each article being different I didn’t think this was viable.
something like this
let articleText = query db for article text;
res.render("article.ejs", {blog_cotent: articleText});

For my application, I am making a new ejs file for every blog article that I write. I am doing this because each blog article that I write has a different amount of pictures, different headings, etc. However, I am realizing that there are a lot of files building up.
Is there a better way of doing this?
You should be able to use the same EJS template for each blog entry, so "yes" there is a better way of doing it. For us to help more specifically, we would need to see how you're storing and naming your images and how you know which images go with which blog post. Shouldn't headings be part of the content itself which is unique for each blog post and not part of the EJS template?
Yes, the headings would be part of the content which is unique.. you are right. Now my question is... if every article should use the same ejs template, what do I do when articles have images in different places within the article? Or, how would I handle article one containing a list of steps while article two does not contain that list?
Can't your unique content for each blog contain EJS and insert it in a way that it gets processed as part of the template? So, you could use EJS commands in your content. Or, you could make your own simple tags in the content that your JS processes and inserts the right things (but it would be better to just let EJS do that work).

Related

Assign multiple photos to blog article in Shopify

Is it possible to extend Shopify objects in Liquid? I'm trying to find a way to have there be more than 1 photo associated with articles belonging to a specific blog. I know I can allow users to upload more photos using the settings schema, but I need to access the photo URLs outside of the Blog template/section the same way I'm able to access its direct properties (something like article.images[2]). My understanding is that anything saved from Settings is only accessible from within the Section in which it was defined. Is that accurate?
I have the idea of saving a list of URLs as the article's content and just parse them out of article.content (and hide the list using CSS when the page is displayed), but I'm not seeing any way to do the parsing (no regEx).
I thought of using tags too, but there will be hundreds of articles and potentially several images associated with each article. I"m not sure if there is a max number of tags, but even if there isn't, it seems hack-y (and probably a bit inefficient to create tags that aren't shared by multiple articles. IDK...
Does anyone have any ideas for a good way to do this?
Metafields are done for these type of cases:
https://shopify.dev/api/storefront/2022-01/objects/metafield

Google Docs: Table of content page numbers

we are currently building an application on the google cloud platform, which generates reports in Google Doc. For them, it is really important to have a table of content ... with page numbers. I know this is a feature request since a few years and there are add-ons (Paragraph Styles +, which didn't work for us) that provide this solution, butt we are considering to build this ourselves. if anybody has a suggestion on how we could start with this, it would be a great help!
thanks,
Best bet is to file a feature request on the product forums.
Currently the only way to do that level of manipulation of a doc to provide a custom TOC is to use Apps Script. It provides access to the document structure sufficient enough to build and insert a basic table of contents, but I'm not sure there's enough to do paging correctly (unless you force a page break on ever page...) There's no method to answer the question of "what page is this element on?"
Hacks like writing to a DOCX and converting don't work because TOCs are recognized for what they and show up without page numbers.
Of course you could write a DOCX or PDF with the TOC as you'd like and upload as a blob rather than as a Google Doc. They can still be viewed in Drive and such.

Pulling two different sets of data from the same document library in a single page SharePoint 2013

I have a document library set up with multiple different categories of document, and I'm using a metadata column to differentiate between them.
I want to be able to display two different document library web part on a page for different categories of file side by side. This is simple for one category, I just set up a list view filtered by the metadata column, but when I add a second web part alongside the first, it breaks the first one.
I have no idea why this is happening, but it seems like SharePoint isn't happy with pulling two sets of data from the same document library.
When I am editing the web parts, I can get them to both display the documents I want, but then when I click save, the first web part empties.
Not sure what other information would be useful for diagnosing or helping with the problem, so if I haven't given enough detail let me know. I am familiar with SPD as well as developing through the web interface, so if this needs a more complex solution that's fine with me!
Having spent some more time playing around with this, it struck me that I could probably achieve what I wanted using something other than a Document web part, and I was right.
Instead of using the somewhat inflexible document web part, I created a content query web part which only searched within the document library from my site, and filtered by the metadata column.
This way I can create as many queries as I like and they don't interact with each other in weird ways. It also has the advantage of being significantly easier to customise the output without needing to resort to SharePoint Designer.
Content Queries are the answer!

docpad as blogging engine, pagination and problems related to many posts?

I spent the last day setting up docpad as a blogging engine, starting from https://github.com/balupton/website
After getting everything working and looking the way I like it I came to one last issue -
In the page showing all blog posts I output document.contentRenderedWithoutLayouts for each document in #documents.
I have to be ready to handle a reasonably big blog
This means I need to do pagination.
What seems like the best way to do that?
I was thinking having posts in subfolders inside of blog, but then I have to iterate folders
assume each folder is a page paginate to next page
need to also sort so that the folder with the newest posts is the first, the folder with the next latest is rendered as page 2
Perhaps your best bet is the Paged Plugin, it will automatically split a specified document into multiple documents, and inject them into the database. Does that work for you?

What is an "include template" in Express/Jade?

This article seems to suggest that there such things as include templates. I've made the obvious Google searches but didn't find any documentation.
What are they?
From the Express guide:
The Express view system has built-in support for partials and
collections, which are “mini” views representing a document fragment.
For example rather than iterating in a view to display comments, we
could use partial collection.
So when you have the same "view" for a user in multiple pages, it's more useful to have that view stored in a file and "include" it everywhere. (DRY - Don't Repeat Yourself)
Another example is when have the same layout everywhere and you want to include the rest of the page (for example you could include different headers, footers and body depending on the page).
Here's a good example with Jade, provided in the Express samples:
https://github.com/visionmedia/express/tree/master/examples/jade/views
https://github.com/visionmedia/jade
It's there in one of the H2 headings.

Resources