Skip to content

Source code for the Watson Content Hub sample site single page application - Oslo.

License

Notifications You must be signed in to change notification settings

mkobbi/wch-site-application

 
 

Repository files navigation

wch-site-application

Source code for the Watson Content Hub starter site application - Oslo.

Prerequisites

  • A WCH tenant in Trial or Standard Tier
  • Node.js v6.11.1 or above Note: We recommend to run npm install after getting the latest from this repository to get the latest prerequisites.

Overview

This github repository contains all the source code files like javascript, css and html but not the Oslo artifacts like pages, content types, categories, and content. WCH tenants created after September 18th 2017 will have the Oslo artifacts automatically deployed. For older tenants you need to manually deploy the artifacts by downloading the Oslo built artifacts from the home page of your tenant from the "Update the sample site" widget. Not sure if you have the Oslo artifacts?

  • Log in to your tenant and go to the Website menu and check if Oslo is rendering in the preview window.
  • Check SDK and SPA build levels from the browser
    • Open the dev console
    • Search for 'Build date' to get the current SPA level
    • Search for 'SDK version' to get the SDK version included in the SPA

You can compare the Build date with the date shown in the "Update the sample site" widget on the Home page to see if your deployed sample is older than the latest sample code. Instructions on how to update Oslo to the latest can be found here: Updating your Oslo sample.

Documentation

  1. Roadmap for developing your own site
  2. Site structure (Content model-How the sample site is built)
  3. Programming Model
  4. Watson Content Hub - Sites Development Overview
  5. Customizing the sample website
  6. Resources
  7. Updating your Oslo sample

Updates

At the end of March we have updated the Oslo starter site with the following features:

  • performance improvements - reducing the size of the generated scripts
  • Added support for script applications

At the end of February we have updated the Oslo starter site with the following features:

  • upgrade to Angular 5.2
  • leveraging ng build versus separate webpack
  • bug fixes and performance improvements

At the beginning of February we have updated the Oslo starter site with the following features:

At the beginning of January we have updated the Oslo starter site with the following features:

  • update of Angular to Angular 4.4.6
  • Introduced a new search component and added search of pages to the functionality - results are displayed on the new search page
  • Introduced the ability to hide pages from the navigation while still available via URL with a new flag that can be set in the page
  • Enhanced Inline Editing support

At the beginning of December we have updated the Oslo starter site with the following features:

  • Performance improvements
  • bug fixes
  • Support for Google crawling of a given page in Oslo (more features planned in this area)
  • Additional layouts for the Standard page type
  • Removal of # from the URLs and now leveraging HTML 5 mode for URLs (i.e. https://myhost/design-topics/clean-design)
  • Enablement for Inline Editing in the Sites Composer
  • Ability to leverage Angular 5 instead of Angular 4

Getting set up

From your cli make sure to install project dependencies by running npm install

Changing the tenant

You can set the tenant information, by changing the values in src/app/Constants.ts. This file determines from which tenant site and layout information gets served from.

Development server

Run npm start for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

Run npm run build to build the project. The build artifacts will be stored in the assets/ directory. Use the -prod flag for a production build.

Deployment to Watson Content Hub

Run npm run deploy to deploy the built code to Watson Content Hub. There is also a shortcut for building and deploying in one step via npm run build-deploy. Note that publishing can take up to 20 minutes for all updates to be available.

Running unit tests and end-to-end tests

See the included detailed documentation on running tests Running unit tests and end-to-end tests .

Install Sample Site Components

The Oslo site provides scripting to ease the process of importing 3rd party components.
We have provided a set of sample component repositories:

Structure of Sample Site Components

  • At the root of the sample-active-site-components project/zip, you can find the content-artifacts directory and the site-application-files directory.
  • The content-artifacts directory contains content/pages required for the components in addition to the layout and layout-mappings files. The directory follows the WCH directory structure. /catagories stores assests in "Taxonomies". /content stores assests in "Content". /types stores content types. /site stores Oslo's pages' setting. /layouts and /layout-mappings store all layout settings created when you run npm run create-layout. You could find them in WCH by their "id" or "name" in json files after you deploy them into the tenant.
  • The site-application-files stores HTML/CSS/TS files needed for the sample components. You can customize the components by editing files in site-application-files/src/app/layouts/<COMPONENT NAME>.

Installation steps

See the readme of sample-active-site-components for details: https://github.com/ibm-wch/sample-active-site-components

HTML5 style URLs

The SPA will now use HTML5 style URLs and routing.

Advanced

Code scaffolding

To use code scaffolding you will want the Angular CLI with this project. To install it globally run npm install -g @angular/cli.

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|module.

Enabling logging

The SPA uses the ng2-logger package for logging. By default logging will be enabled when running locally and disabled when running in production mode on the tenant. The logging level can be changed by setting a cookie in the browser. The available log levels are

  • info
  • warn
  • error
  • data

Setting the logging level will result in a waterfall effect, for example if setting warn logging will also be enabled for error and data.

To change the logging level you can enter the following into the browsers console developer tools
document.cookie = 'wch.sites.logging.level=warn'

Resources

Find more details on the WCH development environment, technical documentation, sample applications, APIs and other information to jumpstart your development project.

Tools

API

Documentation

Samples

Support forum

License

See the included license file License .

About

Source code for the Watson Content Hub sample site single page application - Oslo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 61.3%
  • CSS 17.4%
  • JavaScript 13.8%
  • HTML 7.5%