1
1
Fork
You've already forked dwep
0
Daily Wellness Empowerment Program https://tord.codeberg.page/dwep/
  • HTML 79.8%
  • JavaScript 18.5%
  • CSS 1.3%
  • Shell 0.4%
2025年09月04日 13:14:57 +02:00
.vscode Initial commit after resetting history 2024年11月21日 12:47:44 +01:00
dev/git-hooks changed the start and stop of the local dev server when running tests 2025年04月10日 13:16:29 +02:00
fonts added open-sans fonts and used them for the first onboarding screen 2024年12月26日 15:44:36 +01:00
icons forgot to add the files using git add 2024年12月27日 16:00:56 +01:00
tests changed the way that analytics are enabled/disabled 2025年03月13日 13:57:34 +01:00
.gitignore and added section titles for index.html 2025年04月15日 17:18:53 +02:00
dwep.webmanifest added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
eslint.config.mjs Initial commit after resetting history 2024年11月21日 12:47:44 +01:00
index.html added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
LICENSE.txt update of license file 2024年12月04日 17:06:02 +01:00
localhost-key.pem Initial commit after resetting history 2024年11月21日 12:47:44 +01:00
localhost.pem Initial commit after resetting history 2024年11月21日 12:47:44 +01:00
Lucide_License.txt Initial commit after resetting history 2024年11月21日 12:47:44 +01:00
package-lock.json version bump for all dev dependencies. and fixed issue with pre-commit hook 2025年04月11日 16:36:56 +02:00
package.json added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
playwright.config.js - 2024年12月06日 17:16:44 +01:00
posthog-init.js changed the way that analytics are enabled/disabled 2025年03月13日 13:57:34 +01:00
README.md added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
script.js added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
service-worker.js added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00
styles.css added a persistent notice banner at the top of the main page, notifying the users of the codeberg version/app that the app has been moved 2025年09月04日 13:14:57 +02:00

PROJECT HAS MOVED HERE: https://gitlab.com/dwep-app/dwep-app.gitlab.io


DWEP - Daily Wellness Empowerment Program

About the project: https://codeberg.org/tord/dwep/wiki/Home

Live page, showing the latest development: https://tord.codeberg.page/dwep/

Credits/Thanks/License: Please see "Menu" -> "About" inside the app

This readme file is primarily for developers and is not available inside the app itself

Browser and OS support

This app should work on all major browsers and operating systems, both for mobile and desktop. Javascript is required for the application to run, so the browser needs to support that and cannot block Javascript (for example using a plugin/extension). We expect most people will want to run the application on mobile so the layout has been designed for vertical screens

The browser support is tested (at the time of writing) by running auto-test on desktop with playwright, which runs test using three browser engines - Blink (Chrome, Edge), Gecko (Firefox), WebKit (Safari, Gnome Web) - which in playwright are called "chromium", "firefox", "webkit". Playwright also emulates mobile devices ('Mobile Chrome', 'Mobile Safari'), and this emulation includes platform-specific features

Development setup

Dev dependencies

