Open Jean-Baptiste-Lasselle opened 5 years ago
i'll probably use a streaming processing model like jacksons' in java for XMLand JSON, to parse the HTML in an event driven way, relyng on the "marks" left by the attributes data-omega-loader-href
and data-omega-loader-src
on tags. That way, we do only streaming on parsing HTML / XML (the mechnaism is extensible to MJML), instead of trying to remembervalues with such things as pmongo db, or even just a big JSON kept in RAM by NodeJS inside the os process context.
I found https://www.npmjs.com/package/parse5-sax-parser , which is both purposed specifically for HTML, not just XML (loike the one i'm currently using), and is a SAX style parser, based on event emission
Actors
Omega
Initial Context
$TEMPLATE_GIT_REPO_URI
an omega template repository simply is a git repo, containing only two files at its root :
{
templates : {
'template1' : { /* The unique omega repository id of your template */
title: 'A great starter template for our usual e-commerce customers websites ',
git_ssh: 'git://github.com:Jean-Baptiste-Lasselle/grapejs-server',
git_http: null /* should be used for BOTH http AND https starting uris of git repositories */
},
'template2' : { /* The unique omega repository id of your template */
title: "Our starter template for typical software product's github pages ",
git_ssh: 'git://github.com:Jean-Baptiste-Lasselle/grapejs-server',
git_http: null /* should be used for BOTH http AND https starting uris of git repositories */
}
} }
each pair a set of git repos, that the dev team guarantees they are compatible with omega
*
then :
How are signature checked?
So all in all a registry is something people give you a gaurantee about : "Yes this thing that I provide, does workk properly with that other thing"
private content in : https://gitlab.com/second-bureau/pegasus/recup
Some Refactoring will happen, so now i need tests before big moves. Tests are security for big plans.
So this issue is :
So Ok, Here i a little architecture/product roadmap :+1: , where i'll split server into multiple micro-services (having David Pageot's execellent presentation of K8S Istio in 2018 devoxx) :
service 1 (workspace persistence service) : he knows how to rebase
href
andsrc
attributes properly inside HTML streams. He gets the help of things like Parcel, that helps him test whether any nestested-nested-nested-nested frontend dependency is missing or broken. He knows too, how to do the exact same opposite thing :workspace/omega
folder, of the html file to load in editor. the path isworkspace/omega/path/to/the/page/file/to/load/nameoffile.html
workspace/omega/path/to/the/page/file/to/load/nameoffile.html
, and tansforms it before passing it back to the grapesjs client.href
andsrc
tag attribute in the HTML stream, service1 parses its value and, if the value starts with a double slash//
, or with one of the stringsftp://``ftps://
,htttp://
, andhtttps://
, then the value is not changed. In all other cases, the stringomega/
is prepended to the value. That is because Omega defines a static route to folderworkspace
.data-
prefixed, namelydata-omega-loader-src
(ordata-omega-loader-href
, in case it was href that was changed), which has a value , the old value of thesrc
orhref
attribute. Yeah. Great like that i can really easily unload, just have to get the old value and reset the attribute, plus removing thedata-omega-loader-{src, href}
, from the HTML, though it wouldn't hurt to leave it there...No we'll have to be able to persist it ti git, because it's dev, like we version the test classes with code, but we don't send the unit test classses to production, inside artefacts;GrapeJS
client, exactly to the StorageManager, and itsload
method, wich request the HTML from serveur, providing a file path, relative to theworkspace/omega
folder.workspace/omega
folder, as a treeview. Then the user clicks on an HTML file, and then only the GrapesJS omponent is initialized in the page. Like I could insert it with jQuery.. I'll do that first, and see if the iitialload
method of the Storage MAnager is stilll called, while I injet the editor with jQueryworkspace/omega
folder. To do that, service 1 gets the HTML from the GrapesJS client, more accurately from my implementation of theGrapesJS Editor Storage Manager
, as a JSON Object containing two strngs,style
andhtml
, basically the edited content.html
string, to restore thehref
andsrc
tag attributes values to what they were before the loading the HTML to theGrapesJS
Editor. Only then the "cleared' HTML is persisted back to the file it came from inworkspace/omega/some/sub/folder
. Thestyle
string is appended to a file (created if does not exist) namedworkpsace/omega/some/sub/folder/omega-editon.css
, and its<link href="omega-edition.css" ref="style">
is added inside the HTML page.About that structure, see for example :
My
GrapesJS
Storage ManagerOn the official GrapsJS documentation, You wll read in the Storage Manager guide :
What you have to understand here, is that the HTML the
GrapesJs
editor user is working on, is what the GrapesJS author calls The Canvas. And that the canvas is all set by three properties, namelyhtml
,css
,style
. I know it because I tested it my self, wih release 0.0.x, x being 1, 2, 3 4, 5, 6, and 7.With seven things, I end up here , deciding that I will develop my own implementation of a "Storage Manager", and that it will send a request to a backend REST API (API that I will implement too), request with a JSON object
That REST API endpoint will be service 1, it will know how to persist a template modification persistance request, sent with a JSON Object as the payload to persist. The edited HTML/CSS will be persisted :
workspace/omega
folder, the HTML originally came from.omega-edition.css
file, persisting thestyle
string