@raketa-cloud/admin 0.0.12 → 0.0.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-cloud/admin",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "main": "src/index.js",
5
5
  "scripts": {
6
6
  "dev": "npx tailwindcss -i ./src/styles/application.css -o ../../apps/admin/static/application.css --watch",
package/src/Adapter.js CHANGED
@@ -125,6 +125,7 @@ export default class Adapter {
125
125
 
126
126
  async renderLayout(assigns, body) {
127
127
  const layoutTemplate = `${currentPath}/views/layouts/application.ejs`;
128
+
128
129
  return await ejs.renderFile(layoutTemplate, {
129
130
  ...assigns,
130
131
  body,
@@ -84,113 +84,120 @@ export default class HonoAdapter extends Adapter {
84
84
  ]) {
85
85
  const method = this.getMethod(verb);
86
86
 
87
- [...Object.keys(this.globalConfig.i18n.locales), ""].forEach(
88
- (currentLocale) => {
89
- const completedPath = `/${currentLocale}${path}`;
90
-
91
- method(completedPath, async (routerCtx, next) => {
92
- const ctx = await this.createContext(
93
- routerCtx,
94
- next,
95
- verb,
96
- resource,
97
- action
98
- );
99
-
100
- ctx.locales = this.globalConfig.i18n.locales;
101
- ctx.defaultLocale = this.globalConfig.i18n.defaultLocale;
102
- ctx.locale = currentLocale;
103
-
104
- const _context = {
105
- locales: ctx.locales,
106
- locale: ctx.locale,
107
- defaultLocale: ctx.defaultLocale,
108
- path: ctx.req.path,
109
- query: ctx.query || {},
110
- };
111
-
112
- console.info(
113
- `\x1b[35m[${ctx.method}] ${ctx.rawPath}\x1b[0m -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
114
- );
115
-
116
- const assigns = {
117
- beforeFilterAssigns: {},
118
- actionAssigns: {},
119
- afterFilterAssigns: {},
120
- };
121
-
122
- // Initialize global context
123
- ctx.initGlobalContext();
124
-
125
- // Process before filters
126
- if (before_filter) {
127
- const {
128
- redirect,
129
- json,
130
- assigns: beforeFilterAssigns = {},
131
- } = before_filter(ctx) || {};
132
-
133
- if (redirect) return routerCtx.redirect(redirect);
134
-
135
- if (json) {
136
- return routerCtx.json(json);
137
- }
138
-
139
- assigns.beforeFilterAssigns = beforeFilterAssigns;
140
- }
141
-
142
- // Process action
87
+ Object.keys(this.globalConfig.i18n.locales).forEach((currentLocale) => {
88
+ const completePath = `/${currentLocale}${path}`;
89
+
90
+ // A terrible, terrible hack...
91
+ // So how do we override for the entire handler.. do we need to completely override it, or just partially? Fun stuff?
92
+ this.router.router.routes = this.router.router.routes.filter((route) => {
93
+ return route[0] !== verb || route[1] !== completePath;
94
+ });
95
+
96
+ method(completePath, async (routerCtx, next) => {
97
+ const ctx = await this.createContext(
98
+ routerCtx,
99
+ next,
100
+ verb,
101
+ resource,
102
+ action
103
+ );
104
+
105
+ ctx.locales = this.globalConfig.i18n.locales;
106
+ ctx.defaultLocale = this.globalConfig.i18n.defaultLocale;
107
+ ctx.locale = currentLocale;
108
+
109
+ const _context = {
110
+ locales: ctx.locales,
111
+ locale: ctx.locale,
112
+ defaultLocale: ctx.defaultLocale,
113
+ path: ctx.req.path,
114
+ query: ctx.query || {},
115
+ layout: {
116
+ ...this.globalConfig.layout,
117
+ },
118
+ };
119
+
120
+ console.info(
121
+ `\x1b[35m[${ctx.method}] ${ctx.rawPath}\x1b[0m -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
122
+ );
123
+
124
+ const assigns = {
125
+ beforeFilterAssigns: {},
126
+ actionAssigns: {},
127
+ afterFilterAssigns: {},
128
+ };
129
+
130
+ // Initialize global context
131
+ ctx.initGlobalContext();
132
+
133
+ // Process before filters
134
+ if (before_filter) {
143
135
  const {
144
- headers,
145
136
  redirect,
146
137
  json,
147
- assigns: actionAssigns = {},
148
- } = (await handler(ctx)) || {};
149
- assigns.actionAssigns = actionAssigns;
150
-
151
- this.applyHeaders(headers, routerCtx);
138
+ assigns: beforeFilterAssigns = {},
139
+ } = before_filter(ctx) || {};
152
140
 
153
141
  if (redirect) return routerCtx.redirect(redirect);
154
142
 
155
- // Process after filters
156
- if (after_filter) {
157
- const {
158
- redirect,
159
- json,
160
- assigns: afterFilterAssigns = {},
161
- } = after_filter(ctx) || {};
143
+ if (json) {
144
+ return routerCtx.json(json);
145
+ }
162
146
 
163
- if (redirect) return routerCtx.redirect(redirect);
147
+ assigns.beforeFilterAssigns = beforeFilterAssigns;
148
+ }
164
149
 
165
- if (json) {
166
- return routerCtx.json(json);
167
- }
150
+ // Process action
151
+ const {
152
+ headers,
153
+ redirect,
154
+ json,
155
+ assigns: actionAssigns = {},
156
+ } = (await handler(ctx)) || {};
157
+ assigns.actionAssigns = actionAssigns;
168
158
 
169
- assigns.afterFilterAssigns = afterFilterAssigns;
170
- }
159
+ this.applyHeaders(headers, routerCtx);
160
+
161
+ if (redirect) return routerCtx.redirect(redirect);
162
+
163
+ // Process after filters
164
+ if (after_filter) {
165
+ const {
166
+ redirect,
167
+ json,
168
+ assigns: afterFilterAssigns = {},
169
+ } = after_filter(ctx) || {};
171
170
 
172
- const fullAssigns = {
173
- ...ctx.assigns,
174
- ...assigns.beforeFilterAssigns,
175
- ...assigns.actionAssigns,
176
- ...assigns.afterFilterAssigns,
177
- _context: _context,
178
- };
171
+ if (redirect) return routerCtx.redirect(redirect);
179
172
 
180
173
  if (json) {
181
174
  return routerCtx.json(json);
182
175
  }
183
176
 
184
- const rendered = this.renderAction({
185
- views,
186
- action,
187
- assigns: fullAssigns,
188
- });
189
-
190
- return routerCtx.html(rendered);
177
+ assigns.afterFilterAssigns = afterFilterAssigns;
178
+ }
179
+
180
+ const fullAssigns = {
181
+ ...ctx.assigns,
182
+ ...assigns.beforeFilterAssigns,
183
+ ...assigns.actionAssigns,
184
+ ...assigns.afterFilterAssigns,
185
+ _context: _context,
186
+ };
187
+
188
+ if (json) {
189
+ return routerCtx.json(json);
190
+ }
191
+
192
+ const rendered = this.renderAction({
193
+ views,
194
+ action,
195
+ assigns: fullAssigns,
191
196
  });
192
- }
193
- );
197
+
198
+ return routerCtx.html(rendered);
199
+ });
200
+ });
194
201
  }
195
202
 
196
203
  routeCollection(mapping) {
@@ -28,84 +28,47 @@
28
28
  </button>
29
29
 
30
30
  <div class="my-4">
31
- <div class="group/item">
32
- <a href="<%= `/${_context.locale}/pages` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
33
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
34
- <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
35
- </svg>
36
-
37
- <span class="group-[.expanded]:block hidden">Pages</span>
38
- <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
39
- </a>
40
- </div>
41
-
42
- <div class="group/item">
43
- <a href="<%= `/${_context.locale}/articles` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
44
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
45
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 0 1-2.25 2.25M16.5 7.5V18a2.25 2.25 0 0 0 2.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 0 0 2.25 2.25h13.5M6 7.5h3v3H6v-3Z" />
46
- </svg>
47
-
48
- <span class="group-[.expanded]:block hidden">Articles</span>
49
- <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
50
- </a>
51
- </div>
52
-
53
- <div class="group/item">
54
- <a href="<%= `/${_context.locale}/events` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
55
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
56
- <path stroke-linecap="round" stroke-linejoin="round" d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5" />
57
- </svg>
58
-
59
- <span class="group-[.expanded]:block hidden">Events</span>
60
- <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
61
- </a>
62
- </div>
63
-
64
- <div class="group/item">
65
- <a href="<%= `/${_context.locale}/redirects` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
66
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
67
- <path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" />
68
- </svg>
69
-
70
- <span class="group-[.expanded]:block hidden">Redirects</span>
71
- <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
72
- </a>
73
- </div>
74
-
75
- <div class="group/item">
76
- <a href="<%= `/${_context.locale}/tags` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
77
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
78
- <path stroke-linecap="round" stroke-linejoin="round" d="M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z" />
79
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 6h.008v.008H6V6Z" />
80
- </svg>
81
-
82
- <span class="group-[.expanded]:block hidden">Tags</span>
83
- <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
84
- </a>
85
- </div>
86
-
87
- <div class="group/item">
88
- <details class="unstyled-details">
89
- <summary class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary cursor-pointer transition-all duration-300 ease-in-out">
90
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 opacity-100 group-[.expanded]:opacity-50">
91
- <path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z" />
92
- <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
93
- </svg>
94
-
95
- <span class="group-[.expanded]:block hidden">Settings</span>
96
-
97
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="icon-toggle absolute right-4 size-4 group-[.expanded]:block hidden">
98
- <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
99
- </svg>
100
- </summary>
101
-
102
- <div class="pl-12 py-4 bg-raketa-background/50 group-[.expanded]:block hidden">
103
- <a href="<%= `/${_context.locale}/settings/general/edit` %>" class="block py-2 body-2 text-raketa-foreground/50 hover:text-raketa-foreground transition-all ease-in-out duration-300">General</a>
104
- <a href="<%= `/${_context.locale}/settings/meta/edit` %>" class="block py-2 body-2 text-raketa-foreground/50 hover:text-raketa-foreground transition-all ease-in-out duration-300">Meta and OpenGraph</a>
105
- <a href="<%= `/${_context.locale}/settings/layout/edit` %>" class="block py-2 body-2 text-raketa-foreground/50 hover:text-raketa-foreground transition-all ease-in-out duration-300">Layout and Navigation</a>
31
+ <% _context.layout.sidebar.forEach((menu, idx) => { %>
32
+ <% if (menu.submenus) { %>
33
+
34
+ <div class="group/item">
35
+ <details class="unstyled-details">
36
+ <summary class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary cursor-pointer transition-all duration-300 ease-in-out">
37
+ <div class="size-6 opacity-100 group-[.expanded]:opacity-50">
38
+ <%- atob(menu.icon) %>
39
+ </div>
40
+
41
+ <span class="group-[.expanded]:block hidden"><%= menu.label %></span>
42
+
43
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="icon-toggle absolute right-4 size-4 group-[.expanded]:block hidden">
44
+ <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
45
+ </svg>
46
+ </summary>
47
+
48
+ <div class="pl-12 py-4 bg-raketa-background/50 group-[.expanded]:block hidden">
49
+ <% menu.submenus.forEach(submenu => { %>
50
+ <a href="<%= `/${_context.locale}/${submenu.link}` %>" class="block py-2 body-2 text-raketa-foreground/50 hover:text-raketa-foreground transition-all ease-in-out duration-300"><%= submenu.label %></a>
51
+ <% }) %>
52
+ </div>
53
+ </details>
106
54
  </div>
107
- </details>
108
- </div>
55
+
56
+ <% } else { %>
57
+
58
+ <div class="group/item">
59
+ <a href="<%= `/${_context.locale}${menu.link}` %>" class="relative flex items-center gap-3 px-5 py-4 text-raketa-primary hover:bg-raketa-primary hover:text-white group-[.is-active]/item:bg-raketa-primary group-[.is-active]/item:text-white">
60
+ <div class="size-6 opacity-100 group-[.expanded]:opacity-50">
61
+ <%- atob(menu.icon) %>
62
+ </div>
63
+
64
+ <span class="group-[.expanded]:block hidden"><%= menu.label %></span>
65
+ <div class="absolute group-hover/item:opacity-100 group-[.is-active]/item:opacity-100 opacity-0 top-0 z-10 -right-[10px] w-0 h-0 border-t-[28px] border-t-transparent border-b-[28px] border-b-transparent border-l-[10px] border-l-raketa-primary"></div>
66
+ </a>
67
+ </div>
68
+
69
+ <% } %>
70
+ <% }) %>
71
+
109
72
  </div>
110
73
 
111
74
  <div class="group/item">
@@ -143,4 +106,4 @@
143
106
  </script>
144
107
  </body>
145
108
 
146
- </html>
109
+ </html>
@@ -37,4 +37,4 @@
37
37
  </div>
38
38
  </div>
39
39
  </div>
40
- </div>
40
+ </div>
@@ -39,4 +39,4 @@
39
39
  </div>
40
40
  </div>
41
41
  </div>
42
- </div>
42
+ </div>