From bfbb14bf49c13c30c08a550d131b9dc7777b06b6 Mon Sep 17 00:00:00 2001 From: Aatman Vaidya Date: Tue, 5 Sep 2023 18:17:55 +0530 Subject: [PATCH 01/56] setting up slur crowdsourcing --- browser-extension/docker-compose.yml | 32 ++++++------ .../plugin/manifest.firefox.json | 2 +- browser-extension/plugin/manifest.json | 2 +- browser-extension/plugin/package.json | 14 ++--- .../plugin/src/ui-components/atoms/i18n.jsx | 3 ++ .../plugin/src/ui-components/pages/App.jsx | 10 ++++ .../plugin/src/ui-components/pages/Slur.jsx | 26 ++++++++++ .../src/ui-components/pages/SlurCreate.jsx | 52 +++++++++++++++++++ 8 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 browser-extension/plugin/src/ui-components/pages/Slur.jsx create mode 100644 browser-extension/plugin/src/ui-components/pages/SlurCreate.jsx diff --git a/browser-extension/docker-compose.yml b/browser-extension/docker-compose.yml index d2acc8ee..a86d53f0 100644 --- a/browser-extension/docker-compose.yml +++ b/browser-extension/docker-compose.yml @@ -35,19 +35,19 @@ services: env_file: - "./api-server/development.env" - ogbv-ml-rest: - container_name: ogbv-ml-rest - build: - context: ../ogbv-ml-rest - dockerfile: Dockerfile - restart: always - volumes: - - "~/data/ogbv_plugin/assets:/app/assets" - - "~/data/ogbv_plugin/ml-cache:/root/.cache/huggingface/transformers" - ports: - - 8081:80 - environment: - DB_HOST: db - DB_PORT: 3306 - DB_USERNAME: tattle - DB_PASSWORD: tattle_pw + # ogbv-ml-rest: + # container_name: ogbv-ml-rest + # build: + # context: ../ogbv-ml-rest + # dockerfile: Dockerfile + # restart: always + # volumes: + # - "~/data/ogbv_plugin/assets:/app/assets" + # - "~/data/ogbv_plugin/ml-cache:/root/.cache/huggingface/transformers" + # ports: + # - 8081:80 + # environment: + # DB_HOST: db + # DB_PORT: 3306 + # DB_USERNAME: tattle + # DB_PASSWORD: tattle_pw diff --git a/browser-extension/plugin/manifest.firefox.json b/browser-extension/plugin/manifest.firefox.json index dee8334d..59184187 100644 --- a/browser-extension/plugin/manifest.firefox.json +++ b/browser-extension/plugin/manifest.firefox.json @@ -4,7 +4,7 @@ "description": "Moderate your Twitter Feed", "version": "0.1.13", "author": "tattlemade|cis", - "content_security_policy": "default-src 'none'; connect-src 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';", + "content_security_policy": "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';", "permissions": ["storage", "webRequest", "contextMenus"], "background": { "scripts": ["background.js"] diff --git a/browser-extension/plugin/manifest.json b/browser-extension/plugin/manifest.json index d405e85b..4d59fe86 100644 --- a/browser-extension/plugin/manifest.json +++ b/browser-extension/plugin/manifest.json @@ -5,7 +5,7 @@ "version": "0.1.13", "author": "tattlemade|cis", "content_security_policy": { - "extension_pages": "default-src 'none'; connect-src 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';" + "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';" }, "permissions": ["storage", "contextMenus"], "background": { diff --git a/browser-extension/plugin/package.json b/browser-extension/plugin/package.json index 96e660dd..af2ed5a6 100644 --- a/browser-extension/plugin/package.json +++ b/browser-extension/plugin/package.json @@ -3,14 +3,14 @@ "version": "0.0.1", "description": "", "scripts": { - "prepare": "cd ../.. && husky install \"browser-extension/plugin/.husky\"", + "prepare": "cd ..\\.. && husky install \"browser-extension\\plugin\\.husky\"", "test": "echo \"Error: no test specified\" && exit 1", - "start:options": "parcel src/options.jsx", - "start:contentScript": "parcel src/content-script.js", - "moveBuildArtefactsToDistDir": "cp src/options.html dist && cp manifest.json dist && cp icon* dist && cp src/background.js dist", - "moveBuildArtefactsToFirefoxDistDir": "cp src/options.html dist && cp manifest.firefox.json dist/manifest.json && cp icon* dist && cp src/background.js dist", - "build": "mkdir dist && NODE_ENV=production parcel build src/options.jsx src/content-script.js && npm run moveBuildArtefactsToDistDir", - "build:firefox": "mkdir dist && NODE_ENV=production parcel build src/options.jsx src/content-script.js && npm run moveBuildArtefactsToFirefoxDistDir", + "start:options": "parcel src\\options.jsx", + "start:contentScript": "parcel src\\content-script.js", + "moveBuildArtefactsToDistDir": "copy src\\options.html dist && copy manifest.json dist && copy icon* dist && copy src\\background.js dist", + "moveBuildArtefactsToFirefoxDistDir": "copy src\\options.html dist && copy manifest.firefox.json dist\\manifest.json && copy icon* dist && copy src\\background.js dist", + "build": "mkdir dist && NODE_ENV=production parcel build src\\options.jsx src\\content-script.js && npm run moveBuildArtefactsToDistDir", + "build:firefox": "mkdir dist && NODE_ENV=production parcel build src\\options.jsx src\\content-script.js && npm run moveBuildArtefactsToFirefoxDistDir", "pre-commit": "npm audit --audit-level=moderate", "lint": "lint-staged", "dev:firefox": "mkdir -p dist && concurrently \"npm run start:options\" \"npm run start:contentScript\" \"npm run moveBuildArtefactsToFirefoxDistDir\"", diff --git a/browser-extension/plugin/src/ui-components/atoms/i18n.jsx b/browser-extension/plugin/src/ui-components/atoms/i18n.jsx index efcb2fad..bdc739d9 100644 --- a/browser-extension/plugin/src/ui-components/atoms/i18n.jsx +++ b/browser-extension/plugin/src/ui-components/atoms/i18n.jsx @@ -12,6 +12,7 @@ const resources = { navigation_archive: 'Archive', navigation_resources: 'Resources', navigation_debug: 'Settings', + navigation_slur_list: 'Slur List', activate_account: 'Activate Account', user_guide: 'User Guide', mental_health: 'Mental Health Resources', @@ -48,6 +49,7 @@ const resources = { navigation_archive: 'संग्रह', navigation_resources: 'अन्य संसाधन', navigation_debug: 'सेटिंग', + navigation_slur_list: 'अभद्र शब्दों की सूची', activate_account: 'खाते को सक्रिय करें', user_guide: 'यूजर गाइड', mental_health: 'मानसिक स्वास्थ्य से जुड़े संसाधन', @@ -85,6 +87,7 @@ const resources = { navigation_archive: 'சுவடிக்கூடம்', navigation_resources: 'வழிவகைகள்', navigation_debug: 'செட்டிங்ஸ்', + navigation_slur_list: 'அவதூறு பட்டியல்', activate_account: 'கணக்கை செயல்படுத்தவும்', user_guide: 'பயனர் கையேடு', mental_health: 'மனநல வளங்கள்', diff --git a/browser-extension/plugin/src/ui-components/pages/App.jsx b/browser-extension/plugin/src/ui-components/pages/App.jsx index 1b5560e8..7361826d 100644 --- a/browser-extension/plugin/src/ui-components/pages/App.jsx +++ b/browser-extension/plugin/src/ui-components/pages/App.jsx @@ -15,6 +15,8 @@ import { langNameMap } from '../atoms/language'; const { getPreferenceData, setPreferenceData } = repository; import { ToggleSwitchCustom } from '../atoms/ToggleSwitchCustom'; import { Off } from './Off'; +import { Slur } from './Slur'; +import SlurCreate from './SlurCreate'; export function App() { const [user, setUser] = useState(undefined); @@ -219,6 +221,9 @@ export function App() { {t('navigation_debug')} + + {t('navigation_slur_list')} + )} @@ -242,6 +247,11 @@ export function App() { /> } /> } /> + } /> + } + /> ) : ( diff --git a/browser-extension/plugin/src/ui-components/pages/Slur.jsx b/browser-extension/plugin/src/ui-components/pages/Slur.jsx new file mode 100644 index 00000000..3ab44a7f --- /dev/null +++ b/browser-extension/plugin/src/ui-components/pages/Slur.jsx @@ -0,0 +1,26 @@ +import { Box, Text, Button } from 'grommet'; +import { Add } from 'grommet-icons'; +import { useNavigate } from 'react-router-dom'; + +export function Slur() { + let navigate = useNavigate(); + const navigateToAddSlur = () => { + navigate('/slur/create'); + }; + + return ( + + +