Code Monkey home page Code Monkey logo

bb-learn-ultra-embedded-content's Introduction

Blackboard Learn Ultra Embedded Content

This repo provides getting started project directories (node packages) as well as common library React Components, utilities, and styles, for building an app that can be hosted and launched with LTI and communicate data back and forth with Learn on the front-end (using PostMessage events). An app can also be launched as a "mashup" from the Rich Text Editor to embed content (or even an iFrame) directly in the content editor/authoring space.

Getting Started

Setting Things Up

You can simply enter npm run install:root to install the root level devDependencies and libraries that are used by all example-apps, then cd into the respective folder, run npm install , and use the scripts provided in the (sub-package) package.json to install, develop, run locally, test, and eventually build/compile to the (sub-package) /build directory. npm start will serve the app locally at http://localhost:4321. This will output a bundle.js, bundle.js.map, index.html, styles.css, and styles.css.map. Some commands may require prepending with sudo depending on your local configuration.

For example:

git clone https://github.com/blackboard/bb-learn-ultra-embedded-content.git
cd bb-learn-ultra-embedded-content
npm run install:root
cd example-apps/jsx/rte-giphy-search
npm install
npm start

Next Steps

To build your own LTI User Interface, duplicate one of the directories from /example-apps/getting-started and rename it. Work from the new directory to develop and test locally. Run npm start to see the app running in a local browser at http://localhost:4321. The code base attempts to provide a working knowledge of how PostMessage works to communicate data in the form of JSON to and from Bb Learn. Be creative and build off of this as a starting point. When the app is tested and complete run npm build to output static HTML, CSS, and Javascript to the build folder. These files can then be hosted on a server at a URI that Learn can connect to in order to display your LTI app UI.

For example:

git clone https://github.com/blackboard/bb-learn-ultra-embedded-content.git
cd bb-learn-ultra-embedded-content
npm install
cp -a example-apps/getting-started/typescript-react example-apps/getting-started/my-awesome-app
cd example-apps/getting-started/my-awesome-app
npm install
npm start

Posting Messages

The enclosing window will accept messages sent from each content provider. See javascript's postMessage api for further details.

For example:

window.parent.postMessage(message, document.referrer)

These messages must follow a specific configuration.

Sample Messages

Example 1

{
    messageType: 'content_canceled'
}

Example 2

{
    dataType: 'video', /* Required when type is 'content_ready' */
    dataContent: {
        alt: 'Some alternative text for accessibility', /* Required when type is 'content_ready' */
        src: 'src for embeddable content or links' /* Required when type is 'content_ready' and output is embeddable */
        /* ... dynamic key/value pairs */
        response?: {}
    }, /* Required when type is 'content_ready' */
    messageType: 'content_ready'
}

accepted values

messageType:

'content_canceled' - Close the dialog, canceling any actions,

'content_ready' - Send with content to signal change in ultra and apply to editor

dataType: 'link', 'image', 'audio', 'video', or 'embedded-app'

Receiving Messages

Add an event listener on componentWillMount to to handle messages posted from Blackboard Learn.

For example:

window.addEventListener('message', receiveMessage, false);

function receiveMessage() {
    receiveMessage(event) {
        // This is a security measure to ensure that we only respond to messages
        // that originated from a parent/referrer that is the window embedding this iFrame
        if (document.referrer !== event.origin) {
            return;
        }

        // Respond to incoming message
    }
}

These messages must follow a specific configuration.

Sample Messages

Example 1

{
    messageType: 'init_content',
    config: {},
    dataToDisplay: {
        mode: 'create',
        content: {
            dataType: 'embedded-app',
            dataContent: {},
        },
    },
}

accepted values

messageType:

'init_content' - Load the iFrame/mashup with respective configuration

config:

'apiBasePath': 'base api path for server queries'

'locale': 'localization string to select current locale'

'xsrfToken': 'token for secure server transactions'

dataToDisplay:

'mode': '"create", "edit", or "view"'

'content': 'object containing 'dataContent' and 'dataType' for editing existing mashups

More Info

Check the example-apps/getting-started/typescript-react or example-apps/getting-started/javascript-react directory for step-by-step instructions to create and develop a new LTI single page application for launch. This is a good starting point for understanding the front-end communcation between Blackboard Learn Ultra's Window and the iFrame that your LTI app will launch in.

Helper Utilities and Libraries

Find access to some common utilities/libraries that we have included to help match the styling and UX choices found in Ultra UI. We have also included various javascript utilities that we find helpful for our internal development workflow.

TODO: Add build config (write in typescript, compile to javascript) and implement proper tree-shaking to reduce compile size and consider ways to leverage Blackboard's in-house library to reduce duplicate work.

How to include a Component


Simply add an import to the top of a file, ie.

import { Spinner } from '../bb-public-library/react-components/lib'

NOTE: Typescript requires a different import format for resolving .js files

import { Spinner } from '../bb-public-library/react-components/lib/index.js'

### How to Include a utility
---
Simply add an import to the top of a file, ie.
```javascript
import { configureTranslator } from '../bb-public-library/utilities/lib'

NOTE: Typescript requires a different import format for resolving .js files

import { configureTranslator } from '../bb-public-library/utilities/lib/index.js'

Documentation for Developers of this Entire Repo

Troubleshooting

  • Scripts and npm commands may require sudo depending on your configuration
  • Check that you are using the latest versions of npm and node (we were using [email protected] and [email protected] when this was written)

bb-learn-ultra-embedded-content's People

Contributors

zizzle6717 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.