localgov icon indicating copy to clipboard operation
localgov copied to clipboard

Previewing more than a single page at a time

Open willguv opened this issue 1 year ago • 34 comments

Preview links only work for single pages. This means editors have to send multiple links to service colleagues for them to check guides, step by step, directories, whole content sections... it's not ideal

In Cumbria we got around this issue using separate environments, and Entity Share to push content between them https://cumbria.localgov.blog/2022/05/31/using-entity-share-with-localgov-drupal/

This may not be practical for many councils. It would be good to explore options

willguv avatar Aug 04 '23 13:08 willguv

Big issue for Essex - also inconsistent about what's shown. A big issue for stakeholders who're being asked a lot of "an email with 20 links isn't helping"

Also more urgent than other issues as content reviewing is happening all the time

Haringey has a single read only log in to workaround this

Newcastle uses Entity Share

Content designers can share a variety of content types from single guides to whole sections, so solution needs to work for all scenarios

willguv avatar Aug 15 '23 13:08 willguv

Is also an issue at BHCC, we have used the login with limited role in the past. Does entity share require a seperate provisoned environment just for testing? That might be impractical. Would it be possible to extend preview link or create a new module that grants access to a limited set of pages? Maybe setting as a cookie instead of long links??

andybroomfield avatar Aug 16 '23 11:08 andybroomfield

Hi Andy, yes Entity Share requires a separate environment - agree that this isn't practical for a lot of councils. It was very useful for us in Cumbria though

I'd like us to look at extending preview link functionality or creating something new

Can't do Product Group today sadly (you should have a cancellation) but am catching up with Stephen soon to talk about this and a few other issues. Can invite you?

willguv avatar Aug 16 '23 11:08 willguv

Wondering if we could add another workflow state "Accuracy check" which can only be viewed by a user with limited permissions

Then create a single user account with this role, and details can be shared with services

Thinking aloud here...

willguv avatar Aug 16 '23 14:08 willguv

Easiest - provide a "Service contact" read only login, as Haringey has done. Users would be able to view all unpublished content, but we don't think this is too big an issue. Users would have to find their content again

Also talk at Tech Group about options @finnlewis @andybroomfield @stephen-cox


Other options

Workflow access - a way of restricting view of unpublished content (eg by url or entry in services menu) . Provide documentation on config options

Workspace - could be created for staging etc or for a single guide which could be shared with a service contact

https://www.drupal.org/project/workspace

willguv avatar Aug 30 '23 10:08 willguv

Andy:

Brighton takes read only login approach, and also sometimes publishes on staging environment. Looking at Entity Share

BHCC comms like the temporary link idea, but needs to work for multiple pages

Thoughts:

  • Is there a way of setting a cookie with the extra string of characters attached to a url?
  • Or limit what a user can see using workflow access?
  • Or pair with the service contact notifications work?

Need to make sure the public can't discover the log in screen as they'll try to log in with MyAccount

willguv avatar Aug 30 '23 13:08 willguv

I'd like us to look at extending preview link functionality or creating something new

Yeah, that's what I was thinking. This is how it should work:

  • Editor shares the preview link for a Guide overview page (or service landing page or directory channel page or something like that).
  • Some custom code converts all URLs on the Guide overview page. This means if there is a link for /a/guide/page, it will become /preview-link/a/guide/page/VERY-LONG-TOKEN-GOES-HERE. The localgov_moderngov module does a similar URL modification which could be relevant.
  • When a request for a Guide page belonging to the previewed Guide overview page arrives later, some custom code determines its parent page i.e. the Guide overview page.
  • If the preview token which is part of the Guide page path applies to the parent Guide overview page, access is allowed. This will need some custom access checker code.

Example:

  • Editor shares link for /preview-link/node/10/VERY-LONG-TOKEN.
  • When /preview-link/node/10/VERY-LONG-TOKEN is viewed, all links on the page are converted to this format: /preview-link/Existing/URL/VERY-LONG-TOKEN. Example: /preview-link/node/22/VERY-LONG-TOKEN
  • When /preview-link/node/22/VERY-LONG-TOKEN is viewed, we determine if there is a parent. Turns out there is a parent and that is node 10. This node 10 is our Guide overview page.
  • We see if VERY-LONG-TOKEN applies to node 10 for preview purposes. If yes, we allow access to /preview-link/node/22/VERY-LONG-TOKEN.

