Skip to content

bbernhard/mindfulbytes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MindfulBytes

We are living in stressful times. With all the digital content online and social networks and smartphones that are constantly begging for our attention, it's easy to lose yourself in the digital world.

MindfulBytes is a plugin based application that scans your digital assets and lets you know what has happened at this day x years ago. It does that by looking at the creation timestamp (and in case of pictures by parsing the EXIF timestamp).

Features

  • Plugin based and easily extendable
  • Powerful REST API
  • Built-in Support for Email & Signal Messenger Notifications
  • Fully dockerized and easy to set up

Available Plugins

  • imgreader-fs: scans your local filesystem for images
  • imgreader-nc: scans your Nextcloud instance for images

Installation

In order to install MindfulBytes, the following steps are necessary:

  • Clone this repository with git clone https://github.com/bbernhard/mindfulbytes.git
  • Rename the defaultconfig folder to config
  • Configure the general settings in the config.yaml file
  • Enable the plugins you want to use and configure the plugin specific settings in the appropriate config.yaml files
  • Rename the docker-compose.default.yml file to docker-compose.yml
  • Build the docker images with docker-compose -f env/docker/docker-compose.yml build (run this command from the mindfulbytes root folder!)
  • Start the docker constainers with docker-compose -f env/docker/docker-compose.yml up

Example

The following example describes how to set up MindfulBytes to scan both a local directory and a remote Nextcloud instance for images.

  • Clone this repository with git clone https://github.com/bbernhard/mindfulbytes.git

  • Rename the defaultconfig folder to config

  • Enable both the imgreader-fs and imgreader-nc plugin by setting enabled: true in the imgreader-fs/config.yaml and imgreader-nc/config.yaml file.

  • Change the nextcloud-webdav-url, nextcloud-token and nextcloud-root-dir parameters in the imgreader-nc/config.yaml file.

The Nextcloud Token can be created by navigating to Profile -> Settings -> Security on your Nextcloud instance.

Create new token

Name your token mindfulbytes and click "Generate new app password" to generate a new token.

Create new token

Copy the token and use it as the nextcloud-token parameter.

The WebDAV URL can be found by clicking on the small settings icon in the files tab.

WebDAV Url

Copy the WebDAV Url and use it as the nextcloud-webdav-url parameter.

Last but not least, we need to set the nextcloud-root-dir parameter. Specify the relative path where your images are stored. For now, we assume that all our pictures are stored in the Pictures folder in Nextcloud. So we set the value to Pictures.

  • Edit the global config/config.yaml file to configure Signal Messenger/Email notifications

  • Rename the docker-compose.default.yml file to docker-compose.yml

  • Adapt the docker-compose.yml file and change the /tmp/images folder to the folder on the host system where your images are stored.

  • Build the docker containers with docker-compose -f env/docker/docker-compose.yml build

  • Start the docker containers with docker-compose -f env/docker/docker-compose.yml up

After starting the docker containers, the specified folder on your host system and the folder on your Nextcloud instance gets scanned for images. Depending on the size of the folder, this may take a while.

When the scanning is done, navigate to http://127.0.0.1:8088 with your web browser.

Ideally, you should see a picture ;-).

Web Example

Use Cases

Due to the powerful REST API and the built-in notification support, you can display your mindful bytes on almost any device that has a screen.

Use the built-in notification support to receive your daily mindful bytes via Signal or Email.

Signal Notification

Email Notification

REST API

The REST API Swagger documentation is available here

Examples

  • Get an image that was created at this date x years ago, or if nothing found, a random image

curl -X GET http://127.0.0.1:8088/v1/topics/imgreader/images/today-or-random

Today Or Random

  • Add a caption to the image

curl -X GET http://127.0.0.1:8085/v1/topics/imgreader/images/today-or-random?caption=This%20image%20was%20created%20{{timeago}}

Today Or Random With Caption

  • Format image (for EPaper displays)

curl -X GET http://127.0.0.1:8085/v1/topics/imgreader/images/today-or-random?caption=This%20image%20was%20created%20{{timeago}}&format=bmp&mode=grayscale

Today Or Random For EPaper

  • Cache Images When an image is requested, the request gets delegated to the appropriate plugin which fetches the image. Then, the image will be scaled, labeled, etc. before it will be served. This process can take quite a bit of time.

If you are running a battery powered device (e.g a microcontroller with an E-Paper display), you usually want to spend as much time as possible sleeping and only wake up the device for a short amount of time to maxime the battery life. In order to avoid waiting several seconds for the image processing, it's possible to send a caching request to the backend to cache the image for x seconds in memory.

A typical workflow for a battery powered microcontroller could e.g look like this:

curl -X POST -H "Content-Type: application/json" -d '{"urlpath":"/v1/topics/imgreader/images/today-or-random?size=200x200", "expires": 1800}' http://127.0.0.1:8085/v1/cache

curl -X GET http://127.0.0.1:8085/v1/cache/<cacheid>

With the expires parameter it's possible to specify the duration (in seconds) the image will be kept in the in-memory cache.

About

mindfulbytes - an API to the past.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published