Customization
When the different configuration options are insufficient for your needs, you can customize the sharpie code.
We advise to first create a fork of the latest stable release of SHARPIE, see SHARPIE tags on GitHub.
Next, follow the regular installation steps and make sure to install in editable mode using pip install -e . in the SHARPIE directory.
You can run the sharpie webserver and runner as usual, any changes you make to the SHARPIE source files you installed will be reflected when using the standard SHARPIE commands.
UI elements and Templates
Most of the UI elements and templates are located in one of the apps (directories) in the sharpie/webserver directory:
sharpie/webserver/server and sharpie/webserver/experiment, with the exception of the home page which is in home/.templates/ and static/ directories for these apps.Templates
We here give an overview of the role of different templates that you may want to choose for customization, all located in sharpie/webserver/:
server/templates/base.htmlthe root template, containing the root<html>tags and the menu of all pages.home/templates/home/index.htmlthe landing page that by default gives an overview of all installed experiments.experiment/templates/experiment/config.htmlparticipant-facing experiment configuration page, with room name and agent role selectionexperiment/templates/experiment/run.htmltemplate for experiment, including interaction instructions, history etc. Here you can add custom input elements, additional interaction information, custom history etc.
Styling
sharpie/webserver/server/templates/base.html, and in sharpie/webserver/experiment/static/experiment/css/control.css.Interaction
In case you want to change the interaction, you will need to add the required UI elements to the template first and ensure the styling is as you want it.
Additionally, you will want to implement some logic for capturing and processing the inputs for proper interactions. The javascript files for this are located in
sharpie/webserver/server/experiment/static/experiment/js/mobileControls.jssharpie/webserver/server/experiment/static/experiment/js/inputListener.js
If you want to send different kind of information between the front end, i.e. participant-facing web UI, and the back-end, i.e. the webserver and the runner, read on.
Communication
To change which/how information is sent between the web UI, the webserver and the runner, have a look at the following files in sharpie/webserver/server/experiment:
static/experiment/js/websocket.jsimplements the front-end experiment websocket logic. In particular have a look atwebsocket.onmessagewhich handles how messages from the web server are processed in the front-end.websocket.pyimplements back-end experiment websocket logic. In particular, have a look at_handle_actionfor the processing of participant input and_handle_broadcastfor handling of a a newstep()from the runner.
Finally, have a look at sharpie/runner/manage.py for logic on the runner-side.