PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

https://bitbucket.org/dal-glossary/extension-shared
Markdown | 103 lines | 63 code | 40 blank | 0 comment | 0 complexity | dfba200b40a3e117c85c904df06985ae MD5 | raw file
  1. Shared Extension Components
  2. =================
  3. This repository contains code that is used for both the [Firefox](https://bitbucket.org/dal-glossary/firefox-add-on) and [Chrome](https://bitbucket.org/dal-glossary/chrome-extension) extensions that are part of the Dalhousie Glossary system. It is comprised of two components:
  4. - highlighting
  5. - term viewer
  6. __Note__ Currently, all data is loaded from http://localhost:8080. This is temporary.
  7. ####Highlighting
  8. The highlighting component is a javascript library that can scan a page of HTML and wrap words from a list in span tags. These tags are styled and made clickable.
  9. ####Term Viewer
  10. The Term Viewer is used to display information about a term. The information is read from a server and displayed to the user. For each term, the server provides some number of entries about that term, which the Term Viewer displays. For more information about the REST format, see the [server wiki](https://bitbucket.org/dal-glossary/server/wiki/Home)
  11. ### Dependencies
  12. This project uses the [Grunt](http://gruntjs.com/) build tool, which is based on [Node.js](http://nodejs.org/).
  13. The Highlighter depends on [promise.js](https://github.com/stackp/promisejs), and Oleg Masko's javscript [snowball stemmer](http://code.google.com/p/urim/).
  14. The Term Viewer depends on [EmberJS](http://emberjs.com/), [Handlebars](http://handlebarsjs.com/) and [jQuery](http://jquery.com/)
  15. All dependencies are included in the repository.
  16. ###Usage
  17. ####Highlighter
  18. To use the highlighter in a project:
  19. 1. Run `npm install` to configure the grunt dependencies
  20. 2. Run `grunt` to build the project.
  21. 3. Include `src/highlighting/build/highlight.lib.js` and `src/highlighting/build/highlight.js` in your project (in that order)
  22. 4. Provide the required functions (see below for their semantics):
  23. - `requestStyleSheetUpdate()`
  24. - `performGetFor(path)`
  25. - `displayTerm(term)`
  26. 5. Invoke `addHighlighting()` with no arguments on the page you wish to highlight
  27. This will cause all words on the page that match a list to be wrapped in spans and styled. The required functions dictate where the list is loaded from, what styling is applied and what happens when a word is clicked on.
  28. `requestStyleSheetUpdate()` should look up the current styling preferences and pass them to the function `updateStyleSheet(style)` where `style` is a javascript object with the following keys:
  29. - `bold`: either `bold` or `normal` (will be assigned to the `font-weight` css attribute)
  30. - `underline`: either `underline` or `none` (will be assigned to the `text-decoration` css attribute)
  31. - `color`: an HTML color code (will be assigned to the `color` css attribute)
  32. - `colorenabled`: true if highlighted spans should have the text color changed, false otherwise.
  33. This object will determine the styling of any terms that are matched in the HTML document.
  34. `performGetFor(path)` returns a promise that completes after an HTTP request returns. This function should look up the currently configured server url and append the `path` parameter, then use the concatenated url to do a get request. The result of that get request is the promise that is returned. The callback format should be `function(error, result)`
  35. `displayTerm(term)` should perform some action to display information about the parameter `term`
  36. #####Testing
  37. The highlighter has a number of acceptance tests written for it, using the [Jasmine](http://pivotal.github.io/jasmine/) framework. To invoke these tests, run `grunt test`. This will run the tests using [PhantomJS](http://phantomjs.org/).
  38. To run the tests in a browser, execute the test ask as above, and then open the file SpecRunner.html, which has been generated in the build directory.
  39. ####TermViewer
  40. To use the term viewer, you must first build the project using grunt.
  41. 1. Run `npm install` to configure the grunt dependencies
  42. 2. Run `grunt` to build the project.
  43. 3. Open the file `build/termview.html` in a browser.
  44. 4. Add a fragment of the form `#/term/<term>` to the end of the url, where `<term>` is the word you wish to look up.
  45. This assumes you have a functioning webserver at `http://localhost:8080` conforming to the API.
  46. #####Testing
  47. There is currently no automated testing of TermViewer.
  48. ###Git Notes
  49. The Firefox and Chrome extensions share this code as a [git submodule](http://git-scm.com/book/en/Git-Tools-Submodules).
  50. Briefly, this means that each of the Firefox and Chrome extension repositories are dependant on this one, although this is not dependant on them. This repo can be updated and cloned without working through either of the other extensions.
  51. ###Structure
  52. The `src` folder contains the source code for each of the components. The highlighting component is in `src/highlighting` and the term viewing component is in `src/termview.` Each component contains some of the following directories:
  53. - `lib` where any the source and dependencies of the component are stored.
  54. - `lang` contains translation files for strings.
  55. The `test` folder contains the automated testing, broken down by component
  56. The `build` folder will be created by the build task of the grunt file.
  57. The following grunt targets are available in the root project:
  58. - `build`: Combine and minify each of the subprojects after compiling from CoffeeScript
  59. - `clean`: obliterates the `build` directory.
  60. - `test`: Runs all jasmine tests.
  61. In addition, the grunt build supports the following options (for `build` and `test`):
  62. - `--dev`: maintain the source map files that can be used for debugging. This will work on newer versions of Chrome and Firefox from version 23 on. Firebug does not support it.
  63. - `--no-lib`: Pass in if you wish to supress compilation of the libraries. They take longer than anything else, and if they've already been built, there's no reason to build them again.