Due to the amount of shared information, the search for the right data many times results in an endless loop. While the open data approach is oriented towards the community, it may be difficult to gather feedback from the right people in the right place. 

That’s where Ckanext-disqus comes into play, an extension that allows users to leave their feedback directly on the available data on the portal. By integrating Disqus as a global commenting system into your CKAN portal, you will encourage conversations between the Data Portal users, and allow them to share their opinion about data transparency. 

Disqus is a feature-rich commenting system complete with social network integration, advanced administration and moderation options, and other extensive community functions.

How to get started?

At the very start you should have (or create it now) a Disqus account. Afterwards the extension will be enabled on the portal with the Discus domain name (ex. official organization or company Discus account). In order for other users to comment, they also must have a Disqus account. The upside of this third-party registration is the Disqus user profile, where all discussions made on each CKAN portal will be available. 

To wrap it up, only registered users with a Discus account are able to comment on the portal data. This will prevent the portal from useless comments. 

Available options

The user comments on the portal can be edited or deleted, other users can reply to a certain comment, attach images as part of their comment, link the comment with an URL and share on social media. CKAN administrators have the ability to flag comments as inappropriate. 

While it may be hard to address all customer needs, we had the opportunity to also develop a custom commenting system equipped with the feature to tag other portal users or to relate the comment with some of the portal entities. What better way to ask people to join the discussion, than tagging them and inviting them into the conversation.

Additionally, the custom-built comment feature only requires registration to the particular CKAN portal without using third-party services (ex. The UNHCR Knowledge Hub portal). 

Setting up ckanext-disqus

Note: This extension requires ckan 1.7 or higher In order to set up the Disqus plugin, you first need to go to disqus.com and set up a forum with your domain name. You will be able to choose a forum name. To install the plugin, enter your virtualenv and load the source:

(pyenv)$ pip install -e git+https://github.com/okfn/ckanext-disqus#egg=ckanext-disqus

For ckan versions before 2.0, please use the release-v1.8 branch. This will also register a plugin entry point, so you now should be able to add the following to your CKAN .ini file:

ckan.plugins = disqus <other-plugins>
disqus.name = YOUR_DISQUS_NAME

At this point, each dataset view page will have Disqus comments. To add comments into other pages, see the next section. Disqus will use window.location.href as the disqus_url. It is sometimes helpful, especially during development, to specify the base url for disqus to use instead. This can be added to the CKAN .ini file:

disqus.disqus_url = my_staging.server.com

Do not include ‘http://’ or a trailing slash.

Using the extension:

Comment threads

To have comment threads appear on pages, insert into templates where you want the comments to appear:

{{h.disqus_comments()}}

Note for theme developers: the extensions tries to generate a disqus_identifier of the form:

{controller/domain-object-name}::{id}

Where controller = ‘group’ in the group section, ‘dataset’ in the dataset section (note that this differs from controller name internally which is still package), ‘resource’ for resources etc. This identifier will be useful if you want to then reference this comment (e.g. for comment counts) elsewhere in the site.

Recent comments

Insert on pages where you want recent comments to appear:

{{h.disqus_recent()}}

The recent comments widget will show 5 recent comments by default. To show 10 recent comments use the following:

{{h.disqus_recent(num_comments=10)}}

Other widgets

Disqus offers many other widgets. Rather than providing these automatically as part of this extension we suggest that theme developers incorporate the code directly (note that you access the relevant config variables from the config object passed into all templates).

Single Sign On

Disqus offers a "Single Sign On" option which allows users to submit comments using the local username/password rather than require a seperate disqus account. For instructions on how to set things up on the Disqus end (i.e. create API keys) see: Disqus Help. To integrate with this CKAN plugin, you must store your Public and Secret keys in the CKAN ini file:

ckan.plugins = disqus <other-plugins>
disqus.name = YOUR_DISQUS_NAME
disqus.secret_key  = YOUR_DISQUS_SECRET_KEY
disqus.public_key  = YOUR_DISQUS_PUBLIC_KEY

Well, what are you waiting for? This is the perfect opportunity to engage with like-minded people and even come up with some new ideas. Try it yourself and join the community!

About Petar Efnushev

Computer whisperer at Keitaro