platzky 0.2.7__py3-none-any.whl → 0.2.8__py3-none-any.whl

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/platzky.py CHANGED
@@ -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(db=engine.db, config=engine.config)
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
 
platzky/seo/seo.py CHANGED
@@ -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__,
@@ -21,20 +21,13 @@ def create_seo_blueprint(db, config: dict[str, t.Any]):
21
21
  return response
22
22
 
23
23
  @seo.route("/sitemap.xml")
24
- def main_sitemap():
25
- if domain_to_lang := config["DOMAIN_TO_LANG"]:
26
- return sitemap(domain_to_lang[request.host])
27
- else:
28
- return sitemap(
29
- config.get("TRANSLATION_DIRECTORIES")
30
- ) # TODO should be based on localization not on config
31
-
32
- def sitemap(lang):
24
+ def sitemap():
33
25
  """
34
26
  Route to dynamically generate a sitemap of your website/application.
35
27
  lastmod and priority tags omitted on static pages.
36
28
  lastmod included on dynamic content such as seo posts.
37
29
  """
30
+ lang = locale_func()
38
31
 
39
32
  global url
40
33
  host_components = urllib.parse.urlparse(request.host_url)
@@ -43,17 +36,16 @@ def create_seo_blueprint(db, config: dict[str, t.Any]):
43
36
  # Static routes with static content
44
37
  static_urls = list()
45
38
  for rule in current_app.url_map.iter_rules():
46
- if not str(rule).startswith("/admin") and not str(rule).startswith("/user"):
47
- if rule.methods is not None and "GET" in rule.methods and len(rule.arguments) == 0:
48
- url = {"loc": f"{host_base}{rule!s}"}
49
- static_urls.append(url)
39
+ if rule.methods is not None and "GET" in rule.methods and len(rule.arguments) == 0:
40
+ url = {"loc": f"{host_base}{rule!s}"}
41
+ static_urls.append(url)
50
42
 
51
43
  # Dynamic routes with dynamic content
52
44
  dynamic_urls = list()
53
45
  seo_posts = db.get_all_posts(lang)
54
46
  for post in seo_posts:
55
- slug = post["slug"]
56
- datet = post["date"].split("T")[0]
47
+ slug = post.slug
48
+ datet = post.date.split("T")[0]
57
49
  url = {"loc": f"{host_base}/{slug}", "lastmod": datet}
58
50
  dynamic_urls.append(url)
59
51
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platzky
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Not only blog engine
5
5
  License: MIT
6
6
  Requires-Python: >=3.10,<4.0
@@ -11,12 +11,12 @@ platzky/db/graph_ql_db.py,sha256=aIqRxPV-Txr5MY2-qVALby9fHyIvWgvSz2t24M9SNRI,734
11
11
  platzky/db/json_db.py,sha256=AtZoTcM6S2ZHo19rxkCi4h4E4INGieZ4W6H5O2iormA,3246
12
12
  platzky/db/json_file_db.py,sha256=UQ8TadELmqOzj_tgNfmzhtCkDkMAgcB9vaUy0GQXUY4,1010
13
13
  platzky/models.py,sha256=-IIlyeLzACeTUpzuzvzJYxtT57E6wRiERoRgXJYMMtY,1502
14
- platzky/platzky.py,sha256=-01WVpSxZz96NoilFB_2ispHLRrquCsMR9p3F7Tyf1s,4525
14
+ platzky/platzky.py,sha256=6DROf-0y51ouruGwbAZM9bJ7JNqQqO27ievlnbSCdEE,4570
15
15
  platzky/plugin_loader.py,sha256=KYLDSEd_hseAgBuSbikerU_IFx-YmcYK5UwYw7kla2E,1106
16
16
  platzky/plugins/google-tag-manager/entrypoint.py,sha256=yY5UqFvSdj3tt2upwNS8JkTrKcrbwlaaE2XQ6sRiGLc,1011
17
17
  platzky/plugins/redirections/entrypoint.py,sha256=yoqHsRLqRALdICs5_UMSREkfEo1Lbsjj9tqEA7dsseg,1555
18
18
  platzky/plugins/sendmail/entrypoint.py,sha256=16GszfLaYhVUSuCdL4SPVKYN9-mONp-hK5ZWSiLluPo,1215
19
- platzky/seo/seo.py,sha256=l59Ol56YfJB4bk4IzypYVASYCjLrjJqXRXMIcc4EUZY,2606
19
+ platzky/seo/seo.py,sha256=1_ADEomIBz8nQXeKk48gxZfkanYTKGy53s9JV5rvn2Q,2257
20
20
  platzky/static/blog.css,sha256=jF-8ykgpbPp58SCUqygBhCm4o7ggULojbxpnk6Jbx3c,7895
21
21
  platzky/templates/404.html,sha256=EheoLSWylOscLH8FmcMA4c6Jw14i5HkSvE_GXzGIrUo,78
22
22
  platzky/templates/base.html,sha256=kvN_rLS0K6esgI0rpsZ2iGbu5z3JTBsjBRAflMpFkiI,4496
@@ -30,6 +30,6 @@ platzky/templates/post.html,sha256=GSgjIZsOQKtNx3cEbquSjZ5L4whPnG6MzRyoq9k4B8Q,1
30
30
  platzky/templates/robots.txt,sha256=2_j2tiYtYJnzZUrANiX9pvBxyw5Dp27fR_co18BPEJ0,116
31
31
  platzky/templates/sitemap.xml,sha256=iIJZ91_B5ZuNLCHsRtsGKZlBAXojOTP8kffqKLacgvs,578
32
32
  platzky/www_handler.py,sha256=pF6Rmvem1sdVqHD7z3RLrDuG-CwAqfGCti50_NPsB2w,725
33
- platzky-0.2.7.dist-info/METADATA,sha256=I6AwPyEbIOQce-EYVEXjDRS03MCTMt_V2Ea8GsmPgGo,1591
34
- platzky-0.2.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
35
- platzky-0.2.7.dist-info/RECORD,,
33
+ platzky-0.2.8.dist-info/METADATA,sha256=vY6JcBSYc-T5XQa0u_ZjLgIbZFhwRE8DL5ie12TH_hc,1591
34
+ platzky-0.2.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
35
+ platzky-0.2.8.dist-info/RECORD,,