Giter Club home page Giter Club logo

io-content-example-blog's Introduction

I/O Content Example Blog

A simple HTML, JS and CSS blog backed by I/O Content API driven CMS

This simple blog is an example of how I/O Content can be used to manage content for websites. You can also use this example to run your blog using content in your I/O Content account.

The Demo is hosted on Amazon S3 using S3's static website feature.

This blog uses simple HTML, JS and CSS, backed by the I/O Content API which serves content entries in response to a query sent over an HTTP GET request using the io-content-js library.

The only required files required to run this blog are the index.html file and the bower_components folder.

blog deploy files

Note this demo is not available as a bower package, and all dependencies have been copied to the respository so you can simply copy deploy this website on any web server. This will not run from the local file system, so you will need to run via your local web server (e.g. Apache / IIS) to test.

How this example blog works

This example pulls content hosted in our 'blog-example' sub account. You'll need to set up you're own sub account and content types and edit the sample as appropriate. Full documentation for I/O Content describes how to manage content, set up content types and query the API.

The dependencies for this example are:

Note that I/O Content is queried via REST API, and io-content-js assists with making cross domain requests compatible with all major browsers.

AngularJS routing and templating is intentionally avoided to keep the file structure of this example as basic as possible. If you would like an example using AngularJS routing and disquss comments, our official blog is also available on GitHub.

API Query

The core content fetch code is as follows:

1. Set up the content client

var contentClient = new ContentClient();

contentClient.contentClientBaseParameters.subAccountKey = 'nl7bwlc4txh2uvw3s6h4gcclgb';
contentClient.contentClientBaseParameters.contentType = 'blog-article';

2. Request a list of content entries and load the first into view

// Load a list of blog articles to allow user to navigate
							
var blog = this;

var apiCallBack = function (responseJson) {

	var contentApiResponse = JSON.parse(responseJson); // [] of content entries
	
	blog.articleNavList = contentApiResponse.data;
	
	var loadKey = contentKey != null ? contentKey : blog.articleNavList[0].key;
	
	$scope.blog.loadSingleBlogArticle(loadKey);
	
	$scope.$apply();
}

// Query specifies get content entries in descending order (by custom publicPublishDate field)
// limit to the 20 most recent entries, and restrict the properties (select) to key and title, as
// we don't need the full content entry for a navigation list

var query = 'orderByDescending=publicPublishDate&pageNumber=1&pageSize=20&select=key+title';

contentClient.get(query, apiCallBack);

Content Assets

Content Assets managed in I/O Content are loaded from our CDN using plain HTTPS urls. Where requesting images, our CDN offers 'on the fly' image resizing, specified here using the ?maxHeight=80 query string argument. Resized images are cached in the CDN for fast load times.

Other file types are also served over the CDN in the same manner.

<div>
	<img src="https://cdn.iocontent.com/v1.0/assets/nfm6dwvsmrd6uukgj3rzdugerc/20151209-161905637/rh2v/iocontent-blocks-logo-1454-x-7069.png?maxHeight=80" alt="logo" />
</div>

Which retrieves the following image:

io content logo

io-content-example-blog's People

Contributors

gbro3n avatar

Watchers

 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.