platzky 0.3.4__tar.gz → 0.3.6__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.
Files changed (44) hide show
  1. {platzky-0.3.4 → platzky-0.3.6}/PKG-INFO +1 -1
  2. {platzky-0.3.4 → platzky-0.3.6}/platzky/admin/admin.py +15 -11
  3. {platzky-0.3.4 → platzky-0.3.6}/platzky/admin/templates/admin.html +6 -5
  4. {platzky-0.3.4 → platzky-0.3.6}/platzky/engine.py +10 -0
  5. {platzky-0.3.4 → platzky-0.3.6}/platzky/models.py +16 -0
  6. {platzky-0.3.4 → platzky-0.3.6}/platzky/platzky.py +1 -1
  7. {platzky-0.3.4 → platzky-0.3.6}/pyproject.toml +1 -1
  8. {platzky-0.3.4 → platzky-0.3.6}/README.md +0 -0
  9. {platzky-0.3.4 → platzky-0.3.6}/platzky/__init__.py +0 -0
  10. {platzky-0.3.4 → platzky-0.3.6}/platzky/admin/fake_login.py +0 -0
  11. {platzky-0.3.4 → platzky-0.3.6}/platzky/admin/templates/login.html +0 -0
  12. {platzky-0.3.4 → platzky-0.3.6}/platzky/admin/templates/module.html +0 -0
  13. {platzky-0.3.4 → platzky-0.3.6}/platzky/blog/__init__.py +0 -0
  14. {platzky-0.3.4 → platzky-0.3.6}/platzky/blog/blog.py +0 -0
  15. {platzky-0.3.4 → platzky-0.3.6}/platzky/blog/comment_form.py +0 -0
  16. {platzky-0.3.4 → platzky-0.3.6}/platzky/config.py +0 -0
  17. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/README.md +0 -0
  18. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/__init__.py +0 -0
  19. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/db.py +0 -0
  20. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/db_loader.py +0 -0
  21. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/github_json_db.py +0 -0
  22. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/google_json_db.py +0 -0
  23. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/graph_ql_db.py +0 -0
  24. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/json_db.py +0 -0
  25. {platzky-0.3.4 → platzky-0.3.6}/platzky/db/json_file_db.py +0 -0
  26. {platzky-0.3.4 → platzky-0.3.6}/platzky/locale/en/LC_MESSAGES/messages.po +0 -0
  27. {platzky-0.3.4 → platzky-0.3.6}/platzky/locale/pl/LC_MESSAGES/messages.po +0 -0
  28. {platzky-0.3.4 → platzky-0.3.6}/platzky/plugin/plugin.py +0 -0
  29. {platzky-0.3.4 → platzky-0.3.6}/platzky/plugin/plugin_loader.py +0 -0
  30. {platzky-0.3.4 → platzky-0.3.6}/platzky/seo/seo.py +0 -0
  31. {platzky-0.3.4 → platzky-0.3.6}/platzky/static/blog.css +0 -0
  32. {platzky-0.3.4 → platzky-0.3.6}/platzky/static/styles.css +0 -0
  33. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/404.html +0 -0
  34. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/base.html +0 -0
  35. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/blog.html +0 -0
  36. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/body_meta.html +0 -0
  37. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/dynamic_css.html +0 -0
  38. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/feed.xml +0 -0
  39. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/head_meta.html +0 -0
  40. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/page.html +0 -0
  41. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/post.html +0 -0
  42. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/robots.txt +0 -0
  43. {platzky-0.3.4 → platzky-0.3.6}/platzky/templates/sitemap.xml +0 -0
  44. {platzky-0.3.4 → platzky-0.3.6}/platzky/www_handler.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: platzky
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Not only blog engine
5
5
  License: MIT
6
6
  Requires-Python: >=3.10,<4.0
@@ -3,7 +3,14 @@ from os.path import dirname
3
3
  from flask import Blueprint, render_template, session
4
4
 
5
5
 
6
- def create_admin_blueprint(login_methods, db, locale_func):
6
+ def create_admin_blueprint(login_methods, cms_modules):
7
+ """Create admin blueprint with dynamic module routes.
8
+
9
+ Args:
10
+ login_methods: Available login methods
11
+ cms_modules: List of CMS modules to register routes for
12
+ """
13
+ # …rest of the function…
7
14
  admin = Blueprint(
8
15
  "admin",
9
16
  __name__,
@@ -11,23 +18,20 @@ def create_admin_blueprint(login_methods, db, locale_func):
11
18
  template_folder=f"{dirname(__file__)}/templates",
12
19
  )
13
20
 
14
- @admin.route("/", methods=["GET"])
15
- def admin_panel_home():
16
- user = session.get("user", None)
21
+ for module in cms_modules:
17
22
 
