.net magazine: Semantic CMS with Apache Stanbol, Aloha Editor and Drupal 7


Published on

My .net magazine article about Aloha Editor, Apache Stanbol and Drupal 7 -- Linked Data in Action.

Published in: Technology
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

.net magazine: Semantic CMS with Apache Stanbol, Aloha Editor and Drupal 7

  1. 1. .net technique/backend Drupal semantic content management Rene Kapusta demonstrates how to use the Apache Stanbol service with Drupal 7 to enrich your content with data from the Linked Open Data cloud Knowledge needed Basic PHP, Drupal and command line usage semantic engines that extract related terms and entities. This information about the content is then used to suggest meaningful tags for that article. Requires LAMP stack with PHP 5.2+ and Java 1.6 Whenever there is a reference to a Linked Open Data resource, detailed Project time 2-4 hours information about that item can be automatically displayed on the taxonomy page. By enlisting the help of open source software you can enhance The HTML5 inline rich text Aloha Editor (aloha-editor.org) serves as the user your website for search engines, provide meaningful metadata interface as well as sending the content to the Apache Stanbol API and adding describing your content and enrich your content with data from the suggested terms to the Drupal article tags field, enriched with semantic the Linked Open Data cloud. metadata. Other available widgets for semantic content enhancement and Open source tools such as Apache Stanbol and Drupal can improve content markup include image suggestion and inline annotation. for your visitors, as well as optimise your web pages for search engines with When writing about special topics, knowledge bases consisting of semantic semantic annotations and metadata. These tools are freely available – and in metadata can be very helpful to enhance the content or find relations between this article I’ll be showing you how to use them to make your content more Apache Stanbol helps meaningful and searchable. Drupal and Apache Stanbol Before proceeding, let’s kick off with a brief introduction to the components we’re going to be using: app developers deal with Apache Stanbol (incubator.apache.org/stanbol) provides components to Semantic Web technologies recognise and extract mentions of entities in textual content to assist the user with meaningful categorisation, find related documents and process data. Using information from sources such as Freebase or DBpedia can help semantic metadata. enhance the quality or accuracy of information. Drupal 7 (drupal.org) already supports RDFa for semantic annotations. The flexible taxonomy management is extended to manage relations of System requirements vocabulary terms to Linked Open Data resources and fetch content such as We need a PHP 5.2+, MySQL 5.1+ and Java 1.6 environment. If you don’t have descriptions, links or media files to improve the quality of your content or all these, you can download and install the following software packages: provide additional information. • XAMPP (apachefriends.org/en/xampp.html) – an easy to install Apache How do these components work together? When creating or editing an article distribution containing PHP and MySQL. in your Drupal system, the content will be sent through a RESTful API to the • Java from java.com. Information flow Content is sent via the Aloha Editor, acting as our user interface, to the Apache Stambol API, which assists in categorising and enriching it 106 .net/june 2012NET228.dev_drupal.indd 106 4/3/12 6:02:52 PM
  2. 2. .net technique/backend Background About IKS Interactive Knowledge Stack (IKS) is an open source community, whose projects are focused on constructing an open and flexible technology platform for semantically enhanced content management systems. IKS’s ultimate goal is to develop an open source stack for knowledge management, broaden the reach of semantic CMS technology and serve as a collaboration and software development hub for the whole semantic CMS community. IKS is funded in part by a €6.58m grant from the European Union, and is governed by a core consortium of seven research partners and six industrial partners – and actively encourages both corporate and individual participation in the project. Further information can be found at iks-project.eu. As it comes The default settings offered by Apache Stambol are suitable for our needs in this project Community centre IKS has benefited from EU funding to support its aims Field work Here a new field is being added to the Drupal admin panel in order to of becoming hub for the semantic CMS community make use of the semantic services provided by Apache Stambol Once this is out of the way, we’re going to download our open source For troubleshooting, detailed information about the Drupal installation software components: process can be found at drupal.org/documentation/install. The Semantic CMS package you downloaded and extracted before also • The latest version of popular CMS, Drupal 7 from drupal.org/project/drupal. contains a stanbol directory; your IKS 5.3 reference implementation is located • The latest IKS Project release which contains Apache Stanbol from code. here. You can leave it where it is or move it to any desired location. google.com/p/iks-project. Now open your command line tool and navigate into this directory. To • The Aloha Editor as our inline WYSIWYG editor from aloha-editor.org . launch Apache Stanbol, which is part of the IKS reference implementation, type • Last we need some extra Drupal modules. Some of these are modified for the following command: our use – to make it easier for you, there’s a download package with all components installed in the right place at semantic-cms.info/downloads. java -Xmx1g -jar iks-5.3-launcher.jar Component installation You should see "*INFO* [main] Startup completed" among some other Once you have the PHP and Java environment running and the package output. Now navigate to localhost:8080/stanbol in your web browser to verify downloaded from semantic-cms.info, you can proceed with the installation. that the Apache Stanbol service is up and running. Extract the package to any location and open it in your file browser. Refer to incubator.apache.org/stanbol for further information and The htdocs folder contains the Drupal system with all required modules. documentation about Apache Stanbol. Copy this folder to the document root of your XAMPP environment and rename it semantic-cms. Now navigate one directory up into to the sites Component configuration directory and change the permissions for the folder sites/default to be Once all the components have been installed, proceed to configure Drupal writeable by the server. Navigate into the default directory and copy to make use of the semantic services provided by Apache Stanbol as in the default.settings.php to settings.php and also make this file writeable. following sections. To store the data, we need to create a new MySQL database. If you’re using XAMPP, navigate in your web browser to localhost/phpmyadmin and create Drupal and its modules one named semantic-cms with the given default settings. In the Drupal administration panel: Now navigate to localhost/semantic-cms to start the Drupal installation wizard, which will guide you through the process of setting up your Drupal • Navigate to Modules and enable at the User Interface section the following website. Please choose the Standard install option. modules: Active Tags, Aloha Editor and Wysiwyg. At the Semantic Services When you have successfully completed the installation process and have section activate Apache Stanbol. your Drupal site running, proceed with the installation of Apache Stanbol and • Navigate to Appearance and click Enable and set default at the the configuration of the Semantic CMS Drupal modules. Semantic CMS theme. .net june 2012 107 next>NET228.dev_drupal.indd 107 4/3/12 6:02:53 PM
  3. 3. .net technique/backend IKS IKS Early Adopter Program The IKS Early Adopter Program enables early adopters to validate the various versions of the IKS stack and especially the different components. Components will be available across the layers of the stack from the persistence to the user interaction layer. Such components will include, for example, a semantic engine to manage ontologies and knowledge models, a semantic editor and a semantic content enrichment engine. More information can be found online at iks-project.eu/projects/early- adopter-programme. VIE and the IKS Project VIE is a JavaScript library that makes the content of your web pages editable through markup. This is another open source component that’s been developed by the IKS project team. The VIE UI widgets provide you with the ability to add semantically enhanced annotations – which is also good for SEO (see: schema.org). Further information can be found at iks-project.eu. Place names Content in the editable area of the CMS is sent to Apache Stanbol; once the data has been processed you are sent tag suggestions • Select Aloha Editor at Configuration>Wysiwyg profiles for the two Stanbol. When your data is processed you will get suggestions for tags for HTML formats. that content. In this case it will be Paris and France. • Enable the Clean URLs option at Configuration>Clean URLs – this requires In the Settings section, you can select provide a menu link. Click Save. At a working and enabled Apache mod_rewrite module. this point, you have a basic Drupal 7 CMS with an example article about Paris • Navigate to Structure>Content types and click manage fields for the Article editable with Aloha Editor and a working Apache Stanbol installation accessible content type. via the browser and RESTful API. Open localhost:8080/stanbol/contenthub in • Click Edit at the Tags field. Open the Widget Type tab and select the Active your browser to access the content stored in Apache Stanbol. Tags autocomplete term widget option. Save the changes. • Choose Structure>Taxonomy and click Edit Vocabulary. Open the Manage Use Drupal taxonomy terms to link to the LOD Cloud fields tab and add a new field with the label Same as, the name field_ One advantage of using Apache Stanbol and the provided Semantic Web sameas and select Text as the field type. To add this new field click Save and technologies – here Linked Open Data (en.wikipedia.org/wiki/Linked_Data) confirm the next two steps with the given default values. Apache Stanbol The default setup of Apache Stanbol is fine for our example. Access the Tools such as Apache Stanbol configuration area at localhost:8080/stanbol/system/console. In this area, you can edit enhancement engine settings or create your own EntityHub spaces. and Drupal can improve For more information on this topic, have a look at the documentation at incubator.apache.org/stanbol/docs/trunk or join Apache Stanbol’s mailing list. content for visitors Integrating the components – is that we can query for additional information for a tag entity. This Create an article and get semantic tag suggestions information can be a description, image, related topics or a map, and the Once all the components are successfully installed and configured, it’s time to data is accessible at knowledge bases consisting of metadata. create our first article and see how Apache Stanbol can help us with suggesting To make use of the Semantic Web features of Apache Stanbol in Drupal, we tags for our content. have adopted the default taxonomy configuration. We’ve added a field to store To do this, click Add Content in the Drupal shortcuts bar and select Article. a reference in form of a URI from our taxonomy term to a node in the Linked Give the article a title, for example, ‘One day in Paris’ and then add ‘Paris is the Open Data graph of that entity. capital and largest city of France.’ as content into the body field. After leaving Every vocabulary term associated with a Linked Open Data concept is used the editable area, your content will be sent to the RESTful API of Apache to describe your content semantically. In order to see this in action, simply click on the tag Paris or France of the article we created before. Conclusion This is just one example of how this technology can save you time and help enhance your content. Apache Stanbol provides a number of different components to help application developers deal with Semantic Web technologies. Additionally, there are some web services for content analysis available, depending on your use case. Some of these include AlchemyAPI, Open Calais and Zemanta. ● About the author Name Rene Kapusta Company evo42 communications Ltd (evo42.net) Twitter @rene_kapusta Areas of expertise Drupal and Semantic Web technologies Clients SMEs across Europe French exchange Linked Open Data enables us to query and pull up additional Who’s your favourite cartoon character? The Penguins information regarding a tag entity – in this case France from Madagascar <prev 108 .net june 2012NET228.dev_drupal.indd 108 4/3/12 6:02:53 PM