Sync data for offline usage with Wordpress and Ionic - wordpress

I am trying to build and app that sync the posts from wordpress ( data is highly dynamic and can cross 100-500 mb ) to ionic app which uses sqlite. At the same time download all assets to local. I developed an working code that does this. But I have problems to keep things in sync like check for changed posts, assets, etc. Also I have problem to keep track of deleted posts and stuff.
I am looking for alternates say like a library or some other alternate concepts that can help me keep that data in sync add, delete, update as it happens in server (need not be realtime).
Please do provide me some suggestions or ideas that I can try

Related

Generate site when headless cms modifies database

I've been reading about how nuxt can generate a static site when a client makes a request to view the website. We are planning to build a headless cms to migrate the database with the data the website needs. This data will only be changed when you save it in the headless cms.
My question is since this data will only change when it is changed in the headless cms. Isn't it possible to just generate the site when it is modified from the headless cms, and then serve that site to the client? To reduce server costs.
Is it possible to do this with nuxt? Or are there any possibilities to do this?
We are planning on using Firebase as a backend.
There's nothing explicitly preventing Nuxt from being rebuilt each time you change an item in your DB. The part that matters is how you tell your app to rebuild itself.
By far the simplest way is using some sort of "build hook". See Netlifys docs here for a quick overview of what they are. However, this only really works if you're using a headless CMS that can send hooks on save, and a build provider that can trigger builds using those hooks.
You will absolutely save on server costs using this sort of method, but beware: if you have a lot of user generated content triggering builds, your build cost can easily outweigh the server costs. You also need to be aware that builds generally take a few minutes, so you won't see instant changes on your site.
The other option you have is foregoing static site generation in favour of SSR, which can dynamically load and render your content, completely avoiding the need to build every time a new DB change is made. This is what I'd consider the best alternative if you do indeed have a lot of user generated content.
It's hard to give any further advice without knowing the specifics of the CMS or build provider though.

Large Meteor applications taking too much time for initial loading

I am working on Meteor app(e-commerce site), became very large. It almost takes 9secs to view static part of homepage till then it only shows white/blank screen. After that it starts showing data from DB(mongoDB). The whole site with data takes ~24secs to come at client side. I think the whole bundle is too much huge and that is why it takes more time to download. And it is causing 9secs of white screen. Any solution guys. Thanks in advance!
Alraedy Tried:
1. Fast Render(Flowrouter subscriptions) package
2. Appcache package
3. Query Optimization/Indexing
4. Removed global subscriptions
5. Sending minimal data via pub/sub
6. this.unblock() for publications
7. Not saving files in DB instead saving url's
You are working on an e-commerce website and so you might have a huge admin module bundled with your website. You should consider building the admin module as a separate Meteor app sharing the same Mongo DB collections with the e-commerce website. You can reduce the size of you app considerably using this approach. You can find more details here
You should also be really careful about your subscriptions and use pagination on the server side publications, subscribing to only what data is actually required
For starters, try to remove unused packages which aren't used anymore by any frontend code. Check your entire package.json and all imports.
Reduce the size of all you subscriptions, you probably have tons of them with entire or too big documents, which is easy while developing, but an overkill in production. Try to limit the fields and the amount of loaded objects to what you visualise for the user.
Don't wait for all subscriptions to finsih loading before showing something, load the website and it's design already, but only show a 'loading' icon on the parts that do require data to be shown dynamically.
Make sure your javascript is minified before it's published, this saves a lot of bandwidth.
After implementing these your load times should have decreased.
Providing a detailed network analytic from the debugger of your browser might also help to notcie problems.

IONIC2 Building a custom audio streaming app with firebase

