This is the Development environment of my Angular About page (http://www.goncaloneves.com).
I am using WordPress REST API (http://wp-api.org). This will be integrated in future WP versions. So that's a good thing !
My intention is to share my website source code to anyone who wants to build skills with Angular and want something to start off. This is a simple app that can be extended and changed to your liking, it is simple and super light.
What it does have:
- Development environment: Yeoman Gulp Angular
- Bootstrap Only CSS
- Angular Modules:
- Route
- Sanitize
- Touch
- Angular Directives:
- Auto Hide Navbar
- Error View: Google AJAX Crawl with html5mode, using Prerender.io 404 status to solve this problem.
- Navbar List: I have done this directive to simplify things on the desktop/mobile navbar.
- Angular Controllers:
- Page
What may follow:
- Release Auto Hide Navbar and Error View directives separately
- Update unit / e2e tests
- Add contact page
- Add post page / post list
- Integrate Disqus comments
You will have from Yeoman Gulp-Angular fantastic generator:
gulp
orgulp build
to build an optimized version of your application in/dist
gulp serve
to launch a browser sync server on your source filesgulp serve:dist
to launch a server on your optimized applicationgulp wiredep
to fill bower dependencies in your .html file(s)gulp test
to launch your unit tests with Karma gulp protractor to launch your e2e tests with Protractorgulp protractor:dist
to launch your e2e tests with Protractor on the dist files
Deploy
. deploy.ssh
I have added a shell script file deploy.ssh
in your app root folder, that it is really useful and fast to deploy to production server.
Server:
I am running an Apache server, so I am using .htaccess
to redirect hash requests to index and send ?_escaped_fragment_=
requests to Prerender.io that delivers html snapshots to crawlers using PhantomJS.
WordPress:
I have it installed under the same domain in a sub-folder.
Then install wp-api here or on GitHub.
Install my WordPress REST Domain Redirect plugin if you want to redirect requests from your sub-folder WordPress installation to your root domain folder without including /wp-admin
on template_redirect
action as recommended.
Let's create our App really fast:
mkdir angularAbout
cd angularAbout
git clone https://github.com/goncaloneves/angular-about.git .
npm install
or in my case on OSX I need tosudo npm install
bower install
gulp serve
and you will see it working in your browser. deploy.ssh
to deploy your build, but first you will need to do some changes, read next...
Deploy
What it does ?
The idea is to have a git production repository, cloned in your production directory in your production server and cloned in your /dist
folder to commit and push changes. Then ssh into your production server and pull the latest changes.
Now in steps...
- Clones your production remote repository (mine is this one) to your
/dist
folder gulp build
a new/dist
version- Commits and pushes changes to remote repository
- SSH into your production server and goes to your production directory
- Pulls your latest build and finishes
You will need ssh access from where you run the script to your production server and deployment keys to your repository.
What you need to do:
- Create your git production repository, for example like mine here on GitHub
- Go to your remote server, get to the folder you want
- Clone your repository
- Edit your
deploy.ssh
file and changeproduction_server
,production_directory
andgit_remote
with your information - Check if you can ssh into your production server using ssh keys so you don't have to worry about password prompts in the future
Other files that you need to change before deploying:
/src/index.html
- Metatags in
<head>
/src/.htaccess
- Line 2: Prerender token
- Line 19: Your website domain, search for www.goncaloneves.com
You are done. Now it's time for . deploy.ssh