I recently made my first contribution to Uli. To get started, I tried setting it up on my local machine last week and spent some time doing so. Despite following the official README, it proved to be more challenging than I anticipated. I overlooked certain steps, and there were additional requirements for Windows that I had to address as well.
This is a step-by-step guide on setting up "Uli" locally for development. In this tutorial, I will walk you through the process of setting up Uli on your own local machine, allowing you to dive into its codebase and contribute to its development.
This is the official GitHub repository for Uli - https://github.com/tattle-made/Uli
Uli is a browser plugin that de-normalizes the everyday violence that people of marginalized genders experience online in India and provides tools for relief and collective response. It is an attempt to invert the top-down logics of platform moderation and center the experiences of those subject to online gender-based violence.
The plugin installation link and the user guide can be found here: https://uli.tattle.co.in/
Before we begin, let's understand the file structure of the code a bit. All the code for the browser plugin can be found in the 1
Uli/browser-plugin
folder.
The code is primarily broken into two folders, 1
plugin
and 1
api-server
.
Directory | Description |
---|---|
plugin | code for browser extension - essentially the frontend |
api-server | a rest server for storing user preferences and archived tweets - essentially the backend |
Uli is currently supported on Chrome/Brave and Mozilla Firefox only. The code will work on only these two browsers.
Clone the repository and navigate to the 1
browser-extension
folder.
1
2
git clone https://github.com/tattle-made/Uli.git
cd Uli/browser-extension/
Next, install all the necessary packages in the 1
api-server
and 1
plugin
folders.
1
2
3
4
cd api-server && npm install
cd ..
cd plugin && npm install
cd ..
We've completed step 1 – Uli is cloned, and all the required browser extension libraries are now installed.
Before starting the development server, you'll need to do a few things, like adding a file and making some changes to another file.
1
api-server
folder and create a new file called 1
development.env
with the following content.
Add this content inside the 1
development.env
file.1
2
3
4
5
6
7
NODE_ENV=development
AWS_BUCKET_NAME=XXXXXXXXXXX
SERVICE_AWS_ACCESS_KEY_ID=XXXXXXXXXX
SERVICE_AWS_SECRET_ACCESS_KEY=XXXXXXX
DB_HOST: XXXXXXXXXXX
DB_USERNAME: XXXXXXXXXXX
DB_PASSWORD: XXXXXXXXXXX
1
api-server
folder to change the control characters of a file. You will have to change the 1
entrypoint.sh
file from CRLF to LF by running the following command.
Please ignore this step if you are not using Windows1
dos2unix entrypoint.sh
1
plugin
folder and include the following code in the 1
manifest.json
file. Add this entry to the 1
connect-src
section within the 1
content_security_policy
in the 1
manifest.json
file.1
http://localhost:3000 ws://localhost
Your 1
content_security_policy
in the 1
manifest.json
should now look like this.
1
2
3
"content_security_policy": {
"extension_pages": "default-src 'none'; connect-src http://localhost:3000 ws://localhost https://ogbv-plugin.tattle.co.in/ https://uli-media.tattle.co.in/; font-src https://fonts.gstatic.com; object-src 'none'; script-src 'self'; style-src https://fonts.googleapis.com 'self' 'unsafe-inline'; img-src https://uli-media.tattle.co.in/; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; report-uri 'none';"
},
This process allows you to develop and test your changes on the Chrome browser locally. To enable the same for Firefox, repeat the process in the 1
manifest.firefox.json
file located inside the 1
plugin
folder.
I know that was quite a few steps, but believe me, it's smooth sailing from here on. It's all straightforward and simple now.
1
browser-extension
folder.1
docker-compose up
If you get 1
ERROR: Unknown database 'uli_dev'
, the database was not successfully created and database migration failed. Manually create the 1
uli_dev
database by logging into 1
http://localhost:8080/
using the username and password from 1
Uli/browser-extension/api-server/db/config/config.js
and execute the following.
1
2
docker-compose down -v
docker-compose up
You should now see database migration in the logs. The 1
api-server
will be running now.
NOTE - For if you are on Windows, you might have to start the 1
api-server
manually. You can do this by running the following command inside the 1
api-server
docker container.
Please ignore this step if you are not using Windows
1
docker exec -it api-server nodemon index.js
Or you can also manually access the 1
api-server
container within Docker Desktop. Inside the container's terminal, run the command 1
nodemon index.js
after navigating to the 1
api-server
in Docker Desktop.
Now, you have successfully started the development server.
1
plugin
folder.Run the following command to begin local plugin development.
1
2
1. For Chrome : npm run dev:chrome
2. For Firefox : npm run dev:firefox
If all services run correctly, you should be able to load the plugin from 1
plugin/dist
folder into Chrome/Brave/Firefox.
NOTE - If you are on Windows, you will need to make the following changes before running the commands. You'll need to modify the 1
plugin/package-json
file as described below.
Please ignore this step if you are not using Windows
1
cp
with 1
copy
Secondly, running the commands mentioned in the table above will create a 1
-p
and a 1
dist
folder every time, which you will need to delete in order to generate a new distribution to reflect major changes.
Once you run the 1
npm run dev:chrome
command or the 1
npm run dev:firefox
, a 1
dist
folder will be created. This folder contains the unreleased extension. Load it in your browser to see the extension in action and develop it further.
To learn how to install the unreleased extension in your browser, follow the instructions here
Or, you can follow the instructions below.
1
Settings
and then navigate to 1
Extensions
1
Developer mode
in the Extensions1
Load Unpacked
1
plugin/dist
folder.1
Setup
by executing 1
about:debugging
in the address bar (where you enter url's and do your web searches)1
This Firefox
in the left-hand sidebar.1
Temporary Extensions
dropdown. Within it, click on the 1
Load Temporary Add-on..
button and load any single file from the dist folder. This will load the extension into the browser.To see significant changes, you'll need to reload the 1
dist
folder in your browser each time. To start fresh with a new distribution, use this command to delete the 1
dist
folder.
1
cd plugin && npm run dev:clean
NOTE - if you are on Windows, you will also have to delete the 1
-p
folder along with the 1
dist
folder.
If you have made it here, hurrayy!! (a big hi-fi) You've successfully set up Uli on your local machine for development. We're looking forward to seeing the new changes and pull requests you'll be making!
To start contributing, head over to the contribution guide
You can create issues and reach out to the maintainers of Uli for more help if you need it.