Skip to content

xrd/ReviewsInDispute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

About

A little bit of code to apply to Wordpress for reviews

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published