Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"commit": "8d76f8a131f62fb06a285de1f142973c1ea7222a",
"checkout": null,
"context": {
"cookiecutter": {
"plugin_name": "Tailwind CSS",
"repo_name": "tailwindcss",
"package_name": "tailwindcss",
"distribution_name": "pelican-tailwindcss",
"version": "0.2.0",
"description": "Pelican plugin to add Tailwind CSS to your web site",
"authors": "{name = \"Pelican Dev Team\", email = \"authors@getpelican.com\"}",
"keywords": "\"pelican\", \"plugin\", \"tailwindcss\", \"css\", \"css-framework\"",
"readme": "README.md",
"contributing": "CONTRIBUTING.md",
"license": "GNU Affero General Public License v3|AGPL-3.0",
"repo_url": "https://github.com/pelican-plugins/tailwindcss",
"dev_status": "4 - Beta",
"tests_exist": false,
"python_version": "~=3.9",
"pelican_version": ">=4.5",
"_template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"_commit": "8a4f543e999c7a2b4ab49c724bf84ff4192f4c94"
}
},
"directory": null
}
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
custom: https://donate.getpelican.com
github: justinmayer
liberapay: pelican
104 changes: 48 additions & 56 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,98 +5,90 @@ on: [push, pull_request]
env:
PYTEST_ADDOPTS: "--color=yes"

permissions:
contents: read

jobs:
test:
name: Test - ${{ matrix.python-version }}
name: Test - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Pip cache
uses: actions/cache@v2
id: pip-cache
- uses: actions/checkout@v4
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/pyproject.toml') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Poetry
run: python -m pip install poetry
- name: Set up Poetry cache
uses: actions/cache@v2
id: poetry-cache
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }} & PDM
uses: pdm-project/setup-pdm@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
python-version: ${{ matrix.python-version }}
cache: true
cache-dependency-path: ./pyproject.toml

- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
run: pdm install

- name: Run tests
run: poetry run invoke tests
run: pdm run invoke tests

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/checkout@v4
with:
python-version: "3.9"
- name: Set Poetry cache
uses: actions/cache@v2
id: poetry-cache
persist-credentials: false

- name: Set up Python & PDM
uses: pdm-project/setup-pdm@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Poetry
run: python -m pip install poetry
python-version: "3.10"

- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
run: pdm install

- name: Run linters
run: poetry run invoke lint --diff
run: pdm run invoke lint --diff

deploy:
name: Deploy
environment: Deployment
needs: [test, lint]
runs-on: ubuntu-latest
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'

permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Check release
id: check_release
run: |
python -m pip install --upgrade pip
python -m pip install poetry githubrelease httpx==0.18.2 autopub
echo "##[set-output name=release;]$(autopub check)"
python -m pip install autopub[github]
autopub check

- name: Publish
if: ${{ steps.check_release.outputs.release=='' }}
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }}
autopub prepare
poetry build
autopub commit
autopub build
autopub githubrelease
poetry publish -u __token__ -p $PYPI_PASSWORD

- name: Upload package to PyPI
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ share/python-wheels/
*.egg
MANIFEST

# PDM
.pdm-python
pdm.lock

# Poetry
poetry.lock

Expand Down
29 changes: 7 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ ci:
# See https://pre-commit.com/hooks.html for info on hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
Expand All @@ -19,25 +20,9 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
args: [--max-line-length=88]
language_version: python3

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py36-plus]
- id: ruff
- id: ruff-format
args: ["--check"]
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
0.2.0 - 2022-07-10
------------------

Now we can install and use TailwindCSS plugins.
Add support for installing and using Tailwind CSS plugins.

