Improved documentation for Loklak repos

Its the final week of GSoC 2016. All the projects are nearing their completion stage. Since one of the plugins from FOSSASIA (https://wordpress.org/plugins/tweets-widget/) is already in WordPress directory, I took this opportunity to write some documentation for other plugins and the plugin maintenance repo.

The documentation now verbosely describes the complete Heroku deployment procedure directly from Github as well as using the Git-Heroku toolbelt (see this).

Selection_023

Docs for updating to a newer version of WordPress have also been added.

Selection_022

Screenshots and relevant documentation regarding Loklak API was added to several plugins.

 

Selection_025
readme.txt of https://github.com/fossasia/wp-recent-tweet

Some screenshots of the plugin (wp-recent-tweet) added in the readme

Selection_026

Improved documentation for Loklak repos

Setting up plugins for test!

I spent most of this summer working on wordpress plugins. So when we were up with a substantial amount, we wanted to test them online. I discussed in a previous blog-post regarding putting an online wordpress implementation through Heroku. Once I was done with internal testing, the plugins were supposed to be released for common testing. Now, since we did not want to risk our service, we couldn’t provide admin rights to new users. So in order to overcome this problem I had the following options at my disposal:

  1. Create a script which would automatically activate and configure all plugins and show a basic plugin interface to users who are not logged in; OR
  2. Create a user with lesser privileges than administrator, but enough to view and modify plugin settings.

The problem with the first approach was its static nature. A user would not be able to test your service if he is not leveraged with all options your program provides. So, in order to ensure rigorous testing, I used the second approach.

WordPress, by default, provides 5 user-types:

  1. Administrator
  2. Editor
  3. Author
  4. Contributor
  5. Subscriber

As none of these user profiles fit the required job specification, I had to create my own user-type. After some brainstorming and searching, I found a pretty useful WordPress plugin (User Role Editor) which creates custom user profiles based on actions already present in WP suite. Once I installed the plugin on our WP installation, I used following steps to create my own user-profile called Loklak Tester. 

  • Click on ‘Users’ menu and then click on ‘User Role Editor’.

Selection_010

  • Here I selected the privileges I wanted for my user. Some of them are shown in the figure.

Selection_009

  • Once I was done, I clicked on Add Role and provided the required user-type name.
  • Below screenshot shows the menu for our new user-profile ‘Loklak Tester’.

Selection_011

Creation of this new user-profile would allow users to login using its credentials. Activate/deactivate, modify, edit plugins and change their settings. This would later act as a demo testing user which could be used by our audience to test our plugins on variety of levels.

Setting up plugins for test!

Improving Code Coverage for Loklak PHP API

Tests


This week, I added tests for suggest, map, markdown, push and susi APIs and fixed tests for user topology related queries. PHPUnit was used as the testing framework since it provides code-coverage support.

Loklak PHP API now has a good test-suite support and associated examples to help you use our services

Below are the Tests that were added.

testPushto test Push API.Selection_001

testSusito test newly added Susi API. Selection_003

Refer to this and this for more info about Susi

testMap – to test map API.

testMarkdown – to test markdown API.Selection_002

For more detailed information regarding the entire Loklak PHP API test-suite, refer to this.

In above process, code-coverage was increased from 33% to 61%. Test-suite continuously updated as new APIs are added to Loklak.

Source support for Search API


Apart from that, since Loklak is scaling beyond Twitter. Source argument has been added to the search API to define the source of search results. As far as wordpress plugins are concerned, since they only require twitter results for now, source has been added as a default argument. See below code: Selection_004

Improving Code Coverage for Loklak PHP API

Using Heroku-WordPress Buildpack to test Loklak integration in WordPress plugins

Loklak support was added to several wordpress plugins this summer. In order to properly handle and structure further development in this area, a common repository has been created to host the incumbent plugins. Please refer to this repository. To ensure rigorous testing in the internet environment, all plugins have been installed (loklak_wordpress_plugins/wp-content/plugins) in a sample WordPress site deployed on Heroku.

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.

Heroku provides several buildpacks for different deployment patterns. After careful research I found a useful WordPress+Heroku buildpack here. To create your own wordpress instance to test the plugins follow the below instructions:

Deploy from github directly:

  1. Click on Deploy to Heroku button in the Readme file of your fork of loklak_wordpress_plugins repo. This step would install wordpress on Heroku and setup your database.
  2. Give your website a name and input your time-zone and add authentication information for .htpasswd to access wp-admin page (admin privileges). See the screenshot below. blog2_1
  3. Click on Deploy for Free. Once the app is deployed, Click on ‘Manage App’. Go to ‘Deploy’ tab and choose ‘Deployment method’ as Github
  4. Connect your forked loklak_wordpress_plugins repo to Heroku. blog2_2
  5. To automate the deployment process when the github repo is updated, enable automatic deploys. Now deploy the master branch of your repo and you are good to go. blog2_3

Deploy using Heroku Toolbelt:

To deploy using Heroku-git toolbelt, please refer to this.

After we are done with the deployment, we need to setup our plugins for using and testing:

  1. Follow the steps to install WordPress (as they appear on your computer screen) on your chosen app/domain name.
  2. Once WP is installed, change the language, time-zone and preferred date-time format in ‘general settings’.blog2_4
  3. Now you can activate plugins from ‘plugins’ as per your need and test their functionality!blog2_5
Using Heroku-WordPress Buildpack to test Loklak integration in WordPress plugins