Compare commits

...

11 Commits

Author SHA1 Message Date
Luciano Ramalho
cf3161ca00 moved URL shortening code to https://github.com/pythonfluente/pythonfluente2e 2025-06-04 18:54:30 -03:00
Luciano Ramalho
8c8c08170a Merge pull request #57 from fluentpython/dependabot/pip/21-async/mojifinder/h11-0.16.0
build(deps): bump h11 from 0.12.0 to 0.16.0 in /21-async/mojifinder
2025-05-23 16:36:15 -03:00
Luciano Ramalho
162dbadbe5 links from vol1 to pythonfluente.com 2025-05-23 16:35:01 -03:00
Luciano Ramalho
cf99650007 minor refactoring to make it easier to call shorten() 2025-05-22 14:28:42 -03:00
Luciano Ramalho
ec03da74ca short.py appends timestamps to short.htaccesss 2025-05-22 13:44:46 -03:00
Luciano Ramalho
5b743b5bd7 short.py now reads files and stdin 2025-05-22 13:24:50 -03:00
Luciano Ramalho
648e9f6394 Update short.py to return list of URL substitutions 2025-05-22 10:05:54 -03:00
Luciano Ramalho
cc4e26c67a Remove redundant if from short.py 2025-05-22 02:18:34 -03:00
dependabot[bot]
c5490b1569 build(deps): bump h11 from 0.12.0 to 0.16.0 in /21-async/mojifinder
Bumps [h11](https://github.com/python-hyper/h11) from 0.12.0 to 0.16.0.
- [Commits](https://github.com/python-hyper/h11/compare/v0.12.0...v0.16.0)

---
updated-dependencies:
- dependency-name: h11
  dependency-version: 0.16.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-22 04:13:41 +00:00
Luciano Ramalho
3d5588b75e gerador de URLs curtas 2025-05-22 01:11:34 -03:00
Luciano Ramalho
1bd4b1e7be documentando FPY.LI.htacess 2025-05-21 12:00:57 -03:00
6 changed files with 26 additions and 157 deletions

View File

@@ -1,6 +1,6 @@
click==7.1.2 click==7.1.2
fastapi==0.65.2 fastapi==0.65.2
h11==0.12.0 h11==0.16.0
pydantic==1.10.13 pydantic==1.10.13
starlette==0.40.0 starlette==0.40.0
typing-extensions==3.7.4.3 typing-extensions==3.7.4.3

View File

@@ -1,3 +1,6 @@
# to recreate or update this file:
# $ cat custom.htaccess short.htaccess > FPY.LI.htaccess
ErrorDocument 404 /404.html ErrorDocument 404 /404.html
# main resources # main resources
@@ -1070,3 +1073,17 @@ RedirectTemp /24-27 https://docs.python.org/3/library/functools.html#functools.t
RedirectTemp /24-28 https://www.python.org/download/releases/2.2.3/descrintro/ RedirectTemp /24-28 https://www.python.org/download/releases/2.2.3/descrintro/
RedirectTemp /24-29 https://github.com/lihaoyi/macropy RedirectTemp /24-29 https://github.com/lihaoyi/macropy
RedirectTemp /24-30 https://people.eecs.berkeley.edu/~bh/ss-toc2.html RedirectTemp /24-30 https://people.eecs.berkeley.edu/~bh/ss-toc2.html
# content of short.htaccess file created and managed by short.py
# appended: 2025-05-23 15:12:13
RedirectTemp /22 https://pythonfluente.com/2/#pattern_matching_case_study_sec
RedirectTemp /23 https://pythonfluente.com/2/#how_slicing_works
RedirectTemp /24 https://pythonfluente.com/2/#sliceable_sequence
RedirectTemp /25 https://pythonfluente.com/2/#virtual_subclass_sec
RedirectTemp /26 https://pythonfluente.com/2/#environment_class_ex
RedirectTemp /27 https://pythonfluente.com/2/#subclass_builtin_woes
RedirectTemp /28 https://pythonfluente.com/2/#slots_section
RedirectTemp /29 https://pythonfluente.com/2/#typeddict_sec
RedirectTemp /2a https://pythonfluente.com/2/#problems_annot_runtime_sec
RedirectTemp /2b https://pythonfluente.com/2/#legacy_deprecated_typing_box
RedirectTemp /2c https://pythonfluente.com/2/#positional_pattern_implement_sec

View File

@@ -1,40 +1,6 @@
# Short links for URLs in the book This file is deployed as `.htaccess` to the FPY.LI domain
to map short URLs in Fluent Python to the original URLs.
## Problem: link rot To update it, I use tools in this other repo:
_Fluent Python, Second Edition_ has more than 1000 links to external resources. https://github.com/pythonfluente/pythonfluente2e
Inevitably, some of those links will rot as time passes.
But I can't change the URLs in the print book...
## Solution: indirection
I replaced almost all URLs in the book with shortened versions that go through the `fpy.li` site which I control.
The site has an `.htaccess` file with *temporary* redirects.
When I find out a link is stale, I can thange the redirect in `.htaccess` to a new target,
which may be a link to copy in the Internet Archive's
[Wayback Machine](https://archive.org/web/)
o the link in the book is back in service through the updated redirect.
## Help wanted
Please report broken links as bugs in the [`FPY.LI.htaccess`](FPY.LI.htaccess) file.
Also, feel free to send pull requests with fixes to that file.
When I accept a PR, I will redeploy it to `fpy.li/.htaccess`.
## Details
Almost all URLs in the book are replaced with shortened versions like
[`http://fpy.li/1-3`](http://fpy.li/1-3)—for chapter 1, link #3.
There are also custom short URLs like
[`https://fpy.li/code`](https://fpy.li/code) which redirects to the example code repository.
I used custom short URLs for URLs with 3 or more mentions, or links to PEPs.
Exceptions:
- URLs with `oreilly` in them are unchanged;
- `fluentpython.com` URL (with no path) is unchanged;
The `FPY.LI.htaccess` is deployed at the root folder in `http://fpy.li`.

View File

@@ -1,116 +0,0 @@
ErrorDocument 404 /404.html
# main resources
RedirectTemp /book https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/
RedirectTemp /code https://github.com/fluentpython/example-code-2e
RedirectTemp /home https://www.fluentpython.com/
# URLs mentioned at least three times
RedirectTemp /bisect https://www.fluentpython.com/extra/ordered-sequences-with-bisect/
RedirectTemp /cardxvi https://www.python.org/dev/peps/pep-0484/#the-numeric-tower
RedirectTemp /collec https://docs.python.org/3/library/collections.html
RedirectTemp /dask https://dask.org/
RedirectTemp /dtmodel https://docs.python.org/3/reference/datamodel.html
RedirectTemp /descr101 https://www.python.org/download/releases/2.2.3/descrintro/
RedirectTemp /descrhow https://docs.python.org/3/howto/descriptor.html
RedirectTemp /doctest https://docs.python.org/3/library/doctest.html
RedirectTemp /effectpy https://effectivepython.com/
RedirectTemp /fmtspec https://docs.python.org/3/library/string.html#formatspec
RedirectTemp /gunicorn https://gunicorn.org/
RedirectTemp /hashint https://www.fluentpython.com/extra/internals-of-sets-and-dicts/
RedirectTemp /hattingh https://www.oreilly.com/library/view/using-asyncio-in/9781492075325/
RedirectTemp /httpx https://www.python-httpx.org/
RedirectTemp /initvar https://docs.python.org/3/library/dataclasses.html#init-only-variables
RedirectTemp /mypy https://mypy.readthedocs.io/en/stable/
RedirectTemp /norvigdp http://norvig.com/design-patterns/
RedirectTemp /nsphere https://en.wikipedia.org/wiki/N-sphere
RedirectTemp /oldcoro https://www.fluentpython.com/extra/classic-coroutines/
RedirectTemp /pandas https://pandas.pydata.org/
RedirectTemp /pycook3 https://www.oreilly.com/library/view/python-cookbook-3rd/9781449357337/
RedirectTemp /pynut3 https://www.oreilly.com/library/view/python-in-a/9781491913833/
RedirectTemp /pypydif https://doc.pypy.org/en/latest/cpython_differences.html#subclasses-of-built-in-types
RedirectTemp /shed4051 https://github.com/python/typeshed/issues/4051
RedirectTemp /specattr https://docs.python.org/3/library/stdtypes.html#special-attributes
RedirectTemp /typecoro https://docs.python.org/3.10/library/typing.html#typing.Coroutine
RedirectTemp /typing https://docs.python.org/3/library/typing.html
RedirectTemp /weakref https://www.fluentpython.com/extra/weak-references/
# URL added during QA of the Second Edition
RedirectTemp /bdfl https://www.artima.com/weblogs/viewpost.jsp?thread=235725
# Python Enhancement Proposals
RedirectTemp /pep218 https://www.python.org/dev/peps/pep-0218/
RedirectTemp /pep227 https://www.python.org/dev/peps/pep-0227/
RedirectTemp /pep255 https://www.python.org/dev/peps/pep-0255/
RedirectTemp /pep342 https://www.python.org/dev/peps/pep-0342/
RedirectTemp /pep343 https://www.python.org/dev/peps/pep-0343/
RedirectTemp /pep357 https://www.python.org/dev/peps/pep-0357/
RedirectTemp /pep362 https://www.python.org/dev/peps/pep-0362/
RedirectTemp /pep371 https://www.python.org/dev/peps/pep-0371/
RedirectTemp /pep380 https://www.python.org/dev/peps/pep-0380/
RedirectTemp /pep393 https://www.python.org/dev/peps/pep-0393/
RedirectTemp /pep412 https://www.python.org/dev/peps/pep-0412/
RedirectTemp /pep442 https://www.python.org/dev/peps/pep-0442/
RedirectTemp /pep443 https://www.python.org/dev/peps/pep-0443/
RedirectTemp /pep448 https://www.python.org/dev/peps/pep-0448/
RedirectTemp /pep455 https://www.python.org/dev/peps/pep-0455/
RedirectTemp /pep456 https://www.python.org/dev/peps/pep-0456/
RedirectTemp /pep461 https://www.python.org/dev/peps/pep-0461/
RedirectTemp /pep465 https://www.python.org/dev/peps/pep-0465/
RedirectTemp /pep467 https://www.python.org/dev/peps/pep-0467/
RedirectTemp /pep482 https://www.python.org/dev/peps/pep-0482/
RedirectTemp /pep483 https://www.python.org/dev/peps/pep-0483/
RedirectTemp /pep484 https://www.python.org/dev/peps/pep-0484/
RedirectTemp /pep487 https://www.python.org/dev/peps/pep-0487/
RedirectTemp /pep492 https://www.python.org/dev/peps/pep-0492/
RedirectTemp /pep519 https://www.python.org/dev/peps/pep-0519/
RedirectTemp /pep525 https://www.python.org/dev/peps/pep-0525/
RedirectTemp /pep526 https://www.python.org/dev/peps/pep-0526/
RedirectTemp /pep528 https://www.python.org/dev/peps/pep-0528/
RedirectTemp /pep529 https://www.python.org/dev/peps/pep-0529/
RedirectTemp /pep530 https://www.python.org/dev/peps/pep-0530/
RedirectTemp /pep544 https://www.python.org/dev/peps/pep-0544/
RedirectTemp /pep554 https://www.python.org/dev/peps/pep-0554/
RedirectTemp /pep557 https://www.python.org/dev/peps/pep-0557/
RedirectTemp /pep560 https://www.python.org/dev/peps/pep-0560/
RedirectTemp /pep561 https://www.python.org/dev/peps/pep-0561/
RedirectTemp /pep563 https://www.python.org/dev/peps/pep-0563/
RedirectTemp /pep570 https://www.python.org/dev/peps/pep-0570/
RedirectTemp /pep572 https://www.python.org/dev/peps/pep-0572/
RedirectTemp /pep584 https://www.python.org/dev/peps/pep-0584/
RedirectTemp /pep585 https://www.python.org/dev/peps/pep-0585/
RedirectTemp /pep586 https://www.python.org/dev/peps/pep-0586/
RedirectTemp /pep589 https://www.python.org/dev/peps/pep-0589/
RedirectTemp /pep591 https://www.python.org/dev/peps/pep-0591/
RedirectTemp /pep593 https://www.python.org/dev/peps/pep-0593/
RedirectTemp /pep604 https://www.python.org/dev/peps/pep-0604/
RedirectTemp /pep612 https://www.python.org/dev/peps/pep-0612/
RedirectTemp /pep613 https://www.python.org/dev/peps/pep-0613/
RedirectTemp /pep616 https://www.python.org/dev/peps/pep-0616/
RedirectTemp /pep617 https://www.python.org/dev/peps/pep-0617/
RedirectTemp /pep618 https://www.python.org/dev/peps/pep-0618/
RedirectTemp /pep634 https://www.python.org/dev/peps/pep-0634/
RedirectTemp /pep635 https://www.python.org/dev/peps/pep-0635/
RedirectTemp /pep636 https://www.python.org/dev/peps/pep-0636/
RedirectTemp /pep638 https://www.python.org/dev/peps/pep-0638/
RedirectTemp /pep645 https://www.python.org/dev/peps/pep-0645/
RedirectTemp /pep646 https://www.python.org/dev/peps/pep-0646/
RedirectTemp /pep647 https://www.python.org/dev/peps/pep-0647/
RedirectTemp /pep649 https://www.python.org/dev/peps/pep-0649/
RedirectTemp /pep654 https://www.python.org/dev/peps/pep-0654/
RedirectTemp /pep655 https://www.python.org/dev/peps/pep-0655/
RedirectTemp /pep661 https://www.python.org/dev/peps/pep-0661/
RedirectTemp /pep3099 https://www.python.org/dev/peps/pep-3099/
RedirectTemp /pep3102 https://www.python.org/dev/peps/pep-3102/
RedirectTemp /pep3104 https://www.python.org/dev/peps/pep-3104/
RedirectTemp /pep3106 https://www.python.org/dev/peps/pep-3106/
RedirectTemp /pep3107 https://www.python.org/dev/peps/pep-3107/
RedirectTemp /pep3115 https://www.python.org/dev/peps/pep-3115/
RedirectTemp /pep3118 https://www.python.org/dev/peps/pep-3118/
RedirectTemp /pep3119 https://www.python.org/dev/peps/pep-3119/
RedirectTemp /pep3129 https://www.python.org/dev/peps/pep-3129/
RedirectTemp /pep3132 https://www.python.org/dev/peps/pep-3132/
RedirectTemp /pep3141 https://www.python.org/dev/peps/pep-3141/
RedirectTemp /pep3148 https://www.python.org/dev/peps/pep-3148/
RedirectTemp /pep3155 https://www.python.org/dev/peps/pep-3155/
RedirectTemp /pep3333 https://www.python.org/dev/peps/pep-3333/

View File

@@ -1,2 +0,0 @@
#!/bin/bash
scp FPY.LI.htaccess dh_i4p2ka@fpy.li:~/fpy.li/.htaccess

4
ruff.toml Normal file
View File

@@ -0,0 +1,4 @@
line-length = 100
[format]
# Like Python's repr(), use single quotes for strings.
quote-style = "single"