From 9367805b9ced5681c5257d6504907fdcefd8edfc Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Thu, 4 May 2023 10:45:13 -0400 Subject: [PATCH 1/5] moved files to new extension build process directory --- extension/writing-process/.eslintrc.json | 30 +++++++ extension/writing-process/.gitignore | 2 + extension/writing-process/README.md | 39 +++++++++ .../assets/locales/en/messages.json | 11 +++ .../assets}/lousy-fountain-pen-48.png | Bin extension/writing-process/package.json | 76 ++++++++++++++++++ .../src}/3rdparty/sha256.js | 0 .../src}/background.js | 0 .../src}/inject.js | 0 extension/writing-process/src/manifest.json | 50 ++++++++++++ .../src}/pages/action.css | 0 .../src}/pages/options.html | 0 .../src}/pages/options.js | 0 .../src}/pages/settings.html | 0 .../src}/service_worker.js | 0 .../src}/writing.js | 0 .../src}/writing_common.js | 2 +- extension/writing-process/test/sample.js | 6 ++ 18 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 extension/writing-process/.eslintrc.json create mode 100644 extension/writing-process/.gitignore create mode 100644 extension/writing-process/README.md create mode 100644 extension/writing-process/assets/locales/en/messages.json rename extension/{extension/icons => writing-process/assets}/lousy-fountain-pen-48.png (100%) create mode 100644 extension/writing-process/package.json rename extension/{extension => writing-process/src}/3rdparty/sha256.js (100%) rename extension/{extension => writing-process/src}/background.js (100%) rename extension/{extension => writing-process/src}/inject.js (100%) create mode 100644 extension/writing-process/src/manifest.json rename extension/{extension => writing-process/src}/pages/action.css (100%) rename extension/{extension => writing-process/src}/pages/options.html (100%) rename extension/{extension => writing-process/src}/pages/options.js (100%) rename extension/{extension => writing-process/src}/pages/settings.html (100%) rename extension/{extension => writing-process/src}/service_worker.js (100%) rename extension/{extension => writing-process/src}/writing.js (100%) rename extension/{extension => writing-process/src}/writing_common.js (98%) create mode 100644 extension/writing-process/test/sample.js diff --git a/extension/writing-process/.eslintrc.json b/extension/writing-process/.eslintrc.json new file mode 100644 index 00000000..923c0251 --- /dev/null +++ b/extension/writing-process/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "eslint:recommended" + ], + "globals": { + "document": false, + "escape": false, + "navigator": false, + "unescape": false, + "window": false, + "describe": true, + "before": true, + "it": true, + "expect": true, + "sinon": true, + "chrome": true + }, + "plugins": [], + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module" + }, + "rules": { + } +} diff --git a/extension/writing-process/.gitignore b/extension/writing-process/.gitignore new file mode 100644 index 00000000..db4c6d9b --- /dev/null +++ b/extension/writing-process/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/extension/writing-process/README.md b/extension/writing-process/README.md new file mode 100644 index 00000000..702395ec --- /dev/null +++ b/extension/writing-process/README.md @@ -0,0 +1,39 @@ +# writing-process + +Tracks writing in Google Docs, and provides nifty insights to you and your teachers! + +## Development + +This extension was created with [Extension CLI](https://oss.mobilefirst.me/extension-cli/)! + +If you find this software helpful [star](https://github.com/MobileFirstLLC/extension-cli/) or [sponsor](https://github.com/sponsors/MobileFirstLLC) this project. + + +### Available Commands + +| Commands | Description | +| --- | --- | +| `npm run start` | build extension, watch file changes | +| `npm run build` | generate release version | +| `npm run docs` | generate source code docs | +| `npm run clean` | remove temporary files | +| `npm run test` | run unit tests | +| `npm run sync` | update config files | + +For CLI instructions see [User Guide →](https://oss.mobilefirst.me/extension-cli/) + +### Learn More + +**Extension Developer guides** + +- [Getting started with extension development](https://developer.chrome.com/extensions/getstarted) +- Manifest configuration: [version 2](https://developer.chrome.com/extensions/manifest) - [version 3](https://developer.chrome.com/docs/extensions/mv3/intro/) +- [Permissions reference](https://developer.chrome.com/extensions/declare_permissions) +- [Chrome API reference](https://developer.chrome.com/docs/extensions/reference/) + +**Extension Publishing Guides** + +- [Publishing for Chrome](https://developer.chrome.com/webstore/publish) +- [Publishing for Edge](https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/publish-extension) +- [Publishing for Opera addons](https://dev.opera.com/extensions/publishing-guidelines/) +- [Publishing for Firefox](https://extensionworkshop.com/documentation/publish/submitting-an-add-on/) diff --git a/extension/writing-process/assets/locales/en/messages.json b/extension/writing-process/assets/locales/en/messages.json new file mode 100644 index 00000000..04975919 --- /dev/null +++ b/extension/writing-process/assets/locales/en/messages.json @@ -0,0 +1,11 @@ +{ + "appName": { + "message": "writing-process" + }, + "appShortName": { + "message": "writing-process" + }, + "appDescription": { + "message": "Tracks writing in Google Docs, and provides nifty insights to you and your teachers!" + } +} \ No newline at end of file diff --git a/extension/extension/icons/lousy-fountain-pen-48.png b/extension/writing-process/assets/lousy-fountain-pen-48.png similarity index 100% rename from extension/extension/icons/lousy-fountain-pen-48.png rename to extension/writing-process/assets/lousy-fountain-pen-48.png diff --git a/extension/writing-process/package.json b/extension/writing-process/package.json new file mode 100644 index 00000000..d503bda4 --- /dev/null +++ b/extension/writing-process/package.json @@ -0,0 +1,76 @@ +{ + "name": "writing-process", + "description": "Tracks writing in Google Docs, and provides nifty insights to you and your teachers!", + "version": "0.0.1", + "homepage": "http://chrome.google.com/webstore", + "author": "ENTER YOUR NAME HERE", + "repository": { + "type": "git", + "url": "ENTER GIT REPO URL" + }, + "scripts": { + "start": "xt-build -e dev -w", + "start:firefox": "xt-build -e dev -p firefox -w", + "build": "xt-build -e prod", + "build:firefox": "xt-build -e prod -p firefox", + "clean": "xt-clean", + "docs": "xt-docs", + "test": "xt-test", + "coverage": "nyc --reporter=lcov npm run test", + "sync": "xt-sync" + }, + "babel": { + "presets": [ + "@babel/preset-env" + ] + }, + "eslintIgnore": [ + "test/**/*" + ], + "devDependencies": { + "extension-cli": "latest" + }, + "xtdocs": { + "source": { + "include": [ + "README.md", + "src" + ] + } + }, + "xtbuild": { + "copyAsIs": [ + "./src/pages/*" + ], + "js_bundles": [ + { + "name": "background", + "src": "./src/background.js" + }, + { + "name": "inject", + "src": "./src/inject.js" + }, + { + "name": "service_worker", + "src": "./src/service_worker.js" + }, + { + "name": "writing_common", + "src": "./src/writing_common.js" + }, + { + "name": "writing", + "src": "./src/writing.js" + }, + { + "name": "3rdparty/sha256", + "src": "./src/3rdparty/sha256.js" + }, + { + "name": "3rdparty/sha256", + "src": "./src/3rdparty/sha256.js" + } + ] + } +} \ No newline at end of file diff --git a/extension/extension/3rdparty/sha256.js b/extension/writing-process/src/3rdparty/sha256.js similarity index 100% rename from extension/extension/3rdparty/sha256.js rename to extension/writing-process/src/3rdparty/sha256.js diff --git a/extension/extension/background.js b/extension/writing-process/src/background.js similarity index 100% rename from extension/extension/background.js rename to extension/writing-process/src/background.js diff --git a/extension/extension/inject.js b/extension/writing-process/src/inject.js similarity index 100% rename from extension/extension/inject.js rename to extension/writing-process/src/inject.js diff --git a/extension/writing-process/src/manifest.json b/extension/writing-process/src/manifest.json new file mode 100644 index 00000000..84e180c7 --- /dev/null +++ b/extension/writing-process/src/manifest.json @@ -0,0 +1,50 @@ +{ + "name": "__MSG_appName__", + "short_name": "__MSG_appShortName__", + "description": "__MSG_appDescription__", + "homepage_url": "http://chrome.google.com/webstore", + "incognito": "not_allowed", + "version": "0.0.0.1", + "version_name": "0.0.0.1", + "manifest_version": 3, + "default_locale": "en", + "minimum_chrome_version": "88", + "permissions": [ + "webRequest", + "declarativeNetRequest", + "identity", + "identity.email", + "storage", + "nativeMessaging", + "scripting", + "activeTab" + ], + "icons": { + "48": "assets/lousy-fountain-pen-48.png" + }, + "background": { + "service_worker": "service_worker.js" + }, + "action": { + "default_popup": "pages/settings.html", + "default_icon": { + "48": "assets/lousy-fountain-pen-48.png" + }, + "default_title": "__MSG_appName__" + }, + "content_scripts": [{ + "matches": ["*://docs.google.com/document/*"], + "js": ["3rdparty/sha256.js", "writing_common.js", "writing.js"] + }], + "web_accessible_resources": [{ + "resources": ["inject.js"], + "matches": ["*://docs.google.com/*"], + "use_dynamic_url": true + }], + "host_permissions": [ + "*://docs.google.com/document/*" + ], + "options_ui": { + "page": "pages/options.html" + } +} \ No newline at end of file diff --git a/extension/extension/pages/action.css b/extension/writing-process/src/pages/action.css similarity index 100% rename from extension/extension/pages/action.css rename to extension/writing-process/src/pages/action.css diff --git a/extension/extension/pages/options.html b/extension/writing-process/src/pages/options.html similarity index 100% rename from extension/extension/pages/options.html rename to extension/writing-process/src/pages/options.html diff --git a/extension/extension/pages/options.js b/extension/writing-process/src/pages/options.js similarity index 100% rename from extension/extension/pages/options.js rename to extension/writing-process/src/pages/options.js diff --git a/extension/extension/pages/settings.html b/extension/writing-process/src/pages/settings.html similarity index 100% rename from extension/extension/pages/settings.html rename to extension/writing-process/src/pages/settings.html diff --git a/extension/extension/service_worker.js b/extension/writing-process/src/service_worker.js similarity index 100% rename from extension/extension/service_worker.js rename to extension/writing-process/src/service_worker.js diff --git a/extension/extension/writing.js b/extension/writing-process/src/writing.js similarity index 100% rename from extension/extension/writing.js rename to extension/writing-process/src/writing.js diff --git a/extension/extension/writing_common.js b/extension/writing-process/src/writing_common.js similarity index 98% rename from extension/extension/writing_common.js rename to extension/writing-process/src/writing_common.js index 49c3a648..a805c2dd 100644 --- a/extension/extension/writing_common.js +++ b/extension/writing-process/src/writing_common.js @@ -52,7 +52,7 @@ function treeget(tree, key) { } -function googledocs_id_from_url(url) { +export function googledocs_id_from_url(url) { /* Given a URL like: https://docs.google.com/document/d/jkldfhjklhdkljer8934789468976sduiyui34778dey/edit/foo/bar diff --git a/extension/writing-process/test/sample.js b/extension/writing-process/test/sample.js new file mode 100644 index 00000000..d3f9a09f --- /dev/null +++ b/extension/writing-process/test/sample.js @@ -0,0 +1,6 @@ +describe('Test extension', () => { + + it('This is a dummy test', () => { + expect(true).to.be.true; + }); +}); From febc75b1f7d68dfe924a9cd41b99acff80fffdec Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Thu, 4 May 2023 10:45:59 -0400 Subject: [PATCH 2/5] adjusted imports and undefined var error --- extension/writing-process/src/background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/writing-process/src/background.js b/extension/writing-process/src/background.js index c4fa4b91..75bc9de7 100644 --- a/extension/writing-process/src/background.js +++ b/extension/writing-process/src/background.js @@ -11,7 +11,7 @@ var RAW_DEBUG = false; */ var WEBSOCKET_SERVER_URL = "wss://learning-observer.org/wsapi/in/" - +import { googledocs_id_from_url } from './writing_common'; /* TODO: FSM @@ -111,7 +111,7 @@ function websocket_logger(server) { function are_we_done() { if (state.has("chrome_identity") && state.has("local_storage")) { - event = {}; + var event = {}; event = add_event_metadata('metadata_finished', event); socket.send(JSON.stringify(event)); state.add("ready"); From 4c70586711349aa00fe8bc0a290aaa562d318845 Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Mon, 8 May 2023 08:24:37 -0400 Subject: [PATCH 3/5] updated documentation with extension readme and updated readme --- autodocs/other_docs.rst | 2 ++ extension/writing-process/.gitignore | 4 ++-- extension/writing-process/README.md | 32 ++++++++++++++++------------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/autodocs/other_docs.rst b/autodocs/other_docs.rst index e299265b..bb56ea7d 100644 --- a/autodocs/other_docs.rst +++ b/autodocs/other_docs.rst @@ -8,6 +8,8 @@ Other Docs :parser: myst_parser.sphinx_ .. include:: ../docs/testing.md :parser: myst_parser.sphinx_ +.. include:: ../extension/writing-process/README.md + :parser: myst_parser.sphinx_ .. include:: ../docs/privacy.md :parser: myst_parser.sphinx_ .. include:: ../docs/system_design.md diff --git a/extension/writing-process/.gitignore b/extension/writing-process/.gitignore index db4c6d9b..763301fc 100644 --- a/extension/writing-process/.gitignore +++ b/extension/writing-process/.gitignore @@ -1,2 +1,2 @@ -dist -node_modules \ No newline at end of file +dist/ +node_modules/ \ No newline at end of file diff --git a/extension/writing-process/README.md b/extension/writing-process/README.md index 702395ec..f1a35f29 100644 --- a/extension/writing-process/README.md +++ b/extension/writing-process/README.md @@ -2,38 +2,42 @@ Tracks writing in Google Docs, and provides nifty insights to you and your teachers! -## Development +## Development -This extension was created with [Extension CLI](https://oss.mobilefirst.me/extension-cli/)! +This extension directory structure was created with [Extension CLI](https://oss.mobilefirst.me/extension-cli/). +The original extension, which was just a handful of javascript files, were then copied into the structure. -If you find this software helpful [star](https://github.com/MobileFirstLLC/extension-cli/) or [sponsor](https://github.com/sponsors/MobileFirstLLC) this project. +### To Begin +To get started, run the following: + +```bash +cd extention/writing-process +npm install +``` ### Available Commands | Commands | Description | | --- | --- | -| `npm run start` | build extension, watch file changes | -| `npm run build` | generate release version | -| `npm run docs` | generate source code docs | -| `npm run clean` | remove temporary files | +| `npm run start` | builds extension into `dist/`, watches for file changes | +| `npm run build` | generate release version - `release.zip` | +| `npm run docs` | generate source code docs into `public/documentation` | +| `npm run clean` | removes `dist/` directory | | `npm run test` | run unit tests | -| `npm run sync` | update config files | +| `npm run sync` | update projects config files for `extension-cli` | For CLI instructions see [User Guide →](https://oss.mobilefirst.me/extension-cli/) ### Learn More -**Extension Developer guides** +#### Extension Developer guides - [Getting started with extension development](https://developer.chrome.com/extensions/getstarted) -- Manifest configuration: [version 2](https://developer.chrome.com/extensions/manifest) - [version 3](https://developer.chrome.com/docs/extensions/mv3/intro/) +- Manifest configuration: [version 3](https://developer.chrome.com/docs/extensions/mv3/intro/) - [Permissions reference](https://developer.chrome.com/extensions/declare_permissions) - [Chrome API reference](https://developer.chrome.com/docs/extensions/reference/) -**Extension Publishing Guides** +#### Extension Publishing Guides - [Publishing for Chrome](https://developer.chrome.com/webstore/publish) -- [Publishing for Edge](https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/publish-extension) -- [Publishing for Opera addons](https://dev.opera.com/extensions/publishing-guidelines/) -- [Publishing for Firefox](https://extensionworkshop.com/documentation/publish/submitting-an-add-on/) From 759d5862af70ac3e2176bbcfac139c80dea131d2 Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Wed, 5 Jul 2023 14:40:22 -0400 Subject: [PATCH 4/5] added names and git repo --- extension/writing-process/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/writing-process/package.json b/extension/writing-process/package.json index d503bda4..d49fc288 100644 --- a/extension/writing-process/package.json +++ b/extension/writing-process/package.json @@ -3,10 +3,10 @@ "description": "Tracks writing in Google Docs, and provides nifty insights to you and your teachers!", "version": "0.0.1", "homepage": "http://chrome.google.com/webstore", - "author": "ENTER YOUR NAME HERE", + "author": "Piotr Mitros, Bradley Erickson", "repository": { "type": "git", - "url": "ENTER GIT REPO URL" + "url": "https://github.com/ETS-Next-Gen/writing_observer/tree/master/extension/writing-process" }, "scripts": { "start": "xt-build -e dev -w", From 94a4101a075b8b722ed0ccba128987c32e9eda3d Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Wed, 5 Jul 2023 15:21:10 -0400 Subject: [PATCH 5/5] added version, probably needs a bump or a central location for it --- extension/writing-process/package.json | 2 +- extension/writing-process/src/manifest.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extension/writing-process/package.json b/extension/writing-process/package.json index d49fc288..8cd782ae 100644 --- a/extension/writing-process/package.json +++ b/extension/writing-process/package.json @@ -1,7 +1,7 @@ { "name": "writing-process", "description": "Tracks writing in Google Docs, and provides nifty insights to you and your teachers!", - "version": "0.0.1", + "version": "1.0.0.2", "homepage": "http://chrome.google.com/webstore", "author": "Piotr Mitros, Bradley Erickson", "repository": { diff --git a/extension/writing-process/src/manifest.json b/extension/writing-process/src/manifest.json index 84e180c7..9d26efaa 100644 --- a/extension/writing-process/src/manifest.json +++ b/extension/writing-process/src/manifest.json @@ -2,10 +2,10 @@ "name": "__MSG_appName__", "short_name": "__MSG_appShortName__", "description": "__MSG_appDescription__", - "homepage_url": "http://chrome.google.com/webstore", + "homepage_url": "https://github.com/ETS-Next-Gen/writing_observer/tree/master/extension/writing-process", "incognito": "not_allowed", - "version": "0.0.0.1", - "version_name": "0.0.0.1", + "version": "1.0.0.2", + "version_name": "1.0.0.2", "manifest_version": 3, "default_locale": "en", "minimum_chrome_version": "88",