Skip to content

Commit 0fc1ca8

Browse files
ewdurbindi
andauthored
create a blog (pypi#13231)
* create a blog * developer experience * try to fancy it * Fix blog rendering * Posts should have relative URLs * Fixup fix * Separate link to homepage from blog * Hide site_name from nav * Highlight index in nav * Properly render blog content * Fix typo * Remove author_gh_user * Remove .git volume * Move custom styles * Remove unnecessary volume * Remove test blog post * Add the mkdocs social plugin * Clean up formatting around authors and descriptions * Extend linting to blog * Write an actual blog post! * doin a blerg --------- Co-authored-by: Dustin Ingram <[email protected]>
1 parent d2973f7 commit 0fc1ca8

23 files changed

+1292
-11
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ RUN set -x \
9696
install --no-deps \
9797
-r /tmp/requirements/deploy.txt \
9898
-r /tmp/requirements/main.txt \
99-
$(if [ "$DEVEL" = "yes" ]; then echo '-r /tmp/requirements/tests.txt -r /tmp/requirements/lint.txt -r /tmp/requirements/docs/dev.txt -r /tmp/requirements/docs/user.txt'; fi) \
99+
$(if [ "$DEVEL" = "yes" ]; then echo '-r /tmp/requirements/tests.txt -r /tmp/requirements/lint.txt -r /tmp/requirements/docs/dev.txt -r /tmp/requirements/docs/user.txt -r /tmp/requirements/docs/blog.txt'; fi) \
100100
&& pip check \
101101
&& find /opt/warehouse -name '*.pyc' -delete
102102

@@ -132,7 +132,7 @@ RUN set -x \
132132
&& apt-get update \
133133
&& apt-get install --no-install-recommends -y \
134134
libpq5 libxml2 libxslt1.1 libcurl4 \
135-
$(if [ "$DEVEL" = "yes" ]; then echo 'bash libjpeg62 postgresql-client build-essential libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev'; fi) \
135+
$(if [ "$DEVEL" = "yes" ]; then echo 'bash libjpeg62 postgresql-client build-essential libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev git libcairo2-dev libfreetype6-dev libjpeg-dev libpng-dev libz-dev'; fi) \
136136
&& apt-get clean \
137137
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
138138

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ dev-docs: .state/docker-build-web
7474
user-docs: .state/docker-build-web
7575
docker-compose run --rm web bin/user-docs
7676

77+
blog: .state/docker-build-web
78+
docker-compose run --rm web bin/blog
79+
7780
licenses: .state/docker-build-web
7881
docker compose run --rm web bin/licenses
7982

bin/blog

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Click requires us to ensure we have a well configured environment to run
5+
# our click commands. So we'll set our environment to ensure our locale is
6+
# correct.
7+
export LC_ALL="${ENCODING:-en_US.UTF-8}"
8+
export LANG="${ENCODING:-en_US.UTF-8}"
9+
10+
# Print all the following commands
11+
set -x
12+
13+
mkdocs build -f docs/blog.yml

bin/lint

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ python -m flake8 .
1717
python -m black --check *.py warehouse/ tests/
1818
python -m isort --check *.py warehouse/ tests/
1919
python -m doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path "docs/**/_build/"
20-
python -m curlylint ./warehouse/templates
20+
python -m curlylint ./warehouse/templates ./docs/blog
2121
python -m mypy -p warehouse

bin/rtd-docs

+8
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ if [ "${READTHEDOCS_PROJECT}" = "warehouse" ]; then
1010
make -C docs/dev/ html
1111
mkdir _readthedocs && mv docs/dev/_build/html _readthedocs/html
1212
fi
13+
1314
if [ "${READTHEDOCS_PROJECT}" = "docspypiorg" ]; then
1415
pip install -r requirements/docs/user.txt
1516
asdf reshim
1617
mkdocs build -f mkdocs-user-docs.yml
1718
mkdir _readthedocs && mv docs/user-site _readthedocs/html
1819
fi
20+
21+
if [ "${READTHEDOCS_PROJECT}" = "blogpypiorg" ]; then
22+
pip install -r requirements/docs/blog.txt
23+
asdf reshim
24+
mkdocs build -f docs/blog.yml
25+
mkdir _readthedocs && mv docs/blog-site _readthedocs/html
26+
fi

docker-compose.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ services:
9292
# permissive security context.
9393
- ./dev:/opt/warehouse/src/dev:z
9494
- ./docs:/opt/warehouse/src/docs:z
95-
- ./mkdocs-user-docs.yml:/opt/warehouse/src/mkdocs-user-docs.yml:z
96-
- ./docs/user:/opt/warehouse/src/docs/user:z
9795
- ./warehouse:/opt/warehouse/src/warehouse:z
9896
- ./tests:/opt/warehouse/src/tests:z
9997
- ./htmlcov:/opt/warehouse/src/htmlcov:z
@@ -189,13 +187,21 @@ services:
189187
- "8964:8000"
190188

191189
user-docs:
192-
build:
193-
context: .
194-
args:
195-
DEVEL: "yes"
190+
image: warehouse:docker-compose
196191
command: mkdocs serve -a 0.0.0.0:8000 -f mkdocs-user-docs.yml
197192
volumes:
198193
- ./mkdocs-user-docs.yml:/opt/warehouse/src/mkdocs-user-docs.yml:z
199194
- ./docs/user:/opt/warehouse/src/docs/user:z
200195
ports:
201196
- "10000:8000"
197+
depends_on: [web]
198+
199+
blog:
200+
image: warehouse:docker-compose
201+
command: mkdocs serve -a 0.0.0.0:8000 -f docs/blog.yml
202+
volumes:
203+
- ./docs/blog.yml:/opt/warehouse/src/docs/blog.yml:z
204+
- ./docs/blog:/opt/warehouse/src/docs/blog:z
205+
ports:
206+
- "10001:8000"
207+
depends_on: [web]

docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
user-site
2+
blog-site

docs/blog.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
site_name: The Python Package Index
2+
site_description: The official blog of the Python Package Index
3+
docs_dir: blog
4+
site_dir: blog-site
5+
theme:
6+
name: material
7+
logo: assets/logo.png
8+
favicon: assets/favicon.ico
9+
homepage: https://pypi.org
10+
custom_dir: blog/overrides
11+
markdown_extensions:
12+
- footnotes
13+
extra_css:
14+
- stylesheets/extra.css
15+
plugins:
16+
- social
17+
- blogging:
18+
dirs:
19+
- posts
20+
template: blog/overrides/pypi-blog.html
21+
features:
22+
tags:
23+
index_page: tags.md
24+
insert: top
25+
locale: en # The locale for time localizations, default: system's locale
26+
time_format: '%Y-%m-%d %H:%M:%S' # The format used to display the time
27+
meta_time_format: '%Y-%m-%d %H:%M:%S' # The format used to parse the time from meta
28+
extra:
29+
homepage: https://pypi.org
30+
social:
31+
- icon: fontawesome/brands/github
32+
link: https://github.com/pypi
33+
- icon: fontawesome/brands/twitter
34+
link: https://twitter.com/pypi
35+
site_url: https://blog.pypi.org/
36+
repo_url: https://github.com/pypi/warehouse

docs/blog/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# PyPI Blog
2+
3+
This blog is hosted at https://blog.pypi.org/ to provide a way for the PyPI
4+
Administrators to share new features, breaking changes, and curiosities with
5+
the community.
6+
7+
Posts are written in [Markdown](https://www.markdownguide.org) and built using
8+
[mkdocs](https://www.mkdocs.org).
9+
10+
The blog is built and deployed with [readthedocs.org](https://readthedocs.org/projects/blogpypiorg/).
11+
12+
See our [`.readthedocs.yml`](../.readthedocs.yml) for configuration.
13+
14+
## Setup
15+
16+
After following the [installation instructions](https://warehouse.pypa.io/development/getting-started.html#detailed-installation-instructions)
17+
all the remaining commands take place in containers.
18+
19+
The project can be previewed by running `docker compose up blog` from the
20+
base directory of your clone of pypa/warehouse. This will start a `mkdocs`
21+
development server that will live reload as you change the contents of this
22+
directory, including the `mkdocs.yml` configuration.

docs/blog/assets/favicon.ico

3.93 KB
Binary file not shown.

docs/blog/assets/logo.png

5.39 KB
Loading

docs/blog/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
exclude_from_blog: true
3+
---
4+
5+
# The PyPI Blog
6+
7+
{{ blog_content }}
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!--
2+
Copyright (c) 2016-2023 Martin Donath <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Tags -->
24+
{% if "material/tags" in config.plugins %}
25+
{% include "partials/tags.html" %}
26+
{% endif %}
27+
28+
<!-- Actions -->
29+
{% include "partials/actions.html" %}
30+
31+
<!--
32+
Hack: check whether the content contains a h1 headline. If it doesn't, the
33+
page title (or respectively site name) is used as the main headline.
34+
-->
35+
{% if "\x3ch1" not in page.content %}
36+
<h1>{{ page.title | d(config.site_name, true)}}</h1>
37+
{% endif %}
38+
39+
{% if "author" in page.meta %}
40+
by: <b>{{ page.meta["author"] + " · " if "publish_date" in page.meta else "" }}</b>
41+
{% endif %}
42+
{% if "publish_date" in page.meta %}
43+
<span>{{ page.meta["publish_date"] }}</span>
44+
{% endif %}
45+
46+
<!-- Page content -->
47+
{{ page.content }}
48+
49+
<!-- Source file information -->
50+
{% if page.meta and (
51+
page.meta.git_revision_date_localized or
52+
page.meta.revision_date
53+
) %}
54+
{% include "partials/source-file.html" %}
55+
{% endif %}
56+
57+
<!-- Was this page helpful? -->
58+
{% include "partials/feedback.html" %}
59+
60+
<!-- Comment system -->
61+
{% include "partials/comments.html" %}

0 commit comments

Comments
 (0)