platzky 0.2.7__tar.gz → 0.2.9__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.
- {platzky-0.2.7 → platzky-0.2.9}/PKG-INFO +1 -1
- {platzky-0.2.7 → platzky-0.2.9}/platzky/platzky.py +3 -1
- {platzky-0.2.7 → platzky-0.2.9}/platzky/seo/seo.py +22 -22
- {platzky-0.2.7 → platzky-0.2.9}/pyproject.toml +1 -1
- {platzky-0.2.7 → platzky-0.2.9}/README.md +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/__init__.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/blog/__init__.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/blog/blog.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/blog/comment_form.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/config.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/__init__.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/db.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/db_loader.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/google_json_db.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/graph_ql_db.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/json_db.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/db/json_file_db.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/models.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/plugin_loader.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/plugins/google-tag-manager/entrypoint.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/plugins/redirections/entrypoint.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/plugins/sendmail/entrypoint.py +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/static/blog.css +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/404.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/base.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/blog.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/body_meta.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/feed.xml +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/head_meta.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/home.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/page.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/post.html +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/robots.txt +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/templates/sitemap.xml +0 -0
- {platzky-0.2.7 → platzky-0.2.9}/platzky/www_handler.py +0 -0
|
@@ -130,7 +130,9 @@ def create_app_from_config(config: Config) -> Engine:
|
|
|
130
130
|
blog_prefix=config.blog_prefix,
|
|
131
131
|
locale_func=engine.get_locale,
|
|
132
132
|
)
|
|
133
|
-
seo_blueprint = seo.create_seo_blueprint(
|
|
133
|
+
seo_blueprint = seo.create_seo_blueprint(
|
|
134
|
+
db=engine.db, config=engine.config, locale_func=engine.get_locale
|
|
135
|
+
)
|
|
134
136
|
engine.register_blueprint(blog_blueprint)
|
|
135
137
|
engine.register_blueprint(seo_blueprint)
|
|
136
138
|
|
|
@@ -5,7 +5,7 @@ from os.path import dirname
|
|
|
5
5
|
from flask import Blueprint, current_app, make_response, render_template, request
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def create_seo_blueprint(db, config: dict[str, t.Any]):
|
|
8
|
+
def create_seo_blueprint(db, config: dict[str, t.Any], locale_func: t.Callable[[], str]):
|
|
9
9
|
seo = Blueprint(
|
|
10
10
|
"seo",
|
|
11
11
|
__name__,
|
|
@@ -20,21 +20,26 @@ def create_seo_blueprint(db, config: dict[str, t.Any]):
|
|
|
20
20
|
response.headers["Content-Type"] = "text/plain"
|
|
21
21
|
return response
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
def get_blog_entries(host_base, lang, db, blog_prefix):
|
|
24
|
+
dynamic_urls = list()
|
|
25
|
+
print(blog_prefix)
|
|
26
|
+
for post in db.get_all_posts(
|
|
27
|
+
lang
|
|
28
|
+
): # TODO add get_list_of_posts for faster getting just list of it
|
|
29
|
+
slug = post.slug
|
|
30
|
+
datet = post.date.split("T")[0]
|
|
31
|
+
url = {"loc": f"{host_base}{blog_prefix}/{slug}", "lastmod": datet}
|
|
32
|
+
dynamic_urls.append(url)
|
|
33
|
+
return dynamic_urls
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
@seo.route("/sitemap.xml") # TODO try to replace sitemap logic with flask-sitemap module
|
|
36
|
+
def sitemap():
|
|
33
37
|
"""
|
|
34
38
|
Route to dynamically generate a sitemap of your website/application.
|
|
35
39
|
lastmod and priority tags omitted on static pages.
|
|
36
40
|
lastmod included on dynamic content such as seo posts.
|
|
37
41
|
"""
|
|
42
|
+
lang = locale_func()
|
|
38
43
|
|
|
39
44
|
global url
|
|
40
45
|
host_components = urllib.parse.urlparse(request.host_url)
|
|
@@ -43,19 +48,11 @@ def create_seo_blueprint(db, config: dict[str, t.Any]):
|
|
|
43
48
|
# Static routes with static content
|
|
44
49
|
static_urls = list()
|
|
45
50
|
for rule in current_app.url_map.iter_rules():
|
|
46
|
-
if not
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
static_urls.append(url)
|
|
51
|
+
if rule.methods is not None and "GET" in rule.methods and len(rule.arguments) == 0:
|
|
52
|
+
url = {"loc": f"{host_base}{rule!s}"}
|
|
53
|
+
static_urls.append(url)
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
dynamic_urls = list()
|
|
53
|
-
seo_posts = db.get_all_posts(lang)
|
|
54
|
-
for post in seo_posts:
|
|
55
|
-
slug = post["slug"]
|
|
56
|
-
datet = post["date"].split("T")[0]
|
|
57
|
-
url = {"loc": f"{host_base}/{slug}", "lastmod": datet}
|
|
58
|
-
dynamic_urls.append(url)
|
|
55
|
+
dynamic_urls = get_blog_entries(host_base, lang, db, config["BLOG_PREFIX"])
|
|
59
56
|
|
|
60
57
|
statics = list({v["loc"]: v for v in static_urls}.values())
|
|
61
58
|
dynamics = list({v["loc"]: v for v in dynamic_urls}.values())
|
|
@@ -70,3 +67,6 @@ def create_seo_blueprint(db, config: dict[str, t.Any]):
|
|
|
70
67
|
return response
|
|
71
68
|
|
|
72
69
|
return seo
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# TODO add tests which would check that sitemap is different for different languages
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|