Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Modification for the working of social-help activity. #391

Closed
wants to merge 13 commits into from

Conversation

Projects
None yet
4 participants
@prasoon2211
Copy link
Contributor

commented Jul 29, 2014

This PR introduces the changes required in sugar for the functioning of the social-help activity. The changes are self explanatory and I'm adding a few comments (GitHub ones) in the diiff to explain some of the things.

This PR is a submission to one of the GSoC 2014 sugarlabs projects.

PS: I still have to run pep8 and pyflakes on all files.

@@ -152,6 +152,11 @@
<summary>Publish to Gadget</summary>
<description>If TRUE, Sugar will make us searchable for the other users of the Jabber server.</description>
</key>
<key name="social-help-server" type="s">
<default>'54.187.40.150'</default>

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 29, 2014

Author Contributor

We'll need to change this to the global sugarlabs discourse server, once it's up.

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

You should talk to Bernie or @walterbender about setting up an A record to point help.sugarlabs.org to that IP. Setting up a DNS record now would mean we could switch over to the sugarlabs server just by changing a DNS record, eaiser then changing sugar.

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

It's actually just a micro ec2 instance that I'm running for testing and it's not meant to be used in production. I've already emailed Paul about setting up a discourse server and he had me talk to Matthew Ciao about the usage requirements. I've passed them on - I was told that this will be discussed in a meeting and a decision will be reached. I guess that's yet to be done. @samdroid-apps @walterbender


return 0


This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 29, 2014

Author Contributor

This file has changes regarding the added setting (for the server URL) in the cpanel.

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

Why are you writing deprecated code?

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

Actually, there's this other option in the cpanel about the jabber server and it was using this deprecated code also and so I assumed that unless I use it too, something might break - you know, backward compatibility issues and as such. If it doesn't break anything, we can remove it.

This comment has been minimized.

Copy link
@godiard

godiard Jul 30, 2014

Member

You should use GSettings instead of GConf. The GConf code used in Sugar are things still not ported.

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 31, 2014

Author Contributor

Okay then. I've already used GSettings and I'll remove the deprecated code.


self._validate()
return False

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 29, 2014

Author Contributor

This file adds the actual option for the server URL of the discourse server.

return False
else:
# Must be bool
return bool(ret)

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 29, 2014

Author Contributor

A dbus-callable method to delegate function calls across different modules. I've used it for a call between sugar-toolkit-gtk3 and sugar. This was suggested by Gonzalo and it solved a problem I was having closing the activity.

'org.laptop.physics': 'physics',
'org.laptop.Oficina': 'paint',
'org.sugarlabs.MusicKeyboard': 'music-keyboard'
}

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 29, 2014

Author Contributor

We'll need to add more mappings when we finally launch the discourse server.

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

Why don't we store the mappings on a json file on the server and use that file? That would allow us to add a new forum without requiring people to update sugar (happens about once a year).

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

The problem with that is this - we need to query this file whenever an activity is launched to determine whether to show the social-help launch button or not. Clearly, storage on the server is not an option in this case.

The other thing we can do is to show this launch button by default and then, when the button is clicked, we fetch the said json file and check the existence of the activity and launch the proper forum. However, I'll need to show a notification if the activity-category is absent and that's a problem that I wrote about on the mailing list. I need access to a the activity instance to show the notification - this I don't have. So, unless there is a method to display notifications without access to the activity instance, we have a problem.

Or maybe we can store this data in the .sugar directory? In that case, updating can be done by simply copying a file to the directory.

This comment has been minimized.

Copy link
@godiard

godiard Jul 30, 2014

Member

You can download the json file and check for a new version once in a day or similar.

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 31, 2014

Author Contributor

Here's what I'm thinking we should do: We'll have a json file on the server and our admins can update it. Also, well not check the presence of an activity category and we'll just show the launch button in every activity.

Now, when the user clicks the button (or presses the keyboard shortcut), we'll check the version of the existing json file in .sugar directory and if a newer version is available (which we'll determine by date), we'll first download and save that new version internally. Then, we can find out the category name from the json file and open the social-help activity to the URL. If say, we don't have a category for that activity, we can just show a 404-wiki page that displays information about the unavailable activity and options available to the user (like reporting to the admin). I think this is a pretty good scheme. What do you say @godiard ? I can code it up on this weekend.

This comment has been minimized.

