mirror of
https://github.com/pelican-plugins/share-post.git
synced 2025-10-15 17:08:54 +02:00
Compare commits
90 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b77fb8143 | ||
|
|
35aec507f4 |
||
|
|
376cc12df9 | ||
|
|
167eec5015 |
||
|
491663a71c |
|||
|
|
46ff6e0722 |
||
|
|
cfda0a315a | ||
|
|
897206b8b8 | ||
|
|
d7c2f2bf1f | ||
|
|
ff43fa4542 |
||
|
|
4c00e773e1 |
||
|
|
6869efea17 |
||
|
|
b2655509e0 | ||
|
|
8554d21e0a |
||
|
|
66076766e0 |
||
|
|
3c7656fa10 |
||
|
|
7088f77760 |
||
|
|
56ebe6ad5b |
||
|
|
e32b0ddbd0 |
||
|
|
656d3773ec | ||
|
|
1e7e630453 | ||
|
|
64188516c2 | ||
|
|
33e329de02 | ||
|
|
2387c73609 | ||
|
|
9aa8315ce0 | ||
|
|
1f7e1430ad | ||
|
|
694a2725de | ||
|
|
2832136344 |
||
|
|
f813736c57 | ||
|
|
b3a8f622db |
||
|
|
0fdb907f1f |
||
|
|
59f405d719 |
||
|
|
96dfe3ea42 | ||
|
|
8de72f2182 |
||
|
|
2ddfbbf326 | ||
|
|
5eb4476889 |
||
|
|
6eaa7893ce |
||
|
|
739b4bfb82 | ||
|
|
db31937745 |
||
|
|
bcd1ee341b |
||
|
|
cbbe302c69 | ||
|
|
0af46c53b0 |
||
|
|
aa5780782f |
||
|
|
acdc611633 | ||
|
|
e4fbfebebd |
||
|
|
b46226f6ce | ||
|
|
ab3cd4c3dd | ||
|
|
56488d52d1 | ||
|
|
38429bd52b | ||
|
|
89d1f123e8 |
||
|
|
0312f7a972 | ||
|
|
a50b605129 |
||
|
|
01d75d58e9 |
||
|
|
51ae835866 |
||
|
|
c4d692a412 |
||
|
|
3ad01172d4 |
||
|
|
5e913c20f9 |
||
|
|
75e8e133ea |
||
|
|
3c48e56b62 |
||
|
|
718f0824c4 |
||
|
|
2f7f91af2a |
||
|
|
7f34eb90b7 |
||
|
|
d4dd47a322 |
||
|
|
7cb0f666ac |
||
|
|
3129e0378f |
||
|
|
0de3fcdc78 |
||
|
|
922b99bfae |
||
|
|
03e0832775 |
||
|
|
0f32936bce |
||
|
|
3d2b8ed9fe |
||
|
|
fa7eae4550 |
||
|
|
2ca215ad75 |
||
|
|
1adfca3fec |
||
|
|
7aee0a6d99 |
||
|
|
cf84a2d205 |
||
|
|
fdc8018c07 |
||
|
|
f035026923 |
||
|
|
a0d3b68226 |
||
|
|
612effae83 |
||
|
|
58e5054693 |
||
|
|
554f40881d |
||
|
|
a66d8b0a22 |
||
|
|
9d6e04bc9e |
||
|
|
eba18bca84 | ||
|
|
ba52c4c0d1 | ||
|
|
98f25e3ed0 | ||
|
|
8bc139b335 | ||
|
|
a130020af9 |
||
|
|
10931570ba | ||
|
|
bf2dca8df6 |
12 changed files with 272 additions and 177 deletions
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
github: justinmayer
|
||||||
|
liberapay: pelican
|
||||||
113
.github/workflows/main.yml
vendored
113
.github/workflows/main.yml
vendored
|
|
@ -7,98 +7,89 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: Test - ${{ matrix.python-version }}
|
name: Test - Python ${{ matrix.python-version }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v2
|
- name: Set up Python ${{ matrix.python-version }} & PDM
|
||||||
|
uses: pdm-project/setup-pdm@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Set up Pip cache
|
cache: true
|
||||||
uses: actions/cache@v2
|
cache-dependency-path: ./pyproject.toml
|
||||||
id: pip-cache
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pypoetry/virtualenvs
|
|
||||||
key: poetry-${{ hashFiles('**/poetry.lock') }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
poetry run pip install --upgrade pip
|
|
||||||
poetry install
|
|
||||||
- name: Run tests
|
|
||||||
run: poetry run invoke tests
|
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pdm run invoke tests
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: "3.x"
|
|
||||||
- name: Set Poetry cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: poetry-cache
|
|
||||||
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
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
poetry run pip install --upgrade pip
|
|
||||||
poetry install
|
|
||||||
- name: Run linters
|
|
||||||
run: poetry run invoke lint
|
|
||||||
|
|
||||||
|
- name: Validate links in Markdown files
|
||||||
|
uses: JustinBeckwith/linkinator-action@v1
|
||||||
|
with:
|
||||||
|
retry: true
|
||||||
|
|
||||||
|
- name: Set up Python & PDM
|
||||||
|
uses: pdm-project/setup-pdm@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
|
||||||
|
- name: Run linters
|
||||||
|
run: pdm run invoke lint --diff
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy
|
name: Deploy
|
||||||
environment: Deployment
|
environment: Deployment
|
||||||
needs: [test, lint]
|
needs: [test, lint]
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
- name: Check release
|
- name: Check release
|
||||||
id: check_release
|
id: check_release
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install autopub httpx
|
||||||
python -m pip install poetry githubrelease httpx==0.16.1 autopub
|
python -m pip install https://github.com/scikit-build/github-release/archive/master.zip
|
||||||
echo "##[set-output name=release;]$(autopub check)"
|
autopub check
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
if: ${{ steps.check_release.outputs.release=='' }}
|
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
||||||
run: |
|
run: |
|
||||||
git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }}
|
|
||||||
autopub prepare
|
autopub prepare
|
||||||
poetry build
|
|
||||||
autopub commit
|
autopub commit
|
||||||
|
autopub build
|
||||||
autopub githubrelease
|
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
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
poetry.lock
|
.pdm-python
|
||||||
|
pdm.lock
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,28 @@
|
||||||
|
---
|
||||||
|
ci:
|
||||||
|
autoupdate_schedule: quarterly
|
||||||
|
|
||||||
# See https://pre-commit.com/hooks.html for info on hooks
|
# See https://pre-commit.com/hooks.html for info on hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v4.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-merge-conflict
|
||||||
- id: check-toml
|
- id: check-toml
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
- id: detect-private-key
|
- id: detect-private-key
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
|
- id: forbid-new-submodules
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 19.10b0
|
rev: v0.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
|
- id: ruff-format
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
args: ["--check"]
|
||||||
rev: 3.9.0
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
args: [--max-line-length=88]
|
|
||||||
language_version: python3.7
|
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.7.0
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
|
|
|
||||||
23
CHANGELOG.md
23
CHANGELOG.md
|
|
@ -1,11 +1,30 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
1.2.1 - 2025-03-23
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Add title to Bluesky
|
||||||
|
|
||||||
|
Contributed by [Daniel Lemos](https://github.com/xspager) via [PR #34](https://github.com/pelican-plugins/share-post/pull/34/)
|
||||||
|
|
||||||
|
|
||||||
|
1.2.0 - 2025-01-29
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Add Bluesky support
|
||||||
|
|
||||||
|
Contributed by [Leonardo Giordani](https://github.com/lgiordani) via [PR #33](https://github.com/pelican-plugins/share-post/pull/33/)
|
||||||
|
|
||||||
|
|
||||||
|
1.1.0 - 2023-08-31
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Add Mastodon share link
|
||||||
|
|
||||||
1.0.0 - 2021-03-19
|
1.0.0 - 2021-03-19
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Initial release as namespace plugin
|
Initial release as namespace plugin
|
||||||
|
|
||||||
[Justin Mayer](https://github.com/justinmayer) [PR #1](https://github.com/pelican-plugins/share-post/pull/1/)
|
[Justin Mayer](https://github.com/justinmayer) [PR #1](https://github.com/pelican-plugins/share-post/pull/1/)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
30
README.md
30
README.md
|
|
@ -1,7 +1,8 @@
|
||||||
# Share Post: A Plugin for Pelican
|
# Share Post: A Plugin for Pelican
|
||||||
|
|
||||||
[](https://github.com/pelican-plugins/share-post/actions)
|
[](https://github.com/pelican-plugins/share-post/actions)
|
||||||
[](https://pypi.org/project/pelican-share-post/)
|
[](https://pypi.org/project/pelican-share-post/)
|
||||||
|
[](https://pypi.org/project/pelican-share-post/)
|
||||||

|

|
||||||
|
|
||||||
Share Post is a Pelican plugin that creates share links in articles that allow site visitors to share the current article with others in a privacy-friendly manner.
|
Share Post is a Pelican plugin that creates share links in articles that allow site visitors to share the current article with others in a privacy-friendly manner.
|
||||||
|
|
@ -18,6 +19,8 @@ This plugin can be installed via:
|
||||||
|
|
||||||
python -m pip install pelican-share-post
|
python -m pip install pelican-share-post
|
||||||
|
|
||||||
|
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 `share_post` 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.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
@ -25,13 +28,15 @@ This plugin adds to each Pelican article a dictionary of URLs that, when followe
|
||||||
|
|
||||||
```python
|
```python
|
||||||
article.share_post = {
|
article.share_post = {
|
||||||
"facebook": "<URL>",
|
|
||||||
"email": "<URL>",
|
"email": "<URL>",
|
||||||
"twitter": "<URL>",
|
|
||||||
"diaspora": "<URL>",
|
"diaspora": "<URL>",
|
||||||
"linkedin": "<URL>",
|
"facebook": "<URL>",
|
||||||
"hacker-news": "<URL>",
|
"hacker-news": "<URL>",
|
||||||
|
"linkedin": "<URL>",
|
||||||
|
"mastodon": "<URL>",
|
||||||
"reddit": "<URL>",
|
"reddit": "<URL>",
|
||||||
|
"twitter": "<URL>",
|
||||||
|
"bluesky": "<URL>",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -42,19 +47,23 @@ You can then access those variables in your template. For example:
|
||||||
<section>
|
<section>
|
||||||
<p id="post-share-links">
|
<p id="post-share-links">
|
||||||
Share on:
|
Share on:
|
||||||
<a href="{{article.share_post['diaspora']}}" title="Share on Diaspora">Diaspora*</a>
|
<a href="{{article.share_post['email']}}" title="Share via Email">Email</a>
|
||||||
❄
|
❄
|
||||||
<a href="{{article.share_post['twitter']}}" title="Share on Twitter">Twitter</a>
|
<a href="{{article.share_post['diaspora']}}" title="Share on Diaspora">Diaspora</a>
|
||||||
❄
|
❄
|
||||||
<a href="{{article.share_post['facebook']}}" title="Share on Facebook">Facebook</a>
|
<a href="{{article.share_post['facebook']}}" title="Share on Facebook">Facebook</a>
|
||||||
❄
|
❄
|
||||||
<a href="{{article.share_post['linkedin']}}" title="Share on LinkedIn">LinkedIn</a>
|
|
||||||
❄
|
|
||||||
<a href="{{article.share_post['hacker-news']}}" title="Share on Hacker News">Hacker News</a>
|
<a href="{{article.share_post['hacker-news']}}" title="Share on Hacker News">Hacker News</a>
|
||||||
❄
|
❄
|
||||||
<a href="{{article.share_post['email']}}" title="Share via Email">Email</a>
|
<a href="{{article.share_post['linkedin']}}" title="Share on LinkedIn">LinkedIn</a>
|
||||||
|
❄
|
||||||
|
<a href="{{article.share_post['mastodon']}}" title="Share on Mastodon">Mastodon</a>
|
||||||
❄
|
❄
|
||||||
<a href="{{article.share_post['reddit']}}" title="Share via Reddit">Reddit</a>
|
<a href="{{article.share_post['reddit']}}" title="Share via Reddit">Reddit</a>
|
||||||
|
❄
|
||||||
|
<a href="{{article.share_post['twitter']}}" title="Share on Twitter">Twitter</a>
|
||||||
|
❄
|
||||||
|
<a href="{{article.share_post['bluesky']}}" title="Share on Bluesky">Bluesky</a>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -77,7 +86,8 @@ Contributors
|
||||||
* [Talha Mansoor](https://www.oncrashreboot.com) - talha131@gmail.com
|
* [Talha Mansoor](https://www.oncrashreboot.com) - talha131@gmail.com
|
||||||
* [Jonathan DEKHTIAR](https://github.com/DEKHTIARJonathan) - contact@jonathandekhtiar.eu
|
* [Jonathan DEKHTIAR](https://github.com/DEKHTIARJonathan) - contact@jonathandekhtiar.eu
|
||||||
* [Justin Mayer](https://justinmayer.com)
|
* [Justin Mayer](https://justinmayer.com)
|
||||||
* [Leonardo Giordani](https://www.thedigitalcatonline.com)
|
* [Leonardo Giordani](https://github.com/lgiordani)
|
||||||
|
* [Maurizio Paglia](https://github.com/mpaglia0)
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
from .share_post import * # noqa
|
from .share_post import * # noqa: F403,PGH004,RUF100
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""Share Post plugin for Pelican.
|
||||||
Share Post
|
|
||||||
==========
|
|
||||||
|
|
||||||
This plugin was originally created by
|
This plugin was originally created by
|
||||||
Talha Mansoor <talha131@gmail.com>
|
Talha Mansoor <talha131@gmail.com>
|
||||||
|
|
@ -21,6 +19,8 @@ from pelican.generators import ArticlesGenerator, PagesGenerator
|
||||||
|
|
||||||
_create_link_functions = []
|
_create_link_functions = []
|
||||||
|
|
||||||
|
newline = "%0D%0A"
|
||||||
|
|
||||||
|
|
||||||
# Use this decorator to mark a function as
|
# Use this decorator to mark a function as
|
||||||
# a link creator. The function's prototype shall be
|
# a link creator. The function's prototype shall be
|
||||||
|
|
@ -55,6 +55,17 @@ def create_link_facebook(title, url, content):
|
||||||
return f"https://www.facebook.com/sharer/sharer.php?u={url}"
|
return f"https://www.facebook.com/sharer/sharer.php?u={url}"
|
||||||
|
|
||||||
|
|
||||||
|
@create_link
|
||||||
|
def create_link_mastodon(title, url, content):
|
||||||
|
hashtags = ""
|
||||||
|
|
||||||
|
if hasattr(content, "tags"):
|
||||||
|
new_taglist = [f"%23{str(i).replace(' ', '')}" for i in content.tags]
|
||||||
|
hashtags = " ".join(new_taglist)
|
||||||
|
|
||||||
|
return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}"
|
||||||
|
|
||||||
|
|
||||||
@create_link
|
@create_link
|
||||||
def create_link_twitter(title, url, content):
|
def create_link_twitter(title, url, content):
|
||||||
twitter_username = content.settings.get("TWITTER_USERNAME", "")
|
twitter_username = content.settings.get("TWITTER_USERNAME", "")
|
||||||
|
|
@ -85,6 +96,12 @@ def create_link_linkedin(title, url, content):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@create_link
|
||||||
|
def create_link_bluesky(title, url, content):
|
||||||
|
# https://docs.bsky.app/docs/advanced-guides/intent-links
|
||||||
|
return f"https://bsky.app/intent/compose?text={title}%20{url}"
|
||||||
|
|
||||||
|
|
||||||
def create_share_links(content):
|
def create_share_links(content):
|
||||||
if isinstance(content, contents.Static):
|
if isinstance(content, contents.Static):
|
||||||
return
|
return
|
||||||
|
|
@ -98,10 +115,10 @@ def create_share_links(content):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
sub_title = ""
|
sub_title = ""
|
||||||
|
|
||||||
title = quote(f"{main_title}{sub_title}".encode("utf-8"))
|
title = quote(f"{main_title}{sub_title}".encode())
|
||||||
|
|
||||||
site_url = content.settings["SITEURL"]
|
site_url = content.settings["SITEURL"]
|
||||||
url = quote(f"{site_url}/{content.url}".encode("utf-8"))
|
url = quote(f"{site_url}/{content.url}".encode())
|
||||||
|
|
||||||
content.share_post = {}
|
content.share_post = {}
|
||||||
for func in _create_link_functions:
|
for func in _create_link_functions:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from share_post import run_plugin
|
|
||||||
|
|
||||||
from pelican.generators import ArticlesGenerator
|
from pelican.generators import ArticlesGenerator
|
||||||
from pelican.tests.support import get_context, get_settings
|
from pelican.tests.support import get_context, get_settings
|
||||||
|
|
||||||
|
|
@ -26,7 +24,7 @@ def test_share_post(tmp_folder):
|
||||||
)
|
)
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
|
|
||||||
run_plugin([generator])
|
share_post.run_plugin([generator])
|
||||||
|
|
||||||
share_links = generator.articles[0].share_post
|
share_links = generator.articles[0].share_post
|
||||||
|
|
||||||
|
|
@ -63,3 +61,8 @@ def test_share_post(tmp_folder):
|
||||||
share_links["reddit"]
|
share_links["reddit"]
|
||||||
== "https://www.reddit.com/submit?url=/test-post.html&title=Test%20post"
|
== "https://www.reddit.com/submit?url=/test-post.html&title=Test%20post"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
share_links["bluesky"]
|
||||||
|
== "https://bsky.app/intent/compose?text=Test%20post%20/test-post.html"
|
||||||
|
)
|
||||||
|
|
|
||||||
124
pyproject.toml
124
pyproject.toml
|
|
@ -1,73 +1,109 @@
|
||||||
[tool.poetry]
|
[project]
|
||||||
name = "pelican-share-post"
|
name = "pelican-share-post"
|
||||||
version = "1.0.0"
|
version = "1.2.1"
|
||||||
description = "A Pelican plugin to create share URLs of article"
|
description = "A Pelican plugin to create share URLs of article"
|
||||||
authors = ["Talha Mansoor <talha131@gmail.com>"]
|
authors = [{name = "Talha Mansoor", email = "talha131@gmail.com"}, {name = "Justin Mayer", email = "entroP@gmail.com"}]
|
||||||
license = "MIT"
|
license = {text = "MIT"}
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["pelican", "plugin", "social"]
|
keywords = ["pelican", "plugin", "social"]
|
||||||
repository = "https://github.com/pelican-plugins/share-post"
|
|
||||||
documentation = "https://docs.getpelican.com"
|
|
||||||
packages = [
|
|
||||||
{ include = "pelican" },
|
|
||||||
]
|
|
||||||
|
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
"Framework :: Pelican",
|
"Framework :: Pelican",
|
||||||
"Framework :: Pelican :: Plugins",
|
"Framework :: Pelican :: Plugins",
|
||||||
"Intended Audience :: End Users/Desktop",
|
"Intended Audience :: End Users/Desktop",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
"Topic :: Internet :: WWW/HTTP",
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
]
|
]
|
||||||
|
requires-python = ">=3.8.1,<4.0"
|
||||||
|
dependencies = [
|
||||||
|
"pelican>=4.5",
|
||||||
|
"beautifulsoup4>=4.9.3",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.poetry.urls]
|
[project.urls]
|
||||||
"Funding" = "https://donate.getpelican.com/"
|
Homepage = "https://github.com/pelican-plugins/share-post"
|
||||||
"Issue Tracker" = "https://github.com/pelican-plugins/share-post/issues"
|
"Issue Tracker" = "https://github.com/pelican-plugins/share-post/issues"
|
||||||
|
Funding = "https://donate.getpelican.com/"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[project.optional-dependencies]
|
||||||
python = "^3.6"
|
markdown = ["markdown>=3.4"]
|
||||||
pelican = "^4.5"
|
|
||||||
markdown = {version = "^3.2.2", optional = true}
|
|
||||||
beautifulsoup4 = "^4.9.3"
|
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.pdm]
|
||||||
black = {version = "^19.10b0", allow-prereleases = true}
|
|
||||||
flake8 = "^3.9"
|
|
||||||
flake8-black = "^0.2.0"
|
|
||||||
invoke = "^1.3"
|
|
||||||
isort = "^5.4"
|
|
||||||
livereload = "^2.6"
|
|
||||||
markdown = "^3.2.2"
|
|
||||||
pytest = "^6.0"
|
|
||||||
pytest-cov = "^2.8"
|
|
||||||
pytest-pythonpath = "^0.7.3"
|
|
||||||
pytest-sugar = "^0.9.4"
|
|
||||||
Werkzeug = "^1.0"
|
|
||||||
|
|
||||||
[tool.poetry.extras]
|
[tool.pdm.dev-dependencies]
|
||||||
markdown = ["markdown"]
|
lint = [
|
||||||
|
"invoke>=2.2",
|
||||||
|
"ruff>=0.5.0,<0.6.0"
|
||||||
|
]
|
||||||
|
test = [
|
||||||
|
"markdown>=3.4",
|
||||||
|
"pytest>=7.0",
|
||||||
|
"pytest-cov>=4.0",
|
||||||
|
"pytest-sugar>=1.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.pdm.build]
|
||||||
|
source-includes = [
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
]
|
||||||
|
includes = ["pelican/"]
|
||||||
|
excludes = ["**/.DS_Store", "**/test_data/**", "tasks.py"]
|
||||||
|
|
||||||
[tool.autopub]
|
[tool.autopub]
|
||||||
project-name = "Share Post"
|
project-name = "Share Post"
|
||||||
git-username = "botpub"
|
git-username = "botpub"
|
||||||
git-email = "botpub@autopub.rocks"
|
git-email = "52496925+botpub@users.noreply.github.com"
|
||||||
append-github-contributor = true
|
append-github-contributor = true
|
||||||
|
|
||||||
[tool.isort]
|
[tool.ruff.lint]
|
||||||
# Maintain compatibility with Black
|
select = [
|
||||||
profile = "black"
|
"B", # flake8-bugbear
|
||||||
multi_line_output = 3
|
"BLE", # flake8-blind-except
|
||||||
|
"C4", # flake8-comprehensions
|
||||||
|
"D", # pydocstyle
|
||||||
|
"E", # pycodestyle
|
||||||
|
"F", # pyflakes
|
||||||
|
"I", # isort
|
||||||
|
"ICN", # flake8-import-conventions
|
||||||
|
"ISC", # flake8-implicit-str-concat
|
||||||
|
"PGH", # pygrep-hooks
|
||||||
|
"PL", # pylint
|
||||||
|
"RET", # flake8-return
|
||||||
|
"RUF", # ruff-specific rules
|
||||||
|
"SIM", # flake8-simplify
|
||||||
|
"T10", # flake8-debugger
|
||||||
|
"T20", # flake8-print
|
||||||
|
"TID", # flake8-tidy-imports
|
||||||
|
"TRY", # tryceratops
|
||||||
|
"UP", # pyupgrade
|
||||||
|
"W", # pycodestyle
|
||||||
|
"YTT", # flake8-2020
|
||||||
|
]
|
||||||
|
|
||||||
# Sort imports within their section independent of the import type
|
ignore = [
|
||||||
force_sort_within_sections = true
|
"D100", # missing docstring in public module
|
||||||
|
"D103", # missing docstring in public method
|
||||||
|
"D104", # missing docstring in public package
|
||||||
|
"D203", # blank line before class docstring
|
||||||
|
"D213", # multi-line docstring summary should start at the second line
|
||||||
|
"ISC001", # disabled so `ruff format` works without warning
|
||||||
|
]
|
||||||
|
|
||||||
# Designate "pelican" as separate import section
|
[tool.ruff.lint.isort]
|
||||||
known_pelican = "pelican"
|
combine-as-imports = true
|
||||||
sections = "FUTURE,STDLIB,THIRDPARTY,PELICAN,FIRSTPARTY,LOCALFOLDER"
|
force-sort-within-sections = true
|
||||||
|
known-first-party = ["pelican"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["pdm-backend"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "pdm.backend"
|
||||||
|
|
|
||||||
84
tasks.py
84
tasks.py
|
|
@ -1,79 +1,101 @@
|
||||||
|
from inspect import cleandoc
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import which
|
from shutil import which
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
PKG_NAME = "share_post"
|
PKG_NAME = "share_post"
|
||||||
PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}")
|
PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}")
|
||||||
|
|
||||||
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
||||||
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/.local/share/virtualenvs"))
|
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/.local/share/virtualenvs"))
|
||||||
VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME / PKG_NAME)
|
VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME.expanduser() / PKG_NAME)
|
||||||
VENV = str(VENV_PATH.expanduser())
|
VENV = str(VENV_PATH.expanduser())
|
||||||
|
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
|
||||||
|
VENV_BIN = Path(VENV) / Path(BIN_DIR)
|
||||||
|
|
||||||
TOOLS = ["poetry", "pre-commit"]
|
TOOLS = ("pdm", "pre-commit")
|
||||||
POETRY = which("poetry") if which("poetry") else (VENV / Path("bin") / "poetry")
|
PDM = which("pdm") if which("pdm") else (VENV_BIN / "pdm")
|
||||||
PRECOMMIT = (
|
CMD_PREFIX = f"{VENV_BIN}/" if ACTIVE_VENV else f"{PDM} run "
|
||||||
which("pre-commit") if which("pre-commit") else (VENV / Path("bin") / "pre-commit")
|
PRECOMMIT = which("pre-commit") if which("pre-commit") else f"{CMD_PREFIX}pre-commit"
|
||||||
)
|
PTY = os.name != "nt"
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def tests(c):
|
def tests(c, deprecations=False):
|
||||||
"""Run the test suite"""
|
"""Run the test suite, optionally with `--deprecations`."""
|
||||||
c.run(f"{VENV}/bin/pytest", pty=True)
|
deprecations_flag = "" if deprecations else "-W ignore::DeprecationWarning"
|
||||||
|
c.run(f"{CMD_PREFIX}pytest {deprecations_flag}", pty=PTY)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def black(c, check=False, diff=False):
|
def format(c, check=False, diff=False):
|
||||||
"""Run Black auto-formatter, optionally with --check or --diff"""
|
"""Run Ruff's auto-formatter, optionally with `--check` or `--diff`."""
|
||||||
check_flag, diff_flag = "", ""
|
check_flag, diff_flag = "", ""
|
||||||
if check:
|
if check:
|
||||||
check_flag = "--check"
|
check_flag = "--check"
|
||||||
if diff:
|
if diff:
|
||||||
diff_flag = "--diff"
|
diff_flag = "--diff"
|
||||||
c.run(f"{VENV}/bin/black {check_flag} {diff_flag} {PKG_PATH} tasks.py")
|
c.run(
|
||||||
|
f"{CMD_PREFIX}ruff format {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def isort(c, check=False, diff=False):
|
def ruff(c, fix=False, diff=False):
|
||||||
check_flag, diff_flag = "", ""
|
"""Run Ruff to ensure code meets project standards."""
|
||||||
if check:
|
diff_flag, fix_flag = "", ""
|
||||||
check_flag = "-c"
|
if fix:
|
||||||
|
fix_flag = "--fix"
|
||||||
if diff:
|
if diff:
|
||||||
diff_flag = "--diff"
|
diff_flag = "--diff"
|
||||||
c.run(f"{VENV}/bin/isort {check_flag} {diff_flag} .")
|
c.run(f"{CMD_PREFIX}ruff check {diff_flag} {fix_flag} .", pty=PTY)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def flake8(c):
|
def lint(c, fix=False, diff=False):
|
||||||
c.run(f"{VENV}/bin/flake8 {PKG_PATH} tasks.py")
|
"""Check code style via linting tools."""
|
||||||
|
ruff(c, fix=fix, diff=diff)
|
||||||
|
format(c, check=(not fix), diff=diff)
|
||||||
@task
|
|
||||||
def lint(c):
|
|
||||||
isort(c, check=True)
|
|
||||||
black(c, check=True)
|
|
||||||
flake8(c)
|
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def tools(c):
|
def tools(c):
|
||||||
"""Install tools in the virtual environment if not already on PATH"""
|
"""Install development tools in the virtual environment if not already on PATH."""
|
||||||
for tool in TOOLS:
|
for tool in TOOLS:
|
||||||
if not which(tool):
|
if not which(tool):
|
||||||
c.run(f"{VENV}/bin/pip install {tool}")
|
logger.info(f"** Installing {tool} **")
|
||||||
|
c.run(f"{CMD_PREFIX}pip install {tool}")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def precommit(c):
|
def precommit(c):
|
||||||
"""Install pre-commit hooks to .git/hooks/pre-commit"""
|
"""Install pre-commit hooks to .git/hooks/pre-commit."""
|
||||||
|
logger.info("** Installing pre-commit hooks **")
|
||||||
c.run(f"{PRECOMMIT} install")
|
c.run(f"{PRECOMMIT} install")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def setup(c):
|
def setup(c):
|
||||||
c.run(f"{VENV}/bin/pip install -U pip")
|
"""Set up the development environment."""
|
||||||
|
if which("pdm") or ACTIVE_VENV:
|
||||||
tools(c)
|
tools(c)
|
||||||
c.run(f"{POETRY} install")
|
c.run(f"{CMD_PREFIX}python -m pip install --upgrade pip", pty=PTY)
|
||||||
|
c.run(f"{PDM} update --dev", pty=PTY)
|
||||||
precommit(c)
|
precommit(c)
|
||||||
|
logger.info("\nDevelopment environment should now be set up and ready!\n")
|
||||||
|
else:
|
||||||
|
error_message = """
|
||||||
|
PDM is not installed, and there is no active virtual environment available.
|
||||||
|
You can either manually create and activate a virtual environment, or you can
|
||||||
|
install PDM via:
|
||||||
|
|
||||||
|
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
|
||||||
|
|
||||||
|
Once you have taken one of the above two steps, run `invoke setup` again.
|
||||||
|
""" # noqa: E501
|
||||||
|
raise SystemExit(cleandoc(error_message))
|
||||||
|
|
|
||||||
3
tox.ini
3
tox.ini
|
|
@ -1,3 +0,0 @@
|
||||||
[flake8]
|
|
||||||
max-line-length = 88
|
|
||||||
ignore = E203, W503
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue