solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Add Preview Mode #131

Closed localjo closed 8 years ago

localjo commented 8 years ago

Allow certain query parameters to trigger a "preview mode" where all resources are optional.

localjo commented 8 years ago

I broke a couple tests, so I need to fix those, and then write a test for this feature.

localjo commented 8 years ago
joanniclaborde commented 8 years ago

Changes look good, but I'm wondering if we should pick a more specific keyword than preview, which could happen with real URLs?

localjo commented 8 years ago

Do you mean a more specific query string? A preview situation could happen on an existing URL where there are changes to a post that someone wants to preview.

joanniclaborde commented 8 years ago

Yeah a different query string than preview, just in case that query string actually exists on a real resource.

localjo commented 8 years ago

Well the query string is for the Solidus site, the resources don't get that preview string added.

joanniclaborde commented 8 years ago

Unless one of them is dynamic and uses the preview query string value. It's an edge case, but it could happen.

localjo commented 8 years ago

So, basically if there's a resource with {preview} as a dynamic segment, it could conflict? Any suggestions on a better name? At best we're just making a collision less likely, but is it likely enough that we need to worry about it? I grepped all of my local copies of solidus sites and didn't see any resources that use {preview} as a dynamic segment.

joanniclaborde commented 8 years ago

Right, as I was saying it's an edge case, I guess if it ever happens we can always rename the dynamic segment... Maybe use preview_page?

Also, I think we should also ignore preprocessor errors when in preview mode. Most preprocessors are used to transform resources, and the page will likely blow up if the resource is missing.

pushred commented 8 years ago

Since we're talking about this as a "mode" how about following the boolean convention?

isPreview=true

joanniclaborde commented 8 years ago

Or use Yoda casing: previewIs=true

localjo commented 8 years ago

I originally had isPreview=true, but Joannic said the Solidus convention is to use underscore casing for variables, and camel casing for methods.

pushred commented 8 years ago

Yeah actually for query strings I think underscores are better. Less concerned about case, more concerned about wording =)

But we really ought to switch this project over to semistandard sometime soon. I don't know how I ever lived with all this padding! Then again, I've never contributed any code to solidus!

localjo commented 8 years ago

Wait, are we referring to the query string in the URL or the context.is_preview property?

pushred commented 8 years ago

I'm talking about the query string.

localjo commented 8 years ago

Ok, updated that to isParam throughout all of these PRs.

joanniclaborde commented 8 years ago

In my first comment, I was talking about the isPreview variable name, with the wrong casing... :P

localjo commented 8 years ago

Yeah, noticed that now. :stuck_out_tongue:

localjo commented 8 years ago

Is this good to merge into master and do a release so we don't have to lock package.json files to this branch?

joanniclaborde commented 8 years ago

Before merging, and introducing the new preview mode, I suggest:

localjo commented 8 years ago

How's that look?

joanniclaborde commented 8 years ago

Looking good, but I'd change the req.query.isPreview param to req.query.is_preview (for consistency).

localjo commented 8 years ago

Oops, sorry, got mixed messages about that. It's is_preview everywhere now. Good to go?

joanniclaborde commented 8 years ago

:+1: (please squash your commits before merging!)