Copy link
@godiard

godiard Jul 31, 2014

Member

We don't need check the json file every time. Store the last time you downloaded it, and use a configuration to define how many days until the next check. Other than that, I agree.

@prasoon2211 prasoon2211 changed the title Modification for the working of social-help activity. WIP: Modification for the working of social-help activity. Jul 29, 2014

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Jul 29, 2014

@walterbender Review this please and let me know what to change.

PS: I can't tell why tests are failing. I can't quite understand from the buildbot logs what's the reason. Some of it seems to be due to failing pep8 - that I'll change and push soon. If there's something else (which I suspect there is), please tell me.

return
try:
self._model.set_social(widget.get_text())
except self._model.ReadError, detail:

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

You should use as (better forward compatibility):

except ABC as xyz:

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

Okay. I'll change this.

"""
settings = Gio.Settings('org.sugarlabs.collaboration')
settings.set_string('social-help-server', server)

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

I think you should trim any http:// or trailing slash. Otherwise your code will fail later. For example, http://www.mySocialHelp.cf/ would become www.mySocialHelp.cf

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

Good point. Will do.

if social_server:
uri += social_server
else:
uri += FORUM_URL

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

Why do you need to set a default here? You already set a default in the gesettings.

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

In case someone makes the cpanel setting as blank.

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 30, 2014

Member

Wouldn't it be better to deal with that in the cpanel instead of every time you use that URL?

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 31, 2014

Author Contributor

I suppose. Okay, then - I'll make sure that the field cannot be left blank in the cpanel and is reset to the default URL.

try:
uri += '/category/' + ACTIVITY_CATEGORY_MAP[activity_bundle_id]
except KeyError:
logging.error('Key Error: Map not found for activity')

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Jul 29, 2014

Member

You fail silently here! Why don't you just pop up the window with a message like "There is no form for this activity"? Maybe put a page like that on your server.

This comment has been minimized.

Copy link
@prasoon2211

prasoon2211 Jul 30, 2014

Author Contributor

Actually, I wrote about this problem in the mailing list (https://www.mail-archive.com/sugar-devel%40lists.sugarlabs.org/msg37842.html). Simply put, here's what we're doing now:

  • Don't display the launch button if the activity doesn't have a category.
  • If keyboard shortcut is pressed in such an activity, do nothing - just as sugar-help does.

I don't have an activity instance do show the notification and that's my problem. Unless there's some method around this, I'm at a loss. Though maybe making a wiki page on the server about the absence of the category might be a good idea instead of the notifications.

This comment has been minimized.

Copy link
@godiard

godiard Jul 30, 2014

Member

True. Showing a message in the server have another advantage: we can get statistics in the server about what activities are requested, and add them.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Jul 29, 2014

Hi. This looks really cool, I will test it!

I've been reading your code and it looks pretty good! Could you please split it into separate commits (I am being a hypocrite I know)? Maybe:

  • added config panel item
  • added popup window
  • added keyboard shortcut

Also I have 2 questions:

  • Maybe this needs its own config panel item? (@manuq?)
  • Is there a social help item under the activity menu (in the frame)?
@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Jul 30, 2014

Oh, I see where the menu item is now 😄. Sorry.

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2014

@samdroid-apps @godiard : I've incorporated all the suggestions. If this PR's good, I can submit a PR to sugar-build as well.

Also, please check the PR in sugar-toolkit-gtk3.

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2014

@godiard @walterbender Review this please. Google's soft pencils down date is near (11th Aug)
Also, I can't tell from the buildbot logs, why this test is failing. Can you guys help me here?

Also, this needs review, too : sugarlabs/sugar-toolkit-gtk3#156

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 6, 2014

Hi @prasoon2211,

I've had a look at the code and I have 2 main things:

  • Please display a progress bar while downloading the json data file - not all sugar users have fast internet so some indication of progress stops them from thinking that it has crashed. Use jarabe.util.downloader to download in the background so you can do progress reports (look at the updater for usage and the code for the progress signal)
  • Don't just redirect people to a "activity not found form" - that leaves no logging data on the server of what activities people want. You could write a little server that takes a request to /activity_not_found/bundle.id, logs that bundle id and redirects the user to the activity not found form. (If that's not clear enough I can try to explain more).

Looks good,
Sam

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2014

@samdroid-apps Thanks for the input. I've just started work on this and hopefully, I can finish it today. I'll push the work as soon as I'm finished.

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2014

@samdroid-apps Hey again. I've integrated the downloader in the code. I need to know a few things though:

  1. How do I make the downloader show up as a progress bar? I suppose we can use Gtk.ProgressBar for this.

  2. For using the progress bar, I need a progress amount. I can't see how to get that from the Downloader class...

  3. Even if we have a working Gtk.ProgressBar, we'll still need to 'put' (or append it) somewhere for it to show (just like a notification). How does this work? I had a long discussion with tch on the IRC for this and all we could come up with was a viewsource like window to put it in. Any better suggestions? Example code would help a lot!

Also, for the activity bundle logging, we'll need to keep the logger page on the discourse server itself (since we want localization support). So, I'll probably need to add a view to discourse - which in turn means that I'll have to fiddle with Ruby and ROR. I have little to no idea of either one of those so it might be a bit difficult but I should be able to do it. We can have a json file to store the category names and number of times people tried to access social help for the corresponding activities.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 7, 2014

Hi

On Aug 8, 2014 12:54 AM, "Prasoon Shukla" notifications@github.com wrote:

@samdroid-apps Hey again. I've integrated the downloader in the code. I
need to know a few things though:

  1. How do I make the downloader show up as a progress bar? I suppose we
    can use Gtk.ProgressBar for this.

Yep

  1. For using the progress bar, I need a progress amount. I can't see how
    to get that from the Downloader class...

It has a progress signal which provides decimal numbers (eg. 0.5 means half
download).

def listener(dl, progress):
     # do something
dl.connect('progress', listener)
  1. Even if we have a working Gtk.ProgressBar, we'll still need to 'put'
    (or append it) somewhere for it to show (just like a notification). How
    does this work? I had a long discussion with tch on the IRC for this and
    all we could come up with was a viewsource like window to put it in. Any
    better suggestions? Example code would help a lot!

Why don't you move all the downloading to the actual activity (out of sugar
shell). That way you could just put the progress bar where the web view
goes.

Also, for the activity bundle logging, we'll need to keep the logger page
on the discourse server itself (since we want localization support). So,
I'll probably need to add a view to discourse - which in turn means that
I'll have to fiddle with Ruby and ROR. I have little to no idea of either
one of those so it might be a bit difficult but I should be able to do it.
We can have a json file to store the category names and number of times
people tried to access social help for the corresponding activities.

No, it doesn't have to be that complex: you have a SEPARATE logging server
that logs and then use a http redirect to your form. I will try and make
you something like this tonight (your avo).

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 9, 2014

Hey,

I just wrote one of those servers I was talking about: https://gist.github.com/SAMdroid-apps/8d527279594e8f35492b

I aslo thought; instead of downloading all the JSON and stuff why don't we extend this redirector so the social help thing just sends a request to the redirector and gets redirected to either the right form or has the bundle id logged and goes to the error page?

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 9, 2014

Yes, that idea appeals a lot to me. However, there is this problem of needing a separate server - I talked about it in the last comment. How do we circumvent the problem of needing a new server in a far-flung, not-connected-to-the-internet place? I suppose we can run it on a fixed port on the same machine...

Btw, nice stuff with Go :) I was just reading Go the other day and it seems really nice. Besides, deploying this server would be really easy, I should think.

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 11, 2014

@samdroid-apps : Hey. I've made the changes to work with shfr. I changed the port to 8000; most others are blocked in my uni. We can change this when a time for release comes up.

activity_id = activityfactory.create_activity_id()
bundle = bundleregistry.get_registry().\
get_bundle(SOCIAL_ACTIVITY_BUNDLE_ID)
uri = "http://%s:%s/goto/%s" % (social_server, PORT, activity_bundle_id)

This comment has been minimized.

Copy link
@samdroid-apps

samdroid-apps Aug 11, 2014

Member

Don't hard code in the port:

  • firewalls
  • people want sub domains
  • 8000 is a common port - conflicts on some servers
@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 11, 2014

It looks great! I will test tonight.

You need to fix your commit structure. First remove these 2 commits (the changes will remain):

git reset HEAD^
git reset HEAD^

Then use git add and git commit to break it down into logical sections. Maybe:

  • Added social help to the control panel
  • Added dbus thingo
  • Added social help keyboard shortcut
  • Added functionality to launch social help

Prasoon Shukla added some commits Aug 13, 2014

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2014

@samdroid-apps Hey Sam. I've made the changes you suggested. Please tell me if there's anything more.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 13, 2014

I will test asap 😄 great job @prasoon2211

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 22, 2014

Hi @prasoon2211,

I have downloaded your social help onto my computer and here is my feedback:

  • It is not under the activities icon in the frame!!!!!!!!! prasoon2211#1
  • Why is the port seperate from the uri? People should be able to set the port on their own! See the pr

I also think you need to clean up the social help activity. Does it really need tabs? Shouldn't the home button take the user to the fourm home?

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 23, 2014

Hey @samdroid-apps
Well, I was using $ setup.py dev for now to install the activity - I hadn't added in the activity permanently yet. And I think that the last commit did allow for custom ports, albeit by using a storage file instead of entering in a port right with the user. But, I think your way is the better of the two. Anyway, I'm out of town at the moment so, I'll check out your PR properly once I get back tomorrow and merge it in.
Btw, I passed the evaluation 😄

Prasoon Shukla added some commits Aug 25, 2014

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Aug 25, 2014

@samdroid-apps Hey there. I've merged your PR in. Thanks!

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Aug 30, 2014

I give this pr the 👍. I think that the build is failing because it depends on componants that are not in this pr (in the sugar-toolkit-gtk3 one).

Anyway, we should once sombody else has had a look!

@godiard

This comment has been minimized.

Copy link
Member

commented Aug 31, 2014

Thanks Sam for all your work doing the review.
I think this is ready for the GSoC standards. About the merge, I think this is a big feature, then need follow the feature process. I hoe we can use all this in 0.104.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Oct 9, 2014

Hi @prasoon2211,

I have set up a social help on sugarlabs servers. It is use.socialhelp.sugarlabs.org (forum at socialhelp.sugarlabs.org). Can you change the default in your code?

Thanks,
Sam

@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2014

Hi @samdroid-apps. I'll take a look at it tomorrow after my classes are done. Thanks for setting up the server!

Prasoon Shukla
@prasoon2211

This comment has been minimized.

Copy link
Contributor Author

commented Oct 12, 2014

@samdroid-apps Hi Sam. I made the change. Btw, weren't we supposed to use the shfr server on a different port (instead of a different subdomain)? I guess that this works just as well however for local (no-internet) setups, we'll have to revert to using different ports.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Oct 18, 2014

Thanks for making the change @prasoon2211!

Btw, weren't we supposed to use the shfr server on a different port (instead of a different subdomain)?

We can. But there there are 2 reasons not to:

  1. I doubt that many schools would allow connections to port 8000. At my school, they have set up a proxy between us and the internet (I think it even proxies https - it could be stealing my gmail password!!!). The ACT Government IT department just loves blocking sites (including Sugarizer!!! 😭 @llaske). I don't think they would even allow connections to port 8000.
  2. use.socialhelp.sugarlabs.org is a lot nicer than socialhelp.sugarlabs.org:8000

I guess that this works just as well however for local (no-internet) setups, we'll have to revert to using different ports.

Yep. shfr still uses port 8000, but I proxy it to :80 (default http port) on the sugar labs server.

@llaske

This comment has been minimized.

Copy link

commented Oct 18, 2014

Regarding Sugarizer, you don't need an Internet access. If you've got a school server (or anything that could be used as a web server), you could install Sugarizer Server on it. Have a look on sugarizer.org for more information.

@samdroid-apps

This comment has been minimized.

Copy link
Member

commented Oct 18, 2014

@llaske, I'm not running a deployment sorry 😄 I'm just a student annoyed that it is harder to get to maze web and other fun activities when we "do mathletics" during maths class (our teacher is usually very serious about maths, but by the time he is going into the computer lab he seems not to care).

I just thought it was funny that the .edu department wanted to block sugarizer from school students (sugarizer.org - not llaske.github.io). <sarcasm>Obviously "The Sugar Gaming Platform is a leading time-wasting platform...".</sarcasm> I thought when we upgraded from win XP to win 7 this year, that they would improve the system as a whole... but they didn't.

Sorry to distract you @llaske. This is all a bit weird and not very important :)

@godiard

This comment has been minimized.

Copy link
Member

commented May 12, 2015

@samdroid-apps, we can close this, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.