platzky 0.2.4__py3-none-any.whl → 0.2.5__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/db/db.py CHANGED
@@ -14,7 +14,7 @@ class DB(ABC):
14
14
 
15
15
  def __init_subclass__(cls, *args, **kw):
16
16
  """Check that all methods defined in the subclass exist in the superclasses.
17
- This is to prevent subclasses from adding new methods to the DB object.
17
+ This is to prevent subclasses from splitting up DB interface.
18
18
  """
19
19
  super().__init_subclass__(*args, **kw)
20
20
  for name in cls.__dict__:
@@ -90,10 +90,6 @@ class DB(ABC):
90
90
  def get_font(self) -> str:
91
91
  pass
92
92
 
93
- @abstractmethod
94
- def get_site_content(self) -> str:
95
- pass
96
-
97
93
 
98
94
  class DBConfig(BaseModel):
99
95
  type: str = Field(alias="TYPE")
platzky/db/graph_ql_db.py CHANGED
@@ -232,8 +232,15 @@ class GraphQL(DB):
232
232
  def get_secondary_color(self):
233
233
  return Color()
234
234
 
235
- def get_site_content(self):
236
- return ""
237
-
238
235
  def get_plugins_data(self):
239
- return []
236
+ plugins_data = gql(
237
+ """
238
+ query MyQuery {
239
+ pluginConfigs(stage: PUBLISHED) {
240
+ name
241
+ config
242
+ }
243
+ }
244
+ """
245
+ )
246
+ return self.client.execute(plugins_data)["pluginConfigs"]
platzky/db/json_db.py CHANGED
@@ -34,13 +34,13 @@ class Json(DB):
34
34
  def get_all_posts(self, lang):
35
35
  return [
36
36
  Post.model_validate(post)
37
- for post in self.get_site_content().get("posts", ())
37
+ for post in self._get_site_content().get("posts", ())
38
38
  if post["language"] == lang
39
39
  ]
40
40
 
41
41
  def get_post(self, slug: str) -> Post:
42
42
  """Returns a post matching the given slug."""
43
- all_posts = self.get_site_content().get("posts")
43
+ all_posts = self._get_site_content().get("posts")
44
44
  if all_posts is None:
45
45
  raise ValueError("Posts data is missing")
46
46
  wanted_post = next((post for post in all_posts if post["slug"] == slug), None)
@@ -52,39 +52,39 @@ class Json(DB):
52
52
  def get_page(self, slug):
53
53
  list_of_pages = (
54
54
  page
55
- for page in self.get_site_content().get("pages")
55
+ for page in self._get_site_content().get("pages")
56
56
  if page["slug"] == slug
57
57
  )
58
58
  page = Post.model_validate(next(list_of_pages))
59
59
  return page
60
60
 
61
61
  def get_menu_items(self) -> list[MenuItem]:
62
- menu_items_raw = self.get_site_content().get("menu_items", [])
62
+ menu_items_raw = self._get_site_content().get("menu_items", [])
63
63
  menu_items_list = [MenuItem.model_validate(x) for x in menu_items_raw]
64
64
  return menu_items_list
65
65
 
66
66
  def get_posts_by_tag(self, tag, lang):
67
67
  return (
68
- post for post in self.get_site_content()["posts"] if tag in post["tags"]
68
+ post for post in self._get_site_content()["posts"] if tag in post["tags"]
69
69
  )
70
70
 
71
- def get_site_content(self):
71
+ def _get_site_content(self):
72
72
  content = self.data.get("site_content")
73
73
  if content is None:
74
74
  raise Exception("Content should not be None")
75
75
  return content
76
76
 
77
77
  def get_logo_url(self):
78
- return self.get_site_content().get("logo_url", "")
78
+ return self._get_site_content().get("logo_url", "")
79
79
 
80
80
  def get_font(self) -> str:
81
- return self.get_site_content().get("font", "")
81
+ return self._get_site_content().get("font", "")
82
82
 
83
83
  def get_primary_color(self):