18
- if not user:
19
- return render_template("login.html", login_methods=login_methods)
23
+ @admin.route(f"/module/{module.slug}", methods=["GET"])
24
+ def module_route(module=module):
20
25
 
21
- cms_modules = {"plugins": [plugin.get("name") for plugin in db.get_plugins_data()]}
22
- return render_template("admin.html", user=user, cms_modules=cms_modules)
26
+ return render_template(module.template, module=module)
23
27
 
24
- @admin.route("/module/<module_name>", methods=["GET"])
25
- def module_settings(module_name):
28
+ @admin.route("/", methods=["GET"])
29
+ def admin_panel_home():
26
30
  user = session.get("user", None)
27
31
 
28
32
  if not user:
29
33
  return render_template("login.html", login_methods=login_methods)
30
34
 
31
- return render_template("module.html", user=user, module_name=module_name)
35
+ return render_template("admin.html", user=user, cms_modules=cms_modules)
32
36
 
33
37
  return admin
@@ -18,12 +18,13 @@
18
18
  {% block left_panel %}
19
19
  <div id="admin-panel">
20
20
  <p>User: {{ user.username }}</p>
21
- {% for cms_module_name, cms_entries in cms_modules.items() %}
21
+ {% for cms_module in cms_modules %}
22
22
  <div class="cms-module mb-2">
23
- <p>{{ cms_module_name }}</p>
24
- {% for cms_entry in cms_entries %}
25
- <a href="{{ url_for('admin.module', name=cms_entry) }}" class="cms-entry btn btn-primary btn-block mb-2">{{ cms_entry }}</a>
26
- {% endfor %}
23
+ <ul>
24
+ <li>
25
+ <a href="/{{ cms_module.slug }}"> {{ cms_module.name }} </a>
26
+ </li>
27
+ </ul>
27
28
  </div>
28
29
  {% endfor %}
29
30
  </div>
@@ -1,9 +1,11 @@
1
1
  import os
2
+ from typing import List
2
3
 
3
4
  from flask import Flask, request, session
4
5
  from flask_babel import Babel
5
6
 
6
7
  from platzky.config import Config
8
+ from platzky.models import CmsModule
7
9
 
8
10
 
9
11
  class Engine(Flask):
@@ -25,6 +27,10 @@ class Engine(Flask):
25
27
  default_translation_directories=babel_translation_directories,
26
28
  )
27
29
 
30
+ self.cms_modules: List[CmsModule] = []
31
+ # TODO add plugins as CMS Module - all plugins should be visible from
32
+ # admin page at least as configuration
33
+
28
34
  def notify(self, message: str):
29
35
  for notifier in self.notifiers:
30
36
  notifier(message)
@@ -32,6 +38,10 @@ class Engine(Flask):
32
38
  def add_notifier(self, notifier):
33
39
  self.notifiers.append(notifier)
34
40
 
41
+ def add_cms_module(self, module: CmsModule):
42
+ """Add a CMS module to the modules list."""
43
+ self.cms_modules.append(module)
44
+
35
45
  # TODO login_method should be interface
36
46
  def add_login_method(self, login_method):
37
47
  self.login_methods.append(login_method)
@@ -4,6 +4,22 @@ import humanize
4
4
  from pydantic import BaseModel
5
5
 
6
6
 
7
+ class CmsModule(BaseModel):
8
+ """Represents a CMS module with basic metadata."""
9
+
10
+ name: str
11
+ description: str
12
+ template: str
13
+ slug: str
14
+
15
+
16
+ # CmsModuleGroup is also a CmsModule, but it contains other CmsModules
17
+ class CmsModuleGroup(CmsModule):
18
+ """Represents a group of CMS modules, inheriting module properties."""
19
+
20
+ modules: list[CmsModule] = []
21
+
22
+
7
23
  class Image(BaseModel):
8
24
  url: str = ""
9
25
  alternateText: str = ""
@@ -86,7 +86,7 @@ def create_app_from_config(config: Config) -> Engine:
86
86
  engine = create_engine(config, db)
87
87
 
88
88
  admin_blueprint = admin.create_admin_blueprint(
89
- login_methods=engine.login_methods, db=engine.db, locale_func=engine.get_locale
89
+ login_methods=engine.login_methods, cms_modules=engine.cms_modules
90
90
  )
91
91
 
92
92
  if config.feature_flags and config.feature_flags.get("FAKE_LOGIN", False):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "platzky"
3
- version = "0.3.4"
3
+ version = "0.3.6"
4
4
  description = "Not only blog engine"
5
5
  authors = []
6
6
  license = "MIT"
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