-
Notifications
You must be signed in to change notification settings - Fork 504
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
let the backend serve the template metadata #76
Comments
I thought about this, but I didn't implement it because I didn't want people to think this was needed in a generic backend in order to use mosaico. Mosaico library simply use the link to a single template and doesn't know anything about "list of master templates" (this is something part of the "demo" index.html+editor.html+localstorage). If we change index to rely to a similar backend call then we probably have to change any sample backend to do this (we have the bundled nodejs, the opensource php backend and I know one user developed a .NET backend and another is working on a ruby backend..). I don't think people uses "index.html" in their production environment for mosaico embedded. So, I'm not sure this change, alone, is a step forward: maybe combined with other stuff (like loading/saving the contents to the backend) this can belong to an "extension" that enhance mosaico to do that, but in the mean time it sounds easier to ask people to change the index.html to list the templates they want to use. Any other user out there have comments about this? |
For the time being, this is my problem, that I do not want to go for my "own" index.html now, but want to add tutorial without changing index.html. So for people playing around it would be easier if they can simply add their template. And if the backend does not support "/templates" it would yield a 404 which could be captured by index.html and fall back. But the the bundled nodejs could provide this. You are right, if we could go that step that bundled nodejs also support to save to backend, it would be much easier to see how a production environment could be built. |
If this is only about development then this could be done in grunt task during build time: you could write a grunt task that scan the template folder and create the json you say and then the index could include that static json from the "dist" folder (or maybe index.html could be changed and copied to dist with the full computed json)... |
You can even try to run "editor.html#pathtoyourtemplate" instead of using a key... it should load your template by using the path in the hashtag (that's how I was used to run mosaico in my dev-days before I implemented the localstorage demo). |
One thing that may not be "clear" is that mosaico is able to use templates from any url. |
I tried it. Editor comes up but no save / test / download buttons. I will try further ... Nevertheless, I understand now why you do not want the minimal backend to serve the templates. |
that's because of current localstorage plugin that depends on the key to save/load things: this could be changed so that when it detect an url it automatically create a new entry in the localstorage and then redirect to it.. but it currently doesn't do this... BTW template has been added to the index. |
Thank you, just came home and saw this. the entire plugin thing is a book with 7 seals to me. I find What makes a plugin a plugin? is it the location of a js file, is it a particular api? To be honest my JS skills are more or less not existing :-) I can read code but am not aware of the patterns. I come from Ruby-Land (btw. Sooner or later I will use Opalrb to embed mosaico in production). |
I would like to modify backend.js and index.html such that it retrieves the templates from the backend. This would allow to install templates simply by copying the same to the template folder. The hardcoded templates in the ViewModel would then be a fallback.
It would be easy but the template does not know its description as
one option would be that in the folder for a template I add a file called manifest.json which would be:
based on this, a get-request for /templates would yield the
Any opinion on this?
The text was updated successfully, but these errors were encountered: