Skip to content

Commit

Permalink
merge branch v2 (release 2.0.0-alpha.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcantondahmen committed Oct 13, 2024
2 parents 6c60739 + 550fa5d commit 774d205
Show file tree
Hide file tree
Showing 34 changed files with 285 additions and 56 deletions.
35 changes: 21 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# Changelog

## [v2.0.0-alpha.6](https://github.com/marcantondahmen/automad/commit/2f32588222c4829ca3fad8009d9093949f48360d)
## [v2.0.0-alpha.7](https://github.com/marcantondahmen/automad/commit/5ecf43618492a8260e3f5e06dbbe513537a912cc)

Sun, 15 Sep 2024 19:28:10 +0200
Sun, 13 Oct 2024 20:51:29 +0200

### New Features

- add disk usage monitoring ([bd6495852](https://github.com/marcantondahmen/automad/commit/bd64958529e5fbb7251c7b77ff189310af9593bd))
- add option to define a disk quota ([de39719aa](https://github.com/marcantondahmen/automad/commit/de39719aacb7e84e5ec6377e4cc37cf96b8c9838))
- add option to filter the list of allowed packages ([b525156b2](https://github.com/marcantondahmen/automad/commit/b525156b2d49b327e70188ae1c6145904d57a7bc))
- deduplicate form submissions ([a6ded4e63](https://github.com/marcantondahmen/automad/commit/a6ded4e639f1f0b6dddda26e172891e5ae84b0c6))
- improve naming of resized images in cache ([075b45fec](https://github.com/marcantondahmen/automad/commit/075b45fec5a02cc56b1eb12964d8f9d6a591b095))

### Bugfixes

- **blocks**: fix pasting and merging blocks ([c811131f9](https://github.com/marcantondahmen/automad/commit/c811131f9da6edb333f51c3495f46829be044739))
- **ui**: fix visibility of sidebar items on medium size devices ([de2e6fe40](https://github.com/marcantondahmen/automad/commit/de2e6fe402b2ce2801a2ba4bd632c38d16640fe7))
- fix dashboard redirections when saving pages the are aliases for the home page ([4cb37fd55](https://github.com/marcantondahmen/automad/commit/4cb37fd55757558c8666eb2886e08952ed0e7c6a))
- fix wrong file overwriting errors when editing page and shared data ([1e4903f09](https://github.com/marcantondahmen/automad/commit/1e4903f09af54c900f876da84a60d3bcca6a44eb))

## [v2.0.0-alpha.6](https://github.com/marcantondahmen/automad/commit/6c607392b3fe02b202790bd496e109089525367b)

Sun, 15 Sep 2024 19:37:00 +0200

### New Features

Expand Down Expand Up @@ -333,15 +352,3 @@ Thu, 12 Aug 2021 22:24:51 +0200

- **ui**: fix typo in text modules ([ba8702a87](https://github.com/marcantondahmen/automad/commit/ba8702a87d26afd0172294d541c1573925f77f56))
- **ui**: fix updating links that are wrapped in quotes ([4417468d6](https://github.com/marcantondahmen/automad/commit/4417468d659c1e71e9b76698e377a19a1e209b5a))

## [v1.8.3](https://github.com/marcantondahmen/automad/commit/aa72e82f0192571f5ae1a8b032720fd9b3fb8645)

Mon, 9 Aug 2021 23:21:36 +0200

### New Features

- **core**: use a shortened md5 hash as directory slug in case a sanitized title is too short ([d6d5e57cd](https://github.com/marcantondahmen/automad/commit/d6d5e57cd663bcf0eed7c8697b7b454fac1064fb))

### Bugfixes

- **ui**: fix updating links to images that belong to the page they are used on ([723a6be37](https://github.com/marcantondahmen/automad/commit/723a6be37fb283fdcd42a5a365e6089509a25139))
1 change: 1 addition & 0 deletions automad/lang/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"deteledSuccess": "Successfully removed",
"disable": "Disable",
"discardImageChanges": "Are you sure you want to close the editor without saving changes to the image?",
"diskQuotaExceeded": "The disk quota is exceeded. Please free up some space before adding new content.",
"documentation": "Documentation",
"downloadFile": "Download",
"dropFilesOrClick": "Drop files here or click to browse",
Expand Down
2 changes: 1 addition & 1 deletion automad/src/client/admin/components/File/Upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class UploadComponent extends BaseComponent {
message = message.error;
}

notifyError(html`${message}:<br />$${file.name}`);
notifyError(html`${message}`);
}

/**
Expand Down
52 changes: 50 additions & 2 deletions automad/src/client/admin/components/Forms/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ import {
query,
queryAll,
requestAPI,
create,
} from '@/admin/core';
import { InputElement, KeyValueMap } from '@/admin/types';
import {
DeduplicationSettings,
InputElement,
KeyValueMap,
} from '@/admin/types';
import { BaseComponent } from '@/admin/components/Base';
import { ModalComponent } from '@/admin/components/Modal/Modal';
import { SubmitComponent } from './Submit';
Expand Down Expand Up @@ -100,6 +103,21 @@ export class FormComponent extends BaseComponent {
*/
additionalData: KeyValueMap = {};

/**
* Cache the last submitted form data in order to identify duplicate submissions.
*/
lastSubmittedFormData: KeyValueMap = {};

/**
* The deduplication settings for the form.
*/
protected get deduplicationSettings(): DeduplicationSettings {
return {
getFormData: null,
enabled: false,
};
}

/**
* Allow parallel requests.
*/
Expand Down Expand Up @@ -235,6 +253,32 @@ export class FormComponent extends BaseComponent {
}
}

/**
* Optionally test for duplicate form submissions.
*
* @return boolean
*/
isDuplicateSubmission(): boolean {
if (!this.deduplicationSettings.enabled) {
return false;
}

const data = this.deduplicationSettings.getFormData(this);

if (
Object.keys(data).length &&
JSON.stringify(data) === JSON.stringify(this.lastSubmittedFormData)
) {
getLogger().log('Form data has not changed');

return true;
}

this.lastSubmittedFormData = data;

return false;
}

/**
* Submit the form.
*
Expand All @@ -250,6 +294,10 @@ export class FormComponent extends BaseComponent {
}
}

if (this.isDuplicateSubmission()) {
return;
}

const lockId = App.addNavigationLock();

this.submitButtons.forEach((button) => {
Expand Down
18 changes: 18 additions & 0 deletions automad/src/client/admin/components/Forms/PageDataForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/

import {
DeduplicationSettings,
FieldSectionCollection,
FieldSectionName,
KeyValueMap,
Expand All @@ -44,6 +45,7 @@ import {
App,
Attr,
Binding,
collectFieldData,
create,
createCustomizationFields,
createField,
Expand Down Expand Up @@ -95,6 +97,22 @@ const createBindings = (response: KeyValueMap): PageBindings => {
* @extends FormComponent
*/
export class PageDataFormComponent extends FormComponent {
/**
* The deduplication settings for the form.
*/
protected get deduplicationSettings(): DeduplicationSettings {
return {
getFormData: (element) => {
const data = collectFieldData(element);

data.dataFetchTime = null;

return data;
},
enabled: true,
};
}

/**
* The section collection object.
*/
Expand Down
18 changes: 18 additions & 0 deletions automad/src/client/admin/components/Forms/SharedDataForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
App,
Attr,
Binding,
collectFieldData,
create,
createCustomizationFields,
createField,
Expand All @@ -48,6 +49,7 @@ import {
prepareFieldGroups,
} from '@/admin/core';
import {
DeduplicationSettings,
FieldSectionCollection,
FieldSectionName,
KeyValueMap,
Expand Down Expand Up @@ -80,6 +82,22 @@ const createBindings = (response: KeyValueMap): SharedBindings => {
* @extends FormComponent
*/
export class SharedDataFormComponent extends FormComponent {
/**
* The deduplication settings for the form.
*/
protected get deduplicationSettings(): DeduplicationSettings {
return {
getFormData: (element) => {
const data = collectFieldData(element);

data.dataFetchTime = null;

return data;
},
enabled: true,
};
}

/**
* The section collection object.
*/
Expand Down
4 changes: 4 additions & 0 deletions automad/src/client/admin/components/Home/ServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class ServerInfoComponent extends BaseComponent {
<td>Memory Limit</td>
<td>${data.memoryLimit}</td>
</tr>
<tr>
<td>Disk Usage</td>
<td>${data.diskUsage}M / ${data.diskQuota}M</td>
</tr>
</table>
`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const dashboardLayout = ({ main }: Partials) => {
></am-nav-item>
</nav>
<am-nav-tree></am-nav-tree>
<div class="${CSS.nav} ${CSS.displaySmall}">
<div class="${CSS.nav} ${CSS.displayMedium}">
<span class="${CSS.navItem}">
<am-modal-toggle
class="${CSS.navLink}"
Expand Down
1 change: 0 additions & 1 deletion automad/src/client/admin/core/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
listen,
query,
queryAll,
Section,
titleCase,
} from '.';
import {
Expand Down
12 changes: 7 additions & 5 deletions automad/src/client/admin/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,14 @@ class PendingRequests {
static remove() {
const spinner = query('am-spinner');

this.count--;
setTimeout(() => {
this.count--;

if (this.idle && spinner) {
spinner.remove();
}
if (this.idle && spinner) {
spinner.remove();
}

fire(this.EVENT_NAME);
fire(this.EVENT_NAME);
}, 0);
}
}
17 changes: 8 additions & 9 deletions automad/src/client/admin/editor/blocks/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@

import { App, create, CSS, html, query } from '@/admin/core';
import { HeaderBlockData } from '@/admin/types';
import {
HTMLPasteEvent,
TunesMenuConfig,
} from 'automad-editorjs/types/tools';
import { HTMLPasteEvent, TunesMenuConfig } from 'automad-editorjs/types/tools';
import { BaseBlock } from './BaseBlock';

export class HeaderBlock extends BaseBlock<HeaderBlockData> {
Expand Down Expand Up @@ -176,12 +173,14 @@ export class HeaderBlock extends BaseBlock<HeaderBlockData> {
* @param data
*/
merge(data: HeaderBlockData): void {
const newData = {
text: this.data.text + data.text,
level: this.data.level,
};
const div = query('[contenteditable]', this.wrapper);
const index = this.api.blocks.getBlockIndex(this.blockAPI.id);

div.innerHTML = `${div.innerHTML}${data.text}`;

this.data = newData;
setTimeout(() => {
this.api.caret.setToBlock(index, 'end');
}, 100);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions automad/src/client/admin/editor/blocks/NestedList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ export class NestedListBlock extends NestedList {
},
];
}

/**
* Merge two lists.
*
* @param data
*/
merge(data: { items: any[] }) {
// @ts-ignore
this.appendItems(data.items, this.nodes.wrapper);
}
}
17 changes: 10 additions & 7 deletions automad/src/client/admin/editor/blocks/Paragraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class ParagraphBlock extends BaseBlock<ParagraphBlockData> {
}

/**
* The content of the header.
* The content of the paragraph.
*
* @return the innerHTML
*/
Expand Down Expand Up @@ -187,12 +187,14 @@ export class ParagraphBlock extends BaseBlock<ParagraphBlockData> {
* @param data
*/
merge(data: ParagraphBlockData): void {
const newData = {
text: this.data.text + data.text,
large: this.data.large,
};
const div = query('[contenteditable]', this.wrapper);
const index = this.api.blocks.getBlockIndex(this.blockAPI.id);

div.innerHTML = `${div.innerHTML}${data.text}`;

this.data = newData;
setTimeout(() => {
this.api.caret.setToBlock(index, 'end');
}, 100);
}

/**
Expand All @@ -216,6 +218,7 @@ export class ParagraphBlock extends BaseBlock<ParagraphBlockData> {
large: false,
};

this.data = data;
const div = query('[contenteditable]', this.wrapper);
div.innerHTML = data.text;
}
}
1 change: 0 additions & 1 deletion automad/src/client/admin/mockup/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<span class="am-c-navbar__group">
<span class="am-c-navbar__item" am-tooltip="A system update is available">
<i class="bi bi-download"></i>
<span class="am-e-badge"></span>
</span>
<span class="am-c-navbar__item" am-tooltip="Debugging is enabled"><i class="bi bi-bug"></i></span>
<span class="am-c-navbar__item"><i class="bi bi-three-dots"></i></span>
Expand Down
5 changes: 5 additions & 0 deletions automad/src/client/admin/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export interface BindingOptions {

export type CodeLanguage = (typeof supportedLanguages)[number];

export interface DeduplicationSettings {
getFormData: (element: HTMLElement) => KeyValueMap;
enabled: boolean;
}

export interface Image {
name: string;
thumbnail: string;
Expand Down
8 changes: 7 additions & 1 deletion automad/src/server/API/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function __construct() {
Debug::log('Instanciated new Response instance');

$this->setCode(200);
$this->time = time();
}

/**
Expand All @@ -110,6 +109,13 @@ public function __construct() {
* @return string the json encoded array of response properties
*/
public function json(): string {
// Note that the response time should be set just before returning it
// since longer running requests involving file operations require the
// precise point in time at the moment of returning the response.
// This is particulary true for testing aginst the filemtime of page data
// files based on response times.
$this->time = time();

$properties = array_filter(get_object_vars($this));

return json_encode($properties, JSON_UNESCAPED_SLASHES);
Expand Down
Loading

0 comments on commit 774d205

Please sign in to comment.