File tree Expand file tree Collapse file tree 7 files changed +63
-5
lines changed
Expand file tree Collapse file tree 7 files changed +63
-5
lines changed Original file line number Diff line number Diff line change @@ -88,4 +88,4 @@ node_modules/
8888
8989# Asynchronous HTTP
9090# #####################
91- /src /
91+ /src /
Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ def render(self):
2323 logger .debug ('extension::{} supported-list::{}' .format (self .metadata .ext , settings .EXPORT_SUPPORTED ))
2424 if self .metadata .ext not in settings .EXPORT_SUPPORTED :
2525 logger .debug ('Extension not found in supported list!' )
26- return self .TEMPLATE .render (base = self .assets_url , url = download_url .geturl ())
26+ return self .TEMPLATE .render (
27+ base = self .assets_url ,
28+ url = download_url .geturl (),
29+ enable_hypothesis = settings .ENABLE_HYPOTHESIS
30+ )
2731
2832 logger .debug ('Extension found in supported list!' )
2933 exported_url = furl .furl (self .export_url )
@@ -35,9 +39,17 @@ def render(self):
3539 exported_url .args ['format' ] = settings .EXPORT_TYPE
3640
3741 self .metrics .add ('needs_export' , True )
38- return self .TEMPLATE .render (base = self .assets_url , url = exported_url .url )
39-
40- return self .TEMPLATE .render (base = self .assets_url , url = download_url .geturl ())
42+ return self .TEMPLATE .render (
43+ base = self .assets_url ,
44+ url = exported_url .url ,
45+ enable_hypothesis = settings .ENABLE_HYPOTHESIS
46+ )
47+
48+ return self .TEMPLATE .render (
49+ base = self .assets_url ,
50+ url = download_url .geturl (),
51+ enable_hypothesis = settings .ENABLE_HYPOTHESIS
52+ )
4153
4254 @property
4355 def file_required (self ):
Original file line number Diff line number Diff line change 66EXPORT_TYPE = config .get ('EXPORT_TYPE' , 'pdf' )
77EXPORT_MAXIMUM_SIZE = config .get ('EXPORT_MAXIMUM_SIZE' , '1200x1200' )
88
9+ ENABLE_HYPOTHESIS = config .get_bool ('ENABLE_HYPOTHESIS' , False )
10+
911# supports multiple files in the form of a space separated string
1012EXPORT_SUPPORTED = config .get ('EXPORT_SUPPORTED' , '.tiff .tif' ).split (' ' )
1113EXPORT_MAX_PAGES = int (config .get ('EXPORT_MAX_PAGES' , 40 ))
Original file line number Diff line number Diff line change @@ -37,6 +37,16 @@ http://sourceforge.net/adobe/cmap/wiki/License/
3737
3838 <script src =" debugger.js" ></script >
3939 <script src =" viewer.js" ></script >
40+
41+ % if enable_hypothesis:
42+ <style >
43+ body .show-hypothesis #toolbarViewer {
44+ position : relative ;
45+ margin-right : 36px ;
46+ }
47+ </style >
48+ % endif
49+
4050 </head >
4151
4252 <body tabindex =" 1" class =" loadingInProgress" >
@@ -413,6 +423,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/
413423 var DEFAULT_URL = ' ${url}' ;
414424 window .pymChild .sendMessage (' embed' , ' embed-responsive-pdf' );
415425 </script >
426+ % if enable_hypothesis:
427+ <script src =" /static/js/mfr.child.hypothesis.js" ></script >
428+ % endif
416429 </body >
417430</html >
418431
Original file line number Diff line number Diff line change 1+ ; ( function ( ) {
2+ 'use strict' ;
3+
4+ var hypothesisLoaded = false ;
5+
6+ window . pymChild . onMessage ( 'startHypothesis' , startHypothesis ) ;
7+
8+ window . addEventListener ( 'message' , function ( event ) {
9+ if ( event . data === 'startHypothesis' ) {
10+ startHypothesis ( event ) ;
11+ }
12+ } ) ;
13+
14+ function startHypothesis ( event ) {
15+ if ( hypothesisLoaded ) {
16+ return ;
17+ }
18+
19+ var script = window . document . createElement ( 'script' ) ;
20+ script . type = 'text/javascript' ;
21+ script . src = 'https://hypothes.is/embed.js' ;
22+ window . document . head . appendChild ( script ) ;
23+ window . document . body . classList . add ( 'show-hypothesis' ) ;
24+ hypothesisLoaded = true ;
25+ } ;
26+ } ) ( ) ;
Original file line number Diff line number Diff line change 11; ( function ( ) {
22 'use strict' ;
3+
34 window . pymChild = new pym . Child ( ) ;
45
56 window . addEventListener ( 'load' , function ( ) {
Original file line number Diff line number Diff line change 111111 self . pymParent . sendMessage ( 'resize' , 'x' ) ;
112112 } ;
113113
114+ self . startHypothesis = function ( ) {
115+ self . pymParent . sendMessage ( 'startHypothesis' ) ;
116+ } ;
117+
114118 return self ;
115119 } ;
116120
You can’t perform that action at this time.
0 commit comments