84
- return self.get_site_content().get("primary_color", "white")
84
+ return self._get_site_content().get("primary_color", "white")
85
85
 
86
86
  def get_secondary_color(self):
87
- return self.get_site_content().get("secondary_color", "navy")
87
+ return self._get_site_content().get("secondary_color", "navy")
88
88
 
89
89
  def add_comment(self, author_name, comment, post_slug):
90
90
  comment = {
@@ -95,10 +95,10 @@ class Json(DB):
95
95
 
96
96
  post_index = next(
97
97
  i
98
- for i in range(len(self.get_site_content()["posts"]))
99
- if self.get_site_content()["posts"][i]["slug"] == post_slug
98
+ for i in range(len(self._get_site_content()["posts"]))
99
+ if self._get_site_content()["posts"][i]["slug"] == post_slug
100
100
  )
101
- self.get_site_content()["posts"][post_index]["comments"].append(comment)
101
+ self._get_site_content()["posts"][post_index]["comments"].append(comment)
102
102
 
103
103
  def get_plugins_data(self):
104
104
  return self.data.get("plugins", [])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platzky
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Not only blog engine
5
5
  License: MIT
6
6
  Requires-Python: >=3.10,<4.0
@@ -4,11 +4,11 @@ platzky/blog/blog.py,sha256=R1Otio2Ix5d02CT9mtYZ_kKMbKJArsuJdJLjCfc4Qxg,3031
4
4
  platzky/blog/comment_form.py,sha256=4lkNJ_S_2DZmJBbz-NPDqahvy2Zz5AGNH2spFeGIop4,513
5
5
  platzky/config.py,sha256=XL4oASEZQtc6iNfiLkAJaHp9fUX3A53DEpCXznYyOrQ,2203
6
6
  platzky/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- platzky/db/db.py,sha256=0smTAiP4MDKOF_t60-KVKs1h-oTGydrWvAgPavFjDDo,2660
7
+ platzky/db/db.py,sha256=1SzKuWKHgcHMnPPclRfvkgicMJOVMjmtHZnyc5OcKO8,2577
8
8
  platzky/db/db_loader.py,sha256=CuEiXxhIa4bFMm0vi7ugzm7j3WycilGRKCU6smgIImE,905
9
9
  platzky/db/google_json_db.py,sha256=65NKwbalGA1FfQz724dAK_3PS9e-MeLUb7WZkVU6nBo,1513
10
- platzky/db/graph_ql_db.py,sha256=jAfz9WK7tYjTFFwurR0piuW_M79vK7IbV9AbQpNLnOo,6444
11
- platzky/db/json_db.py,sha256=lbDZiEDWZebd9sssF8td1HKod4o7CdIvHu2fcPFgs7U,3184
10
+ platzky/db/graph_ql_db.py,sha256=fJfSvoKLTSMNz4UXgIiV4-GnVDAYx33f1nrTNx8_pjQ,6661
11
+ platzky/db/json_db.py,sha256=Bz3uxI47ritKCN5HR2vxlbXTRZSIx7mP9N4jTzifGXA,3197
12
12
  platzky/db/json_file_db.py,sha256=UQ8TadELmqOzj_tgNfmzhtCkDkMAgcB9vaUy0GQXUY4,1010
13
13
  platzky/models.py,sha256=8ATKVrGRtQ1JV_z7IdYbx1cxBU7ISoXjTmNxTlxok-k,1450
14
14
  platzky/platzky.py,sha256=3KljmS4lTB1yscOSDoavZ2yFwHcdQ_K8Om8qlJBA73U,4649
@@ -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.4.dist-info/METADATA,sha256=0OfFP9xpFYKvGbAnNVJ9qsKyq5D6l2FvsnsPxEzr3GE,1591
34
- platzky-0.2.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
35
- platzky-0.2.4.dist-info/RECORD,,
33
+ platzky-0.2.5.dist-info/METADATA,sha256=201srerrBPL9m4s5uKqXXKYPx9VAByaOQrKMt36KwIk,1591
34
+ platzky-0.2.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
35
+ platzky-0.2.5.dist-info/RECORD,,