This repository contains the source code for the Shatabang web application. The application has been developed to solve a one of my own problems and is supposed to be used to maintain an image and video library. The web application is the core of the platform and the web client is supposed to use modern frameworks and be platform independent. It includes several external tools which you can read about further down in this document.
The Shatabang image and video library orders all imported media files in chronological order, and include the following features:
- Exif information extraction
- Resize to web optimal size
- Download the original file from the server
- Detect and block import of image duplicates
- Authentication with basic or Google
- Infinite image scroll in web client
- Responsive web interface which suits desktop, pads as well as mobile screens.
The following features are under development:
- Search and filter based on
- the exif/meta information
- the date
- the location
- Add/Edit/delete meta information on single and multiple images
- Manage the trash bin
- Create public gallery
- Group similar images
- Other authentication methods
- Authorization of media files between users
This is a list of all the external library dependencies which must be installed on the machine for the the application to work properly.
The platform upon which the application is built.
To read exif info from images.
One of the fastest libraries to resize and transform images.
To resize videos and extract images from different time frames.
To identify objects in the images.
A key-value in memory NoSQL database used by the session and task processor.
brew tap homebrew/science brew install exiftool redis
sudo apt-get update
sudo apt-get install git libimage-exiftool-perl libvips-dev build-essential ffmpeg redis-server -y
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get update
sudo apt-get install git libimage-exiftool-perl libvips-dev build-essential libav-tools redis-server -y
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
libav-tools will install avprobe, need to create a symbolic link so it can be use by fluent-ffmpeg.
ln -s /usr/bin/avprobe /usr/bin/ffprobe
ln -s /usr/bin/avconv /usr/bin/ffmpeg
I've added a docker image to package the application with all the necessary dependencies in one single container. This docker image is based on a base image including all the necessary tools listed above. The base image is called shatabang-base and can be found here https://cloud.docker.com/repository/docker/softbrix/shatabang-base/
The docker image is built with the following command:
docker build . -t softbrix/shatabang
Please use the provided docker-compose.yml to spin up the instance. This will also start the required redis server which will be used by the task processor.
docker-compose up -d
The application can use a configured with a file or with environment variables. The environment variables will be used primarily and the config values in the file if not configured in the context. Configurable settings is regarding the different folders and settings about the authentication.
Env | Config file | Default value | Description |
---|---|---|---|
BASE_URL | baseUrl | '/' | The url this application is served at, needs to be configured if using authentication with redirection or if the application is not in the root of the server context |
PORT | port | 3000 | The port number the server is exposing |
SERVER_SALT | serverSalt | - | This should be a unique hash for the server |
ADMIN_HASH | adminHash | - | The unique hash for the admin password |
STORAGE_DIR | storageDir | - | The path to the root for the media storage |
CACHE_DIR | cacheDir | - | The path to the root for the media cache |
REDIS_PORT_6379_TCP_ADDR | redisHost | '127.0.0.1' | The host to the redis server |
REDIS_PORT_6379_TCP_PORT | redisPort | 6379 | The port to the redis server |
GOOGLE_AUTH | google_auth object | - | Read more in the following chapter |
GOOGLE_AUTH_ALLOW | google_auth.allowed_ids | - | ^^ |
The docker compose file will list all configurable variables with a leading underscore.
Set the environment variable before starting the application.
To create the configuration file it simplest if you run the shatabang_config.sh script from the root directory.
./install_scripts/shatabang_config.sh
This will ask you all the necessary questions and write the answers to a config_server.json file.
It is possible to configure the application in two ways. Either with the config_server.json or with environment variables. The configuration file is preferred and the environment variable support is mainly for docker container.
You can configure the google oauth2 credentials at https://console.developers.google.com/apis/credentials.
Add a new key called "google_auth" and add the following variables in an object:
- "clientID", the unique application ID
- "clientSecret", the unique application client secret
- "callbackURL", the url a successful sign in should return to. This should be your applications hostname.
- "allowed_ids", an array with either valid user id's or user emails.
Add the following environment variables
- GOOGLE_AUTH with the clientID and clientSecret joined with a ':', ie clientID:clientSecret.
- GOOGLE_AUTH_CALLBACK with the url a successful authentication should return to.
- GOOGLE_AUTH_ALLOW with a comma separated list of either user id's or emails.
The directory and file structure is all lower case to simplify moving between case sensetive and case insensitive file systems.
.
├── storage
│ ├── import
│ ├── filtered
│ │ ├── deleted
│ │ ├── duplicates
│ │ └── unknown
│ ├── sorted
│ │ └── <YYYY>
│ │ └── <MM>
│ │ └── <DD>
│ │ └── <HHmmSSnnn.ext>
│ └── upload
└── cache
├── 320
│ └── <YYYY>
│ └── <MM>
│ └── <DD>
│ └── <HHmmSSnnn.ext>
The following properties are indexed for each media file.
- a, aspect ratio
- b, blur
- r, rating
- s, file size
Now days it's hard to come up with a unique name both on companies and products. One morning during the summer of 2016 I shouted "Shatabang" when I solved one of the problems I was working with. I guess it was some what inspired by Alkimedes who shouted Eureka when he found Archimedes' principle. Although heureka already had a meaning (I have found (it)), the meaning of Shatabang is still to be defined.
My personal definition of Shatabang is: I have solved it!