Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #91, #96] Rewrite renderer #106

Merged
merged 24 commits into from
Jul 8, 2016
Merged

[Fixes #91, #96] Rewrite renderer #106

merged 24 commits into from
Jul 8, 2016

Conversation

bluepichu
Copy link
Contributor

@bluepichu bluepichu commented Jul 6, 2016

This PR includes a total overhaul of the renderer and moves post content to the DB.

Please be very careful with this. Errors here would be bad. I'd like multiple LGTMs before merging this since it's so likely to break all the things.

@el1t: Feel free to throw all the style comments you want at me now. I cleared the comments on the original commit because they clutter the PR and aren't relevant anymore.

@bluepichu bluepichu changed the title [Fixes #91, #93] Rewrite renderer [Fixes #91, #96] Rewrite renderer Jul 6, 2016
return fs.readFile(path.join(__dirname, `../posts/${post.guid}.md`))
.then((content) => {
console.log(`Updating ${post.title.text}.`);
return db.posts.update({ guid: post.guid }, { $set: { content: content.toString() } });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So. Let's talk about organisation. When I wrote this transfer code the first time, I too stuffed content into the same collection as the post metadata. But that seemed problematic to me. I realised that while posts and post data are inexorably linked, there are many cases in which you would want only the post data and not the post itself, but by linking them this way, you always force a fetch of the data. Now, I know that with a mongo server running on the same backend as the node server, making big queries is less of an issue. At the same time, it adds a lot of overhead to every query which we don't necessarily need

What I ended up doing was creating a separate collection for the posts, and linking them with ObjectIds. This means you have negligible lookup times for fetching the post from the metadata, and you also don't have to always grab the whole big content field. This might be an unnecessary optimisation, so I'm open to suggestion/debate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want post content, can't you just use the appropriate projection to not include it? i.e., db.posts.find({query}, {content: false})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

._. I forgot that operated on the cursor and not the object.

rip me

@el1t
Copy link
Contributor

el1t commented Jul 7, 2016

Also, if switching to promised-mongo, thoughts on koa vs express?

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
<script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this stay minified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same JS beautifier issue. Fixing.

}
db.authors.findOne({"id": user.id})
.then((data) => {
console.log("here", data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAYBE I WANT TO KNOW WHEN IT GETS THERE

@@ -287,7 +287,7 @@ content-row {
line-height: 1.4;

&:last-child {
// margin-bottom: 0px;
margin-bottom: 0px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying 0px is redundant, 0 works

@bluepichu
Copy link
Contributor Author

Regarding koa: I see no reason to switch at this time.

@zwade
Copy link
Contributor

zwade commented Jul 7, 2016

nor do I

console.log(`Updating ${post.title.text}.`);
return db.posts.update({ guid: post.guid }, { $set: { content: content.toString() } });
})
}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to })).then(() => process.exit(0)) so that the program terminates properly

@zwade
Copy link
Contributor

zwade commented Jul 7, 2016

Author's page should indicate that you are viewing an author's page

@zwade
Copy link
Contributor

zwade commented Jul 7, 2016

same with tags

@bluepichu
Copy link
Contributor Author

bluepichu commented Jul 7, 2016

I was hoping you wouldn't notice :|

I'm planning a full overhaul of the UI there anyway, so I was planning to handle that post-this-PR.

I could put in something temporary if you'd like.

@zwade
Copy link
Contributor

zwade commented Jul 7, 2016

lol, is that the same for contact not including any contact info?

@bluepichu
Copy link
Contributor Author

...nope, that wasn't intentional, that was just me doing a poor job porting the previous template

@bluepichu
Copy link
Contributor Author

bluepichu commented Jul 7, 2016

It occurred to me that not showing the filter "because modifying the templates is too hard" kind of undermines the primary goal of the changes of this PR, so I took the two minutes to add an ugly plaintext indicator (to be styled later).

@bluepichu
Copy link
Contributor Author

bluepichu commented Jul 8, 2016

@zwade, @el1t: Is this good to merge?

@el1t
Copy link
Contributor

el1t commented Jul 8, 2016

Can't tell, I defer to @zwade

On Thu, Jul 7, 2016, 10:11 PM Matthew Savage [email protected]
wrote:

@zwade https://github.com/zwade @el1t https://github.com/el1t is this
good to merge?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#106 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AFnNwjDZhDXkN96TF7wIirmsCQZPUZIXks5qTbG_gaJpZM4JFuql
.

@zwade
Copy link
Contributor

zwade commented Jul 8, 2016

Sorry, had to do a bunch of stuff this evening. Giving it the final rundown now

@zwade
Copy link
Contributor

zwade commented Jul 8, 2016

yeah lgtm. Would recommend waiting to push to live until after we get a few more field tests in, but merging now

@zwade zwade merged commit 44a29f4 into master Jul 8, 2016
@bluepichu bluepichu deleted the iss96 branch July 8, 2016 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants