Compare commits
2 Commits
5c74c2e667
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e98f9ad2d9 | |||
| c1ffbc3f3a |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
_agent-data/
|
_agent-data/
|
||||||
|
.claude/
|
||||||
|
|||||||
50
deploy.ps1
50
deploy.ps1
@@ -11,7 +11,8 @@ $TARGET = "S:\7-Infrastructure\lib\plugins\luxtools"
|
|||||||
$DRY_RUN = $false
|
$DRY_RUN = $false
|
||||||
$DELETE = $true
|
$DELETE = $true
|
||||||
|
|
||||||
function Resolve-PathUsingExistingCase {
|
function Resolve-PathUsingExistingCase
|
||||||
|
{
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Path
|
[string]$Path
|
||||||
@@ -20,7 +21,8 @@ function Resolve-PathUsingExistingCase {
|
|||||||
$fullPath = [System.IO.Path]::GetFullPath($Path)
|
$fullPath = [System.IO.Path]::GetFullPath($Path)
|
||||||
$root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\')
|
$root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\')
|
||||||
|
|
||||||
if ($fullPath.TrimEnd('\\') -ieq $root) {
|
if ($fullPath.TrimEnd('\\') -ieq $root)
|
||||||
|
{
|
||||||
return $root
|
return $root
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,12 +30,14 @@ function Resolve-PathUsingExistingCase {
|
|||||||
$leaf = Split-Path -Path $fullPath -Leaf
|
$leaf = Split-Path -Path $fullPath -Leaf
|
||||||
$resolvedParent = Resolve-PathUsingExistingCase -Path $parent
|
$resolvedParent = Resolve-PathUsingExistingCase -Path $parent
|
||||||
|
|
||||||
if (Test-Path -LiteralPath $resolvedParent) {
|
if (Test-Path -LiteralPath $resolvedParent)
|
||||||
|
{
|
||||||
$match = Get-ChildItem -LiteralPath $resolvedParent -Force -ErrorAction SilentlyContinue |
|
$match = Get-ChildItem -LiteralPath $resolvedParent -Force -ErrorAction SilentlyContinue |
|
||||||
Where-Object { $_.Name -ieq $leaf } |
|
Where-Object { $_.Name -ieq $leaf } |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
|
|
||||||
if ($null -ne $match) {
|
if ($null -ne $match)
|
||||||
|
{
|
||||||
return (Join-Path -Path $resolvedParent -ChildPath $match.Name)
|
return (Join-Path -Path $resolvedParent -ChildPath $match.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,18 +45,22 @@ function Resolve-PathUsingExistingCase {
|
|||||||
return (Join-Path -Path $resolvedParent -ChildPath $leaf)
|
return (Join-Path -Path $resolvedParent -ChildPath $leaf)
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($arg in $args) {
|
foreach ($arg in $args)
|
||||||
if ($arg -eq "--dry-run" -or $arg -eq "-n") {
|
{
|
||||||
|
if ($arg -eq "--dry-run" -or $arg -eq "-n")
|
||||||
|
{
|
||||||
$DRY_RUN = $true
|
$DRY_RUN = $true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($arg -eq "--no-delete") {
|
if ($arg -eq "--no-delete")
|
||||||
|
{
|
||||||
$DELETE = $false
|
$DELETE = $false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($arg -eq "-h" -or $arg -eq "--help") {
|
if ($arg -eq "-h" -or $arg -eq "--help")
|
||||||
|
{
|
||||||
Get-Content $PSCommandPath
|
Get-Content $PSCommandPath
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -65,7 +73,8 @@ $TARGET = Resolve-PathUsingExistingCase -Path $TARGET
|
|||||||
$SRC_DIR = $PSScriptRoot
|
$SRC_DIR = $PSScriptRoot
|
||||||
|
|
||||||
# Safety checks: make sure source looks like luxtools plugin
|
# Safety checks: make sure source looks like luxtools plugin
|
||||||
if (-not (Test-Path "$SRC_DIR/plugin.info.txt")) {
|
if (-not (Test-Path "$SRC_DIR/plugin.info.txt"))
|
||||||
|
{
|
||||||
Write-Error "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)."
|
Write-Error "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -75,11 +84,14 @@ New-Item -ItemType Directory -Force -Path "$TARGET" | Out-Null
|
|||||||
|
|
||||||
# Safety check: refuse to deploy to an obviously wrong directory.
|
# Safety check: refuse to deploy to an obviously wrong directory.
|
||||||
# Allow empty dir (fresh install) OR existing luxtools plugin dir.
|
# Allow empty dir (fresh install) OR existing luxtools plugin dir.
|
||||||
if (Test-Path "$TARGET/plugin.info.txt") {
|
if (Test-Path "$TARGET/plugin.info.txt")
|
||||||
|
{
|
||||||
$content = Get-Content "$TARGET/plugin.info.txt" -ErrorAction SilentlyContinue
|
$content = Get-Content "$TARGET/plugin.info.txt" -ErrorAction SilentlyContinue
|
||||||
if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+") {
|
if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+")
|
||||||
|
{
|
||||||
# It's a luxtools plugin, allow it
|
# It's a luxtools plugin, allow it
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
Write-Error "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools."
|
Write-Error "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools."
|
||||||
Write-Error "Refusing to deploy."
|
Write-Error "Refusing to deploy."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -92,6 +104,8 @@ $EXCLUDE_DIRS = @(
|
|||||||
"_agent-data",
|
"_agent-data",
|
||||||
".github",
|
".github",
|
||||||
".vscode",
|
".vscode",
|
||||||
|
".zed",
|
||||||
|
".claude",
|
||||||
"_test"
|
"_test"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,21 +135,25 @@ $ROBOCOPY_ARGS = @(
|
|||||||
"/Z" # restartable mode
|
"/Z" # restartable mode
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($EXCLUDE_DIRS.Count -gt 0) {
|
if ($EXCLUDE_DIRS.Count -gt 0)
|
||||||
|
{
|
||||||
$ROBOCOPY_ARGS += "/XD"
|
$ROBOCOPY_ARGS += "/XD"
|
||||||
$ROBOCOPY_ARGS += $EXCLUDE_DIRS
|
$ROBOCOPY_ARGS += $EXCLUDE_DIRS
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($EXCLUDE_FILES.Count -gt 0) {
|
if ($EXCLUDE_FILES.Count -gt 0)
|
||||||
|
{
|
||||||
$ROBOCOPY_ARGS += "/XF"
|
$ROBOCOPY_ARGS += "/XF"
|
||||||
$ROBOCOPY_ARGS += $EXCLUDE_FILES
|
$ROBOCOPY_ARGS += $EXCLUDE_FILES
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DRY_RUN) {
|
if ($DRY_RUN)
|
||||||
|
{
|
||||||
$ROBOCOPY_ARGS += "/L" # list mode
|
$ROBOCOPY_ARGS += "/L" # list mode
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DELETE) {
|
if ($DELETE)
|
||||||
|
{
|
||||||
$ROBOCOPY_ARGS += "/MIR" # mirror
|
$ROBOCOPY_ARGS += "/MIR" # mirror
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ RSYNC_ARGS=(
|
|||||||
--exclude=_agent-data/
|
--exclude=_agent-data/
|
||||||
--exclude=.github/
|
--exclude=.github/
|
||||||
--exclude=.vscode/
|
--exclude=.vscode/
|
||||||
|
--exclude=.zed/
|
||||||
|
--exclude=.claude/
|
||||||
--exclude=_test/
|
--exclude=_test/
|
||||||
--exclude=deleted.files
|
--exclude=deleted.files
|
||||||
--exclude=*.swp
|
--exclude=*.swp
|
||||||
|
|||||||
@@ -51,19 +51,33 @@
|
|||||||
|
|
||||||
function getCalendarStateKey(calendar) {
|
function getCalendarStateKey(calendar) {
|
||||||
var baseNs = calendar.getAttribute('data-base-ns') || 'chronological';
|
var baseNs = calendar.getAttribute('data-base-ns') || 'chronological';
|
||||||
return 'luxtools.calendar.month.' + baseNs;
|
return 'luxtools_calendar_month_' + baseNs.replace(/[^a-zA-Z0-9]/g, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldPersistCalendarMonth(calendar) {
|
function shouldPersistCalendarMonth(calendar) {
|
||||||
return (calendar.getAttribute('data-luxtools-size') || 'large') === 'small';
|
return (calendar.getAttribute('data-luxtools-size') || 'large') === 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCookieValue(name) {
|
||||||
|
var match = document.cookie.match('(^|;)\\s*' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*=\\s*([^;]+)');
|
||||||
|
return match ? decodeURIComponent(match[2]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCookie(name, value) {
|
||||||
|
var date = new Date();
|
||||||
|
date.setFullYear(date.getFullYear() + 1);
|
||||||
|
document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + date.toUTCString() + '; path=/; SameSite=Lax';
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCookie(name) {
|
||||||
|
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax';
|
||||||
|
}
|
||||||
|
|
||||||
function readSavedCalendarMonth(calendar) {
|
function readSavedCalendarMonth(calendar) {
|
||||||
if (!shouldPersistCalendarMonth(calendar)) return null;
|
if (!shouldPersistCalendarMonth(calendar)) return null;
|
||||||
if (!window.localStorage) return null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var raw = window.localStorage.getItem(getCalendarStateKey(calendar));
|
var raw = getCookieValue(getCalendarStateKey(calendar));
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
|
|
||||||
var parsed = JSON.parse(raw);
|
var parsed = JSON.parse(raw);
|
||||||
@@ -79,31 +93,17 @@
|
|||||||
|
|
||||||
function saveCalendarMonth(calendar) {
|
function saveCalendarMonth(calendar) {
|
||||||
if (!shouldPersistCalendarMonth(calendar)) return;
|
if (!shouldPersistCalendarMonth(calendar)) return;
|
||||||
if (!window.localStorage) return;
|
|
||||||
|
|
||||||
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
|
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
|
||||||
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
|
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
|
||||||
if (!year || month < 1 || month > 12) return;
|
if (!year || month < 1 || month > 12) return;
|
||||||
|
|
||||||
try {
|
setCookie(getCalendarStateKey(calendar), JSON.stringify({ year: year, month: month }));
|
||||||
window.localStorage.setItem(getCalendarStateKey(calendar), JSON.stringify({
|
|
||||||
year: year,
|
|
||||||
month: month
|
|
||||||
}));
|
|
||||||
} catch (e) {
|
|
||||||
// ignore storage failures
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSavedCalendarMonth(calendar) {
|
function clearSavedCalendarMonth(calendar) {
|
||||||
if (!shouldPersistCalendarMonth(calendar)) return;
|
if (!shouldPersistCalendarMonth(calendar)) return;
|
||||||
if (!window.localStorage) return;
|
deleteCookie(getCalendarStateKey(calendar));
|
||||||
|
|
||||||
try {
|
|
||||||
window.localStorage.removeItem(getCalendarStateKey(calendar));
|
|
||||||
} catch (e) {
|
|
||||||
// ignore storage failures
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchCalendarMonth(calendar, year, month) {
|
function fetchCalendarMonth(calendar, year, month) {
|
||||||
@@ -227,11 +227,22 @@
|
|||||||
|
|
||||||
function restoreCalendarMonth(calendar) {
|
function restoreCalendarMonth(calendar) {
|
||||||
if (!shouldPersistCalendarMonth(calendar)) return;
|
if (!shouldPersistCalendarMonth(calendar)) return;
|
||||||
var saved = readSavedCalendarMonth(calendar);
|
|
||||||
if (!saved) return;
|
|
||||||
|
|
||||||
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
|
var year = parseInt(calendar.getAttribute('data-current-year') || '', 10);
|
||||||
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
|
var month = parseInt(calendar.getAttribute('data-current-month') || '', 10);
|
||||||
|
if (!year || !month) return;
|
||||||
|
|
||||||
|
var saved = readSavedCalendarMonth(calendar);
|
||||||
|
if (!saved) {
|
||||||
|
var now = new Date();
|
||||||
|
var todayYear = now.getFullYear();
|
||||||
|
var todayMonth = now.getMonth() + 1;
|
||||||
|
if (year !== todayYear || month !== todayMonth) {
|
||||||
|
loadCalendarMonth(calendar, todayYear, todayMonth, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (saved.year === year && saved.month === month) return;
|
if (saved.year === year && saved.month === month) return;
|
||||||
|
|
||||||
loadCalendarMonth(calendar, saved.year, saved.month, true);
|
loadCalendarMonth(calendar, saved.year, saved.month, true);
|
||||||
@@ -258,7 +269,17 @@
|
|||||||
navigateCalendarMonth(calendar, direction, true);
|
navigateCalendarMonth(calendar, direction, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateClientDateCookie() {
|
||||||
|
var now = new Date();
|
||||||
|
setCookie('luxtools_client_month', JSON.stringify({
|
||||||
|
year: now.getFullYear(),
|
||||||
|
month: now.getMonth() + 1
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
function initCalendarWidgets() {
|
function initCalendarWidgets() {
|
||||||
|
updateClientDateCookie();
|
||||||
|
|
||||||
var calendars = document.querySelectorAll('div.luxtools-calendar[data-luxtools-calendar="1"]');
|
var calendars = document.querySelectorAll('div.luxtools-calendar[data-luxtools-calendar="1"]');
|
||||||
for (var i = 0; i < calendars.length; i++) {
|
for (var i = 0; i < calendars.length; i++) {
|
||||||
syncCalendarToday(calendars[i]);
|
syncCalendarToday(calendars[i]);
|
||||||
|
|||||||
@@ -91,6 +91,16 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
|
|||||||
$size = ChronologicalCalendarWidget::normalizeSize((string)($data['size'] ?? 'large'));
|
$size = ChronologicalCalendarWidget::normalizeSize((string)($data['size'] ?? 'large'));
|
||||||
$showTimes = (bool)($data['show_times'] ?? true);
|
$showTimes = (bool)($data['show_times'] ?? true);
|
||||||
|
|
||||||
|
if ($size === 'small') {
|
||||||
|
$resolved = $this->resolveMonthFromCookie(
|
||||||
|
'luxtools_calendar_month_' . preg_replace('/[^a-zA-Z0-9]/', '_', $baseNs)
|
||||||
|
) ?? $this->resolveMonthFromCookie('luxtools_client_month');
|
||||||
|
if ($resolved !== null) {
|
||||||
|
$year = $resolved['year'];
|
||||||
|
$month = $resolved['month'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$slots = CalendarSlot::loadEnabled($this);
|
$slots = CalendarSlot::loadEnabled($this);
|
||||||
$widgetSlots = CalendarSlot::filterWidgetVisible($slots);
|
$widgetSlots = CalendarSlot::filterWidgetVisible($slots);
|
||||||
$indicators = [];
|
$indicators = [];
|
||||||
@@ -122,6 +132,25 @@ class syntax_plugin_luxtools_calendar extends SyntaxPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $cookieName
|
||||||
|
* @return array{year:int,month:int}|null
|
||||||
|
*/
|
||||||
|
protected function resolveMonthFromCookie(string $cookieName): ?array
|
||||||
|
{
|
||||||
|
$raw = $_COOKIE[$cookieName] ?? null;
|
||||||
|
if ($raw === null) return null;
|
||||||
|
|
||||||
|
$decoded = json_decode($raw, true);
|
||||||
|
if (!is_array($decoded)) return null;
|
||||||
|
|
||||||
|
$year = (int)($decoded['year'] ?? 0);
|
||||||
|
$month = (int)($decoded['month'] ?? 0);
|
||||||
|
if ($year < 1 || $month < 1 || $month > 12) return null;
|
||||||
|
|
||||||
|
return ['year' => $year, 'month' => $month];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $flags
|
* @param string $flags
|
||||||
* @return array<string,string>
|
* @return array<string,string>
|
||||||
|
|||||||
Reference in New Issue
Block a user