To install all the dev dependencies in the package.json file you can run this command: npm install. (The app itself doesn't have any dependencies at the time of writing)

eslint is also available as a vscode extension

Git hooks

Run git config core.hooksPath ./dev/git-hooks/ to configure git to use our git-hooks. They will run auto-tests and do some work with the version. For details please see the git-hook files

We rely on Unix-system and bash commands in our git-hook files, so you need something like Ubuntu, MacOS (or if you are running on Windows maybe Cygwin or similar)

Versioning and Caching

Please remember to update the version in package.json before making any changes you want the user to see

Because of how caching is done in our service worker you need to update the app version for any changes to be shown. The central/master version is stored in package.json, and when a commit is done the version string is copied into other files (using the precommit hook)

An alternative way to ensure you are seeing the latest version is to keep doing hard reloads since this will bypass the caching system we have implemented (this can be useful during development)

For more info about the caching strategy please see service-worker.js

Local development server

Below two local dev server options are discussed. Both require a certificate to work

To generate certificate files, mkcert can be used

http-server

This is used in the script section in package.json, and therefore also by the git-hook scripts

To start the server the certificate files can be given on the command line. (See the script section in package.json)

URL: https://localhost:3001/

VSCode Liveserver extension

Configure the vscode liveserver extension (in the global settings.json file). See below for the configuration (not version controlled). You will have to replace the paths to match your system

"liveServer.settings.https": {
 "enable": true,
 "cert": "/home/sunyata/DevProjects/dwep/localhost.pem",
 "key": "/home/sunyata/DevProjects/dwep/localhost-key.pem",
 "passphrase": ""
}

URL: https://localhost:3000/

Debugging options

  • Desktop -> Chrome on Android
  • Desktop Chrome through http-server (or liveserver)
    • Start local server
      • http-server: npm run start-server
      • vscode liveserver: click "Go Live" in lower-right corner
    • Go to the url (if not already open)
    • Chrome devtools settings:
      • Console tab -> Settings -> Preserve log
      • Application tab -> Service workers -> Update on reload (If we don't have this we either need to make a "hard reload", ctrl+shift+r, or update the app version in package.json)
  • Desktop Firefox through liveserver
  • Desktop Firefox directly through index.html

Workflow

Branches:

  1. switch to the development branch
  2. make changes
  3. Before merging any branch into main, please remember to update the version in package.json --- if you forget this you will get a reminder from the pre-merge-commit
  4. switch to the main branch
  5. git merge development
  6. git push
  7. the changes will be visible on https://tord.codeberg.page/dwep/ --- you may need to do a soft reload or even two

Testing

Auto-tests

Playwright is used for auto-testing

To run tests in the terminal: npm run test

To run tests in the Playwright GUI: npm run test-visual

To generate tests using Playwright codegen: npm run test-codegen

By default tests will run in multiple emulated browsers. Playwright's Firefox has been configured to ignore https errors (see playwright.config.js), but not Playwright's Chromium. The reason is that Chromium uses the certificate store from the OS, while Firefox uses it's own, and it's difficult to configure this in Firefox

Manual tests

Test procedures to be carried out manually by developers are kept at the bottom of the test file (tests/main.spec.js), and are intended to complement the auto-tests by testing things which cannot be covered by Playwright

Technical notes

We use relative instead of absolute paths (./ rather than /dwep/) for the app, which works without issue.

Please note that the path in the start_url in dwep.webmanifest doesn't have index.html in it. In general index.html will not work (in general, not just for installed PWA) because of a redirect+security issue around caching (that i don't understand). I thought it best to simply not use index.html since it's not needed. (However there is a possible solution discussed here)

Hard and soft/normal reload when debugging: TODO A hard reload will bypass the fetch event handler

Update of version for cache reasons: TODO

You can find more tech notes in the code files

Problems and solutions

Unregistering the service worker might help in some cases

Failed to fetch index.html (ERR_FAILED)

Solution: Rewrote the fetch handler

Hosting/Server

We use Codeberg for the hosting. Since we use a cache-first strategy the app shouldn't put a lot of load on the server

The server status can be seen here: https://status.codeberg.org/status/codeberg

There's a delay of maybe 5 minutes after pushing new changes to main/origin

PostHog telemetry/analytics

TBD

Please use an adblocker for the development users so they don't effect the stats that we see in PostHog

Please note that there is some delay in the posthog interface

  • Even just when looking at the activity there's about 30-60 seconds delay. To update use the "Reload" button inside of the page, rather than the browser reload
  • _

Translations and localization

The plan is to have all language-specific texts in the index.html file, using the lang attribute on the html tag. In the future (if the number of languages grows) we might move to a separate json file for each language.

We store dates in this format: 2025年01月05日 (year-month-day)

Technical strategy and reasoning

Maintainability is prio

SPA, no build-tools, plain JS

Choice of PWA (Progressive Web App) over other options

In short, we choose PWA rather than using native apps because we need something that can be run on both Android, iOS and desktop platforms

Choice of local only (no server-side code)

This is to reduce complexity (which in turn reduces the development time, increases maintainability, and makes bugs easier to fix since we have more control)

Choice of cache-first (see service-worker.js)

This was an easy choice. It makes it easy to run the PWA when offline (which people in plumvillage may be), and to reduce the load on the server (makes it possible to run the app from a low-performance server). (I don't see any downsides)

Choice of using few or no frameworks, libs and external connections

This is to reduce complexity, and make the app more future-safe (frameworks may change, bug plain JavaScript will be supported for a long time)