├── .gitignore ├── LICENSE ├── README.md └── example ├── .bowerrc ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── Gruntfile.js ├── app ├── .buildignore ├── .htaccess ├── 404.html ├── favicon.ico ├── images │ └── yeoman.png ├── index.html ├── robots.txt ├── scripts │ ├── app.js │ ├── controllers │ │ └── main.js │ ├── wp-pods-api.js │ └── wp-pods-sample-app.js ├── styles │ └── main.css └── views │ ├── main.html │ ├── pods.editor.html │ └── pods.html ├── bower.json ├── package.json └── test ├── .jshintrc ├── karma.conf.js ├── runner.html └── spec └── controllers └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | example/.idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Björn Klose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angular-wordpress-pods 2 | ====================== 3 | 4 | a sample client for the [`pods-json-api`](https://github.com/pods-framework/pods-json-api) using Angular.js 5 | 6 | ## Introduction 7 | 8 | ### main ingredients 9 | 10 | you take 11 | 12 | * [Wordpress](http://wordpress.org/) as a backend 13 | * [Pods](http://pods.io/) for storing custom data types and their relations 14 | * [AngularJS](https://angularjs.org/) for creating a completely independent UI that looks nothing like a CMS 15 | 16 | and glue them together using various pieces 17 | 18 | * [WP-API](https://github.com/WP-API/WP-API) for enabling a JSON-based API for Wordpress 19 | * [pods-json-api](https://github.com/pods-framework/pods-json-api) for accessing your Pods 20 | * [wp-pods-api.js](/example/app/scripts/wp-pods-api.js) from *this* project, so you can use it in your own Angular.js app 21 | 22 | to make things easier, this repo also contains a small Angular.js app that can list, add, edit and delete pods from your existing wordpress installation. 23 | 24 | ## Installation 25 | 26 | This assumes that you want your Angular App and the Wordpress Backend to live in 2 separate locations, which can even be different domains [if you enable CORS](https://github.com/WP-API/WP-API/issues/144). 27 | 28 | ### *server* in location 1 29 | 1. install Wordpress 30 | 2. install Pods as a plugin 31 | 3. install WP-API as a plugin (until it's merged with WP Core) 32 | 4. install pods-json-api as a plugin 33 | 5. create a new Pod 34 | 6. install the [base-auth-plugin](https://github.com/WP-API/Basic-Auth) 35 | 7. create a new user that will be user for http basic auth combination (or use your admin account from first install ;-) ) 36 | 37 | ### *client* in location 2 // localhost 38 | 1. clone this repository into a folder of your choice 39 | 2. edit the settings in [the config() block of your main app.js](/example/app/scripts/app.js#L22) 40 | - APIend 41 | - podTypes 42 | - auth header 43 | 3. run `grunt:serve` 44 | 4. check out the list of Pods in your browser at `http:// localhost:3000` 45 | 5. add, edit and delete them 46 | 6. use Chrome DevTools or Firebug for seeing all the details 47 | 7. use [Postman](www.getpostman.com/) for trying things out when you are stuck with the Wordpress or Pods API 48 | 49 | ## Usage 50 | 51 | a few words about how things fit together 52 | 53 | ## Contributing 54 | 55 | feel free to send pull requests, add issues and use this code to your heart's delight 56 | 57 | ## License 58 | 59 | [MIT](/LICENSE) 60 | -------------------------------------------------------------------------------- /example/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "app/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /example/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .tmp 4 | .sass-cache 5 | app/bower_components 6 | .idea -------------------------------------------------------------------------------- /example/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "globals": { 22 | "angular": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | before_script: 5 | - 'npm install -g bower grunt-cli' 6 | - 'bower install' 7 | -------------------------------------------------------------------------------- /example/Gruntfile.js: -------------------------------------------------------------------------------- 1 | // Generated on 2014-06-04 using generator-angular 0.8.0 2 | 'use strict'; 3 | 4 | // # Globbing 5 | // for performance reasons we're only matching one level down: 6 | // 'test/spec/{,*/}*.js' 7 | // use this if you want to recursively match all subfolders: 8 | // 'test/spec/**/*.js' 9 | 10 | module.exports = function (grunt) { 11 | 12 | // Load grunt tasks automatically 13 | require('load-grunt-tasks')(grunt); 14 | 15 | // Time how long tasks take. Can help when optimizing build times 16 | require('time-grunt')(grunt); 17 | 18 | // Define the configuration for all the tasks 19 | grunt.initConfig({ 20 | 21 | // Project settings 22 | yeoman: { 23 | // configurable paths 24 | app: require('./bower.json').appPath || 'app', 25 | dist: 'dist' 26 | }, 27 | 28 | // Watches files for changes and runs tasks based on the changed files 29 | watch: { 30 | bower: { 31 | files: ['bower.json'], 32 | tasks: ['bowerInstall'] 33 | }, 34 | js: { 35 | files: ['<%= yeoman.app %>/scripts/{,*/}*.js'], 36 | tasks: ['newer:jshint:all'], 37 | options: { 38 | livereload: true 39 | } 40 | }, 41 | jsTest: { 42 | files: ['test/spec/{,*/}*.js'], 43 | tasks: ['newer:jshint:test', 'karma'] 44 | }, 45 | styles: { 46 | files: ['<%= yeoman.app %>/styles/{,*/}*.css'], 47 | tasks: ['newer:copy:styles', 'autoprefixer'] 48 | }, 49 | gruntfile: { 50 | files: ['Gruntfile.js'] 51 | }, 52 | livereload: { 53 | options: { 54 | livereload: '<%= connect.options.livereload %>' 55 | }, 56 | files: [ 57 | '<%= yeoman.app %>/{,*/}*.html', 58 | '.tmp/styles/{,*/}*.css', 59 | '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' 60 | ] 61 | } 62 | }, 63 | 64 | // The actual grunt server settings 65 | connect: { 66 | options: { 67 | port: 9000, 68 | // Change this to '0.0.0.0' to access the server from outside. 69 | hostname: 'localhost', 70 | livereload: 35729 71 | }, 72 | livereload: { 73 | options: { 74 | open: true, 75 | base: [ 76 | '.tmp', 77 | '<%= yeoman.app %>' 78 | ] 79 | } 80 | }, 81 | test: { 82 | options: { 83 | port: 9001, 84 | base: [ 85 | '.tmp', 86 | 'test', 87 | '<%= yeoman.app %>' 88 | ] 89 | } 90 | }, 91 | dist: { 92 | options: { 93 | base: '<%= yeoman.dist %>' 94 | } 95 | } 96 | }, 97 | 98 | // Make sure code styles are up to par and there are no obvious mistakes 99 | jshint: { 100 | options: { 101 | jshintrc: '.jshintrc', 102 | reporter: require('jshint-stylish') 103 | }, 104 | all: [ 105 | 'Gruntfile.js', 106 | '<%= yeoman.app %>/scripts/{,*/}*.js' 107 | ], 108 | test: { 109 | options: { 110 | jshintrc: 'test/.jshintrc' 111 | }, 112 | src: ['test/spec/{,*/}*.js'] 113 | } 114 | }, 115 | 116 | // Empties folders to start fresh 117 | clean: { 118 | dist: { 119 | files: [{ 120 | dot: true, 121 | src: [ 122 | '.tmp', 123 | '<%= yeoman.dist %>/*', 124 | '!<%= yeoman.dist %>/.git*' 125 | ] 126 | }] 127 | }, 128 | server: '.tmp' 129 | }, 130 | 131 | // Add vendor prefixed styles 132 | autoprefixer: { 133 | options: { 134 | browsers: ['last 1 version'] 135 | }, 136 | dist: { 137 | files: [{ 138 | expand: true, 139 | cwd: '.tmp/styles/', 140 | src: '{,*/}*.css', 141 | dest: '.tmp/styles/' 142 | }] 143 | } 144 | }, 145 | 146 | // Automatically inject Bower components into the app 147 | bowerInstall: { 148 | app: { 149 | src: ['<%= yeoman.app %>/index.html'], 150 | ignorePath: '<%= yeoman.app %>/' 151 | } 152 | }, 153 | 154 | // Renames files for browser caching purposes 155 | rev: { 156 | dist: { 157 | files: { 158 | src: [ 159 | '<%= yeoman.dist %>/scripts/{,*/}*.js', 160 | '<%= yeoman.dist %>/styles/{,*/}*.css', 161 | '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', 162 | '<%= yeoman.dist %>/styles/fonts/*' 163 | ] 164 | } 165 | } 166 | }, 167 | 168 | // Reads HTML for usemin blocks to enable smart builds that automatically 169 | // concat, minify and revision files. Creates configurations in memory so 170 | // additional tasks can operate on them 171 | useminPrepare: { 172 | html: '<%= yeoman.app %>/index.html', 173 | options: { 174 | dest: '<%= yeoman.dist %>', 175 | flow: { 176 | html: { 177 | steps: { 178 | js: ['concat', 'uglifyjs'], 179 | css: ['cssmin'] 180 | }, 181 | post: {} 182 | } 183 | } 184 | } 185 | }, 186 | 187 | // Performs rewrites based on rev and the useminPrepare configuration 188 | usemin: { 189 | html: ['<%= yeoman.dist %>/{,*/}*.html'], 190 | css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], 191 | options: { 192 | assetsDirs: ['<%= yeoman.dist %>'] 193 | } 194 | }, 195 | 196 | // The following *-min tasks produce minified files in the dist folder 197 | cssmin: { 198 | options: { 199 | root: '<%= yeoman.app %>' 200 | } 201 | }, 202 | 203 | imagemin: { 204 | dist: { 205 | files: [{ 206 | expand: true, 207 | cwd: '<%= yeoman.app %>/images', 208 | src: '{,*/}*.{png,jpg,jpeg,gif}', 209 | dest: '<%= yeoman.dist %>/images' 210 | }] 211 | } 212 | }, 213 | 214 | svgmin: { 215 | dist: { 216 | files: [{ 217 | expand: true, 218 | cwd: '<%= yeoman.app %>/images', 219 | src: '{,*/}*.svg', 220 | dest: '<%= yeoman.dist %>/images' 221 | }] 222 | } 223 | }, 224 | 225 | htmlmin: { 226 | dist: { 227 | options: { 228 | collapseWhitespace: true, 229 | collapseBooleanAttributes: true, 230 | removeCommentsFromCDATA: true, 231 | removeOptionalTags: true 232 | }, 233 | files: [{ 234 | expand: true, 235 | cwd: '<%= yeoman.dist %>', 236 | src: ['*.html', 'views/{,*/}*.html'], 237 | dest: '<%= yeoman.dist %>' 238 | }] 239 | } 240 | }, 241 | 242 | // ngmin tries to make the code safe for minification automatically by 243 | // using the Angular long form for dependency injection. It doesn't work on 244 | // things like resolve or inject so those have to be done manually. 245 | ngmin: { 246 | dist: { 247 | files: [{ 248 | expand: true, 249 | cwd: '.tmp/concat/scripts', 250 | src: '*.js', 251 | dest: '.tmp/concat/scripts' 252 | }] 253 | } 254 | }, 255 | 256 | // Replace Google CDN references 257 | cdnify: { 258 | dist: { 259 | html: ['<%= yeoman.dist %>/*.html'] 260 | } 261 | }, 262 | 263 | // Copies remaining files to places other tasks can use 264 | copy: { 265 | dist: { 266 | files: [{ 267 | expand: true, 268 | dot: true, 269 | cwd: '<%= yeoman.app %>', 270 | dest: '<%= yeoman.dist %>', 271 | src: [ 272 | '*.{ico,png,txt}', 273 | '.htaccess', 274 | '*.html', 275 | 'views/{,*/}*.html', 276 | 'images/{,*/}*.{webp}', 277 | 'fonts/*' 278 | ] 279 | }, { 280 | expand: true, 281 | cwd: '.tmp/images', 282 | dest: '<%= yeoman.dist %>/images', 283 | src: ['generated/*'] 284 | }] 285 | }, 286 | styles: { 287 | expand: true, 288 | cwd: '<%= yeoman.app %>/styles', 289 | dest: '.tmp/styles/', 290 | src: '{,*/}*.css' 291 | } 292 | }, 293 | 294 | // Run some tasks in parallel to speed up the build process 295 | concurrent: { 296 | server: [ 297 | 'copy:styles' 298 | ], 299 | test: [ 300 | 'copy:styles' 301 | ], 302 | dist: [ 303 | 'copy:styles', 304 | 'imagemin', 305 | 'svgmin' 306 | ] 307 | }, 308 | 309 | // By default, your `index.html`'s will take care of 310 | // minification. These next options are pre-configured if you do not wish 311 | // to use the Usemin blocks. 312 | // cssmin: { 313 | // dist: { 314 | // files: { 315 | // '<%= yeoman.dist %>/styles/main.css': [ 316 | // '.tmp/styles/{,*/}*.css', 317 | // '<%= yeoman.app %>/styles/{,*/}*.css' 318 | // ] 319 | // } 320 | // } 321 | // }, 322 | // uglify: { 323 | // dist: { 324 | // files: { 325 | // '<%= yeoman.dist %>/scripts/scripts.js': [ 326 | // '<%= yeoman.dist %>/scripts/scripts.js' 327 | // ] 328 | // } 329 | // } 330 | // }, 331 | // concat: { 332 | // dist: {} 333 | // }, 334 | 335 | // Test settings 336 | karma: { 337 | unit: { 338 | configFile: 'karma.conf.js', 339 | singleRun: true 340 | } 341 | } 342 | }); 343 | 344 | 345 | grunt.registerTask('serve', function (target) { 346 | if (target === 'dist') { 347 | return grunt.task.run(['build', 'connect:dist:keepalive']); 348 | } 349 | 350 | grunt.task.run([ 351 | 'clean:server', 352 | 'bowerInstall', 353 | 'concurrent:server', 354 | 'autoprefixer', 355 | 'connect:livereload', 356 | 'watch' 357 | ]); 358 | }); 359 | 360 | grunt.registerTask('server', function (target) { 361 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); 362 | grunt.task.run(['serve:' + target]); 363 | }); 364 | 365 | grunt.registerTask('test', [ 366 | 'clean:server', 367 | 'concurrent:test', 368 | 'autoprefixer', 369 | 'connect:test', 370 | 'karma' 371 | ]); 372 | 373 | grunt.registerTask('build', [ 374 | 'clean:dist', 375 | 'bowerInstall', 376 | 'useminPrepare', 377 | 'concurrent:dist', 378 | 'autoprefixer', 379 | 'concat', 380 | 'ngmin', 381 | 'copy:dist', 382 | 'cdnify', 383 | 'cssmin', 384 | 'uglify', 385 | 'rev', 386 | 'usemin', 387 | 'htmlmin' 388 | ]); 389 | 390 | grunt.registerTask('default', [ 391 | 'newer:jshint', 392 | 'test', 393 | 'build' 394 | ]); 395 | }; 396 | -------------------------------------------------------------------------------- /example/app/.buildignore: -------------------------------------------------------------------------------- 1 | *.coffee -------------------------------------------------------------------------------- /example/app/.htaccess: -------------------------------------------------------------------------------- 1 | # Apache Configuration File 2 | 3 | # (!) Using `.htaccess` files slows down Apache, therefore, if you have access 4 | # to the main server config file (usually called `httpd.conf`), you should add 5 | # this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html. 6 | 7 | # ############################################################################## 8 | # # CROSS-ORIGIN RESOURCE SHARING (CORS) # 9 | # ############################################################################## 10 | 11 | # ------------------------------------------------------------------------------ 12 | # | Cross-domain AJAX requests | 13 | # ------------------------------------------------------------------------------ 14 | 15 | # Enable cross-origin AJAX requests. 16 | # http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity 17 | # http://enable-cors.org/ 18 | 19 | # 20 | # Header set Access-Control-Allow-Origin "*" 21 | # 22 | 23 | # ------------------------------------------------------------------------------ 24 | # | CORS-enabled images | 25 | # ------------------------------------------------------------------------------ 26 | 27 | # Send the CORS header for images when browsers request it. 28 | # https://developer.mozilla.org/en/CORS_Enabled_Image 29 | # http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html 30 | # http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ 31 | 32 | 33 | 34 | 35 | SetEnvIf Origin ":" IS_CORS 36 | Header set Access-Control-Allow-Origin "*" env=IS_CORS 37 | 38 | 39 | 40 | 41 | # ------------------------------------------------------------------------------ 42 | # | Web fonts access | 43 | # ------------------------------------------------------------------------------ 44 | 45 | # Allow access from all domains for web fonts 46 | 47 | 48 | 49 | Header set Access-Control-Allow-Origin "*" 50 | 51 | 52 | 53 | 54 | # ############################################################################## 55 | # # ERRORS # 56 | # ############################################################################## 57 | 58 | # ------------------------------------------------------------------------------ 59 | # | 404 error prevention for non-existing redirected folders | 60 | # ------------------------------------------------------------------------------ 61 | 62 | # Prevent Apache from returning a 404 error for a rewrite if a directory 63 | # with the same name does not exist. 64 | # http://httpd.apache.org/docs/current/content-negotiation.html#multiviews 65 | # http://www.webmasterworld.com/apache/3808792.htm 66 | 67 | Options -MultiViews 68 | 69 | # ------------------------------------------------------------------------------ 70 | # | Custom error messages / pages | 71 | # ------------------------------------------------------------------------------ 72 | 73 | # You can customize what Apache returns to the client in case of an error (see 74 | # http://httpd.apache.org/docs/current/mod/core.html#errordocument), e.g.: 75 | 76 | ErrorDocument 404 /404.html 77 | 78 | 79 | # ############################################################################## 80 | # # INTERNET EXPLORER # 81 | # ############################################################################## 82 | 83 | # ------------------------------------------------------------------------------ 84 | # | Better website experience | 85 | # ------------------------------------------------------------------------------ 86 | 87 | # Force IE to render pages in the highest available mode in the various 88 | # cases when it may not: http://hsivonen.iki.fi/doctype/ie-mode.pdf. 89 | 90 | 91 | Header set X-UA-Compatible "IE=edge" 92 | # `mod_headers` can't match based on the content-type, however, we only 93 | # want to send this header for HTML pages and not for the other resources 94 | 95 | Header unset X-UA-Compatible 96 | 97 | 98 | 99 | # ------------------------------------------------------------------------------ 100 | # | Cookie setting from iframes | 101 | # ------------------------------------------------------------------------------ 102 | 103 | # Allow cookies to be set from iframes in IE. 104 | 105 | # 106 | # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"" 107 | # 108 | 109 | # ------------------------------------------------------------------------------ 110 | # | Screen flicker | 111 | # ------------------------------------------------------------------------------ 112 | 113 | # Stop screen flicker in IE on CSS rollovers (this only works in 114 | # combination with the `ExpiresByType` directives for images from below). 115 | 116 | # BrowserMatch "MSIE" brokenvary=1 117 | # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 118 | # BrowserMatch "Opera" !brokenvary 119 | # SetEnvIf brokenvary 1 force-no-vary 120 | 121 | 122 | # ############################################################################## 123 | # # MIME TYPES AND ENCODING # 124 | # ############################################################################## 125 | 126 | # ------------------------------------------------------------------------------ 127 | # | Proper MIME types for all files | 128 | # ------------------------------------------------------------------------------ 129 | 130 | 131 | 132 | # Audio 133 | AddType audio/mp4 m4a f4a f4b 134 | AddType audio/ogg oga ogg 135 | 136 | # JavaScript 137 | # Normalize to standard type (it's sniffed in IE anyways): 138 | # http://tools.ietf.org/html/rfc4329#section-7.2 139 | AddType application/javascript js jsonp 140 | AddType application/json json 141 | 142 | # Video 143 | AddType video/mp4 mp4 m4v f4v f4p 144 | AddType video/ogg ogv 145 | AddType video/webm webm 146 | AddType video/x-flv flv 147 | 148 | # Web fonts 149 | AddType application/font-woff woff 150 | AddType application/vnd.ms-fontobject eot 151 | 152 | # Browsers usually ignore the font MIME types and sniff the content, 153 | # however, Chrome shows a warning if other MIME types are used for the 154 | # following fonts. 155 | AddType application/x-font-ttf ttc ttf 156 | AddType font/opentype otf 157 | 158 | # Make SVGZ fonts work on iPad: 159 | # https://twitter.com/FontSquirrel/status/14855840545 160 | AddType image/svg+xml svg svgz 161 | AddEncoding gzip svgz 162 | 163 | # Other 164 | AddType application/octet-stream safariextz 165 | AddType application/x-chrome-extension crx 166 | AddType application/x-opera-extension oex 167 | AddType application/x-shockwave-flash swf 168 | AddType application/x-web-app-manifest+json webapp 169 | AddType application/x-xpinstall xpi 170 | AddType application/xml atom rdf rss xml 171 | AddType image/webp webp 172 | AddType image/x-icon ico 173 | AddType text/cache-manifest appcache manifest 174 | AddType text/vtt vtt 175 | AddType text/x-component htc 176 | AddType text/x-vcard vcf 177 | 178 | 179 | 180 | # ------------------------------------------------------------------------------ 181 | # | UTF-8 encoding | 182 | # ------------------------------------------------------------------------------ 183 | 184 | # Use UTF-8 encoding for anything served as `text/html` or `text/plain`. 185 | AddDefaultCharset utf-8 186 | 187 | # Force UTF-8 for certain file formats. 188 | 189 | AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml 190 | 191 | 192 | 193 | # ############################################################################## 194 | # # URL REWRITES # 195 | # ############################################################################## 196 | 197 | # ------------------------------------------------------------------------------ 198 | # | Rewrite engine | 199 | # ------------------------------------------------------------------------------ 200 | 201 | # Turning on the rewrite engine and enabling the `FollowSymLinks` option is 202 | # necessary for the following directives to work. 203 | 204 | # If your web host doesn't allow the `FollowSymlinks` option, you may need to 205 | # comment it out and use `Options +SymLinksIfOwnerMatch` but, be aware of the 206 | # performance impact: http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks 207 | 208 | # Also, some cloud hosting services require `RewriteBase` to be set: 209 | # http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site 210 | 211 | 212 | Options +FollowSymlinks 213 | # Options +SymLinksIfOwnerMatch 214 | RewriteEngine On 215 | # RewriteBase / 216 | 217 | 218 | # ------------------------------------------------------------------------------ 219 | # | Suppressing / Forcing the "www." at the beginning of URLs | 220 | # ------------------------------------------------------------------------------ 221 | 222 | # The same content should never be available under two different URLs especially 223 | # not with and without "www." at the beginning. This can cause SEO problems 224 | # (duplicate content), therefore, you should choose one of the alternatives and 225 | # redirect the other one. 226 | 227 | # By default option 1 (no "www.") is activated: 228 | # http://no-www.org/faq.php?q=class_b 229 | 230 | # If you'd prefer to use option 2, just comment out all the lines from option 1 231 | # and uncomment the ones from option 2. 232 | 233 | # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME! 234 | 235 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 236 | 237 | # Option 1: rewrite www.example.com → example.com 238 | 239 | 240 | RewriteCond %{HTTPS} !=on 241 | RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 242 | RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] 243 | 244 | 245 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246 | 247 | # Option 2: rewrite example.com → www.example.com 248 | 249 | # Be aware that the following might not be a good idea if you use "real" 250 | # subdomains for certain parts of your website. 251 | 252 | # 253 | # RewriteCond %{HTTPS} !=on 254 | # RewriteCond %{HTTP_HOST} !^www\..+$ [NC] 255 | # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 256 | # 257 | 258 | 259 | # ############################################################################## 260 | # # SECURITY # 261 | # ############################################################################## 262 | 263 | # ------------------------------------------------------------------------------ 264 | # | Content Security Policy (CSP) | 265 | # ------------------------------------------------------------------------------ 266 | 267 | # You can mitigate the risk of cross-site scripting and other content-injection 268 | # attacks by setting a Content Security Policy which whitelists trusted sources 269 | # of content for your site. 270 | 271 | # The example header below allows ONLY scripts that are loaded from the current 272 | # site's origin (no inline scripts, no CDN, etc). This almost certainly won't 273 | # work as-is for your site! 274 | 275 | # To get all the details you'll need to craft a reasonable policy for your site, 276 | # read: http://html5rocks.com/en/tutorials/security/content-security-policy (or 277 | # see the specification: http://w3.org/TR/CSP). 278 | 279 | # 280 | # Header set Content-Security-Policy "script-src 'self'; object-src 'self'" 281 | # 282 | # Header unset Content-Security-Policy 283 | # 284 | # 285 | 286 | # ------------------------------------------------------------------------------ 287 | # | File access | 288 | # ------------------------------------------------------------------------------ 289 | 290 | # Block access to directories without a default document. 291 | # Usually you should leave this uncommented because you shouldn't allow anyone 292 | # to surf through every directory on your server (which may includes rather 293 | # private places like the CMS's directories). 294 | 295 | 296 | Options -Indexes 297 | 298 | 299 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 300 | 301 | # Block access to hidden files and directories. 302 | # This includes directories used by version control systems such as Git and SVN. 303 | 304 | 305 | RewriteCond %{SCRIPT_FILENAME} -d [OR] 306 | RewriteCond %{SCRIPT_FILENAME} -f 307 | RewriteRule "(^|/)\." - [F] 308 | 309 | 310 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 311 | 312 | # Block access to backup and source files. 313 | # These files may be left by some text editors and can pose a great security 314 | # danger when anyone has access to them. 315 | 316 | 317 | Order allow,deny 318 | Deny from all 319 | Satisfy All 320 | 321 | 322 | # ------------------------------------------------------------------------------ 323 | # | Secure Sockets Layer (SSL) | 324 | # ------------------------------------------------------------------------------ 325 | 326 | # Rewrite secure requests properly to prevent SSL certificate warnings, e.g.: 327 | # prevent `https://www.example.com` when your certificate only allows 328 | # `https://secure.example.com`. 329 | 330 | # 331 | # RewriteCond %{SERVER_PORT} !^443 332 | # RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L] 333 | # 334 | 335 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 336 | 337 | # Force client-side SSL redirection. 338 | 339 | # If a user types "example.com" in his browser, the above rule will redirect him 340 | # to the secure version of the site. That still leaves a window of opportunity 341 | # (the initial HTTP connection) for an attacker to downgrade or redirect the 342 | # request. The following header ensures that browser will ONLY connect to your 343 | # server via HTTPS, regardless of what the users type in the address bar. 344 | # http://www.html5rocks.com/en/tutorials/security/transport-layer-security/ 345 | 346 | # 347 | # Header set Strict-Transport-Security max-age=16070400; 348 | # 349 | 350 | # ------------------------------------------------------------------------------ 351 | # | Server software information | 352 | # ------------------------------------------------------------------------------ 353 | 354 | # Avoid displaying the exact Apache version number, the description of the 355 | # generic OS-type and the information about Apache's compiled-in modules. 356 | 357 | # ADD THIS DIRECTIVE IN THE `httpd.conf` AS IT WILL NOT WORK IN THE `.htaccess`! 358 | 359 | # ServerTokens Prod 360 | 361 | 362 | # ############################################################################## 363 | # # WEB PERFORMANCE # 364 | # ############################################################################## 365 | 366 | # ------------------------------------------------------------------------------ 367 | # | Compression | 368 | # ------------------------------------------------------------------------------ 369 | 370 | 371 | 372 | # Force compression for mangled headers. 373 | # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping 374 | 375 | 376 | SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding 377 | RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding 378 | 379 | 380 | 381 | # Compress all output labeled with one of the following MIME-types 382 | # (for Apache versions below 2.3.7, you don't need to enable `mod_filter` 383 | # and can remove the `` and `` lines 384 | # as `AddOutputFilterByType` is still in the core directives). 385 | 386 | AddOutputFilterByType DEFLATE application/atom+xml \ 387 | application/javascript \ 388 | application/json \ 389 | application/rss+xml \ 390 | application/vnd.ms-fontobject \ 391 | application/x-font-ttf \ 392 | application/x-web-app-manifest+json \ 393 | application/xhtml+xml \ 394 | application/xml \ 395 | font/opentype \ 396 | image/svg+xml \ 397 | image/x-icon \ 398 | text/css \ 399 | text/html \ 400 | text/plain \ 401 | text/x-component \ 402 | text/xml 403 | 404 | 405 | 406 | 407 | # ------------------------------------------------------------------------------ 408 | # | Content transformations | 409 | # ------------------------------------------------------------------------------ 410 | 411 | # Prevent some of the mobile network providers from modifying the content of 412 | # your site: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5. 413 | 414 | # 415 | # Header set Cache-Control "no-transform" 416 | # 417 | 418 | # ------------------------------------------------------------------------------ 419 | # | ETag removal | 420 | # ------------------------------------------------------------------------------ 421 | 422 | # Since we're sending far-future expires headers (see below), ETags can 423 | # be removed: http://developer.yahoo.com/performance/rules.html#etags. 424 | 425 | # `FileETag None` is not enough for every server. 426 | 427 | Header unset ETag 428 | 429 | 430 | FileETag None 431 | 432 | # ------------------------------------------------------------------------------ 433 | # | Expires headers (for better cache control) | 434 | # ------------------------------------------------------------------------------ 435 | 436 | # The following expires headers are set pretty far in the future. If you don't 437 | # control versioning with filename-based cache busting, consider lowering the 438 | # cache time for resources like CSS and JS to something like 1 week. 439 | 440 | 441 | 442 | ExpiresActive on 443 | ExpiresDefault "access plus 1 month" 444 | 445 | # CSS 446 | ExpiresByType text/css "access plus 1 year" 447 | 448 | # Data interchange 449 | ExpiresByType application/json "access plus 0 seconds" 450 | ExpiresByType application/xml "access plus 0 seconds" 451 | ExpiresByType text/xml "access plus 0 seconds" 452 | 453 | # Favicon (cannot be renamed!) 454 | ExpiresByType image/x-icon "access plus 1 week" 455 | 456 | # HTML components (HTCs) 457 | ExpiresByType text/x-component "access plus 1 month" 458 | 459 | # HTML 460 | ExpiresByType text/html "access plus 0 seconds" 461 | 462 | # JavaScript 463 | ExpiresByType application/javascript "access plus 1 year" 464 | 465 | # Manifest files 466 | ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" 467 | ExpiresByType text/cache-manifest "access plus 0 seconds" 468 | 469 | # Media 470 | ExpiresByType audio/ogg "access plus 1 month" 471 | ExpiresByType image/gif "access plus 1 month" 472 | ExpiresByType image/jpeg "access plus 1 month" 473 | ExpiresByType image/png "access plus 1 month" 474 | ExpiresByType video/mp4 "access plus 1 month" 475 | ExpiresByType video/ogg "access plus 1 month" 476 | ExpiresByType video/webm "access plus 1 month" 477 | 478 | # Web feeds 479 | ExpiresByType application/atom+xml "access plus 1 hour" 480 | ExpiresByType application/rss+xml "access plus 1 hour" 481 | 482 | # Web fonts 483 | ExpiresByType application/font-woff "access plus 1 month" 484 | ExpiresByType application/vnd.ms-fontobject "access plus 1 month" 485 | ExpiresByType application/x-font-ttf "access plus 1 month" 486 | ExpiresByType font/opentype "access plus 1 month" 487 | ExpiresByType image/svg+xml "access plus 1 month" 488 | 489 | 490 | 491 | # ------------------------------------------------------------------------------ 492 | # | Filename-based cache busting | 493 | # ------------------------------------------------------------------------------ 494 | 495 | # If you're not using a build process to manage your filename version revving, 496 | # you might want to consider enabling the following directives to route all 497 | # requests such as `/css/style.12345.css` to `/css/style.css`. 498 | 499 | # To understand why this is important and a better idea than `*.css?v231`, read: 500 | # http://stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring 501 | 502 | # 503 | # RewriteCond %{REQUEST_FILENAME} !-f 504 | # RewriteCond %{REQUEST_FILENAME} !-d 505 | # RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] 506 | # 507 | 508 | # ------------------------------------------------------------------------------ 509 | # | File concatenation | 510 | # ------------------------------------------------------------------------------ 511 | 512 | # Allow concatenation from within specific CSS and JS files, e.g.: 513 | # Inside of `script.combined.js` you could have 514 | # 515 | # 516 | # and they would be included into this single file. 517 | 518 | # 519 | # 520 | # Options +Includes 521 | # AddOutputFilterByType INCLUDES application/javascript application/json 522 | # SetOutputFilter INCLUDES 523 | # 524 | # 525 | # Options +Includes 526 | # AddOutputFilterByType INCLUDES text/css 527 | # SetOutputFilter INCLUDES 528 | # 529 | # 530 | 531 | # ------------------------------------------------------------------------------ 532 | # | Persistent connections | 533 | # ------------------------------------------------------------------------------ 534 | 535 | # Allow multiple requests to be sent over the same TCP connection: 536 | # http://httpd.apache.org/docs/current/en/mod/core.html#keepalive. 537 | 538 | # Enable if you serve a lot of static content but, be aware of the 539 | # possible disadvantages! 540 | 541 | # 542 | # Header set Connection Keep-Alive 543 | # 544 | -------------------------------------------------------------------------------- /example/app/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Page Not Found :( 6 | 141 | 142 | 143 |
144 |

Not found :(

145 |

Sorry, but the page you were trying to view does not exist.

146 |

It looks like this was the result of either:

147 | 151 | 154 | 155 |
156 | 157 | 158 | -------------------------------------------------------------------------------- /example/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernklose/angular-wordpress-pods/3711e6525f1203b6a6fbebc0b4277b9996eceb46/example/app/favicon.ico -------------------------------------------------------------------------------- /example/app/images/yeoman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernklose/angular-wordpress-pods/3711e6525f1203b6a6fbebc0b4277b9996eceb46/example/app/images/yeoman.png -------------------------------------------------------------------------------- /example/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 |
28 | 29 | 30 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /example/app/robots.txt: -------------------------------------------------------------------------------- 1 | # robotstxt.org 2 | 3 | User-agent: * 4 | -------------------------------------------------------------------------------- /example/app/scripts/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var app = angular 4 | .module('exampleApp', [ 5 | 'ngCookies', 6 | 'ngResource', 7 | 'ngSanitize', 8 | 'ngRoute', 9 | 'ui.bootstrap', // for Modal window and such 10 | 'wp-pods-api' 11 | ]) 12 | .config(function ($routeProvider) { 13 | $routeProvider 14 | .when('/', { 15 | templateUrl: 'views/pods.html', 16 | controller: 'PodsCtrl' 17 | }) 18 | .otherwise({ 19 | redirectTo: '/' 20 | }); 21 | }) 22 | .config(function(PodsEndPointProvider) { 23 | PodsEndPointProvider.setAPI('http://your.domain.tld/wp-json/' + 'pods/'); 24 | PodsEndPointProvider.setAuth('Basic base64auth'); 25 | PodsEndPointProvider.setPodTypes(['mypod']); 26 | }); 27 | -------------------------------------------------------------------------------- /example/app/scripts/controllers/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('exampleApp') 4 | .controller('MainCtrl', function ($scope) { 5 | $scope.awesomeThings = [ 6 | 'HTML5 Boilerplate', 7 | 'AngularJS', 8 | 'Karma' 9 | ]; 10 | }); 11 | -------------------------------------------------------------------------------- /example/app/scripts/wp-pods-api.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('wp-pods-api', []) 4 | 5 | /** 6 | * PodsEndPoint is a configurable Provider 7 | * use it to set your API endpoint and auth credentials 8 | * during app.config() phase 9 | */ 10 | .provider('PodsEndPoint', function() { 11 | 12 | var APIurl = 'this.needs.to.change'; 13 | var APIauth = 'Basic ' + 'window.btoa(username + ":" + password)';// compare https://github.com/WP-API/Basic-Auth 14 | var APIpods = new Array('posts'); 15 | 16 | return { 17 | $get: function() { 18 | return { 19 | getURL: function() { 20 | return APIurl; 21 | }, 22 | getAuth : function() { 23 | return APIauth; 24 | }, 25 | getPodTypes : function() { 26 | return APIpods; 27 | } 28 | } 29 | }, 30 | setAPI: function (newValue) { 31 | APIurl = newValue; 32 | }, 33 | setAuth : function(textAndbase64) { 34 | APIauth = textAndbase64; 35 | }, 36 | setPodTypes : function(typesArray) { 37 | APIpods = typesArray; 38 | } 39 | }; 40 | 41 | }) 42 | /** 43 | * PodsService is the Pods DATA API, used to create, update, delete and list entries of a specific Pod type 44 | */ 45 | .service('PodsService', function(PodsEndPoint, $resource, $http) { 46 | 47 | var APIend = PodsEndPoint.getURL(); 48 | 49 | $http.defaults.headers.common['Authorization'] = PodsEndPoint.getAuth(); 50 | 51 | var PodService = {}; 52 | 53 | PodService.getPodTypes = function() { 54 | // TODO: get a list of all available Pod types from the API 55 | // for now, just return what has been configured before 56 | return PodsEndPoint.getPodTypes(); 57 | }; 58 | 59 | /** 60 | * list all entries of a specific pod type 61 | * @param {string} podType 62 | * @returns {*} 63 | */ 64 | PodService.list = function(podType) { 65 | return $http({ 66 | url: APIend + podType, 67 | method: "GET" 68 | }); 69 | }; 70 | 71 | PodService.save = function(pod) { 72 | if (pod.id !== undefined) { 73 | return PodService.update(pod); 74 | } 75 | else { 76 | return PodService.create(pod); 77 | } 78 | }; 79 | 80 | PodService.create = function(pod) { 81 | return $http({ 82 | url: APIend + pod.post_type, 83 | method: "POST", 84 | data: pod, 85 | headers: {'Content-Type': 'application/x-www-form-urlencoded'} 86 | }).success(function(data) { 87 | pod = data; 88 | }); 89 | }; 90 | 91 | PodService.update = function(pod) { 92 | 93 | var podId = pod.id || pod.ID; 94 | 95 | return $http({ 96 | url: APIend + pod.post_type + "/" + podId, 97 | method: "PUT", 98 | data: pod, 99 | headers: {'Content-Type': 'application/x-www-form-urlencoded'} 100 | }).success(function(data) { 101 | // update with new values from API callback 102 | // TODO: update everything? 103 | pod.post_modified = data.post_modified; 104 | pod.post_modified_gmt = data.post_modified_gmt; 105 | 106 | }).error(function (data, status, headers, config) { 107 | 108 | console.log("FAIL!"); 109 | console.log(data, status, headers, config); 110 | 111 | }); 112 | }; 113 | 114 | PodService.delete = function(pod) { 115 | var podId = pod.ID || pod.id; 116 | return $http({ 117 | url: APIend + pod.post_type + "/" + podId, 118 | method: "DELETE" 119 | }); 120 | }; 121 | 122 | 123 | return PodService; 124 | }); -------------------------------------------------------------------------------- /example/app/scripts/wp-pods-sample-app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * we use the $modal from ui.bootstrap for editing Pods 5 | * this is the controller that is invoked once a Pod is opened inside the modal 6 | * @param $scope 7 | * @param $modalInstance 8 | * @param editPod 9 | * @constructor 10 | */ 11 | var ModalPodEditorCtrl = function ($scope, $modalInstance, editPod) { 12 | 13 | $scope.pod = editPod; 14 | $scope.hideRawJSON = true; 15 | 16 | $scope.ok = function () { 17 | // Make sure we send back the edited element after user is done 18 | $modalInstance.close($scope.pod); 19 | }; 20 | 21 | $scope.cancel = function () { 22 | $modalInstance.dismiss('cancel'); 23 | }; 24 | }; 25 | 26 | /** 27 | * this is the main Pods Controller that deals with listing, editing and deleting Pods 28 | * it uses the PodsService from wp-pods-api.js 29 | * and the $modal service from ui.bootstrap 30 | * 31 | * all currently listed Pods are stored in $scope.pods 32 | */ 33 | app.controller('PodsCtrl', function ($scope, PodsService, $modal, $log) { 34 | 35 | $scope.pods = []; // the list 36 | $scope.podType = PodsService.getPodTypes()[0]; // only needed for listing and creating a new entry 37 | 38 | /** 39 | * make sure we have a list of entries that can be displayed when the user loads the main list view 40 | */ 41 | 42 | PodsService.list($scope.podType).then(function(res) { 43 | $scope.pods = res.data; 44 | }); 45 | 46 | /** 47 | * to add a new pod, open a modal, show a nice view inside, then use PodsService.save() 48 | */ 49 | $scope.addPod = function() { 50 | 51 | var newPod = { 52 | post_title : 'title goes here', 53 | post_content : 'content goes here', 54 | post_status : 'publish', // set this to "publish" as default, otherwise it won't show up in our next list() call 55 | post_type : $scope.podType 56 | 57 | // TODO: add other default values here or pull in from a proper Model in some service 58 | }; 59 | 60 | // TODO: maybe have a different UI for adding new elements? 61 | var modalInstance = $modal.open({ 62 | templateUrl: 'views/pods.editor.html', 63 | controller: ModalPodEditorCtrl, 64 | //size: size, 65 | resolve: { 66 | editPod: function () { 67 | return newPod; 68 | } 69 | } 70 | }); 71 | 72 | /** 73 | * after editing in the modal view is done, continue here 74 | */ 75 | modalInstance.result.then(function (podAfterEdit) { 76 | 77 | $log.log("getting ready for saving ", podAfterEdit); 78 | PodsService.save(podAfterEdit).success(function(podAfterSaving) { 79 | 80 | // add new element to pods in UI 81 | $scope.pods[podAfterSaving.id] = podAfterSaving; 82 | 83 | // TODO: handle result of adding process here or in PodsService 84 | // e.g. show notification to user 85 | 86 | }); 87 | 88 | }, function () { 89 | $log.info('Modal dismissed at: ' + new Date()); 90 | }); 91 | }; 92 | 93 | /** 94 | * we use ui.bootstrap's $modal service for showing a modal window to edit 95 | * @param pod 96 | */ 97 | $scope.editPod = function(pod) { 98 | 99 | var modalInstance = $modal.open({ 100 | templateUrl: 'views/pods.editor.html', 101 | controller: ModalPodEditorCtrl, 102 | //size: size, 103 | resolve: { 104 | editPod: function () { 105 | return pod; 106 | } 107 | } 108 | }); 109 | 110 | modalInstance.result.then(function (podAfterEdit) { 111 | 112 | $log.log("getting ready for saving ", podAfterEdit); 113 | PodsService.save(podAfterEdit); 114 | // TODO: handle result of saving process here or in PodsService 115 | // e.g. show notification to user 116 | 117 | }, function () { 118 | $log.info('Modal dismissed at: ' + new Date()); 119 | }); 120 | }; 121 | 122 | /** 123 | * directly delete a Pod, no questions asked 124 | * @param pod 125 | */ 126 | $scope.deletePod = function(pod) { 127 | // TODO: add an "Are you sure you want to delete ____ ?" dialogue here 128 | PodsService.delete(pod) 129 | .success(function(data) { 130 | // remove element from our scope 131 | delete $scope.pods[pod.id]; 132 | }) 133 | .error(function(data, headers) { 134 | // TODO: nice error handling 135 | alert("could not delete pod"); 136 | }) 137 | ; 138 | }; 139 | }); -------------------------------------------------------------------------------- /example/app/styles/main.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-left: 15px; 12 | padding-right: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | margin-top: 0; 22 | margin-bottom: 0; 23 | line-height: 40px; 24 | padding-bottom: 19px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | font-size: 21px; 51 | padding: 14px 24px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-left: 0; 69 | padding-right: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /example/app/views/main.html: -------------------------------------------------------------------------------- 1 |
2 | 7 |

example

8 |
9 | 10 |
11 |

'Allo, 'Allo!

12 |

13 | I'm Yeoman
14 | Always a pleasure scaffolding your apps. 15 |

16 |

Splendid!

17 |
18 | 19 |
20 |

HTML5 Boilerplate

21 |

22 | HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites. 23 |

24 | 25 |

Angular

26 |

27 | AngularJS is a toolset for building the framework most suited to your application development. 28 |

29 | 30 |

Karma

31 |

Spectacular Test Runner for JavaScript.

32 |
33 | 34 | 37 | -------------------------------------------------------------------------------- /example/app/views/pods.editor.html: -------------------------------------------------------------------------------- 1 | 4 | 28 | -------------------------------------------------------------------------------- /example/app/views/pods.html: -------------------------------------------------------------------------------- 1 |

2 | Hey there! Hope you've got your {{podType}} set up correctly in the 3 |

4 | 5 | 6 |
7 | ({{pod.id}}) {{pod.post_title}}
8 | last edited: {{pod.post_modified | date:'short'}} 9 | 10 | 11 |
-------------------------------------------------------------------------------- /example/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "angular": "1.2.15", 6 | "json3": "~3.2.6", 7 | "es5-shim": "~2.1.0", 8 | "angular-resource": "1.2.15", 9 | "angular-cookies": "1.2.15", 10 | "angular-sanitize": "1.2.15", 11 | "angular-route": "1.2.15" 12 | }, 13 | "devDependencies": { 14 | "angular-mocks": "1.2.15", 15 | "angular-scenario": "1.2.15" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.0", 4 | "dependencies": {}, 5 | "devDependencies": { 6 | "grunt": "~0.4.5", 7 | "grunt-autoprefixer": "~0.4.0", 8 | "grunt-bower-install": "~1.0.0", 9 | "grunt-concurrent": "~0.5.0", 10 | "grunt-contrib-clean": "~0.5.0", 11 | "grunt-contrib-concat": "~0.3.0", 12 | "grunt-contrib-connect": "~0.5.0", 13 | "grunt-contrib-copy": "~0.4.1", 14 | "grunt-contrib-cssmin": "~0.7.0", 15 | "grunt-contrib-htmlmin": "~0.1.3", 16 | "grunt-contrib-imagemin": "~0.3.0", 17 | "grunt-contrib-jshint": "~0.7.1", 18 | "grunt-contrib-uglify": "~0.2.0", 19 | "grunt-contrib-watch": "~0.5.2", 20 | "grunt-google-cdn": "~0.2.0", 21 | "grunt-newer": "~0.6.1", 22 | "grunt-ngmin": "~0.0.2", 23 | "grunt-rev": "~0.1.0", 24 | "grunt-svgmin": "~0.2.0", 25 | "grunt-usemin": "~2.0.0", 26 | "jshint-stylish": "~0.1.3", 27 | "load-grunt-tasks": "~0.4.0", 28 | "time-grunt": "~0.2.1", 29 | "karma-phantomjs-launcher": "~0.1.4", 30 | "grunt-karma": "~0.8.3", 31 | "karma": "~0.12.16", 32 | "karma-jasmine": "~0.1.5" 33 | }, 34 | "engines": { 35 | "node": ">=0.10.0" 36 | }, 37 | "scripts": { 38 | "test": "grunt test" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/test/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "globals": { 22 | "after": false, 23 | "afterEach": false, 24 | "angular": false, 25 | "before": false, 26 | "beforeEach": false, 27 | "browser": false, 28 | "describe": false, 29 | "expect": false, 30 | "inject": false, 31 | "it": false, 32 | "jasmine": false, 33 | "spyOn": false 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /example/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // http://karma-runner.github.io/0.12/config/configuration-file.html 3 | // Generated on 2014-06-04 using 4 | // generator-karma 0.8.1 5 | 6 | module.exports = function(config) { 7 | config.set({ 8 | // enable / disable watching file and executing tests whenever any file changes 9 | autoWatch: true, 10 | 11 | // base path, that will be used to resolve files and exclude 12 | basePath: '', 13 | 14 | // testing framework to use (jasmine/mocha/qunit/...) 15 | frameworks: ['jasmine'], 16 | 17 | // list of files / patterns to load in the browser 18 | files: [], 19 | 20 | // list of files / patterns to exclude 21 | exclude: [], 22 | 23 | // web server port 24 | port: 8080, 25 | 26 | // Start these browsers, currently available: 27 | // - Chrome 28 | // - ChromeCanary 29 | // - Firefox 30 | // - Opera 31 | // - Safari (only Mac) 32 | // - PhantomJS 33 | // - IE (only Windows) 34 | browsers: [ 35 | 'PhantomJS' 36 | ], 37 | 38 | // Which plugins to enable 39 | plugins: [ 40 | 'karma-phantomjs-launcher', 41 | 'karma-jasmine' 42 | ], 43 | 44 | // Continuous Integration mode 45 | // if true, it capture browsers, run tests and exit 46 | singleRun: false 47 | 48 | colors: true, 49 | 50 | // level of logging 51 | // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG 52 | logLevel: config.LOG_INFO, 53 | 54 | // Uncomment the following lines if you are using grunt's server to run the tests 55 | // proxies: { 56 | // '/': 'http://localhost:9000/' 57 | // }, 58 | // URL root prevent conflicts with the site root 59 | // urlRoot: '_karma_' 60 | }); 61 | }; 62 | -------------------------------------------------------------------------------- /example/test/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | End2end Test Runner 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/test/spec/controllers/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Controller: MainCtrl', function () { 4 | 5 | // load the controller's module 6 | beforeEach(module('exampleApp')); 7 | 8 | var MainCtrl, 9 | scope; 10 | 11 | // Initialize the controller and a mock scope 12 | beforeEach(inject(function ($controller, $rootScope) { 13 | scope = $rootScope.$new(); 14 | MainCtrl = $controller('MainCtrl', { 15 | $scope: scope 16 | }); 17 | })); 18 | 19 | it('should attach a list of awesomeThings to the scope', function () { 20 | expect(scope.awesomeThings.length).toBe(3); 21 | }); 22 | }); 23 | --------------------------------------------------------------------------------