Rjain has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71364


Change subject: Added the create class Just tried out adding the create class 
but there are some errors passing the Json data of annotations.
......................................................................

Added the create class
Just tried out adding the create class but there are some errors passing the
Json data of annotations.

Change-Id: I9f55c03a9d5876b951d89035a0550d81a4b7b685
---
M Annotator.php
A api/ApiAnnotatorCreate.php
M modules/Annotator.js
3 files changed, 30 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Annotator 
refs/changes/64/71364/1

diff --git a/Annotator.php b/Annotator.php
index 750f94d..2ab6852 100755
--- a/Annotator.php
+++ b/Annotator.php
@@ -21,7 +21,10 @@
 
 //Autoloading
 $wgAutoloadClasses['AnnotatorHooks'] = $dir . 'Annotator.hooks.php';
+$wgAutoloadClasses['ApiAnnotatorCreate'] = $dir . 'api/ApiAnnotatorCreate.php';
 
 //Hooks
 $wgHooks['BeforePageDisplay'][] = 'AnnotatorHooks::onBeforePageDisplay';
-$wgHooks['LoadExtensionSchemaUpdates'][] = 
'AnnotatorHooks::loadExtensionSchemaUpdates';
\ No newline at end of file
+$wgHooks['LoadExtensionSchemaUpdates'][] = 
'AnnotatorHooks::loadExtensionSchemaUpdates';
+
+$wgAPIModules['annotator-create'] = 'ApiAnnotatorCreate';
\ No newline at end of file
diff --git a/api/ApiAnnotatorCreate.php b/api/ApiAnnotatorCreate.php
new file mode 100644
index 0000000..895fc09
--- /dev/null
+++ b/api/ApiAnnotatorCreate.php
@@ -0,0 +1,22 @@
+<?php
+class ApiAnnotatorCreate extends ApiBase {
+       public function execute() {
+               // Get the parameters
+        $params = $this->extractRequestParams();
+        var_dump($params['text']);
+        return true;
+       }
+        public function getAllowedParams() {
+            return array(
+                'text' => array (
+                ApiBase::PARAM_TYPE => 'string',
+                ApiBase::PARAM_REQUIRED => true
+            ),
+                'quote' => array (
+                APiBase::PARAM_TYPE => 'string',
+                ApiBase::PARAM_REQUIRED =>true
+            ),
+
+         );
+    }
+}
\ No newline at end of file
diff --git a/modules/Annotator.js b/modules/Annotator.js
index ecae1dd..2c93317 100644
--- a/modules/Annotator.js
+++ b/modules/Annotator.js
@@ -9,9 +9,12 @@
        var annotations = $('#mw-content-text').annotator();
     //Add the store plugin and modify the urls according to mediawiki api
     annotations.annotator('addPlugin', 'Store', {
+      data: annotations.data('annotator'),
       prefix: this.apiUrl,
+      'Content-Type': 'application/json',
+      'method': 'POST',
       urls: {
-        create: '',
+        create: '?action=annotator-create',
         update: '',
         read: '',
         destroy: '',

-- 
To view, visit https://gerrit.wikimedia.org/r/71364
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f55c03a9d5876b951d89035a0550d81a4b7b685
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Annotator
Gerrit-Branch: master
Gerrit-Owner: Rjain <richa.jain1...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to