This widget is meant as an example for building a Top Pages widget and using Chartbeat APIs on your site. This returns the top 5 articles that share a section with the current page the widget is opened on, ranked by avg engaged time * concurrents. If no sections are tagged it just returns top the 5 articles
Install dependencies
Install CORS flask extension pip install -U flask-cors
https://flask-cors.readthedocs.org/en/latest/
Install requests pip install requests
Insert your API key into inpage_recirc_worker.py.
Create bookmark in your browser with any name, select "Edit" on the bookmark and insert the following as the URL javascript:void(function(){var head=document.head||document.getElementsByTagName('head')[0];var style=document.createElement('link');style.type='text/css';style.rel='stylesheet';style.href='http://127.0.0.1:8000/css/styles.css';head.appendChild(style);script=document.createElement('script');script.src='http://127.0.0.1:8000/scripts/mysticPouch.js';document.body.appendChild(script);})();
This hosts up your javascript and css on the flask server and executes it on the page
For testing: In terminal run python inpage_recirc_worker.py
in the project home dir which serves up the data object on a local server (port: 8000) (inpage-recirc2 requests from inpage_recirc_worker.py).
For use: Host the inpage_recirc_worker.py file locally and update onPageConfigFound() in mysticPouch.js so that the request points to that file. Be sure to retain the "?domain='+config.domain;" parameter appended to the URL of the request. Please note that any change to the location of the locally hosted file will also break the bookmarklet -- this must be updated in there as well if you want to continue to use the bookmarklet after setting this up.
Open any URL hosting Chartbeat code that your API key has permission to access, let the page load complete and click the bookmarklet. It should load!