Skip to content

Commit c256a8a

Browse files
author
Josh Hebb
authored
Create README.md
1 parent 3c6c154 commit c256a8a

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# AngularJS Contentful Starter Kit
2+
3+
The project is a quick starter for AngularJS applications consuming content from Contentful, a content as a service provider.
4+
5+
### Features
6+
7+
* AngularJS application running on JS only - no compiling!
8+
* Content & configurations pulled from Contentful via Angular libraries
9+
* Bootstrap 4 template with SASS
10+
* Build quickly with some preferred npm packages including gulp, bower & more
11+
* Watch your changes reload in real time with livereload
12+
13+
### Prerequisite tools
14+
15+
* [Node](https://nodejs.org/en/download/) (npm)
16+
17+
At the time of writing this guide, I was on **node v8.9.4** and **npm v4.6.1**.
18+
19+
*NodeJS is a javascript runtime built on Chromes V8 Javascript engine,
20+
and npm is simply a node package which is a package manage in itself. It allows you to install all other packages that you will be using. It can be installed with a simple installer on their website.*
21+
22+
23+
### Getting Started
24+
25+
Just [fork](https://github.com/joshhebb/angularjs-contentful-starter) or pull down the repository and run the following commands.
26+
27+
```shell
28+
git clone https://github.com/joshhebb/angularjs-contentful-starter.git your-project-name-here
29+
cd your-project-name-here
30+
npm install -g gulp # Install Gulp (global)
31+
npm install -g bower # Install Bower (global)
32+
npm run init # Run init task to install the node modules, libraries and then call gulp to build the app
33+
```
34+
35+
### Contentful Integration
36+
37+
The project relies heavily on Contentful which is a headless CMS. It's a content as a service provider that exposes it's content through rest APIs exposing content as JSON, easily consumed in Angular.
38+
39+
When you pull down the project - it will be pointed at my Contentful space which has content to imitate an Apple store selling some categorized products, with some additional store information hosted on the site as well as a simple blog. I was curious how the component relationships would work and it is what drove my content modelling.
40+
41+
You can either experiment with the JSON that's returned to you, or rip out any implementation details in the context of my Contentful space and start on your own content model.
42+
43+
44+
### Gulp Tasks
45+
46+
Take a quick scan through the following gulp commands thats that you can run for the project.
47+
48+
```shell
49+
# build (also starts livereload for development)
50+
gulp
51+
52+
# build the project
53+
gulp build
54+
55+
# start the project in dev mode (starts livereload for development)
56+
gulp dev
57+
58+
# update npm & bower
59+
gulp update
60+
```
61+
62+
Open the following URLs in your browser:
63+
* Development: http://localhost:9000/index.dev.html
64+
* Live: http://localhost:9000/index.html
65+
66+
Keeping in mind you'll only be able to open the node instance if you started livereload for development.
67+
68+
### Developing Workflow
69+
70+
The process for developing with the app couldn't be easier. Once you have the project downloaded and setup start livereload via one of the various gulp commands (gulp dev, gulp) and start editing away!
71+
72+
When editing in livereload - you'll see your changes reflected in the browser reflected in real time; no reloading whatsoever as long as livereload is running in the command line.
73+
74+
Some things to know:
75+
76+
* You don't need to tell the application you've created new SCSS files. It will precompile them for you
77+
* You do need to specify when adding new javascript libraries and files in index.dev.html
78+
* Edit index.dev.html and not index.html which is the production version of the page
79+
* When you are in livereload, the index.dev.html page will be rebuilt in real time
80+
* The other page index.html which would be used in production is only built when you run gulp build
81+
* Index.html is built from index.dev.html so **always make your edits in index.dev.html**
82+
* The production pages and resources will be minified by gulp
83+
84+
85+
### Adding AngularJS Libraries
86+
87+
The project uses one of the node packages to install libraries - bower. The process is simple - run the bower command specifying the library (and optional version) with the save command which will download the library into our lib folder which we can reference.
88+
89+
Install the library which will save the folder into our /lib folder.
90+
91+
```shell
92+
# Install the ui-router package and save it in bower (important to use --save to update the .bower file)
93+
bower install ui-router --save
94+
```
95+
96+
Update the index.dev.html page referencing the library JS / CSS files required (minified versions preferably).
97+
98+
```patch
99+
<!-- build:css public/index.min.css -->
100+
<link rel="stylesheet" href="lib/downloaded-library/dist/file.min.css">
101+
<!-- endbuild -->
102+
103+
...
104+
105+
<!-- build:js public/index.min.js -->
106+
<script src="lib/downloaded-library/dist/file.min.js"></script>
107+
<!-- endbuild -->
108+
```
109+
110+
If you remove a library:
111+
112+
* Delete the files from the lib folder
113+
* Remove the reference from bower.json
114+
* Remove any references in the application or in index.dev.html
115+
116+
117+
118+

0 commit comments

Comments
 (0)