Browse Source

rimosso totalmnete dal javascript la parte di upload (passata dentro il prgetto arkiwiupladapi) e aggiunti i metodi per avere RSS e jsonML (H MERDA!)

cek 8 years ago
parent
commit
a3e01a883b
2 changed files with 21 additions and 140 deletions
  1. 20 137
      app/scripts/arkiwi.js
  2. 1 3
      package.json

+ 20 - 137
app/scripts/arkiwi.js

@@ -33,6 +33,26 @@ ARKIWI.Aggregator.prototype.path = function (path, callback, notBase64) {
     });
 };
 
+ARKIWI.Aggregator.prototype.getRSS = function (path, callback, notBase64) {
+    var pathType = notBase64 ? 'path' : 'path64';
+    $.getJSON(this.aggregator + '/' + pathType + '/' + path + '/rss/?' + this.defaultParameters, function (result) {
+        if (callback != undefined)
+            callback(result);
+    }).fail(function (error) {
+        throw 'Arkiwi.getRSS(): status ' + status + ' error ' + error.responseText;
+    });
+};
+
+ARKIWI.Aggregator.prototype.getJsonML = function (path, callback, notBase64) {
+    var pathType = notBase64 ? 'path' : 'path64';
+    $.getJSON(this.aggregator + '/' + pathType + '/' + path + '/jsonml/?' + this.defaultParameters, function (result) {
+        if (callback != undefined)
+            callback(result);
+    }).fail(function (error) {
+        throw 'Arkiwi.getJsonML(): status ' + status + ' error ' + error.responseText;
+    });
+};
+
 /* Esegue un ricerca sull'aggregatore */
 ARKIWI.Aggregator.prototype.search = function (query, callback, jailFolder) {
     var sanitizedQuery = query;
@@ -50,140 +70,3 @@ ARKIWI.Aggregator.prototype.search = function (query, callback, jailFolder) {
         throw 'Arkiwi.search(): status ' + status + ' error ' + error.responseText;
     });
 };
-
-
-ARKIWI.AssetStore = function (assetStore, defaultParameters, formName, sessionUploadProgressName) {
-    this.assetStore = assetStore;
-    this.defaultParameters = defaultParameters || '';
-    this.formName = formName || 'arkiwiUploadForm';
-    this.sessionUploadProgressName = sessionUploadProgressName || 'PHP_SESSION_UPLOAD_PROGRESS';
-
-    this.sessionId = '';
-
-    if ($('#arkiwi_hidden_iframe').length == 0)
-        $(document.body).append('<iframe id="arkiwi_hidden_iframe" name="arkiwi_hidden_iframe" src="about:blank" style="visibility: hidden;"></iframe>');
-};
-
-ARKIWI.AssetStore.constructor = ARKIWI.AssetStore;
-
-/* Inizializza la sessione di dialogo con l'asset store. */
-ARKIWI.AssetStore.prototype.create = function (callbacks) {
-    $.ajax({
-        url: this.assetStore + '/create/?' + this.defaultParameters,
-        type: 'GET',
-        async: false,
-        cache: false,
-        context: this,
-        data: '',
-        dataType: 'json',
-        error: function (xhr, status, error) {
-            if (error != 'Unauthorized')
-                throw 'Arkiwi.create(): error ' + error;
-            else {
-                if (callbacks != undefined && callbacks.unauthorized != undefined)
-                    callbacks.unauthorized();
-            }
-        },
-        success: function (result, status, xhr) {
-            this.sessionId = result.id;
-            if (callbacks != undefined && callbacks.success != undefined)
-                callbacks.success(this.sessionId);
-        },
-        complete: function (xhr, status) {},
-    });
-};
-
-/* Invia un file all'asset store. */
-ARKIWI.AssetStore.prototype.upload = function (form, destinationFolderBase64, callbacks) {
-    form = $(form);
-
-    form.attr('method', 'POST');
-    form.attr('action', this.assetStore + '/upload/' + this.sessionId + '/' + destinationFolderBase64 + '/?' + this.defaultParameters);
-    form.attr('id', this.formName);
-    form.attr('enctype', 'multipart/form-data');
-    form.attr('target', 'arkiwi_hidden_iframe');
-
-    form.append('<input type="hidden" value="' + this.formName + '" name="' + this.sessionUploadProgressName + '" />');
-
-    $(':file', form).attr('name', this.sessionId);
-
-    form.ajaxForm({
-        beforeSend: function () {
-            callbacks.beforeSend();
-        },
-        uploadProgress: function (event, position, total, percentComplete) {
-            callbacks.uploadProgress(event, position, total, percentComplete);
-        },
-        complete: function (xhr) {
-            callbacks.complete(xhr);
-        },
-        error: function (xhr, status, error) {
-            throw 'Arkiwi.upload(): error ' + error;
-        }
-    });
-
-    form.submit();
-};
-
-/* Aggiunge o sovrascrive i metadati di un file. */
-ARKIWI.AssetStore.prototype.metadata = function (jsonKVString, callback) {
-    $.ajax({
-        url: this.assetStore + '/metadata/' + this.sessionId + '/?' + this.defaultParameters,
-        type: 'POST',
-        async: true,
-        cache: false,
-        context: this,
-        data: jsonKVString,
-        dataType: 'json',
-        error: function (xhr, status, error) {
-            throw 'Arkiwi.metadata(): status ' + status + ' error ' + error;
-        },
-        success: function (result, status, xhr) {
-            if (callback != undefined)
-                callback(result);
-        },
-        complete: function (xhr, status) {}
-    });
-};
-
-/* Cancella un metadato da un file */
-ARKIWI.AssetStore.prototype.removeMetadata = function (jsonKVString, callback) {
-    $.ajax({
-        url: this.assetStore + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
-        type: 'POST',
-        async: true,
-        cache: false,
-        context: this,
-        data: jsonKVString,
-        dataType: 'json',
-        error: function (xhr, status, error) {
-            throw 'Arkiwi.removeMetadata(): status ' + status + ' error ' + error;
-        },
-        success: function (result, status, xhr) {
-            if (callback != undefined)
-                callback(result);
-        },
-        complete: function (xhr, status) {}
-    });
-};
-
-/* Chiude la sessione con l'asset store */
-ARKIWI.AssetStore.prototype.close = function (callback) {
-    $.ajax({
-        url: this.assetStore + '/close/' + this.sessionId + '/?' + this.defaultParameters,
-        type: 'GET',
-        async: true,
-        cache: false,
-        context: this,
-        data: '',
-        dataType: 'json',
-        error: function (xhr, status, error) {
-            throw 'Arkiwi.close(): status ' + status + ' error ' + error;
-        },
-        success: function (result, status, xhr) {
-            if (callback != undefined)
-                callback(result);
-        },
-        complete: function (xhr, status) {}
-    });
-};

+ 1 - 3
package.json

@@ -15,9 +15,7 @@
     "grunt-contrib-uglify": "~0.5.0",
     "grunt-contrib-watch": "^0.6.1",
     "grunt-newer": "^1.1.1",
-    "grunt-wiredep": "^2.0.0"
-  },
-  "dependencies": {
+    "grunt-wiredep": "^2.0.0",
     "time-grunt": "^1.2.1"
   }
 }