Skip to content

Commit

Permalink
Merge pull request #2 from NomadicDaddy/dev
Browse files Browse the repository at this point in the history
fixed npm cmds; crudmgr; aw icon; htmx-debugger links
  • Loading branch information
NomadicDaddy authored Oct 4, 2024
2 parents 6c31292 + 7e282cc commit e5c60c3
Show file tree
Hide file tree
Showing 12 changed files with 421 additions and 41 deletions.
9 changes: 9 additions & 0 deletions api/debug/clear.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP TABLE "items";

CREATE TABLE "items" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"item" TEXT NOT NULL,
"description" TEXT NOT NULL,
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME DEFAULT CURRENT_TIMESTAMP
);
48 changes: 48 additions & 0 deletions api/debug/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
DROP TABLE "items";

CREATE TABLE "items" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"item" TEXT NOT NULL,
"description" TEXT NOT NULL,
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO
"items" ("item", "description")
VALUES
('Item 1', 'Description for item 1'),
('Item 2', 'Description for item 2'),
('Item 3', 'Description for item 3'),
('Item 4', 'Description for item 4'),
('Item 5', 'Description for item 5'),
('Item 6', 'Description for item 6'),
('Item 7', 'Description for item 7'),
('Item 8', 'Description for item 8'),
('Item 9', 'Description for item 9'),
('Item 10', 'Description for item 10'),
('Item 11', 'Description for item 11'),
('Item 12', 'Description for item 12'),
('Item 13', 'Description for item 13'),
('Item 14', 'Description for item 14'),
('Item 15', 'Description for item 15'),
('Item 16', 'Description for item 16'),
('Item 17', 'Description for item 17'),
('Item 18', 'Description for item 18'),
('Item 19', 'Description for item 19'),
('Item 20', 'Description for item 20'),
('Item 21', 'Description for item 21'),
('Item 22', 'Description for item 22'),
('Item 23', 'Description for item 23'),
('Item 24', 'Description for item 24'),
('Item 25', 'Description for item 25'),
('Item 26', 'Description for item 26'),
('Item 27', 'Description for item 27'),
('Item 28', 'Description for item 28'),
('Item 29', 'Description for item 29'),
('Item 30', 'Description for item 30'),
('Item 31', 'Description for item 31'),
('Item 32', 'Description for item 32'),
('Item 33', 'Description for item 33'),
('Item 34', 'Description for item 34'),
('Item 35', 'Description for item 35');
2 changes: 1 addition & 1 deletion errors/404.html.pode
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="description" content="404 Not Found" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="PowerShell $($PSVersionTable.'PSEdition' ;) $([string]$PSVersionTable.'PSVersion' ;)" />
<meta name="generator" content="Podex 0.1.2 using PowerShell $($PSVersionTable.'PSEdition' ;) $([string]$PSVersionTable.'PSVersion' ;)" />
<title>404 Not Found</title>
<link rel="stylesheet" type="text/css" href="/public/css/output.css" />
<link rel="icon" type="image/svg+xml" href="/public/images/favicon.svg" />
Expand Down
2 changes: 1 addition & 1 deletion errors/default.html.pode
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="description" content="$($data.status.code) Error" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="PowerShell $($PSVersionTable.'PSEdition' ;) $([string]$PSVersionTable.'PSVersion' ;)" />
<meta name="generator" content="Podex 0.1.2 using PowerShell $($PSVersionTable.'PSEdition' ;) $([string]$PSVersionTable.'PSVersion' ;)" />
<title>$($data.status.code ;) Error</title>
<link rel="stylesheet" type="text/css" href="/public/css/output.css" />
<link rel="icon" type="image/svg+xml" href="/public/images/favicon.svg" />
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podex",
"version": "0.1.1",
"version": "0.1.2",
"description": "Podex - PowerShell/Pode + htmx Framework for Building Web Applications",
"author": "Phillip Beazley",
"license": "MIT",
Expand All @@ -14,13 +14,13 @@
"sqlite"
],
"scripts": {
"format": "prettier --write \"./views/**/*.*\" \"./api/**/*.*\" \"./htmx/**/*.*\" \"./errors/**/*.*\"",
"format": "prettier --write .",
"lint": "eslint .",
"analyze": "Invoke-ScriptAnalyzer -Path ./ -Recurse",
"test": "Invoke-Pester -Path ./tests/*.ps1",
"css": "tailwindcss -c ./tailwind.config.mjs -i ./public/css/tailwind.css -o ./public/css/output.css --minify",
"build": "powershell ./.build.ps1",
"start": "powershell ./podex.ps1"
"analyze": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -Command \"Import-Module PSScriptAnalyzer ; Invoke-ScriptAnalyzer -Path ./\"",
"test": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -Command \"Import-Module Pester ; Invoke-Pester -Path ./tests/*.ps1\"",
"build": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass \"./.build.ps1\"",
"start": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass \"./podex.ps1\""
},
"dependencies": {
"htmx-ext-client-side-templates": "^2.0.0",
Expand All @@ -31,9 +31,9 @@
"tailwindcss": "^3.4.13"
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@eslint/js": "^9.12.0",
"eslint": "^9.11.1",
"globals": "^15.9.0",
"globals": "^15.10.0",
"prettier": "^3.3.3",
"prettier-plugin-sql": "^0.18.1",
"prettier-plugin-tailwindcss": "^0.6.8"
Expand Down
4 changes: 2 additions & 2 deletions podex.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ Start-PodeServer -Name 'Podex' -Threads 5 -ScriptBlock {

# front-end routes
Add-PodeRoute -Path '/' -Method Get, Post -ScriptBlock { Write-PodeViewResponse -Path 'layouts/main' -Data @{ PageName = 'Home'; Title = 'Podex - PowerShell/Pode + htmx Framework for Building Web Applications'; Components = @('about'); } }
Add-PodeRoute -Path '/crudmgr' -Method Get, Post -ScriptBlock { Write-PodeViewResponse -Path 'layouts/main' -Data @{ PageName = 'CRUD'; Title = 'Podex - CRUD Management Demo'; Components = @('crudmgr'); } }
Add-PodeRoute -Path '/crudmgr' -Method Get, Post -ScriptBlock { Write-PodeViewResponse -Path 'layouts/main' -Data @{ PageName = 'CRUDMgr'; Title = 'Podex - CRUD Management Demo'; Components = @('crudmgr'); } }

# htmx routes (html only)
Add-PodeRoute -Path '/htmx/hello' -Method Get -FilePath './htmx/hello.ps1'
Add-PodeRoute -Path '/htmx/crud-new' -Method Get -ScriptBlock { Write-PodeViewResponse -Path 'layouts/bare' -Data @{ Components = @('crud-new'); } }
Add-PodeRoute -Path '/htmx/crudmgr-new' -Method Get -ScriptBlock { Write-PodeViewResponse -Path 'layouts/bare' -Data @{ Components = @('crud-new'); } }

# file-based api routes (json or html)
foreach ($file in (Get-ChildItem -Path './api' -Filter *.ps1 -Recurse -File)) {
Expand Down
61 changes: 61 additions & 0 deletions public/images/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions views/components/crudmgr-new.pode
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div class="relative rounded-lg bg-white shadow dark:bg-gray-700">
<div class="flex items-center justify-between rounded-t border-b p-4 dark:border-gray-600">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Add New Item</h3>
<button
type="button"
class="ml-auto inline-flex items-center rounded-lg bg-transparent p-1.5 text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
hx-on:click="htmx.trigger('body', 'closeModal')">
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
</button>
</div>
<form hx-post="/api/crud" hx-swap="none" hx-on::after-request="this.reset(); htmx.trigger('body', 'crudChanged')">
<div class="space-y-6 p-6">
<div>
<label for="item" class="mb-2 block text-sm font-medium text-gray-900 dark:text-white">Item Name</label>
<input
type="text"
name="item"
id="item"
class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-500 dark:bg-gray-600 dark:text-white dark:placeholder-gray-400"
placeholder="Enter item name"
required />
</div>
<div>
<label for="crudText" class="mb-2 block text-sm font-medium text-gray-900 dark:text-white">Item Description</label>
<textarea
name="description"
id="description"
class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-500 dark:bg-gray-600 dark:text-white dark:placeholder-gray-400"
placeholder="Enter description in markdown or HTML format"
required></textarea>
</div>
</div>
<div class="flex items-center space-x-2 rounded-b border-t border-gray-200 p-6 dark:border-gray-600">
<button
type="submit"
hx-on:click="htmx.trigger('body', 'crudChanged'); htmx.trigger('body', 'closeModal')"
class="rounded-lg bg-blue-700 px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
Add Item
</button>
<button
type="button"
class="rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-900 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:border-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-600"
hx-on:click="htmx.trigger('body', 'crudChanged'); htmx.trigger('body', 'closeModal')">
Cancel
</button>
</div>
</form>
</div>
Loading

0 comments on commit e5c60c3

Please sign in to comment.