I must say I haven't tried anything like this. The whole thing may not work or prove too complex.

Adnan-cds avatar Oct 05 '23 13:10 Adnan-cds

Thanks @Adnan-cds

Any thoughts @andybroomfield @stephen-cox @finnlewis? Worth chatting about it at the Tech Group too?

willguv avatar Oct 05 '23 15:10 willguv

@stephen-cox separately, could we specify a new read only "Service contact" role to go along with the Service contact work you're doing elsewhere?

Is this a lot of effort?

willguv avatar Oct 05 '23 15:10 willguv

It might be a bit simpler than rewriting links, just using hook_node_access and then maybe using either condition field or entity references to determine whats allowed. Theres also the issue of nodes that are linked into landing pages but not yet published so they don't show on landing pages unless you have permission to view them.

Its something to think about and possibly worth those interested getting heads together post Drupal 10 to work out the best approach.

andybroomfield avatar Oct 05 '23 16:10 andybroomfield

Anyone tried the "Preview Site" module? Looks like it might do what we want here and is created by the same developers as the Preview Link module.

https://www.drupal.org/project/preview_site

However, it does add Tome and other modules to the site as well as preview_site itself, so might be a heavy duty piece of work.

markconroy avatar Dec 04 '23 18:12 markconroy

@stephen-cox separately, could we specify a new read only "Service contact" role to go along with the Service contact work you're doing elsewhere?

Is this a lot of effort?

@willguv This shouldn't be a lot of work, but as it's a self contained task I would suggest creating a separate issue for this. There's already too much stuff going on on the email notification issue and it's possible for someone else to pick up if they get to before I do.

stephen-cox avatar Dec 08 '23 10:12 stephen-cox

Anyone tried the "Preview Site" module? Looks like it might do what we want here and is created by the same developers as the Preview Link module.

This has an interesting approach to this issue:

Extends the paradigm of the Preview link module to the concept of previewing more than one item of content, by way of a static site.

It looks to create a static site for each preview. I doubt this is a simple drop-in solution though as there's going to be some hosting setup needed to allow multiple previews to be deployed. I would also imagine creating a static copy of a large site is going to be quite time consuming and resource hungry. Could be worth evaluating through.

stephen-cox avatar Dec 08 '23 10:12 stephen-cox

What about recommending using workspaces for this sort of thing?

Workspaces is part of Drupal core experimental, but I've tested it with guides and step-by-step and it works.

https://www.drupal.org/docs/8/core/modules/workspace/overview

I did run into some problem with subsites, but I'm sure we could work through issues if we wanted to go this route.

I wonder if/how preview link would work with workspaces.... ?

finnlewis avatar Dec 08 '23 12:12 finnlewis

@finnlewis workspaces sounds like a very good idea and definitely worth some investigation.

markconroy avatar Dec 08 '23 13:12 markconroy

We'd also need to check how this works with caching, as if we used the same urls and a CDN or varnish cache is in use it might be that pages that anon users browse get saved to serve all anon traffic so there is potential for data leakage.

I like the approach of creating a static preview, but it should limit it to just the pages being previewed as otherwise there will be 1000s of pages generated, the use case is previewing a section as it would appear when published, so a way of bundling a set of pages or everything under this page, if the module linked above can do that.

andybroomfield avatar Dec 08 '23 13:12 andybroomfield

So reading it more closely

Content editors can create unlimited preview sites - each site consists of one or more pieces of draft content they wish to share with non-authenticated users to preview before publishing

andybroomfield avatar Dec 08 '23 13:12 andybroomfield

This is what the admin screen for preview site module looks like, would be nice if it could use wildcard urls.

screencapture-bhcclocalgov-test-admin-structure-preview-site-builds-1-edit-2023-12-08-13_48_58

