Kunstmaan / KunstmaanBundlesCMS

An advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.
https://kunstmaancms.be
MIT License
402 stars 186 forks source link

Static Site Exporter for Kunstmaan CMS #1360

Closed Perni1984 closed 6 years ago

Perni1984 commented 7 years ago

I currently have the use case for one of my projects of exporting several Node Trees / Node Translations as static html sites. Does anyone know if there is already a bundle available for that, or @KunstmaanTeam and all others what would be your approach of implementing this in a bundle? Eventually I am planning to release a bundle on this feature.

jverdeyen commented 7 years ago

@Perni1984 And the HTTP Cache - Symfony Reverse Proxy isn't an option? http://symfony.com/doc/current/http_cache.html#symfony2-reverse-proxy

Or do you really need exported files?

Perni1984 commented 7 years ago

@jverdeyen: I really need static html files for my use case.

Perni1984 commented 7 years ago

Basically what my project is doing is using a heavily modified version of Kunstmaan CMS to generate static website packages (html files, precompiled css, js, font, image files) that can be easily deployed and hosted on a static web server environment.

mlebkowski commented 7 years ago

@Perni1984, yeah, this is a great feature. I wanted to do this on one of my websites, since it has no interactive functions. I ended up launching a small heroku app hidden behind a heavy-caching CDN, but it would be way better for me to push it all to a S3 bucket!

Look at the NodeSearchBundle — the indexer basically does the same thing — renders each NodeTranslation and uses the result string. It shouldn’t be that difficult to dump to HTML files.

Please share if you come up with something. BTW, is there any place to share kunstmaan-related bundles? Maybe we could have a separate documentation page for this? Or Kunstmaan/AwesomeKunstmaan repository? :D We have some bundles published at @syzygypl that can be useful to other people.

sandergo90 commented 7 years ago

Hi !

@Devolicious has written a solution for this for one of our projects I thought?

Perni1984 commented 7 years ago

@Devolicious: That would be perfect. If you are able to share that, I could also offer help to integrate your code into a separate bundle, if that would be interesting for you.

Devolicious commented 7 years ago

@Perni1984, it was a basic wget crawler via bash. So not really something to put into a bundle :) If you want I can throw it into a gist.

Perni1984 commented 7 years ago

@Devolicious @mlebkowski

Thanks for the tips - in the end the start was quite easy, I ended up using something like the following:

            $renderer = $this->get('templating');

            $em = $this->getEntityManager();
            $node = $company->getRootNode();
            $nodeTranslation = $node->getNodeTranslation($request->getLocale());
            $page = $nodeTranslation->getRef($em);

            $content = $renderer->render(
                $page->getDefaultView(),
                array(
                    'locale' => $nodeTranslation->getLang(),
                    'page'   => $page,
                )
            );
            file_put_contents($exportDir.'/index.html', $content);

although there are still some things to figure out to have a complete bundle for static sites (e.g. css / javascript assets, etc.), this should be enough for a start.

aistis- commented 7 years ago

Would be nice to use Filesystem abstraction for static files dumping :)

Perni1984 commented 7 years ago

@aistis: thanks for the comment. This is just a working prototype to share for other that may face a similar problem. In fact I am using Gaufrette to do the heavy lifting.

mlebkowski commented 7 years ago

Hey all,

So in the last few days this happened: Kunstmaan Static Site Bundle.

I added some basic documentation and tested briefly on one of our websites and… it seems to be working! It is still an alpha version and a lot needs to be done I guess. Does this feel interesting to you? Would you like to use it, test it or contribute in any other way?

Perni1984 commented 7 years ago

@mlebkowski: Wow - great! For my current project the implementation is stable now already and kind of tailored to this one project - but I general I appreciate that there is a "bundle" solution for this. Thanks a lot for your efforts!