Contributed by [Luca Fedrizzi](https://github.com/lcfd) via [PR #3](https://github.com/pelican-plugins/tailwindcss/pull/3/)

Expand Down
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
# TailwindCSS Plugin for Pelican 🌬
# Tailwind CSS Plugin for Pelican 🌬

[![Build Status](https://img.shields.io/github/actions/workflow/status/pelican-plugins/tailwindcss/main.yml?branch=main)](https://github.com/pelican-plugins/tailwindcss/actions)
[![PyPI Version](https://img.shields.io/pypi/v/pelican-tailwindcss)](https://pypi.org/project/pelican-tailwindcss/)
[![Downloads](https://img.shields.io/pypi/dm/pelican-tailwindcss)](https://pypi.org/project/pelican-tailwindcss/)
![License](https://img.shields.io/pypi/l/pelican-tailwindcss?color=blue)

This plugin helps you use [TailwindCSS][] in your Pelican website.

| Author | GitHub | Twitter |
| :-----------: | :------------------------------------------------: | :----------------------------------------------------: |
| Luca Fedrizzi | [https://github.com/lcfd](https://github.com/lcfd) | [https://twitter.com/lc_fd](https://twitter.com/lc_fd) |
This plugin helps you use [Tailwind CSS][] in your Pelican web site.

## Why Use This Plugin?

Because you want use [TailwindCSS][] in seconds.
Not hours.
Because you want use [Tailwind CSS][] in seconds. Not hours.

## Requirements

In order to run this plugin, you need to install NodeJS. (I'm looking to replace this dependency by using a Python package. – Luca)
In order to run this plugin, you need to install Node.JS. (Someday this dependency could be replaced with a Python package.)

## Installation

This plugin can be installed via:

`python -m pip install pelican-tailwindcss`

or
python -m pip install pelican-tailwindcss

`poetry add pelican-tailwindcss`
As long as you have not explicitly added a `PLUGINS` setting to your Pelican settings file, then the newly-installed plugin should be automatically detected and enabled. Otherwise, you must add `tailwindcss` to your existing `PLUGINS` list. For more information, please see the [How to Use Plugins](https://docs.getpelican.com/en/latest/plugins.html#how-to-use-plugins) documentation.

## Basic Usage

Expand Down Expand Up @@ -60,7 +54,7 @@ or
<link rel="stylesheet" href="/output.css" />
```

4. Done! You should be ready to use [TailwindCSS][] in your website template.
4. Done! You should be ready to use [Tailwind CSS][] in your website template.

## Advanced Usage

Expand All @@ -80,16 +74,16 @@ TAILWIND = {
}
```

### Tailwind plugins install
### Tailwind Plugin Installation

As you can see from the example above it is possible to add the `plugins` property to the configuration.
Just add the name of a Tailwind plugin in this property and the plugin will be installed.
As you can see from the example above, it is possible to add the `plugins` property to the configuration.
Just add the name of a Tailwind plugin to the list, and the plugin will be installed.

## Useful informations
## Useful Information

### Plugins

Your `tailwind.config.js` file will only be copied when Pelican starts. This means that any changes after starting Pelican will not be considered. For example if you want to install a new plugin for Tailwind you will have to restart Pelican.
Your `tailwind.config.js` file will only be copied when Pelican starts. This means that any changes made after starting Pelican will not be recognized. For example, if you want to install a new plugin for Tailwind, you will have to restart Pelican in order for that plugin to become active.

## Contributing

Expand All @@ -104,4 +98,4 @@ To start contributing to this plugin, review the [Contributing to Pelican][] doc

This project is licensed under the AGPL-3.0 license.

[TailwindCSS]: https://github.com/tailwindlabs/tailwindcss
[Tailwind CSS]: https://github.com/tailwindlabs/tailwindcss
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Release type: minor

* Fix NPM error (`could not determine executable to run`), perhaps related to Tailwind CSS 4.x release ([#8](https://github.com/pelican-plugins/tailwindcss/pull/8/))
* Use PDM & Ruff instead of Poetry, Black, Flake8, and isort ([#9](https://github.com/pelican-plugins/tailwindcss/pull/9/))
2 changes: 1 addition & 1 deletion pelican/plugins/tailwindcss/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .tailwindcss import * # NOQA
from .tailwindcss import * # noqa: F403,PGH004,RUF100
6 changes: 3 additions & 3 deletions pelican/plugins/tailwindcss/tailwindcss.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import os.path as path
from os import path
import shutil
import subprocess

Expand Down Expand Up @@ -48,7 +48,7 @@ def initialize(po):
else:
print(f"{utils.LOG_PREFIX} No settings were found")
else:
print("{utils.LOG_PREFIX} Initialization required, first start")
print(f"{utils.LOG_PREFIX} Initialization required -- first start")
commands.run_in_plugin("npm install")
if TAILWIND_SETTINGS:
print(f"{utils.LOG_PREFIX} Settings were found")
Expand All @@ -63,7 +63,7 @@ def generate_css(po):
twconfig_file_path = os.path.join(BASE_DIR, "tailwind.config.js")

input_output = f"-i {input_file_path} -o {output_file_path}"
print(f"{utils.LOG_PREFIX} Build css ({output_file_path})")
print(f"{utils.LOG_PREFIX} Build CSS ({output_file_path})")

commands.run_in_plugin(
f"npx tailwindcss -c {twconfig_file_path} {input_output}",
Expand Down
3 changes: 2 additions & 1 deletion pelican/plugins/tailwindcss/utils/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os.path as path
from os import path
import subprocess

PLUGIN_BASE_DIR = path.abspath(path.join(__file__, "../../"))
Expand All @@ -9,4 +9,5 @@ def run_in_plugin(command: str):
args=command,
cwd=PLUGIN_BASE_DIR,
shell=True,
check=False,
)
Loading