Manol Posted May 2, 2013 Share Posted May 2, 2013 Hello everybody. I have generated same json data following this link, and I would like to: Save it under myfile.json into the assets folder. Read it from javascript. It belongs to a project to get information about some monuments in a town (images, lat, lng, text, accesibility, etc) probably many people would use it at the same time. Information is static, it will be changed rarely, so I tought about generating the info about each monument in a single json file that way is no need to generate that information every time by the server or worrying about cache. After that a use jquerymobile and angularjs to read the json file and present it to a mobile device. I will appreciate any help. Regards. Link to comment Share on other sites More sharing options...
ryan Posted May 3, 2013 Share Posted May 3, 2013 I think this sounds like a fine approach, though would be more inclined to generate it dynamically. Assuming the JSON is originally generated from ProcessWire, having it generated dynamically is going to give you more flexibility and make it easier to update. Having a dynamic request cached is basically the same thing as having a static file. You could cache it with MarkupCache, the built-in template cache, or ProCache. On the other hand, if the data really is static, then you don't need ProcessWire to generate it or serve it, as you could just upload a JSON file to a page and be done with it. 1 Link to comment Share on other sites More sharing options...
Manol Posted May 4, 2013 Author Share Posted May 4, 2013 Hello Ryan. I was developing this project with nodejs and backbone, at that time I discovered processwire, and it became an open door to take a different approach. Processwire allowed me the administrator to fill in the various fields, upload images, sounds, texts, etc for each monument in a really easy way, but for mobile users trying to get audios and images for certain monument concurrently is a best idea to let a nodejs server do the job instead of apache. This is the reason for generating json files for each monument indicating where all stuff such audios and images can be found. Maybe I'm wrong with this aproach, I´ll share the results here for anybody who could be interested. Link to comment Share on other sites More sharing options...
ryan Posted May 7, 2013 Share Posted May 7, 2013 That makes sense to me. Seems like a good approach. Link to comment Share on other sites More sharing options...
bfncs Posted May 11, 2013 Share Posted May 11, 2013 What you're doing there sounds interesting. Are you going to have Processwire itself online then or will you copy the created JSON files to be delivered by your node server? In the first case, you might try whether it isn't already sufficient to employ site caching to archive your desired performance. In the latter case you might install Processwire locally, make proper JSON templates for your data as if you wanted to just normally display them and build an index with links to all of your JSON files. Afterwards you can use a website scraper (Wget with the recursive option would be sufficient) to generate all your content, save it and copy it to your node server afterwards. You might even use some toolset (Cronjobs or the likes) that automatically transports your files to the server. The other possibility would be to write a Processwire module ("Static website exporter") that iterates the trees, renders each page with it's proper template and saves it to some folder on disk. You will probably have to deal with saving the export state and using some extent of asynchronous building to not run in a PHP timeout. You might even go crazy and build a small PHP CLI application, that includes Pw and does everything with a shell command. If you're really planning not to regenerate the files very often, I would definitely go with the second method because what you will have to do is a one-liner on your console. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now