It then builds a static site, but (at least in default config, havnt dived into settings yet) the links are all back to the main site.

Screenshot 2023-12-08 at 1 53 02 pm

andybroomfield avatar Dec 08 '23 13:12 andybroomfield

This looks very promising. Thanks @andybroomfield

markconroy avatar Dec 11 '23 09:12 markconroy

Hi @andybroomfield @finnlewis @markconroy @stephen-cox it would be good to restart the conversation about this as it's still amongst the most wanted fixes for content editors - just discussed again in a content session

willguv avatar Jan 09 '24 14:01 willguv

Preview Site looks like the best for non authenticated users - see Andy's demo above

x What infrastructure is required? x What technical support would councils need to install and use? x Have to specify every individual item to be included in the Preview Site

willguv avatar Jan 10 '24 14:01 willguv

It might be a bit simpler than rewriting links, just using hook_node_access and then maybe using either condition field or entity references to determine whats allowed.

On a form dev site, I am using the newest preview_link which is version 2.1.0-alpha2 and this may have implemented something like the above. This is how it works:

  • Add all unpublished child Guide pages to a preview link for a Guide overview page.
  • Open the preview link for the Guide overview page.
  • Click any of the Guide page links on the previewed page.
  • The Guide page opens and says it is available only because of the preview link.

Screenshot of the preview link form follows: screenshot-preview-link-edit-form

Not bad :)

Adnan-cds avatar Jan 11 '24 18:01 Adnan-cds

@stephen-cox please install on Product site - thank you!

willguv avatar Jan 24 '24 17:01 willguv

Require a config option (can't find it in the UI) for preview_link.settings.yml set the key multiple_entities: true

andybroomfield avatar Jan 24 '24 21:01 andybroomfield

@willguv This is now on the product site. You can now add extra content when generating a preview link.

It looks like we'll need to make some changes to accommodate it though. This is an unpublished guide overview: https://product.localgovdrupal.org/preview-link/node/120/755882c3-d07f-4dca-8bbd-5d18f7348efb

The guide pages are not in the navigation even though they are accessible:

  • https://product.localgovdrupal.org/preview-link/node/121/755882c3-d07f-4dca-8bbd-5d18f7348efb
  • https://product.localgovdrupal.org/preview-link/node/122/755882c3-d07f-4dca-8bbd-5d18f7348efb

stephen-cox avatar Feb 07 '24 16:02 stephen-cox

@stephen-cox this looks promising - thank you!

When clicking "Preview link" for a Guide overview, are all the linked guide pages automatically populated in the entities list?

I think we should remove the Drupal-isms. The content group can help with new wording

Is it possible to include a control to vary the expiry time (either per link or somewhere in config?)

What else would we need to do please?

willguv avatar Feb 07 '24 17:02 willguv

When clicking "Preview link" for a Guide overview, are all the linked guide pages automatically populated in the entities list?

It's a manual job to add all the links you want to preview. We could build a form to do this automatically for things like guides and step by steps, but it would a chunk of work.

Is it possible to include a control to vary the expiry time (either per link or somewhere in config?)

This can be configured at a global level; not on a given page. As discussed in Slack there's no UI for setting this, although patching the module to add a config form should be easy enough.

What else would we need to do please?

To release this as is, it's just a matter of turning it on for new sites and documenting how to do it for existing sites.

stephen-cox avatar Feb 13 '24 14:02 stephen-cox

@stephen-cox patch the module to provide an UI for:

  • switching the module on and off
  • changing the expiry time

willguv avatar Feb 14 '24 14:02 willguv

@stephen-cox could we talk at today's PG about the work involved to provide a form to add all guides/ step by step assets to a preview link automatically?

Would be good to get an estimate

We think around a day's work, followed by technical review

Let's check out why it's an Alpha

If urgent need, devs can turn on the Alpha version via the command line

willguv avatar Mar 13 '24 10:03 willguv

PR adding the admin UI which will allow sites to turn on previewing of multiple pages here: https://github.com/localgovdrupal/localgov/pull/691

stephen-cox avatar Mar 28 '24 10:03 stephen-cox