Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data Liberation][Huge PR] Git client, static files editor #2118

Draft
wants to merge 14 commits into
base: trunk
Choose a base branch
from

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Jan 9, 2025

This is a rebased version of #2109 to be sliced into smaller chunks. The PRs I've carved out of this one so far:

Adds a basic WP_HTML_To_Blocks class that accepts HTML and outputs block markup.

It only considers the markup and won't consider any visual changes introduced via CSS or JavaScript.

A part of #1894

 ## Example

```html
$html = <<<HTML
<meta name="post_title" content="My first post">
<p>Hello <b>world</b>!</p>
HTML;

$converter = new WP_HTML_To_Blocks( $html );
$converter->convert();

var_dump( $converter->get_all_metadata() );
/*
 * array( 'post_title' => array( 'My first post' ) )
 */

var_dump( $converter->get_block_markup() );
/*
 * <!-- wp:paragraph -->
 * <p>Hello <b>world</b>!</p>
 * <!-- /wp:paragraph -->
 */
```

 ## Testing instructions

This PR mostly adds new code. Just confirm the unit tests pass in CI.
Builds data-liberation-markdown.phar.gz (200KB) to enable downloading
the
Markdown importer only when needed instead of on every page load.

A part of:

* #2080
* #1894

 ## Testing instructions

Run `nx build playground-data-liberation-markdown`, confirm it finished
without errors. A smoke test of the built phar file is included in the
build command.
…tory

Experimental static page editing workflow and blocks -> markdown converter

Improve conversion to markdown

Unit test the directory reader commit the missing files

Split out WP_Filesystem_To_Post_Hierarchy to enable turning each file into a stream of entities

Remove the unimplemented get_reentrancy_cursor method

Use a generic WP_Block_Markup_Entity_Reader for sourcing entities from disk files

Adjust the used array heys

Save data to the original static file path

Rewrite Blocks to Markdown

Two way Blocks <-> Markdown conversion pipeline

Early concept of synchronizing page saves to local files

Propagate WP Admin changes to the local disk directory

Document a bunch of todos

Adjust docstrings

Remount NODEFS and other mounts after hotswapPhpRuntime is called

Preserve the /internal directory when hotSwapPhpRuntime is called

Test with 4 mounts

Local files browser in the post editor

Add Editor UI and hooks to synchronize WordPress pages to local files

Implement Git sparse checkout in PHP

Plug in WP_Git_Filesystem to directly browse and edit the static files from a git repo

Prototype git push

Put all pack-related methods in WP_Git_Pack_Processor

WP_Git_Filesystem that can read and write files from a Git repo

Tweak new file creation and metadata loading

Add specific exception for renaming directories

Support renaming and deleting files

Tweak the user experience of the file picker. Enable drag&drop

Replace recursive props with a context

Enable file uploading by drag&drop

Enable deleting file subtrees

Dsplay directories before files, use a more useful default commit
message

Display a visually consistent selection in the Local Files tab without a
visible split between the file name and the ellipsis menu

Use the vertical three dots icon for "more"

CSS tweaks

CSS tweaks

Restrict the local files tab to the list view sidebar

WP_Git_Client: Use AsyncHttp\Client for HTTP requests

Fix disappearing editor, add post loading overlay

Add WP_Git_Cached_Index that stores objects in a local directory

Expand WP_Git_Cached_Index to support more operations and commits

Streaming git read, ability to compute objects newly added in a commit

Implement git pull and push

Rename Git_Cached_Index to Git_Repository ane enable remote management

Support user.name and user.email git settings and auto push mode in the filesystem

Use serialize_blocks to store custom blocks in markdown

Resolve minor papercuts to enable using the plugin with git

Store auto-saves on the disk

Improve Blocks/Markdown conversion

Implement reparent, squash, amend

Send autosaves as commit amends

Drag and drop from the editor to desktop

Preview static files

Only force pull at most once every 10 minutes, exclude .autosaves from the files browser

Reduce waiting in the UI – server provides each page's ID, the editor reuses that ID while it can

Import attachments on boot and on upload

Suport UTF-8 filenames in download_file_endpoint

Rewrite WordPress URLs to relative URLs when serializing to markdown

Preserve images as blocks

Upload media files to the static files filesystem

Use the correct paths in wp_handle_upload

Delete files when backspace is pressed

Store updated media files when they're, e.g., rotated

Media files preview

Derive WP_Block_Markup_Processor from WP_HTML_Tag_Processor, not WP_HTML_Processor, to avoid bailing on unsupported structures

Preserve the correct last href in Blocks -> Markdown conversion

Don't explicitly force pull after writes

Rudimentary commit diffing and text diffing

Clarify a TODO comment

Implement three way merge

Support for the HTML format and changing file extensions

Start implementing a git server

Parse Git Client messages

Add unit tests

Functional fetch support

Implement git push in WP_Git_Server

Remove debug comment

Add TODO

git fetch WordPress pages

Add readme for the git repo plugin

Add a todo

git push to update content

When fetching, fetch all the relevant objects without leaving out any

Comment out the failure in find_objects_added_in

Handle content deletions in the git endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

1 participant