"Keep Journal" is a simple, private Progressive Web Application (PWA) designed for journaling. It allows users to quickly jot down thoughts, URLs, and even paste images, all accessible and manageable via a web interface. The application supports real-time updates across multiple connected clients (e.g., browser windows) and features pagination for easy navigation through entries. It also implements an "edit" and "view" key system for access control, ensuring privacy for your thoughts.
- Private Journaling: Keep your thoughts secure with key-based access.
- Real-time Updates: New posts appear instantly across all connected browser sessions without full page reloads.
- Image Pasting & Upload: Directly paste images from your clipboard into the input field. Images are automatically uploaded and displayed.
- URL Detection: URLs in your posts automatically become clickable links.
- Image Rendering: Image URLs are rendered directly in the feed, with a grayscale-to-color hover effect.
- Pagination: Navigate through your journal entries with "Older" and "Newer" buttons, displaying 10 posts per page. Invalid page numbers automatically default to the last available page.
- Edit/View Access Control:
- Edit Key: Allows posting new entries, uploading images, and full interaction.
- View Key: Provides read-only access to the journal.
- PWA Installability: Installable as a standalone application on supported devices (mobile and desktop).
- Clear Project Structure: Separated HTML templates, CSS styles, and client-side JavaScript for maintainability.
To get the Keep Journal PWA up and running on your local machine, follow these steps:
If you have this project in a Git repository:
git clone <your-repo-url>
cd keep-journalOtherwise, navigate to your project directory:
cd keep-journalInstall all necessary Node.js packages listed in package.json:
npm installCreate a .env file in the root of your project to store your secret keys and other environment-specific variables. A .env.example file is provided as a template; copy its contents to a new file named .env and fill in your actual values.
cp .env.example .envYou'll need to generate VAPID keys for potential future push notification functionality, even if not actively used right now.
Generate VAPID Keys (if needed for future notification features):
npx web-push generate-vapid-keysThis will output a public and private key. Copy them into your .env file if you plan to enable notifications.
Your .env file should eventually look like this (with your actual secrets):
PRIVATE_KEY=YOUR_SUPER_SECRET_EDIT_KEY
PUBLIC_KEY=YOUR_SUPER_SECRET_VIEW_KEY
# VAPID_PUBLIC=PASTE_GENERATED_VAPID_PUBLIC_KEY_HERE
# VAPID_PRIVATE=PASTE_GENERATED_VAPID_PRIVATE_KEY_HERE
Remember to replace YOUR_SUPER_SECRET_EDIT_KEY and YOUR_SUPER_SECRET_VIEW_KEY with strong, unique keys of your choice. I recommend using a tool like this password generator
Create a uploads directory to store user-uploaded images and other media files.
This directory must exist and be writable by the application at runtime.
mkdir -p keep/public/uploadsNotes:
- The
uploadsdirectory is served as a public static path. - Ensure proper write permissions for the server process.
keep/
├── public/
│ ├── static/ # Holds static assets like the favicon and PWA icons
│ ├── styles/
│ │ └── style.css # Application styles
│ ├── templates/
│ │ └── index.html # HTML template
│ ├── uploads/ # Image storage
│ ├── client.js # Client-side JavaScript logic
│ ├── manifest.json # PWA manifest configuration
│ ├── robots.txt # Block certain bots
│ └── sw.js # Service Worker (for caching and PWA features)
├── posts.json # Flat-file database for posts
├── server.js # Express server, API endpoints, WebSocket server
└── .env # Environment variables (keys, VAPID)
node server.jsThe server will start on http://localhost:3000.
- Edit Access: Navigate to
http://localhost:3000and input your keyYOUR_SUPER_SECRET_EDIT_KEY - View-Only Access: Navigate to
http://localhost:3000and input your keyYOUR_SUPER_SECRET_VIEW_KEY
Replace YOUR_SUPER_SECRET_EDIT_KEY, YOUR_SUPER_SECRET_VIEW_KEY, and YOUR_SESSION_SECRET with the actual keys from your .env file.
- Access the journal with your edit key.
- Type your message into the input field.
- Click "Share" or press Enter.
- Access the journal with your edit key.
- Copy an image to your clipboard (e.g., from a screenshot or another application).
- Paste the image directly into the input field. The image will be uploaded, and its URL will appear in the input.
- Click "Share" or press Enter to post the image.
- If there are more than 10 posts, "Older" and "Newer" buttons will appear below the feed.
- Click "Older" to navigate to the next set of older posts.
- Click "Newer" to go back to newer posts.
- Directly specify pages in the URL (e.g.,
&page=2). If the page number is out of bounds, it will default to the last available page.
- Implement Push Notification Logic: Add the necessary server-side and client-side logic to deliver notifications to users for new posts. This will involve reactivating the
notify.jsmodule, the notification endpoints inserver.js, and the client-side subscription/unsubscription logic.
A .gitignore file has been provided to exclude unnecessary files and sensitive information when pushing your project to a Git repository.