Skip to content

Commit d8c6752

Browse files
authored
Merge pull request #11 from Levis92/develop
Rewrite to Next.js and update project structure
2 parents 3174963 + df733ff commit d8c6752

151 files changed

Lines changed: 5435 additions & 12682 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ __pycache__/
1212

1313
# Distribution / packaging
1414
.Python
15-
env/
15+
#env/
1616
build/
1717
develop-eggs/
1818
dist/
@@ -84,7 +84,7 @@ celerybeat-schedule
8484
*.sage.py
8585

8686
# dotenv
87-
.env
87+
#.env
8888

8989
# virtualenv
9090
.venv

README.md

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,88 @@
1-
# InfoHub
1+
![Screenshot](screenshot.png)
2+
3+
# 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)
4+
25
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.
36

47
## Application
8+
59
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.
610

11+
It fetches background wallpapers from [Unsplash API](https://unsplash.com/developers).
12+
713
### Current widgets
8-
* **Clock with time and date.** Displays the current time and date.
914

10-
* **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/#/).
15+
- **Clock with time and date.** Displays the current time and date.
1116

12-
* **Twitter images.** Displays the latest images from specified Twitter user.
17+
- **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/#/).
1318

14-
* **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/).
19+
- **Twitter images.** Displays the latest images from specified Twitter user.
1520

16-
## React
17-
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).
21+
- **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/).
1822

19-
### Development
20-
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.
23+
## Docker
2124

22-
The first time you run the application (and every time you add new dependencies) you need do run:
23-
```
24-
npm install
25-
```
26-
After that you only need to run:
27-
```
28-
npm start
29-
```
25+
The application can, after fixing the configuration files, be composed with [Docker](https://www.docker.com).
3026

31-
#### Sass
32-
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).
27+
To build it run:
3328

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

39-
### Production
40-
To build the React application you run:
41-
```
42-
npm run build
33+
To just compose it, after being built, run:
34+
35+
```shell
36+
$ docker-compose up
4337
```
4438

45-
## Flask
46-
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.
39+
## Next.js
40+
41+
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).
4742

4843
### Development
49-
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.
44+
45+
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.
46+
47+
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.
5048

5149
The first time you run the application (and every time you add new dependencies) you need do run:
50+
51+
```shell
52+
$ yarn install
5253
```
53-
sh ./init.sh
54-
```
54+
5555
After that you only need to run:
56-
```
57-
sh ./debug.sh
56+
57+
```shell
58+
$ yarn dev
5859
```
5960

61+
#### Sass
62+
63+
Sass files are automatically compiled during runtime or when building the application.
64+
6065
### Production
61-
There are currently no specified script for production mode.
66+
67+
To build and run the Next.js application you run:
68+
69+
```shell
70+
$ yarn build && yarn start
71+
```
6272

6373
## Dependencies
64-
* [React](https://facebook.github.io/react/)
65-
* [Flask](http://flask.pocoo.org)
66-
* [npm](https://www.npmjs.com)
67-
* [Sass](http://sass-lang.com)
68-
* [SuperAgent](https://visionmedia.github.io/superagent/)
69-
* [Requests: HTTP for Humans](http://docs.python-requests.org/en/master/)
70-
* [Moment.js](http://momentjs.com)
71-
* [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/)
74+
75+
- [Next.js](https://nextjs.org/)
76+
- [React](https://facebook.github.io/react/)
77+
- [Yarn](https://yarnpkg.com/)
78+
- [Sass](http://sass-lang.com)
79+
- [React Query](https://react-query.tanstack.com/)
80+
- [Day.js](https://day.js.org/en/)
81+
- [Puppeteer](https://pptr.dev/)
7282

7383
## Resources
74-
* [Västtrafik Developer Portal](https://developer.vasttrafik.se/portal/#/)
75-
* [Dark Sky API](https://darksky.net/dev/)
84+
85+
- [Västtrafik Developer Portal](https://developer.vasttrafik.se/portal/#/)
86+
- [Tomorrow API](https://www.tomorrow.io/weather-api/)
87+
- [Unsplash](https://unsplash.com/developers)
88+
- [News API](https://newsapi.org/docs)

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
services:
3+
infohub:
4+
build:
5+
context: ./infohub
6+
dockerfile: Dockerfile
7+
image: infohub:prod
8+
ports:
9+
- "3000:3000"
10+
volumes:
11+
- ./infohub:/usr/src/app
12+
redis:
13+
image: "redis:alpine"

flask-app/InfoHubAPI/__init__.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

flask-app/InfoHubAPI/api_keys.example.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

flask-app/InfoHubAPI/darksky.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

flask-app/InfoHubAPI/twitter.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

flask-app/InfoHubAPI/vasttrafik.py

Lines changed: 0 additions & 103 deletions
This file was deleted.

flask-app/LICENSE

Whitespace-only changes.

flask-app/README.rst

Whitespace-only changes.

0 commit comments

Comments
 (0)