# !!!! Be careful !!!! ## Use at your own risk Soshot make webshot of internet page with headless machine (Google Chrome). ## 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 - nhd = 640x360 - hd = 1280x720 - full = 1920x1080 - complete = 1920xpage height ## 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 - PHP 8.* - Sqlite3 - PDO - Composer - Imagick - PHP-GD - CRON - Chrome / Chromium Make directory on your web server and go in ```shell mkdir /var/www/soshot && cd /var/www/soshot ``` Clone git repo ```shell git clone https://forge.leslibres.org/Knah-Tsaeb/Soshot.git . ``` Install dependencies ```shell composer install --no-dev ``` Add cron task ```shell sudo crontab -u www-data -e ``` ```shell php /var/www/soshot/bin/thumbShoter.php ``` Configure your web server to serve in "public" directory. 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. ```json { "onlyLocalServer": true, "webPage": false, "log": true, "alwaysMakePdf": true, "icoSize": 48, "expireCache": 12, "maxGenPerBatch": 50, "permitType": [ "fav", "og", "pdf", "thumb", "nhd", "hd", "full", "complete" ], "password": "$2y$10$HE5odSvieeVv0cbmK4jau.eg6nqrtpoN0KNPHHaVnPC3vDACAYVAu", "key": "acb295c94b12d6364e433d73", "chromePath": "chromium", "fileFormat": "jpeg" } ``` | 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 | ## 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 - [Iconify.design](https://icon-sets.iconify.design/iconamoon/star-off/) for default favicon - [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)