Gordon Lesti - Magento 2 content under version control

49

Transcript of Gordon Lesti - Magento 2 content under version control

MAGENTO 2 CONTENTUNDER VERSION CONTROL

Gordon Lesti

• Student

• @GordonLesti

• gordonlesti.com

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Typical scenario

• content of a CMS page isn’t decoupled from styles

• content of a CMS page is large and confusing

• content manager tries to change a CMS page

• the layout is destroyed

• nobody knows why

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Possible solutions

Database backups

• hopefully one with the last stable content

• time consuming and complicated to restore

• has to be done by a developer

CMS pages under version control

• has every version of the content

• can be restored in seconds

• can be done by a content manager in the backend

Example - Wordpress

• it’s called revision

• every save creates a new rowin the database

• versions can be compared

• older versions can be restoredeasily

Is that possible with Magento 2?

ContentVersion

• Magento 2 content under version control

• https://github.com/GordonLesti/ContentVersion

• MIT License

ContentVersion

• Magento 2 content under version control

• https://github.com/GordonLesti/ContentVersion

• MIT License

ContentVersion

• Magento 2 content under version control

• https://github.com/GordonLesti/ContentVersion

• MIT License

ContentVersion

• Magento 2 content under version control

• https://github.com/GordonLesti/ContentVersion

• MIT License

Installation

• Add the repository to the repositories section of your composer.json file

"repositories": [

{

"type": "vcs",

"url": "[email protected]:GordonLesti/ContentVersion.git"

}

],

• Require the module and install

composer require lesti/module-content-version:dev-master

Example - ContentVersion

• creates version with eventcms page save after

• send Ajax request to compareversion x with y

• sebastian/diff compares xwith y

• send Ajax response with thediff back to client

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Possible feature plan

• version for more model properties• Title• ...

• version control for other models• CMS blocks• ...

• restore versions

• store the saving admin user

• save x last versions

Feel free to contribute!

How does diff algorithm work?

Different approaches for different purposes

• maximize matching lines

• maximize size of the biggest matching subsequence

• ...

How does diff algorithm work?

Different approaches for different purposes

• maximize matching lines

• maximize size of the biggest matching subsequence

• ...

How does diff algorithm work?

Different approaches for different purposes

• maximize matching lines

• maximize size of the biggest matching subsequence

• ...

How does diff algorithm work?

Different approaches for different purposes

• maximize matching lines

• maximize size of the biggest matching subsequence

• ...

Example - diff algorithm

from toM Me ee et tM Ma ag gn ee nt to o?

Create matrix from × to

For all i = {1, . . . , |from|} , j = {1, . . . , |to|}• ai ,j = max {ai−1,j−1, ai−1,j , ai ,j−1}• if fromi == toj and ai ,j == ai−1,j−1 then

ai ,j = ai ,j + 1

Create matrix from × to

For all i = {1, . . . , |from|} , j = {1, . . . , |to|}

• ai ,j = max {ai−1,j−1, ai−1,j , ai ,j−1}• if fromi == toj and ai ,j == ai−1,j−1 then

ai ,j = ai ,j + 1

Create matrix from × to

For all i = {1, . . . , |from|} , j = {1, . . . , |to|}• ai ,j = max {ai−1,j−1, ai−1,j , ai ,j−1}

• if fromi == toj and ai ,j == ai−1,j−1 thenai ,j = ai ,j + 1

Create matrix from × to

For all i = {1, . . . , |from|} , j = {1, . . . , |to|}• ai ,j = max {ai−1,j−1, ai−1,j , ai ,j−1}• if fromi == toj and ai ,j == ai−1,j−1 then

ai ,j = ai ,j + 1

M e e t M a g n e t o ?M 1 1 1 1 1 1 1 1 1 1 1 1e 1 2 2 2 2 2 2 2 2 2 2 2e 1 2 3 3 3 3 3 3 3 3 3 3t 1 2 3 4 4 4 4 4 4 4 4 4M 1 2 3 4 5 5 5 5 5 5 5 5a 1 2 3 4 5 6 6 6 6 6 6 6g 1 2 3 4 5 6 7 7 7 7 7 7e 1 2 3 4 5 6 7 7 8 8 8 8n 1 2 3 4 5 6 7 8 8 8 8 8t 1 2 3 4 5 6 7 8 8 9 9 9o 1 2 3 4 5 6 7 8 8 9 10 10

Find ADDs, REMOVE s and MATCHs

• start at ai ,j

• end at a1,1

• prefer maximum or diagonal if there is more than one maximum value

• every step• left is a ADD• top is a REMOVE• diagonal is a MATCH

for the current position

Find ADDs, REMOVE s and MATCHs

• start at ai ,j

• end at a1,1

• prefer maximum or diagonal if there is more than one maximum value

• every step• left is a ADD• top is a REMOVE• diagonal is a MATCH

for the current position

Find ADDs, REMOVE s and MATCHs

• start at ai ,j

• end at a1,1

• prefer maximum or diagonal if there is more than one maximum value

• every step• left is a ADD• top is a REMOVE• diagonal is a MATCH

for the current position

Find ADDs, REMOVE s and MATCHs

• start at ai ,j

• end at a1,1

• prefer maximum or diagonal if there is more than one maximum value

• every step• left is a ADD• top is a REMOVE• diagonal is a MATCH

for the current position

Find ADDs, REMOVE s and MATCHs

• start at ai ,j

• end at a1,1

• prefer maximum or diagonal if there is more than one maximum value

• every step• left is a ADD• top is a REMOVE• diagonal is a MATCH

for the current position

M e e t M a g n e t o ?M 1 1 1 1 1 1 1 1 1 1 1 1e 1 2 2 2 2 2 2 2 2 2 2 2e 1 2 3 3 3 3 3 3 3 3 3 3t 1 2 3 4 4 4 4 4 4 4 4 4M 1 2 3 4 5 5 5 5 5 5 5 5a 1 2 3 4 5 6 6 6 6 6 6 6g 1 2 3 4 5 6 7 7 7 7 7 7e 1 2 3 4 5 6 7 7 8 8 8 8n 1 2 3 4 5 6 7 8 8 8 8 8t 1 2 3 4 5 6 7 8 8 9 9 9o 1 2 3 4 5 6 7 8 8 9 10 10

Thanks for listening