Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek committed Jun 30, 2023
1 parent 3790efa commit 9724723
Show file tree
Hide file tree
Showing 28 changed files with 526 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/deploy-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build and deploy docs to GitHub Pages
on:
push:
branches:
- master
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- run: pip install 'mkdocs-resize-images[dev]'
- run: make fixRelativeLinkDocs
- run: mkdocs gh-deploy --force
28 changes: 28 additions & 0 deletions .github/workflows/mkdoxy-build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: MkDoxy build all supported Python versions

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
# You can use PyPy versions in python-version.
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install 'mkdocs-resize-images[dev]'
- name: Build docs
run: mkdocs build --clean --strict --verbose
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.resize-hash
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/mkdocs-resize-images.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.PHONY: package release release-test clean reviewCode docs-serve docs-build

# Packaging
package:
rm -f dist/*
python3 setup.py sdist bdist_wheel

install: package
python3 -m pip install --no-deps --force dist/*.whl

install-dev: package
python3 -m pip install --force --editable .

release: package
twine upload --repository pypi dist/*

release-test: package
twine upload --repository testpypi dist/*

clean:
rm -rf dist build


fixRelativeLinkDocs:
# change ./docs/ to ./
sed 's/\.\/docs\//\.\//g' README.md > docs/README.md

# Testing
reviewCode:
sourcery review mkdoxy --in-place

install-dev:
python3 -m pip install --force --editable .

# Documentation
docs-serve: fixRelativeLinkDocs
mkdocs serve

docs-build: fixRelativeLinkDocs
mkdocs build
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# mkdocs-resize-images
# MkDocs Resize Images Plugin

<p align="center">
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.51.al%2FJakubAndrysek%2Fmkdocs-resize-images&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=true"/></a>
<img src="https://img.shields.io/github/license/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/v/release/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/stars/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/forks/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/issues/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://static.pepy.tech/personalized-badge/mkdocs-resize-images?period=month&units=international_system&left_color=black&right_color=orange&left_text=Downloads">
</p>

This MkDocs plugin finds all folders with a certain name, by default `assets-large`, resizes all images in those folders according to the plugin configuration.
Then saves the resized images in a different folder, by default `assets`.
The plugin also supports caching: if a file has not changed since the last time the plugin ran, it won't be processed again.

## Installation

Install the plugin using pip from [PyPI](https://pypi.org/project/mkdocs-resize-images/):

```bash
pip install mkdocs-resize-images
```

Activate the plugin in `mkdocs.yml`:

```yaml
plugins:
- search
- resize-images
```
Create `.gitignore` file in your project root directory and add the following line to it:

```bash
assets-large # or whatever you have set as source-dir
.resize-hash # if you have enabled caching
```


## Usage

By default, the plugin will look for images in all directories named assets-large, resize them to 800x600 pixels, and then save the resized images in assets directories in the same parent directories as the assets-large directories.

You can configure the plugin in your mkdocs.yml:

```yaml
plugins:
- search
- resize-images:
source-dir: assets-large
target-dir: assets
enable_cache: True
size: [800, 600]
extensions: ['.jpg', '.jpeg', '.png', '.gif', '.svg']
```

`source-dir`: The name of the directories to search for images to resize. Default is `assets-large`.

`target-dir`: The name of the directories to save the resized images in. Default is `assets`.

`size`: The size to resize the images to, specified as [width, height]. Default is `[800, 600]`.

`extensions`: List of image file extensions to consider for resizing. The plugin will look for images with these extensions in both lower and upper case. Default is `['.jpg', '.jpeg', '.png', '.gif', '.svg']`.

`enable_cache`: Whether to enable caching. If enabled, the plugin will check if a file has changed since the last time the plugin ran, and if not, it won't process the file again. Default is `True`.
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resize.kubaandrysek.cz
67 changes: 67 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# MkDocs Resize Images Plugin

<p align="center">
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.51.al%2FJakubAndrysek%2Fmkdocs-resize-images&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=true"/></a>
<img src="https://img.shields.io/github/license/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/v/release/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/stars/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/forks/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://img.shields.io/github/issues/JakubAndrysek/mkdocs-resize-images?style=flat-square">
<img src="https://static.pepy.tech/personalized-badge/mkdocs-resize-images?period=month&units=international_system&left_color=black&right_color=orange&left_text=Downloads">
</p>

This MkDocs plugin finds all folders with a certain name, by default `assets-large`, resizes all images in those folders according to the plugin configuration.
Then saves the resized images in a different folder, by default `assets`.
The plugin also supports caching: if a file has not changed since the last time the plugin ran, it won't be processed again.

## Installation

Install the plugin using pip from [PyPI](https://pypi.org/project/mkdocs-resize-images/):

```bash
pip install mkdocs-resize-images
```

Activate the plugin in `mkdocs.yml`:

```yaml
plugins:
- search
- resize-images
```
Create `.gitignore` file in your project root directory and add the following line to it:

```bash
assets-large # or whatever you have set as source-dir
.resize-hash # if you have enabled caching
```


## Usage

By default, the plugin will look for images in all directories named assets-large, resize them to 800x600 pixels, and then save the resized images in assets directories in the same parent directories as the assets-large directories.

You can configure the plugin in your mkdocs.yml:

```yaml
plugins:
- search
- resize-images:
source-dir: assets-large
target-dir: assets
enable_cache: True
size: [800, 600]
extensions: ['.jpg', '.jpeg', '.png', '.gif', '.svg']
```

`source-dir`: The name of the directories to search for images to resize. Default is `assets-large`.

`target-dir`: The name of the directories to save the resized images in. Default is `assets`.

`size`: The size to resize the images to, specified as [width, height]. Default is `[800, 600]`.

`extensions`: List of image file extensions to consider for resizing. The plugin will look for images with these extensions in both lower and upper case. Default is `['.jpg', '.jpeg', '.png', '.gif', '.svg']`.

`enable_cache`: Whether to enable caching. If enabled, the plugin will check if a file has changed since the last time the plugin ran, and if not, it won't process the file again. Default is `True`.
Binary file added docs/assets-large/002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets-large/004.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets-large/005.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets-large/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Image source: https://roboruka.robotickytabor.cz/
Binary file added docs/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example

This is large image in `assets-large` folder:
![Large image](assets-large/002.jpg)


This is resized image in `assets` folder:
![If you see this message, it means the plugin does not work, please check your configuration.](assets/002.jpg)

Binary file added docs/project1/assets-large/002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/project1/assets-large/004.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/project1/assets-large/005.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9724723

Please sign in to comment.