Skip to content

Commit

Permalink
Merge pull request #11 from Levis92/develop
Browse files Browse the repository at this point in the history
Rewrite to Next.js and update project structure
  • Loading branch information
Levis92 authored Apr 11, 2021
2 parents 3174963 + df733ff commit d8c6752
Show file tree
Hide file tree
Showing 151 changed files with 5,435 additions and 12,682 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
#env/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -84,7 +84,7 @@ celerybeat-schedule
*.sage.py

# dotenv
.env
#.env

# virtualenv
.venv
Expand Down
101 changes: 57 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,88 @@
# InfoHub
![Screenshot](screenshot.png)

# InfoHub · [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Levis92/InfoHub/blob/master/LICENCE)

This project is made for my personal use, but you're welcome to use any part of the code. Some widgets may need [API keys](https://en.wikipedia.org/wiki/Application_programming_interface_key) and it's up to you to acquire those yourself.

## Application

InfoHub is an application to display widgets on a screen. That's it. No accounts or special features for touchscreen monitors. Just for displaying information.

It fetches background wallpapers from [Unsplash API](https://unsplash.com/developers).

### Current widgets
* **Clock with time and date.** Displays the current time and date.

* **Västtrafik.** Displays the current departures from chosen bus-, tram- or trainstops. Needs API keys. You can get them from [developer.vasttrafik.se](https://developer.vasttrafik.se/portal/#/).
- **Clock with time and date.** Displays the current time and date.

* **Twitter images.** Displays the latest images from specified Twitter user.
- **Västtrafik.** Displays the current departures from chosen bus-, tram- or trainstops. Needs API keys. You can get them from [developer.vasttrafik.se](https://developer.vasttrafik.se/portal/#/).

* **Weather (Dark Sky API).** Displays current and hourly weather data for chosen location. Needs API key. You can get it from [darksky.net/dev](https://darksky.net/dev/).
- **Twitter images.** Displays the latest images from specified Twitter user.

## React
The frontend is built with the Javascript library [React](https://facebook.github.io/react/) and is styled with the CSS extension language [Sass](http://sass-lang.com).
- **Weather (Tomorrow API).** Displays current and hourly weather data for chosen location. Needs API key. You can get it from [tomorrow.io/weather-api](https://www.tomorrow.io/weather-api/).

### Development
First you need to add a copy of `widget-settings.example.js` and rename it to `widget-settings.js`. The file can be found in `infohub/src/components/`. Add your own settings in the file.
## Docker

The first time you run the application (and every time you add new dependencies) you need do run:
```
npm install
```
After that you only need to run:
```
npm start
```
The application can, after fixing the configuration files, be composed with [Docker](https://www.docker.com).

#### Sass
To compile the Sass files you need to have Sass installed. Instructions on how to do that can be found [here](http://sass-lang.com/install).
To build it run:

There's a [npm](https://www.npmjs.com) script included, so to compile you only need to run:
```
npm run sass
```shell
$ docker-compose up --build
```

### Production
To build the React application you run:
```
npm run build
To just compose it, after being built, run:

```shell
$ docker-compose up
```

## Flask
The backend runs on the Python framework [Flask](http://flask.pocoo.org) and is used as an [API](https://en.wikipedia.org/wiki/Application_programming_interface) to request data and structure it in a format more convenient for the frontend application.
## Next.js

The frontend is built with the Javascript framework [Next.js](https://nextjs.org/) based on [React](https://facebook.github.io/react/) and is styled with [CSS Modules](https://github.com/css-modules/css-modules) and the CSS extension language [Sass](http://sass-lang.com).

### Development
First you need to add a copy of `api_keys.example.py` and rename it to `api_keys.py`. The file can be found in `flask-app/InfoHubAPI/`. Add your API keys in this file.

First you need to add a copy of `widget-settings.example.ts` and rename it to `widget-settings.ts`. The file can be found in `infohub/`. Add your own settings in the file.

Then you also need to make a copy of the `.env` file in `infohub/` and rename it `.env.local`. Add your API keys in it.

The first time you run the application (and every time you add new dependencies) you need do run:

```shell
$ yarn install
```
sh ./init.sh
```

After that you only need to run:
```
sh ./debug.sh

```shell
$ yarn dev
```

#### Sass

Sass files are automatically compiled during runtime or when building the application.

### Production
There are currently no specified script for production mode.

To build and run the Next.js application you run:

```shell
$ yarn build && yarn start
```

## Dependencies
* [React](https://facebook.github.io/react/)
* [Flask](http://flask.pocoo.org)
* [npm](https://www.npmjs.com)
* [Sass](http://sass-lang.com)
* [SuperAgent](https://visionmedia.github.io/superagent/)
* [Requests: HTTP for Humans](http://docs.python-requests.org/en/master/)
* [Moment.js](http://momentjs.com)
* [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/)

- [Next.js](https://nextjs.org/)
- [React](https://facebook.github.io/react/)
- [Yarn](https://yarnpkg.com/)
- [Sass](http://sass-lang.com)
- [React Query](https://react-query.tanstack.com/)
- [Day.js](https://day.js.org/en/)
- [Puppeteer](https://pptr.dev/)

## Resources
* [Västtrafik Developer Portal](https://developer.vasttrafik.se/portal/#/)
* [Dark Sky API](https://darksky.net/dev/)

- [Västtrafik Developer Portal](https://developer.vasttrafik.se/portal/#/)
- [Tomorrow API](https://www.tomorrow.io/weather-api/)
- [Unsplash](https://unsplash.com/developers)
- [News API](https://newsapi.org/docs)
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'
services:
infohub:
build:
context: ./infohub
dockerfile: Dockerfile
image: infohub:prod
ports:
- "3000:3000"
volumes:
- ./infohub:/usr/src/app
redis:
image: "redis:alpine"
38 changes: 0 additions & 38 deletions flask-app/InfoHubAPI/__init__.py

This file was deleted.

11 changes: 0 additions & 11 deletions flask-app/InfoHubAPI/api_keys.example.py

This file was deleted.

17 changes: 0 additions & 17 deletions flask-app/InfoHubAPI/darksky.py

This file was deleted.

18 changes: 0 additions & 18 deletions flask-app/InfoHubAPI/twitter.py

This file was deleted.

103 changes: 0 additions & 103 deletions flask-app/InfoHubAPI/vasttrafik.py

This file was deleted.

Empty file removed flask-app/LICENSE
Empty file.
Empty file removed flask-app/README.rst
Empty file.
12 changes: 0 additions & 12 deletions flask-app/debug.sh

This file was deleted.

10 changes: 0 additions & 10 deletions flask-app/init.sh

This file was deleted.

Loading

0 comments on commit d8c6752

Please sign in to comment.