[ckan-dev] Disqus comments plugin SSO enhancement
George Sattler
George.sattler at xvt.com.au
Thu Dec 4 04:30:36 UTC 2014
Hi Andrew
This is really great! I’ve just given it a try and it works well for me. I see what you mean by jumping through the hoops on the Disqus side of things. I actually only followed the Disqus SSO instructions down to the end of the ‘Configure your application settings’ and somehow it worked okay. Always the possibility that it’s not 100% setup (just wanted to quickly test) but I can confirm that I was able to make comments on a dataset. I logged in with several different users and made comments as well.
This is certainly adding some great functionality to the disqus extension!
Thanks
George
> On 4 Dec 2014, at 4:01 am, Koebrick, Andrew (MNIT) <andrew.koebrick at state.mn.us> wrote:
>
> I have what appears to be a functional fork of the ckanext-disqus extension that integrates the Disqus Single Sign On. This allows CKAN users to comment without having to establish a separate username/password with Disqus. If anyone would like to try installing it, it is at:
>
> https://github.com/exlibris/ckanext-disqus
>
> To use SSO you need to jump through various hoops with Disqus (i.e. register your application, get keys...) and them put the keys in your CKAN .ini file. See my documentation for more info. The extension should also still work in the prior fashion if the required keys are not in the .ini file.
>
> I read through the documentation on contributing to CKAN and making pull requests (http://docs.ckan.org/en/latest/contributing/pull-requests.html) and unfortunately was not able to follow the steps exactly: I was unable to create a branch on the main repo prior to forking. So I just forked and made my changes to the master. If the maintainers of the main repo would like to integrate these changes into the main extension, and I can do anything at my end to make this easier just let me know. This is my first attempt at both writing python and contributing to a github project, so suggestions on how to improve my coding and git skills are welcome.
>
> Andrew Koebrick
>
>
>
> -----Original Message-----
> From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Adrià Mercader
> Sent: Friday, November 14, 2014 5:03 AM
> To: CKAN Development Discussions
> Subject: Re: [ckan-dev] Disqus comments plugin SSO enhancement
>
> Hi Andrew,
>
> To access properties in c you need to access them like `c.user`. This gives you the user name.
>
> Passing data in c to the templates is not the recommended method any more. Passing variables as in here is recommended:
>
> https://github.com/ckan/ckanext-disqus/blob/master/ckanext/disqus/plugin.py#L92:L96
>
> These can be later accessed from the templates directly:
>
> https://github.com/ckan/ckanext-disqus/blob/master/ckanext/disqus/templates/disqus_comments.html#L5:L6
>
> In your case you need to call `user_show` to get all the extra details you need, something like this should get you started:
>
>
> user_dict = p.toolkit.get_action('user_show')({'keep_email':
> True}, {'id': c.name})
>
> data = {
> ...
> 'user_id: user_dict['id'],
> 'user_name': user_dict['name'],
> 'user_email': user_dict['email'],
> }
> return p.toolkit.render_snippet('disqus_comments.html', data)
>
>
> Hope this helps,
>
> Adrià
>
>
> On 13 November 2014 19:02, Koebrick, Andrew (MNIT) <andrew.koebrick at state.mn.us> wrote:
>> I am trying to create a fork of the ckanext-disqus extension that
>> makes use of the Single Sign On (SSO) which Disqus offers. Rather
>> than have users have to sign into the Disqus service, local user data is sent to Disqus.
>> For more info see:
>> https://help.disqus.com/customer/portal/articles/236206-integrating-si
>> ngle-sign-on
>>
>>
>>
>> However, I have having a difficult time accessing the ckan user model
>> from the extension. Could somebody with a better knowledge of CKAN
>> and python give me a pointer or two? I seem to be unable to access to context object.
>> I have been trying things like the below with no luck;
>>
>>
>>
>> def disqus_comments(cls):
>> #Original code
>>
>> ''' Adds Disqus Comments to the page.'''
>> #Original code
>>
>> # we need to create an identifier #Original code
>>
>> c = p.toolkit.c
>> #Original code
>>
>>
>>
>> user_name = c['user']
>> #My addition … It fails.
>>
>> user_name = context['user']
>> #Another try. as seen in the extension tutorial… It fails.
>>
>>
>>
>>
>>
>> I need to access to user’s name, email, and Id.
>>
>>
>>
>> Thanks in advance for any pointers anyone can provide. If I get SSO
>> hooked up in my fork, I will happily share my code back to the main extension.
>>
>>
>>
>> Andrew Koebrick
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
This email and any files transmitted with it is confidential and intended solely for the use of the addressee. The unauthorised use, dissemination, forwarding, printing or copying of this communication is strictly prohibited. If you have received this communication in error please notify us immediately by reply email and destroy this communication. Any views and opinions presented in this email are solely those of the author and do not necessarily represent the views of XVT Solutions. The recipient should check this email and any attachments for viruses. XVT Solutions accepts no liability for the content of this email, and any damage caused by any viruses that could potentially be transmitted through this email.
More information about the ckan-dev
mailing list