GSOC 2014 – 07/07 Update

Hello everyone! I’m Arian, a Computer Science student, one of the students accepted in the Google Summer of Code Program. This is my 5th update, and you can view my other posts here.

This week I’ve added the API for Glotpress profiles. This basically allows the profile data to be used by other web applications.

The profile data can be accessed at //glotpressurl.tld/api/profile/profile-nicename. Let’s break up an example response when querying my username:

{
  "meta": {
    "user_display_name": "Secretmapper",
    "user_is_admin": true,
    "user_registered": "2014-05-05 03:00:29"
  },
  "total_strings": 123,
  "project_contrib_count": 14,
  "locale_data": {
    "Bulgarian": 116,
    "Afar": 4,
    "Akan": 3
  },
  "permissions": [
    
  ],
  "recent_actions": [
    {
      "set_name": "Rosetta | Bulgarian",
      "project_url": "\/projects\/rosetta\/bg\/default",
      "project_id": "7",
      "set_id": "13",
      "human_time": "3 days",
      "date_added": "2014-07-04 07:28:53",
      "count": 55
    },
    {
      "set_name": "Sample | Akan",
      "project_url": "\/projects\/sample\/ak\/default",
      "project_id": "1",
      "set_id": "25",
      "human_time": "1 week",
      "date_added": "2014-06-26 03:50:14",
      "count": 3
    },
    {
      "set_name": "Rosetta | Forums | Bulgarian\u00a0\u2192\u00a0ForumBulg",
      "project_url": "\/projects\/rosetta\/forums\/bg\/forumbulg",
      "project_id": "8",
      "set_id": "15",
      "human_time": "1 week",
      "date_added": "2014-06-26 03:49:55",
      "count": 2
    },
    {
      "set_name": "Sample | Sample 1 | Bulgarian",
      "project_url": "\/projects\/sample\/sample-1\/bg\/default",
      "project_id": "2",
      "set_id": "3",
      "human_time": "1 week",
      "date_added": "2014-06-26 03:08:15",
      "count": "3"
    },
    {
      "set_name": "Sample | Bulgarian\u00a0\u2192\u00a0My Translation",
      "project_url": "\/projects\/sample\/bg\/my",
      "project_id": "1",
      "set_id": "1",
      "human_time": "1 week",
      "date_added": "2014-06-25 15:29:24",
      "count": "33"
    }
  ]
}

Let’s break this data up quickly:

  "meta": {
    "user_display_name": "Secretmapper",
    "user_is_admin": true,
    "user_registered": "2014-05-05 03:00:29"
  },

A Meta subobject contains basic user properties.

  "total_strings": 123,
  "project_contrib_count": 14,
  "locale_data": {
    "Bulgarian": 116,
    "Afar": 4,
    "Akan": 3
  },

Then we have some aggregate properties like total strings and contributed project count.

locale_data on the other hand, is an object that maps locale names to the number of corresponding contributions of the user. So for example, we see here that I’ve contributed 116 strings to Bulgarian projects, 4 to Afar, and 3 to Akan.

"permissions": [
  
],

An array containing of translation sets the user approves. In this particular case there are no translation sets the user explicitly approves (note though that this user can, being an admin – admin users have blank permissions array in the API)

 "recent_actions": [
    {
      "set_name": "Rosetta | Bulgarian",
      "project_url": "\/projects\/rosetta\/bg\/default",
      "project_id": "7",
      "set_id": "13",
      "human_time": "3 days",
      "date_added": "2014-07-04 07:28:53",
      "count": 55
    },
    {
      "set_name": "Sample | Akan",
      "project_url": "\/projects\/sample\/ak\/default",
      "project_id": "1",
      "set_id": "25",
      "human_time": "1 week",
      "date_added": "2014-06-26 03:50:14",
      "count": 3
    },
    ...
  ]

A Recent Actions Array contains sets the user has recently contributed to, accompanied by corresponding metadata.

The API allows selective querying (i.e., ?filter=meta), enabling users to get only the data they need.

The creation of a public profile API allows for fancy stuff such as WordPress Widgets that queries recent actions of a user. Here it is in action on the default WordPress theme:

ss (2014-07-04 at 03.44.58)

Thanks and Ciao~!