A little bit of code to apply to Wordpress for reviews
Ruby CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
db
doc
lib
log
public
script
test
vendor
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

This shows how to embed a little bit of AngularJS into a Wordpress blog.

You can see this live here: http://www.webiphany.com/2012/10/01/when-did-airbn…ating-its-wife

WARNING: Wordpress will strip your ng-* tags if you toggle between HTML and Visual mode, so stay in HTML mode!!!

To use it:

  • Add the JS to the top of the Wordpress post
  • Setup a rails server with this repo
  • Configure the resource route in app/assets/javascripts/review.js.coffee by changing the BASE_URL variable
  • Customize the options inside the controller

If running in production, run rake assets:precompile

In other words, copy this into a Wordpress post (in HTML mode, not visual mode):

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular-resource.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular-cookies.min.js"></script>
<script type="text/javascript" src="//reviews.myhost.com/assets/application.js"></script>
<div ng-controller="ReviewCtrl" ng-app="reviews">

Don't let me convince you which way to vote.

Your choices:
<button ng-click="doVote(option)" ng-repeat="option in options">{{option.description}}</button>

<div ng-show="vote">
Now you've voted! Here is my expert analysis.

<strong>
{{(percentages.truthy/percentages.total)*100|number:0}}% voted for the truthy choice. 
{{(percentages.falsy/percentages.total)*100|number:0}}% chose the falsy item.
</strong>

</div>

</div>