goatseo-flask 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- goatseo_flask-0.1.0/LICENSE +21 -0
- goatseo_flask-0.1.0/PKG-INFO +40 -0
- goatseo_flask-0.1.0/README.md +15 -0
- goatseo_flask-0.1.0/pyproject.toml +49 -0
- goatseo_flask-0.1.0/pyproject.toml.orig +39 -0
- goatseo_flask-0.1.0/src/goatseo/flask/__init__.py +5 -0
- goatseo_flask-0.1.0/src/goatseo/flask/extension.py +64 -0
- goatseo_flask-0.1.0/src/goatseo/flask/py.typed +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Louis Midson LAJEANTY <midsonlajeanty@proton.me>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: goatseo-flask
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Flask integration for GoatSEO.
|
|
5
|
+
Keywords: seo,schema.org,json-ld,opengraph,twitter-cards,metadata
|
|
6
|
+
Author: Louis Midson LAJEANTY
|
|
7
|
+
Author-email: Louis Midson LAJEANTY <midsonlajeanty@proton.me>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Framework :: Flask
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Dist: goatseo-seo==0.1.0
|
|
19
|
+
Requires-Dist: flask>=3.1
|
|
20
|
+
Requires-Python: >=3.14
|
|
21
|
+
Project-URL: Homepage, https://github.com/goatlabshq/goatseo
|
|
22
|
+
Project-URL: Documentation, https://goatlabshq.github.io/goatseo/
|
|
23
|
+
Project-URL: Issues, https://github.com/goatlabshq/goatseo/issues
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# goatseo-flask
|
|
27
|
+
|
|
28
|
+
Flask integration for GoatSEO: the `SEOExtension`, request-scoped state through `get_seo()` and a `goatseo_head()` Jinja global.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install "goatseo[flask]"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from goatseo.flask import SEOExtension, get_seo
|
|
36
|
+
|
|
37
|
+
SEOExtension(app)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Part of [GoatSEO](https://github.com/goatlabshq/goatseo). See the [documentation](https://goatlabshq.github.io/goatseo/).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# goatseo-flask
|
|
2
|
+
|
|
3
|
+
Flask integration for GoatSEO: the `SEOExtension`, request-scoped state through `get_seo()` and a `goatseo_head()` Jinja global.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install "goatseo[flask]"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from goatseo.flask import SEOExtension, get_seo
|
|
11
|
+
|
|
12
|
+
SEOExtension(app)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Part of [GoatSEO](https://github.com/goatlabshq/goatseo). See the [documentation](https://goatlabshq.github.io/goatseo/).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "goatseo-flask"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Flask integration for GoatSEO."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.14"
|
|
9
|
+
keywords = [
|
|
10
|
+
"seo",
|
|
11
|
+
"schema.org",
|
|
12
|
+
"json-ld",
|
|
13
|
+
"opengraph",
|
|
14
|
+
"twitter-cards",
|
|
15
|
+
"metadata",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Framework :: Flask",
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"goatseo-seo==0.1.0",
|
|
29
|
+
"flask>=3.1",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[[project.authors]]
|
|
33
|
+
name = "Louis Midson LAJEANTY"
|
|
34
|
+
email = "midsonlajeanty@proton.me"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/goatlabshq/goatseo"
|
|
38
|
+
Documentation = "https://goatlabshq.github.io/goatseo/"
|
|
39
|
+
Issues = "https://github.com/goatlabshq/goatseo/issues"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["uv_build>=0.12,<0.13"]
|
|
43
|
+
build-backend = "uv_build"
|
|
44
|
+
|
|
45
|
+
[tool.uv.build-backend]
|
|
46
|
+
module-name = "goatseo.flask"
|
|
47
|
+
|
|
48
|
+
[tool.uv.sources.goatseo-seo]
|
|
49
|
+
workspace = true
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "goatseo-flask"
|
|
3
|
+
version = "0.1.0" # x-release-please-version
|
|
4
|
+
description = "Flask integration for GoatSEO."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Louis Midson LAJEANTY", email = "midsonlajeanty@proton.me" }]
|
|
9
|
+
requires-python = ">=3.14"
|
|
10
|
+
keywords = ["seo", "schema.org", "json-ld", "opengraph", "twitter-cards", "metadata"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Framework :: Flask",
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
18
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
19
|
+
"Typing :: Typed",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"goatseo-seo==0.1.0", # x-release-please-version
|
|
23
|
+
"flask>=3.1",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/goatlabshq/goatseo"
|
|
28
|
+
Documentation = "https://goatlabshq.github.io/goatseo/"
|
|
29
|
+
Issues = "https://github.com/goatlabshq/goatseo/issues"
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["uv_build>=0.12,<0.13"]
|
|
33
|
+
build-backend = "uv_build"
|
|
34
|
+
|
|
35
|
+
[tool.uv.build-backend]
|
|
36
|
+
module-name = "goatseo.flask"
|
|
37
|
+
|
|
38
|
+
[tool.uv.sources]
|
|
39
|
+
goatseo-seo = { workspace = true }
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Flask extension: request-scoped SEO state and a ``goatseo_head()`` Jinja global."""
|
|
2
|
+
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
from flask import Flask, Response, current_app, g, request
|
|
6
|
+
from goatseo.core import Metadata, SafeHtml, StaticRequestContext
|
|
7
|
+
from goatseo.seo import SEO
|
|
8
|
+
|
|
9
|
+
EXTENSION_KEY: Final = "goatseo"
|
|
10
|
+
_STATE_KEY: Final = "_goatseo_seo"
|
|
11
|
+
ROBOTS_HEADER: Final = "X-Robots-Tag"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SEOExtension:
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
app: Flask | None = None,
|
|
18
|
+
*,
|
|
19
|
+
defaults: Metadata | None = None,
|
|
20
|
+
robots_header: bool = False,
|
|
21
|
+
) -> None:
|
|
22
|
+
self.defaults = defaults
|
|
23
|
+
self.robots_header = robots_header
|
|
24
|
+
if app is not None:
|
|
25
|
+
self.init_app(app)
|
|
26
|
+
|
|
27
|
+
def init_app(self, app: Flask) -> None:
|
|
28
|
+
app.extensions[EXTENSION_KEY] = self
|
|
29
|
+
app.add_template_global(goatseo_head, "goatseo_head")
|
|
30
|
+
app.context_processor(_inject_seo)
|
|
31
|
+
if self.robots_header:
|
|
32
|
+
app.after_request(_robots_header)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _extension() -> SEOExtension:
|
|
36
|
+
extension: object = current_app.extensions.get(EXTENSION_KEY)
|
|
37
|
+
if not isinstance(extension, SEOExtension):
|
|
38
|
+
raise RuntimeError("SEOExtension is not initialized on the current Flask app")
|
|
39
|
+
return extension
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_seo() -> SEO:
|
|
43
|
+
"""Returns the SEO object of the current request, created from the defaults on first use."""
|
|
44
|
+
seo: object = g.get(_STATE_KEY)
|
|
45
|
+
if not isinstance(seo, SEO):
|
|
46
|
+
seo = SEO(defaults=_extension().defaults)
|
|
47
|
+
setattr(g, _STATE_KEY, seo)
|
|
48
|
+
return seo
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def goatseo_head() -> SafeHtml:
|
|
52
|
+
return get_seo().render(StaticRequestContext(request.url))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _inject_seo() -> dict[str, SEO]:
|
|
56
|
+
return {"seo": get_seo()}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _robots_header(response: Response) -> Response:
|
|
60
|
+
seo: object = g.get(_STATE_KEY)
|
|
61
|
+
robots = seo.metadata.robots if isinstance(seo, SEO) else None
|
|
62
|
+
if robots is not None and (directives := robots.directives()):
|
|
63
|
+
response.headers.setdefault(ROBOTS_HEADER, ", ".join(directives))
|
|
64
|
+
return response
|
|
File without changes
|