2023-06-21 11:42:36 +02:00
# !!!! Be careful !!!!
## Use at your own risk
2024-09-18 10:02:32 +02:00
Soshot make webshot of internet page with headless machine (Google Chrome).
2023-06-21 11:42:36 +02:00
## Ideas
- If webshot exist in desired size, serve them, if not, verif if complete exist, if exist, crop and resize, save and serve
- If webshot not exist get information of page and add in the queue
- Cron job take a webshot of complete page and save them (1920 x complete lenth)
- Crop image and resize desired format (1920x1080, 1280x720, 160x90 ...), save and serve
SoShot always make complete webshot (1920x page lenght) + first demande size.
Size use 16/9 ratio :
- fav = define by config (default 48px)
- og = define by the website himself (no resize or crop)
- thumb = 160x90
2024-09-18 10:02:32 +02:00
- nhd = 640x360
2023-06-21 11:42:36 +02:00
- hd = 1280x720
- full = 1920x1080
- complete = 1920xpage height
2024-09-18 10:02:32 +02:00
## Installation
### Docker (recommended)
For the moment I don't provide any image in any hub.
#### Build image
```shell
wget https://forge.leslibres.org/Knah-Tsaeb/Soshot/raw/branch/main/Dockerfile
docker buildx build --no-cache -t soshot:0.3.0 .
```
#### Start container
You can use native docker volume.
docker run -v soshot_datas:/var/www/datas -v soshot_cache:/var/www/cache -e TZ=UTC -p 8187:80 --name soshot soshot:0.3.0
Or use absolute path
docker run -v /opt/soshot/datas:/var/www/datas -v /opt/soshot/cache:/var/www/public/cache -e TZ=UTC -p 8187:80 --name soshot soshot:0.3.0
### Classic way
#### Requirements
2023-06-21 11:42:36 +02:00
- PHP 8.*
- Sqlite3
- PDO
- Composer
- Imagick
- PHP-GD
- CRON
- Chrome / Chromium
Make directory on your web server and go in
2024-09-18 10:02:32 +02:00
```shell
2023-06-21 11:42:36 +02:00
mkdir /var/www/soshot & & cd /var/www/soshot
2024-09-18 10:02:32 +02:00
```
2023-06-21 11:42:36 +02:00
Clone git repo
2024-09-18 10:02:32 +02:00
```shell
2023-06-21 11:42:36 +02:00
git clone https://forge.leslibres.org/Knah-Tsaeb/Soshot.git .
2024-09-18 10:02:32 +02:00
```
2023-06-21 11:42:36 +02:00
Install dependencies
2024-09-18 10:02:32 +02:00
```shell
2023-06-21 11:42:36 +02:00
composer install --no-dev
2024-09-18 10:02:32 +02:00
```
2023-06-21 11:42:36 +02:00
2023-06-22 16:04:11 +02:00
Add cron task
2024-09-18 10:02:32 +02:00
```shell
2023-06-22 16:04:11 +02:00
sudo crontab -u www-data -e
2024-09-18 10:02:32 +02:00
```
2023-06-22 16:04:11 +02:00
2024-09-18 10:02:32 +02:00
```shell
2023-06-22 16:04:11 +02:00
php /var/www/soshot/bin/thumbShoter.php
2024-09-18 10:02:32 +02:00
```
2023-06-22 16:04:11 +02:00
2024-09-18 10:02:32 +02:00
Configure your web server to serve in "public" directory.
2023-06-21 11:42:36 +02:00
Go to web page
https://shoshot.your-domain.tld
## Configuration
You can use a web interface (if option "use web gui" is set to true), https://shoshot.your-domain.tld/backend?page=settings
Or you can modify config file /datas/config.json.
2024-09-18 10:04:22 +02:00
```json
{
"onlyLocalServer": true,
"webPage": false,
"log": true,
"alwaysMakePdf": false,
"icoSize": 48,
"expireCache": 12,
"maxGenPerBatch": 5,
"permitType": [],
"password": null,
"key": null,
"chromePath": null,
"fileFormat": "jpeg"
}
```
2024-09-18 10:02:32 +02:00
2024-09-18 10:04:22 +02:00
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| onlyLocalServer | bool | true | ShoShot only work for local machine, return 404 if use with remote machine |
| webPage | bool | false | Soshot only work with endpoint /api. Return 404 if not |
| log | bool | true | Not implemented yet |
| alwaysMakePdf | bool | false | If true, SoShot make a complete webshot and PDF of page |
| icoSize | int | 48 | Define size of favicon |
| expireCache | int | 12 | Not implemented yet |
| permitType | array | null | Select authorized size or type of webshot |
| maxGenPerBatch | int | 5 | Foreach cron task as launch, SoShot make 5 webshot |
| key | string | 12 | !!! DANGER !!! If you change key, all previous generation will be invalid. Soshot re make all previous generationt |
| password | string | null | Password for admin interface. No min or max character |
| chromePath | string | null | If path of Chrome/Chromium is not in PATH, you can define here |
2023-06-21 11:42:36 +02:00
## Usage
For generating webshot the entry point is https://shoshot.your-domain.tld/api?
You need to define 3 parameters :
- type (fav, og, pdf, thumb, hd, full, complete)
- hmac (hash_hmac('sha1', url of page, your Api key);)
- url (url of page encode with url_encode)
Example : https://shoshot.your-domain.tld/api?type=fav& hmac=44a2b3f1bc43895c23779f4e71558e9976a4daf2& url=https%3A%2F%2Ffr.wikipedia.org%2Fwiki%2FLogiciel_libre
## License
GNU General Public License v3.0
See LICENSE file for more detail.
**Thanks**
- [W3c ](https://www.w3schools.com/w3css/ ) for w3.css
- [Fork Awesome ](https://forkaweso.me/Fork-Awesome/ ) for icon
2024-03-20 10:35:43 +01:00
- [Iconify.design ](https://icon-sets.iconify.design/iconamoon/star-off/ ) for default favicon
2023-06-21 11:42:36 +02:00
- [embed/embed ](https://github.com/oscarotero/Embed ) for embed (fav and og)
- [hassankhan/config ](https://github.com/hassankhan/config ) for config (config mananger)
- [chrome-php/chrome ](https://github.com/chrome-php/chrome ) for chrome-php (wrapper for chrome dev-tool)
- [stefangabos/zebra_image ](https://github.com/stefangabos/Zebra_Image ) for zebra-image (resize and manipulate image)
- [guzzlehttp/psr7 ](https://github.com/guzzle/psr7 ) for psr7 (PSR7 implement)