Good morning
I am working on porting this module to D8.
I have pretty much success upto now (still to adapt path conditions)

Looking at the large portion of code relating to visibility, I am wondering if moving to the block system (make it a custom block to load the hypothesis embed.js on chosen pages only) would not be an option ?

Code replication/maintenance would be greatly reduced.

Has this been considered yet ? Would you see obstacles ?

Thanks

Comments

f2boot created an issue. See original summary.

f2boot’s picture

StatusFileSize
new20.31 KB

Here is a patch file porting hypothesis from 7.x-1.x to 8.x-1.x
Not tested thoroughly yet, but seems fine as a starting point

Moving now to working on a 8.x-2-x branch that would better use D8 functionalities (Block or Conditions system)

f2boot’s picture

StatusFileSize
new14.93 KB

Here is a patch file porting drupal/hypothesis module from 7.x-1.x to 8.x-2.x (so it is an alternative to previous patch)

Hypothes.is client javascript is loaded in a (invisible) block.
The core of the initial module is preserved but all configurations are managed through the block system.

f2boot’s picture

StatusFileSize
new14.85 KB

Found two errors in #3 patch. Please use this one

@Maintainers, I have also made patches to restore "load hypothesis" permission and to allow user override showHighlights and openSidebar settings. I will add issues and upload patches for them if/when 8.x-2.x branch (or alike) is created.

Thanks

luke adams’s picture

Hey f2boot, we appear to have done nearly the same exact thing! lol idk how I didn't catch this issue 4 days ago when I decided I needed a D8 port of this... anyway I've created an issue in the d.o contrib_tracker project and uploaded a zip of my D8 version of this.

https://www.drupal.org/project/contrib_tracker/issues/3012400

I've got my copy of this running in a dev site and behaving super nicely. I wonder if the block approach is best stuck into like a hypothesis_block module or something vs a total redo on how this module is setup and configured? It does seem to make sense, to just leverage how Drupal manages block visibility... could just add via the block management page or render said block via the theme.

f2boot’s picture

Hi Luke,

Got a quick look to your code and looks like we got it very close indeed (I think yours is a bit cleaner ;) )
I have tried this "block" approach (#4) and I am using it on a dev site. At this point, I would say it is a better approach since it has much less code and we can use all context plugins to manage visibility.

I also have now a few other features on my dev site:
- add user prefs to use hypothesis or not (+ showHighlights and openSidebar)
- made a module derived from drupal/pdf to have hypothesis on pdf files
- working on a module to apply hypothes.is to html file in an iframe

I would love hypothesis code maintainer would open a 8.x branch so it is easier to share this.

bramdriesen’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Updated version. Not to sure the patches of this issue are going to be used since the maintainers seem to be working on sub-issues to do the porting.

rahul.shinde’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.