Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
app/bower_components
npm-debug.log

.idea/
.DS_Store
.directory
59 changes: 18 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# angular-drupal

An Angular JS module for Drupal 7 Services.
An Angular JS module for Drupal 8 RESTful Web Services.

# Intro

Expand All @@ -25,8 +25,7 @@ angular.module('myApp', ['angular-drupal']).run(['drupal', function(drupal) {
angular.module('angular-drupal').config(function($provide) {

$provide.value('drupalSettings', {
sitePath: 'http://my-drupal-site.com',
endpoint: 'api'
sitePath: 'http://my-drupal-site.com'
});

});
Expand All @@ -48,52 +47,31 @@ drush dl angular_drupal
drush en -y angular_drupal
```

## 1. Drupal Services Module Setup
## 1. Drupal Setup

https://www.drupal.org/project/services
### 1.1 Enable Drupal core's "RESTful Web Services" module

```
drush dl services
drush en -y rest_server
```

Then create a new endpoint by going to *admin/structure/services/add* with the
following info:
### 1.2 Install the REST UI module

```
machine name: api
server: REST
path: api
debug: unchecked
session authentication: checked
```
https://www.drupal.org/project/restui

Then click the edit resources link and check the box next to each resource that
should be available to your app:
Then go to "admin/config/services/rest" and enable your desired resources. We
recommend the following resources, http methods, authentications, and formats:

```
comment
file
node
system
taxonomy_term
taxonomy_vocabulary
user
User - GET - json - cookie
User - POST - json - cookie
```

Then click *Save*. After that, click the *Server* tab and make sure the
following boxes are checked:
### 1.3 Specify User Permissions

```
json
application/json
application/x-www-form-urlencoded
```

Then click *Save*. After that flush all of Drupal's caches.
Go to admin/people/permissions and allow a user role(s) to access some of these
resources. We recommend the following (at minimum) for anonymous and
authenticated users:

```
drush cc all
Access GET on Content resource
Access GET on User resource
```

## 2. Angular JS Setup
Expand Down Expand Up @@ -144,11 +122,10 @@ drupal.user_register(account).then(function(data) {
```

### USER LOGIN
@see https://www.drupal.org/node/2403307
```
drupal.user_login('bob', 'secret').then(function(data) {
if (data.user.uid) {
alert('Hello ' + data.user.name + '!');
}

});
```

Expand Down
40 changes: 40 additions & 0 deletions angular-drupal
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Globals
#APP_MODULES_DIRECTORY="app/modules"
#APP_MODULES_CUSTOM_DIRECTORY="$APP_MODULES_DIRECTORY/custom"

function angular_drupal_install() {
cd app
mkdir bower_components
cd bower_components
mkdir angular
cd angular/
wget https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js
mv angular.min.js angular.js
cd ../
mkdir angular-route
cd angular-route/
wget https://code.angularjs.org/1.4.2/angular-route.min.js
mv angular-route.min.js angular-route.js
cd ../
mkdir angular-resource
cd angular-resource/
wget https://code.angularjs.org/1.4.2/angular-resource.min.js
mv angular-resource.min.js angular-resource.js
cd ../
mkdir angular-mocks
cd angular-mocks/
wget https://code.angularjs.org/1.4.2/angular-mocks.js
cd ../
mkdir angular-drupal
cd angular-drupal
ln -s ../../../src/angular-drupal.js angular-drupal.js
}


case "$1" in
install) angular_drupal_install;;
-*) usage "bad argument $1";;
esac

Loading