Creating a New Topic/Activity in VIEW ====================================== Creating a new topic is a little complicated. First off, the terminology can potentially be confusing, so to clarify: - topic: the grammar topic being presented, e.g., determiners - activity: the type of presentation, e.g., colorize, click, multiple choice, practice Unfortunately, we haven't always used these names correctly in the directory structure, but we'll try to use them consistently in the instructions below. It's easiest to start out with a copy of an existing topic and modify it gradually. In the first section, we'll start out by modifying a copy of the Determiners topic that annotates prepositions instead of determiners. This involves adding a new topic to the web interface and firefox add-on, but doesn't yet involve new annotators. The second section will discuss how to add new annotators and the third section will discuss how to modify the activities. Update: By now, a prepositions topic already exists. So, by following the steps below, you would override the exitsing code. This is not a problem if you only want to get familiar with VIEW. In this case, just check out VIEW from SVN another time and use one working copy for playing around (but never committing your changes) and the other for actual development. The Simplest New Topic ---------------------- We're going to make a copy of the determiners topic and modify it to highlight prepositions instead. 1. Make a copy of the topic specification Make a copy of the Dets directory in 'src/main/webapp/activities/Dets called 'src/main/webapp/activities/Preps'. (Yes, this directory should actually be called "topics" to line up with the terminology above.) 2. Edit 'src/main/webapp/activities/Preps/activity.xml' Change the of the topic to "Prepositions". Modify the following line so that the tag under consideration is IN instead of DT. (Note: IN probably isn't quite sufficient for a prepositions activity, but that's not important for this explanation. The TokenEnhancer can also annotate more that one tag if you provide a comma-separated list like "JJ,JJR,JJS".) 3. Edit 'src/main/webapp/activities/Preps/help.jsp for the new topic. (This step can easily be postponed, but don't forget it!) 4. Create a new topic in the VIEW firefox extension 4a. Add the new topic to the VIEW toolbar Edit 'src/main/resources/firefox-extension/view/chrome/content/browser.xul' to add a new item to the wertiview-toolbar-topic-menu menu: Add the string for &prepositions; to 'src/main/resources/firefox-extension/view/locale/en-US/translations.dtd'. NEW Don't forget to do the same for any language you want to add. NEW 4b. Add the javascript implementing the activities for the new topic to the extension Our example new topic 'Preps' is similar enough to 'Dets' that several shortcuts can be taken. Option 1 describes these shortcuts. Option 2 describes the steps for a completely new topic. Option 1: The 'Preps' topic is extremely similar to the 'Dets' topic, so it's possible to use most of the same code from pos.js. Add the case 'Preps' to the switch(topic) statements in 'src/main/resources/firefox-extension/view/chrome/content/pos.js' with new CSS class names and add the colorize styles to 'src/main/resources/firefox-extension/view/chrome/content/view.css'. Search in werti.util.HTMLEnhancer and in 'src/main/resources/firefox-extension/view/chrome/content/activity.js' for the places where 'Dets' is translated to 'pos' and add 'Preps' to this set of special cases. Option 2: If the new topic is not as similar, add a new class to handle the activities for the new topic: Copy 'src/main/resources/firefox-extension/view/chrome/content/pos.js' to 'src/main/resources/firefox-extension/view/chrome/content/preps.js'. The name of the new class should be the lowercase version of the directory name chosen in step #1. Edit 'preps.js' to change the class name to wertiview.preps (in line 2) wertiview.preps = { Add the colorize styles to 'src/main/resources/firefox-extension/view/chrome/content/view.css'. In 'preps.js', change all occurrences of 'wertiview.pos' to 'wertiview.preps'. Edit 'src/main/resources/firefox-extension/view/chrome/content/browser.xul' to tell the add-on to load this new class (near the beginning of the file):