I was thinking of making an app which plays a specific set of small audio files stored away in a firebase database, or any other database on the cloud.
The number of files may exceed hundreds, so wrapping all the files in the app might not be the best of ideas.
I'd really like to know how to go about this problem.
Downloading only the required file from firebase when it's clicked and playing as its being downloaded all the while caching it for future playback seems plausible, but I'm not quite sure how to implement it.
I'd appreciate a few pointers towards this, thanks
Yes. You are thinking in the right direction.
You might use these things.
App UI - Ionic2 will provide you a very nice and easy to implement platform to create a UI. Please refer this documentation for the basics and details about using Ionic2.
Local Storage - You can use this to store downloaded files. In any app where data is relatively large, using local storage is the smart choice. This helps you reducing the size of the initial app to be installed and download the content as and when needed.
A well defined database - Now, whether to use non-structured (No-SQL) or structured (SQL) is the first choice you have to make.
If it's just content - audio files download and play with no complex cross querying the database, then you can choose to use non-structured (No-SQL) database like Firebase database.
But, if you have good requirements for structuring data, query it with constraints like "Give me all the audio files list where a particular user has played it in last 10 days" or "Give me all the users who has played/downloaded a particular audio file more than 10 times" and so on, then you better use structured (SQL) database like PostgreSQL.
RxJS - Now, this might not be very important to do, but, if you use this from the start, it's a good choice. Advantages are, e.g. you might not have to wait for all the file to get downloaded before playing it. Use Observables and Promises for such a mechanism.
Could help with the specifics when needed. Hope this helps. :)

Handling Git Deployment (WordPress)

So, like most of you, I develop my sites locally using MAMP. I've recently been learning git and in doing so, preparing to drop FTP from my workflow completely.
Though, I was wondering if there's a best practice for handling WordPress' databases.
Currently I'm only using version control on my current theme, but would like to expand this into controlling the whole site locally and pushing it to the server accordingly. That means making changes to files, adding posts/pages and generally mucking around with the whole site, keeping both local and remote site in sync. Is this possible?
I've read tons of guides over the past week, and followed countless tutorials, so any help would be appreciated.
Thanks in advance!
This is not really feasible, git is for file changes, not for your database. Due to how WordPress stores data in the database you cannot sync content without custom scripting (bash, ruby, etc) aka... jumping through hoops.
You can dump your database file using cron and throw it into git, but again you cannot sync the files due to how WordPress stores values.
This has been asked on https://wordpress.stackexchange.com/

Wordpress pages and version control

We are a software development company and are using Wordpress for static portion of the web site. Naturally, all our workflow is built around version control: multiple developers -> continious integration -> staging -> deployment.
Our challenge with integrating Wordpress into our workflow is that its database is stuck like a bone in the throat: you cannot put it into the version control, easily roll back, promote from staging to production etc.
I am wondering what people do in similar situations? I would like to find a way to integrate WP into the development workflow and not the other way around :-)
Clarification we want to "develop" and test pages on the staging system and when ready then move them over to the production as part of the version upgrade process. We don't want to do full replication of the staging database to production.
That's a common question and one that I've worked on tackling. I've written some code to address these issues albeit the code's not ready for distribution. Basically the idea is to create scripts to import the content and then version control the scripts. (Actually my approach uses a custom import/export format designed to be easy to hand-modify, but the idea is similar.)
Anyway, there are some related questions over on StackOverflow's sister site WordPress Answers:
Questions tagged with the term [staging]
Questions tagged with the term [deploy]
UPDATE
Per the clarification, this would probably be helpful too:
Is there any way to draft a revision of a published page or post? What workarounds have you used?
Hope this helps.
-Mike
I've just hit the same problem. For now we are using MySQL dump files to export/import database content, but it gets ugly with several people working on the database changes.
Since the team that works on the project is all internal and consists of just a few people, I'm thinking into the direction of locking the database dump file in VCS. Subversion had this functionality built-in, but we are using git, which, I think, is conceptually opposite of any kind of locking.
Probably we'll have a workaround script with pre-commit hook to check for the existence of a lock file next to the dump. The person who committed the lock file will be the only one allowed to commit the dump. Once he finishes the work, he will need to commit the removal of the lock file.
It sounds ugly, I know. But I've thought about it for a while and don't see an elegant solution yet.
If you're only using WordPress for static content, then any tool/methodology for version controlling databases should work - for example, work the mysql command line tools into your CI and deployment routines.

Resources