Difference between revisions of "Summer of Code/2013/Social Sugar project/Documentation"
Axitkhurana (talk | contribs) (→Mini Profiles: Update docs with initial description) |
Axitkhurana (talk | contribs) (→Code: Add moksaya fork link) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
For identification of a user on a webservice such as Project Sharing Website, or Fedora pastebin, a unique id will be used. The API of the webservice should allow posting/fetching resources related to the user via this UID (and if required authentication credentials such as API token). | For identification of a user on a webservice such as Project Sharing Website, or Fedora pastebin, a unique id will be used. The API of the webservice should allow posting/fetching resources related to the user via this UID (and if required authentication credentials such as API token). | ||
− | Changes to Sugar | + | === Changes to Sugar === |
==== BuddyModel ==== | ==== BuddyModel ==== | ||
* Each Buddy used to have properties like nick, color and current activity | * Each Buddy used to have properties like nick, color and current activity | ||
− | * We add another property | + | * We add another property <code>social_ids</code> to the <code>BaseBuddyModel</code> which are populated initially from all webservice accounts. |
− | * social_ids is a dictionary of `service name`: `public id` pairs. E.g. {'gmoksaya': 'a454', 'gpaste': 'adsfq524325'} | + | * social_ids is a dictionary of `service name`: `public id` pairs. E.g.<code> {'gmoksaya': 'a454', 'gpaste': 'adsfq524325'}</code> |
* As are other properties like color, serialized social_ids are broadcasted to other online Sugar users via Telepathy. | * As are other properties like color, serialized social_ids are broadcasted to other online Sugar users via Telepathy. | ||
==== WebServices Account Interface ==== | ==== WebServices Account Interface ==== | ||
− | * Two new methods: | + | * Two new methods: <code>get_public_id()</code> and <code>get_latest_post()</code> are added to Account class. (webservice.account.Account) |
− | * | + | * <code>get_public_id</code> returns the public id associated with that account. |
** It is used to populate social_ids property initially | ** It is used to populate social_ids property initially | ||
** Public ids are used to fetch posts from the external webservice, e.g. latest project uploaded on Project Sharing Website. (This is implemented in the service specific extension.) | ** Public ids are used to fetch posts from the external webservice, e.g. latest project uploaded on Project Sharing Website. (This is implemented in the service specific extension.) | ||
− | * | + | * <code>get_latest_post</code> returns the latest post on the service. |
− | New Classes | + | === New Classes === |
==== WebServicePost ==== | ==== WebServicePost ==== | ||
− | * This is an abstract class for WebService posts returned by | + | * This is an abstract class for WebService posts returned by <code>get_latest_post</code> |
* Has unimplemented methods for title, message, image and hyperlink. | * Has unimplemented methods for title, message, image and hyperlink. | ||
+ | === UI additions === | ||
+ | All additions are in Group view. (F2) | ||
+ | |||
+ | ==== Small Cloud Icon ==== | ||
+ | * A small cloud shaped icon is displayed over your friend when you both have a social sugar extension installed. | ||
+ | * This icon can be clicked to view latest posts from web service account of your friend. | ||
+ | |||
+ | [[File:MiniprofileScreenshot.jpg|260 px|Small cloud icon in friends view.]] | ||
+ | |||
+ | ==== Large Cloud Icon ==== | ||
+ | * On clicking the small cloud icon, it expands to a larger cloud | ||
+ | * This Icon acts as a placeholder for the latest post from webservice. | ||
+ | * The cloud has a speech bubble like pointer to the buddy. | ||
+ | * The content on this icon: | ||
+ | ** is provided by fetching latest posts from all the webservice accounts of my friend. | ||
+ | ** is rotated after a fixed time to make the interface interactive and responsive. | ||
+ | ** can be paused using the pause icon for kids who can take longer to read a message. | ||
+ | ** can have a small icon (of the service) and upto 180 characters of text. | ||
+ | * Large cloud is closed by clicking on the cross (x) button which automatically suspends auto fetching/rotating of the latest posts. | ||
+ | |||
+ | [[File:MiniprofileScreenshot6.gif|260 px|Large cloud icon]] | ||
+ | |||
+ | ==== Technical details for the cloud content implementation ==== | ||
+ | * SmallCloudIcon inherits <code>sugar3.graphics.icon.CanvasIcon</code> which gives it the color matching that of the buddy. | ||
+ | * CloudContent is placed on top of the LargeCloudIcon using Gtk.Overlay | ||
+ | * LargeCloudIcon inherits <code>sugar3.graphics.icon.EventIcon</code> | ||
+ | * The button-release-event is bound to SmallCloudIcon, whose callback draws the Gtk.Overlay containing LargeCloudIcon and CloudContent. | ||
+ | * Cloud content consists of a VBox of service icon, a label and HBox containing close and pause icons. | ||
+ | |||
+ | |||
+ | === Sugar-GMoksaya === | ||
+ | |||
+ | Sugar-GMoksaya is a webservice extension which allows us to post journal projects to Moksaya, the Project Sharing Website. Addition of Mini Profile code allows us to view latest projects from our friends in Group View. | ||
+ | |||
+ | ==== Details ==== | ||
+ | |||
+ | * Moksaya needs username and api key for any request. Also, we need public id of the moksaya user to fetch latest projects. | ||
+ | ** We ask for username and password from the user in Settings > WebService. | ||
+ | ** These are used to fetch the api key and public id. | ||
+ | ** api key, username and public id are stored in GConf for future use. Passwords are not stored. | ||
+ | * Sharing is same as in webservice extension, from Journal > Copy to > GMoksaya | ||
+ | * If Gmoksaya account is also configured in your friends' Sugar, then they will send you their public ids. | ||
+ | * Our extension fetches latest post from friends account and keeps it in memory. | ||
+ | ** If the cloud is expanded, the latest post is displayed followed by <code>get_latest_post()</code> calls to other services and looping back to this service. | ||
+ | ** Powered by [https://github.com/axitkhurana/gmoksaya GMoksaya] and [https://github.com/axitkhurana/grestful gRESTful] | ||
+ | |||
+ | ==== Videos ==== | ||
+ | |||
+ | |||
+ | * <div class="NavFrame collapsed"><div class="NavHead">[http://www.youtube.com/watch?v=o0Svzqqintw Setup and sharing journal projects] </div><div class="NavContent">{{#widget:YouTube | ||
+ | |id=o0Svzqqintw | ||
+ | }}</div></div> | ||
+ | |||
+ | * <div class="NavFrame collapsed"><div class="NavHead">[http://www.youtube.com/watch?v=ANzPpFJkOjI View latest projects in Group View] </div><div class="NavContent">{{#widget:YouTube | ||
+ | |id=ANzPpFJkOjI | ||
+ | }}</div></div> | ||
+ | |||
+ | === Code === | ||
+ | social-sugar branch on: | ||
+ | |||
+ | * [https://github.com/axitkhurana/sugar Sugar] | ||
+ | * [https://github.com/axitkhurana/sugar-toolkit-gtk3 Sugar Toolkit GTK 3] | ||
+ | * [https://github.com/axitkhurana/sugar-artwork Sugar Artwork] | ||
+ | |||
+ | master branch on: | ||
+ | * [https://github.com/axitkhurana/sugar-gmoksaya Sugar GMoksaya] | ||
+ | |||
+ | (Requires [https://github.com/axitkhurana/moksaya moksaya] setup on local machine, social-sugar branch will use Rahul's deployed server making it easy to set up) | ||
=== Testing === | === Testing === |
Latest revision as of 11:06, 24 September 2013
Social Sugar
Social Sugar project involves development of GUI components that can help bring user's social interactions on external platforms into Sugar.
The first component we've are working on are the mini profiles.
Mini Profiles
Mini Profiles extend Web Service code adding minimal changes to the existing models to support social features such as fetching latest posts from multiple webservices and displaying it in Group View.
Detailed Description
For identification of a user on a webservice such as Project Sharing Website, or Fedora pastebin, a unique id will be used. The API of the webservice should allow posting/fetching resources related to the user via this UID (and if required authentication credentials such as API token).
Changes to Sugar
BuddyModel
- Each Buddy used to have properties like nick, color and current activity
- We add another property
social_ids
to theBaseBuddyModel
which are populated initially from all webservice accounts. - social_ids is a dictionary of `service name`: `public id` pairs. E.g.
{'gmoksaya': 'a454', 'gpaste': 'adsfq524325'}
- As are other properties like color, serialized social_ids are broadcasted to other online Sugar users via Telepathy.
WebServices Account Interface
- Two new methods:
get_public_id()
andget_latest_post()
are added to Account class. (webservice.account.Account) get_public_id
returns the public id associated with that account.- It is used to populate social_ids property initially
- Public ids are used to fetch posts from the external webservice, e.g. latest project uploaded on Project Sharing Website. (This is implemented in the service specific extension.)
get_latest_post
returns the latest post on the service.
New Classes
WebServicePost
- This is an abstract class for WebService posts returned by
get_latest_post
- Has unimplemented methods for title, message, image and hyperlink.
UI additions
All additions are in Group view. (F2)
Small Cloud Icon
- A small cloud shaped icon is displayed over your friend when you both have a social sugar extension installed.
- This icon can be clicked to view latest posts from web service account of your friend.
Large Cloud Icon
- On clicking the small cloud icon, it expands to a larger cloud
- This Icon acts as a placeholder for the latest post from webservice.
- The cloud has a speech bubble like pointer to the buddy.
- The content on this icon:
- is provided by fetching latest posts from all the webservice accounts of my friend.
- is rotated after a fixed time to make the interface interactive and responsive.
- can be paused using the pause icon for kids who can take longer to read a message.
- can have a small icon (of the service) and upto 180 characters of text.
- Large cloud is closed by clicking on the cross (x) button which automatically suspends auto fetching/rotating of the latest posts.
Technical details for the cloud content implementation
- SmallCloudIcon inherits
sugar3.graphics.icon.CanvasIcon
which gives it the color matching that of the buddy. - CloudContent is placed on top of the LargeCloudIcon using Gtk.Overlay
- LargeCloudIcon inherits
sugar3.graphics.icon.EventIcon
- The button-release-event is bound to SmallCloudIcon, whose callback draws the Gtk.Overlay containing LargeCloudIcon and CloudContent.
- Cloud content consists of a VBox of service icon, a label and HBox containing close and pause icons.
Sugar-GMoksaya
Sugar-GMoksaya is a webservice extension which allows us to post journal projects to Moksaya, the Project Sharing Website. Addition of Mini Profile code allows us to view latest projects from our friends in Group View.
Details
- Moksaya needs username and api key for any request. Also, we need public id of the moksaya user to fetch latest projects.
- We ask for username and password from the user in Settings > WebService.
- These are used to fetch the api key and public id.
- api key, username and public id are stored in GConf for future use. Passwords are not stored.
- Sharing is same as in webservice extension, from Journal > Copy to > GMoksaya
- If Gmoksaya account is also configured in your friends' Sugar, then they will send you their public ids.
- Our extension fetches latest post from friends account and keeps it in memory.
Videos
Code
social-sugar branch on:
master branch on:
(Requires moksaya setup on local machine, social-sugar branch will use Rahul's deployed server making it easy to set up)
Testing
You can test the current implementation by following these steps:
- Set up your Sugar development environment
- Clone the social-sugar branch from following repositories replacing the appropriate modules in your sugar-build code:
- Clone the contents of mock-service repository inside
~/.sugar/default
. You'll end up with the directory structure as shown below. - Build Sugar and add Akshit Khurana (or other people running the service) as a friend from the neighbourhood view(F1). You can use the search to find people.
- Checkout the Friend view(F2).
- Click on the small cloud icon over the buddy icon, to view my latest mock-post!
- You should see something like: "Designed from the ground up especially for children, Sugar offers an alternative to traditional "office-desktop" software. Id: 458" in a giant speech bubble like cloud.
- Congratulations! You've got mock service running on Mini Profiles.
Directory Structure
~/.sugar/default/extensions/webservice/ ├── __init__.py └── mock-service ├── __init__.py ├── account.py ├── mock-service │ ├── __init__.py │ └── mock-service.py └── icons └── mock-service.svg ~/.sugar/default/extensions/cpsection/ ├── __init__.py └── webaccount ├── __init__.py └── services ├── __init__.py └── mock-service ├── __init__.py └── service.py