Temperature-Blanket-Web-App

๐ŸŒค๏ธ Weather Data + ๐Ÿงถ Art! Get historical weather data, choose yarn colors, and visualize your crochet or knitting project.

GPL-3.0 License

Stars
8

๐ŸŒค๏ธ Weather Data + ๐Ÿงถ Art!

Website: temperature-blanket.com

Visualize your city's historical climate data, create color gauges, and preview your pattern for your crochet or knitting temperature project. Save your project in your browser and as a URL, and download project information in PDF, CSV, and PNG files.

Built with:

๐Ÿšง Note: Some of the codebase lacks documentation. I plan to update and refactor code as needed.

๐Ÿš€ Getting Started

To run this site locally on your computer for development, clone this repository and create a .env file. Additionally, in order for certain features to work you'll need to register for some free API services.

๐Ÿ’ก Node.js must be installed on your machine.

  1. Copy the .env.example file to a new file named .env in the root directory of your project.

  2. For the location search features to work, register for a free GeoNames username. You will then receive an email with a confirmation link and after you have confirmed the email you can enable your account for the webservice on your account page. In your .env file, set SECRET_GEONAMES_USERNAME to your GeoNames username. The free plan gets 10,000 credits per month.

  3. For the Meteostat weather data features to work, sign up for the free Meteostat Base plan through RapidAPI. In your .env file, set SECRET_METEOSTAT_API_KEY to your key from RapidAPI. The free Base plan gets 500 requests per month.

๐Ÿ› ๏ธ Developing

Install dependencies:

npm install

Start a development server:

npm run dev

โœ… Testing

First build the app (to generate cloudflare _routes.json file)

npm run build

Test frontend pages and functions

npm run test

Test internal api routes (for the Yarn Colorways API)

npm run test:api

๐Ÿ™Œ Acknowledgments

Thanks for the support and feedback from users like you!

Temperature-blanket.com gets data from several APIs:

๐Ÿ“š Documentation & Notes

๐Ÿ—„๏ธ Database

Temperature-blanket.com uses a backend database in the form of a headless Wordpress site on a separate domain to store user-created gallery pages.

โ„น๏ธ The information below is intended for documentation only. You can test and develop this project locally without setting up your own backend database.

Here are the steps for setting up the headless Wordpress site:

  • Install Wordpress on a separate domain.
  • I use the following plugins
    • EWWW Image Optimizer - To compress and optimize project preview images
    • Redirection - To redirect the headless Wordpress home page to the temperature-blanket.com site, and to redirect project pages to their corresponding gallery pages on temperature-blanket.com.
    • Temperature Blanket Custom Plugin - I created a Wordpress plugin which handles the necessary setup and allows for creation of project gallery pages through a custom REST endpoint.
    • Wordfence - For general site security
    • Wordpress Popular Posts - For tracking popular projects
    • WP-GraphQL - For interacting with the Wordpress backend
  • Add the following line to wp-config.php:
define('PROJECT_CREATION_AUTH_KEY', 'auth_key');
  • In this project's .env file, SECRET_WORDPRESS_PROJECT_CREATION_AUTH_KEY should be the same 'auth_key' value. Without the correct auth key, the Wordpress site won't accept POST requests for new project gallery pages.

๐Ÿ’ก When developing locally, POST requests to create new temperature blanket project gallery pages will be rejected. This is normal, because you don't have the necessary authentication key.

๐Ÿ’พ Local Storage

Various site settings and data are stored in the browser.

Key Name Description Default Value Possible Values Version Added*
skeletonTheme The theme for the site "classic" "classic" or one of the presets in plugins.themes.presets in tailwind.config.js < 3.28.3
theme Whether to use the light or dark version of the theme, or follow the system "light" "light", "dark", "system" < 3.28.3
layout How to display groups of items list list, grid < 3.28.3
projects Projects the user has saved [] array of SavedProject objects < 3.28.3
disable_toast_analytics Weather to always hide the notification about analytics false true, false 3.28.3
[/weather]units Units for the weather forecast page imperial imperial, metric < 3.28.3
[/weather]hour_format Time format for the weather forecast page 12 12, 24 < 3.28.3
[/weather]locations Locations the user has added for the weather forecast page [] array of Location objects < 3.28.3

*Items with a < before the version means sometime before that version, I'm not sure exactly when because I wasn't keeping track before version 3.28.3.

Related Projects