OSDN Git Service

add cache
authoryasushiito <yas@pen-chan.jp>
Wed, 1 Oct 2014 04:45:17 +0000 (13:45 +0900)
committeryasushiito <yas@pen-chan.jp>
Wed, 1 Oct 2014 04:45:17 +0000 (13:45 +0900)
43 files changed:
app/assets/javascripts/addons/circle_speech_balloons/init.js.coffee
app/assets/javascripts/addons/plain_speech_balloons/init.js.coffee
app/assets/javascripts/addons/square_speech_balloons/init.js.coffee
app/assets/javascripts/ap.js
app/assets/javascripts/backbone.fetch-cache.js [new file with mode: 0644]
app/assets/javascripts/controllers/balloons.js.coffee
app/assets/javascripts/controllers/comics.js.coffee
app/assets/javascripts/controllers/folders.js.coffee
app/assets/javascripts/controllers/ground_colors.js.coffee
app/assets/javascripts/controllers/ground_pictures.js.coffee
app/assets/javascripts/controllers/panel_pictures.js.coffee
app/assets/javascripts/controllers/panels.js.coffee
app/assets/javascripts/controllers/scrolls.js.coffee
app/assets/javascripts/controllers/sheets.js.coffee
app/assets/javascripts/controllers/speech_balloons.js.coffee
app/assets/javascripts/controllers/speeches.js.coffee
app/assets/javascripts/controllers/stories.js.coffee
app/assets/javascripts/locmare/form/field/helper/tail_angle.js.coffee
app/assets/javascripts/locmare/list_group/list/base.js.coffee
app/assets/javascripts/locmare/profiler/association/belongs_to.js.coffee
app/assets/javascripts/main.js.coffee
app/assets/javascripts/models/balloon.js.coffee
app/assets/javascripts/models/ground_picture.js.coffee
app/assets/javascripts/models/license.js.coffee
app/assets/javascripts/models/original_picture.js.coffee
app/assets/javascripts/models/panel_picture.js.coffee
app/assets/javascripts/models/picture.js.coffee
app/assets/javascripts/models/resource_picture.js.coffee
app/assets/javascripts/models/speech.js.coffee
app/assets/javascripts/models/speech_balloon.js.coffee
app/assets/javascripts/models/speech_balloon_template.js.coffee
app/assets/javascripts/models/system_picture.js.coffee
app/assets/javascripts/models/writing_format.js.coffee
app/assets/javascripts/pettanr.js.coffee
app/assets/javascripts/views/balloons/element.js.coffee
app/assets/javascripts/views/ground_colors/show.js.coffee
app/assets/javascripts/views/ground_pictures/show.js.coffee
app/assets/javascripts/views/panel_pictures/element.js.coffee
app/assets/javascripts/views/panel_pictures/show.js.coffee
app/assets/javascripts/views/scroll_panels/summary.js.coffee
app/assets/javascripts/views/scrolls/summary.js.coffee
app/assets/javascripts/views/show.js.coffee
app/assets/javascripts/views/speech_balloons/show.js.coffee

index fa2fe9c..9ff71b8 100644 (file)
@@ -86,7 +86,7 @@ class Pettanr.CircleSpeechBalloon.SpeechBalloonModule
     super()\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.speech_balloon_template_module_name = sbt.get('module_name')\r
   \r
   speech_balloon_extend: () ->\r
@@ -131,7 +131,7 @@ class Pettanr.CircleSpeechBalloon.BalloonModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   select_system_picture: () ->\r
@@ -177,7 +177,7 @@ class Pettanr.CircleSpeechBalloon.SpeechModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   arrayed_quotes: () ->\r
index 4066d75..b923e02 100644 (file)
@@ -86,7 +86,7 @@ class Pettanr.PlainSpeechBalloon.SpeechBalloonModule
     super()\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.speech_balloon_template_module_name = sbt.get('module_name')\r
   \r
   speech_balloon_extend: () ->\r
@@ -131,7 +131,7 @@ class Pettanr.PlainSpeechBalloon.BalloonModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   select_system_picture: () ->\r
@@ -171,7 +171,7 @@ class Pettanr.PlainSpeechBalloon.SpeechModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   arrayed_quotes: () ->\r
index 2648db8..b6d46ad 100644 (file)
@@ -86,7 +86,7 @@ class Pettanr.SquareSpeechBalloon.SpeechBalloonModule
     super()\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.speech_balloon_template_module_name = sbt.get('module_name')\r
   \r
   speech_balloon_extend: () ->\r
@@ -131,7 +131,7 @@ class Pettanr.SquareSpeechBalloon.BalloonModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   select_system_picture: () ->\r
@@ -171,7 +171,7 @@ class Pettanr.SquareSpeechBalloon.SpeechModule
     return @parsed if @parsed\r
     _this = this\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       _this.parsed = sbt.parsed_settings()\r
   \r
   arrayed_quotes: () ->\r
index 7178793..ae183a0 100644 (file)
 //= require ./pettanr/picture
 //= require ./pettanr/pettan_imager
 //= require ./pettanr/operator
+//= require backbone.fetch-cache
 //= require main
diff --git a/app/assets/javascripts/backbone.fetch-cache.js b/app/assets/javascripts/backbone.fetch-cache.js
new file mode 100644 (file)
index 0000000..7bff9aa
--- /dev/null
@@ -0,0 +1,333 @@
+/*!
+  backbone.fetch-cache v1.4.1
+  by Andy Appleton - https://github.com/mrappleton/backbone-fetch-cache.git
+ */
+
+// AMD wrapper from https://github.com/umdjs/umd/blob/master/amdWebGlobal.js
+
+(function (root, factory) {
+  if (typeof define === 'function' && define.amd) {
+    // AMD. Register as an anonymous module and set browser global
+    define(['underscore', 'backbone', 'jquery'], function (_, Backbone, $) {
+      return (root.Backbone = factory(_, Backbone, $));
+    });
+  } else if (typeof exports !== 'undefined') {
+    module.exports = factory(require('underscore'), require('backbone'), require('jquery'));
+  } else {
+    // Browser globals
+    root.Backbone = factory(root._, root.Backbone, root.jQuery);
+  }
+}(this, function (_, Backbone, $) {
+
+  // Setup
+  var superMethods = {
+    modelFetch: Backbone.Model.prototype.fetch,
+    modelSync: Backbone.Model.prototype.sync,
+    collectionFetch: Backbone.Collection.prototype.fetch
+  },
+  supportLocalStorage = (function() {
+    var supported = typeof window.localStorage !== 'undefined';
+    if (supported) {
+      try {
+        // impossible to write on some platforms when private browsing is on and
+        // throws an exception = local storage not supported.
+        localStorage.setItem('test_support', 'test_support');
+        localStorage.removeItem('test_support');
+      } catch (e) {
+        supported = false;
+      }
+    }
+    return supported;
+  })();
+
+  Backbone.fetchCache = (Backbone.fetchCache || {});
+  Backbone.fetchCache._cache = (Backbone.fetchCache._cache || {});
+  // Global flag to enable/disable caching
+  Backbone.fetchCache.enabled = true;
+
+  Backbone.fetchCache.priorityFn = function(a, b) {
+    if (!a || !a.expires || !b || !b.expires) {
+      return a;
+    }
+
+    return a.expires - b.expires;
+  };
+
+  Backbone.fetchCache._prioritize = function() {
+    var sorted = _.values(this._cache).sort(this.priorityFn);
+    var index = _.indexOf(_.values(this._cache), sorted[0]);
+    return _.keys(this._cache)[index];
+  };
+
+  Backbone.fetchCache._deleteCacheWithPriority = function() {
+    Backbone.fetchCache._cache[this._prioritize()] = null;
+    delete Backbone.fetchCache._cache[this._prioritize()];
+    Backbone.fetchCache.setLocalStorage();
+  };
+
+  Backbone.fetchCache.getLocalStorageKey = function() {
+    return 'backboneCache';
+  };
+
+  if (typeof Backbone.fetchCache.localStorage === 'undefined') {
+    Backbone.fetchCache.localStorage = true;
+  }
+
+  // Shared methods
+  function getCacheKey(instance, opts) {
+    var url;
+
+    if(opts && opts.url) {
+      url = opts.url;
+    } else {
+      url = _.isFunction(instance.url) ? instance.url() : instance.url;
+    }
+
+    // Need url to use as cache key so return if we can't get it
+    if(!url) { return; }
+
+    if(opts && opts.data) {
+      if(typeof opts.data === 'string') {
+        return url + '?' + opts.data;
+      } else {
+        return url + '?' + $.param(opts.data);
+      }
+    }
+    return url;
+  }
+
+  function setCache(instance, opts, attrs) {
+    opts = (opts || {});
+    var key = Backbone.fetchCache.getCacheKey(instance, opts),
+        expires = false;
+
+    // Need url to use as cache key so return if we can't get it
+    if (!key) { return; }
+
+    // Never set the cache if user has explicitly said not to
+    if (opts.cache === false) { return; }
+
+    // Don't set the cache unless cache: true or prefill: true option is passed
+    if (!(opts.cache || opts.prefill)) { return; }
+
+    if (opts.expires !== false) {
+      expires = (new Date()).getTime() + ((opts.expires || 5 * 60) * 1000);
+    }
+
+    Backbone.fetchCache._cache[key] = {
+      expires: expires,
+      value: attrs
+    };
+
+    Backbone.fetchCache.setLocalStorage();
+  }
+
+  function clearItem(key) {
+    if (_.isFunction(key)) { key = key(); }
+    delete Backbone.fetchCache._cache[key];
+    Backbone.fetchCache.setLocalStorage();
+  }
+
+  function setLocalStorage() {
+    if (!supportLocalStorage || !Backbone.fetchCache.localStorage) { return; }
+    try {
+      localStorage.setItem(Backbone.fetchCache.getLocalStorageKey(), JSON.stringify(Backbone.fetchCache._cache));
+    } catch (err) {
+      var code = err.code || err.number || err.message;
+      if (code === 22) {
+        this._deleteCacheWithPriority();
+      } else {
+        throw(err);
+      }
+    }
+  }
+
+  function getLocalStorage() {
+    if (!supportLocalStorage || !Backbone.fetchCache.localStorage) { return; }
+    var json = localStorage.getItem(Backbone.fetchCache.getLocalStorageKey()) || '{}';
+    Backbone.fetchCache._cache = JSON.parse(json);
+  }
+
+  function nextTick(fn) {
+    return window.setTimeout(fn, 0);
+  }
+
+  // Instance methods
+  Backbone.Model.prototype.fetch = function(opts) {
+    //Bypass caching if it's not enabled
+    if(!Backbone.fetchCache.enabled) {
+      return superMethods.modelFetch.apply(this, arguments);
+    }
+    opts = _.defaults(opts || {}, { parse: true });
+    var key = Backbone.fetchCache.getCacheKey(this, opts),
+        data = Backbone.fetchCache._cache[key],
+        expired = false,
+        attributes = false,
+        deferred = new $.Deferred(),
+        self = this;
+
+    function setData() {
+      if (opts.parse) {
+        attributes = self.parse(attributes, opts);
+      }
+
+      self.set(attributes, opts);
+      if (_.isFunction(opts.prefillSuccess)) { opts.prefillSuccess(self, attributes, opts); }
+
+      // Trigger sync events
+      self.trigger('cachesync', self, attributes, opts);
+      self.trigger('sync', self, attributes, opts);
+
+      // Notify progress if we're still waiting for an AJAX call to happen...
+      if (opts.prefill) { deferred.notify(self); }
+      // ...finish and return if we're not
+      else {
+        if (_.isFunction(opts.success)) { opts.success(self, attributes, opts); }
+        deferred.resolve(self);
+      }
+    }
+
+    if (data) {
+      expired = data.expires;
+      expired = expired && data.expires < (new Date()).getTime();
+      attributes = data.value;
+    }
+
+    if (!expired && (opts.cache || opts.prefill) && attributes) {
+      // Ensure that cache resolution adhers to async option, defaults to true.
+      if (opts.async == null) { opts.async = true; }
+
+      if (opts.async) {
+        nextTick(setData);
+      } else {
+        setData();
+      }
+
+      if (!opts.prefill) {
+        return deferred;
+      }
+    }
+
+    // Delegate to the actual fetch method and store the attributes in the cache
+    var jqXHR = superMethods.modelFetch.apply(this, arguments);
+    // resolve the returned promise when the AJAX call completes
+    jqXHR.done( _.bind(deferred.resolve, this, this) )
+      // Set the new data in the cache
+      .done( _.bind(Backbone.fetchCache.setCache, null, this, opts) )
+      // Reject the promise on fail
+      .fail( _.bind(deferred.reject, this, this) );
+
+    deferred.abort = jqXHR.abort;
+
+    // return a promise which provides the same methods as a jqXHR object
+    return deferred;
+  };
+
+  // Override Model.prototype.sync and try to clear cache items if it looks
+  // like they are being updated.
+  Backbone.Model.prototype.sync = function(method, model, options) {
+    // Only empty the cache if we're doing a create, update, patch or delete.
+    // or caching is not enabled
+    if (method === 'read' || !Backbone.fetchCache.enabled) {
+      return superMethods.modelSync.apply(this, arguments);
+    }
+
+    var collection = model.collection,
+        keys = [],
+        i, len;
+
+    // Build up a list of keys to delete from the cache, starting with this
+    keys.push(Backbone.fetchCache.getCacheKey(model, options));
+
+    // If this model has a collection, also try to delete the cache for that
+    if (!!collection) {
+      keys.push(Backbone.fetchCache.getCacheKey(collection));
+    }
+
+    // Empty cache for all found keys
+    for (i = 0, len = keys.length; i < len; i++) { clearItem(keys[i]); }
+
+    return superMethods.modelSync.apply(this, arguments);
+  };
+
+  Backbone.Collection.prototype.fetch = function(opts) {
+    // Bypass caching if it's not enabled
+    if(!Backbone.fetchCache.enabled) {
+      return superMethods.collectionFetch.apply(this, arguments);
+    }
+
+    opts = _.defaults(opts || {}, { parse: true });
+    var key = Backbone.fetchCache.getCacheKey(this, opts),
+        data = Backbone.fetchCache._cache[key],
+        expired = false,
+        attributes = false,
+        deferred = new $.Deferred(),
+        self = this;
+
+    function setData() {
+      self[opts.reset ? 'reset' : 'set'](attributes, opts);
+      if (_.isFunction(opts.prefillSuccess)) { opts.prefillSuccess(self); }
+
+      // Trigger sync events
+      self.trigger('cachesync', self, attributes, opts);
+      self.trigger('sync', self, attributes, opts);
+
+      // Notify progress if we're still waiting for an AJAX call to happen...
+      if (opts.prefill) { deferred.notify(self); }
+      // ...finish and return if we're not
+      else {
+        if (_.isFunction(opts.success)) { opts.success(self, attributes, opts); }
+        deferred.resolve(self);
+      }
+    }
+
+    if (data) {
+      expired = data.expires;
+      expired = expired && data.expires < (new Date()).getTime();
+      attributes = data.value;
+    }
+
+    if (!expired && (opts.cache || opts.prefill) && attributes) {
+      // Ensure that cache resolution adhers to async option, defaults to true.
+      if (opts.async == null) { opts.async = true; }
+
+      if (opts.async) {
+        nextTick(setData);
+      } else {
+        setData();
+      }
+
+      if (!opts.prefill) {
+        return deferred;
+      }
+    }
+
+    // Delegate to the actual fetch method and store the attributes in the cache
+    var jqXHR = superMethods.collectionFetch.apply(this, arguments);
+    // resolve the returned promise when the AJAX call completes
+    jqXHR.done( _.bind(deferred.resolve, this, this) )
+      // Set the new data in the cache
+      .done( _.bind(Backbone.fetchCache.setCache, null, this, opts) )
+      // Reject the promise on fail
+      .fail( _.bind(deferred.reject, this, this) );
+
+    deferred.abort = jqXHR.abort;
+
+    // return a promise which provides the same methods as a jqXHR object
+    return deferred;
+  };
+
+  // Prime the cache from localStorage on initialization
+  getLocalStorage();
+
+  // Exports
+
+  Backbone.fetchCache._superMethods = superMethods;
+  Backbone.fetchCache.setCache = setCache;
+  Backbone.fetchCache.getCacheKey = getCacheKey;
+  Backbone.fetchCache.clearItem = clearItem;
+  Backbone.fetchCache.setLocalStorage = setLocalStorage;
+  Backbone.fetchCache.getLocalStorage = getLocalStorage;
+
+  return Backbone;
+}));
index b9b35e5..847b42a 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.BalloonsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Balloon.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 61b3f22..a0e3c60 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.ComicsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Comic.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 8282ce0..57f5cb7 100644 (file)
@@ -7,14 +7,14 @@ class Pettanr.FoldersController extends Pettanr.AppController
     @set_model()\r
     @item = new Pettanr.Folder.Root()\r
     _this = this\r
-    @item.fetch({}).done () ->\r
+    @item.fetch({cache: true}).done ->\r
       _this.children_html()\r
   \r
   show_html_format: (format) -> \r
   \r
   children_html: () -> \r
     collection = new Pettanr.Folder.Children({id: @item.get('id')})\r
-    collection.fetch().done ->\r
+    collection.fetch({cache: true}).done ->\r
       f = new Locmare.Filer({\r
         item_name: 'folder', \r
         items: collection.models, \r
@@ -32,7 +32,7 @@ class Pettanr.FoldersController extends Pettanr.AppController
     else\r
       @item = new Pettanr.FolderWatch({id: id})\r
       _this = this\r
-      @item.fetch({}).done () ->\r
+      @item.fetch({cache: true}).done () ->\r
         if _this.item.is_remote()\r
           c = _this.item.get('controller_name')\r
           a = if Pettanr.is_blank(_this.item.get('action_name'))\r
index 2cdf253..ec50f36 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.GroundColorsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.GroundColor.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 6059883..365c8cb 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.GroundPicturesController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.GroundPicture.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index ecc7710..d2f9332 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.PanelPicturesController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.PanelPicture.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 60caf94..906723b 100644 (file)
@@ -18,7 +18,7 @@ class Pettanr.PanelsController extends Pettanr.AppController
   show_html: () ->\r
     _this = this\r
     @item = new Pettanr.Panel({id: @item.get('id')}, {with_elements: true}) # retake panel for 'with_elements' mode\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: false}).done ->\r
       view = new Pettanr.Views.Panel.Show({\r
         el: "#pettanr",\r
         panel: _this.item,\r
index 97f1eb8..3e634fc 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.ScrollsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Scroll.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 3fa33f3..c086fa8 100644 (file)
@@ -14,7 +14,7 @@ class Pettanr.SheetsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Sheet.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 0ec2565..90c210e 100644 (file)
@@ -14,7 +14,7 @@ class Pettanr.SpeechBalloonsController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.SpeechBalloon.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 339ccc7..a8c257c 100644 (file)
@@ -11,7 +11,7 @@ class Pettanr.SpeechesController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Speech.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index 02e620d..c6cda6f 100644 (file)
@@ -14,7 +14,7 @@ class Pettanr.StoriesController extends Pettanr.AppController
   \r
   show_html: () -> \r
     _this = this\r
-    @item.fetch().done ->\r
+    @item.fetch({cache: true}).done ->\r
       view = new Pettanr.Views.Story.Show({\r
         el: "#pettanr",\r
         item: _this.item,\r
index b4ee5e7..f52f25e 100644 (file)
@@ -11,7 +11,7 @@ class Locmare.FormModule.FieldModule.HelperModule.TailAngle extends Locmare.Form
       id: @field.item().get('speech_balloon_template_id')\r
     })\r
     _this = this\r
-    @speech_balloon_template.fetch().done ->\r
+    @speech_balloon_template.fetch({cache: true}).done ->\r
       _this.r_step = _this._r_step()\r
   \r
   render: () ->\r
index 0d8daf9..4fc3d30 100644 (file)
@@ -39,9 +39,9 @@ class Locmare.ListGroupModule.Base extends Backbone.Collection
     @model = Manifest.item_name_to_model action.item_name\r
     _this = this\r
     counter = new Locmare.ListGroupModule.Counter({}, {url: '/' + action.counter_url(params)})\r
-    counter.fetch().done ->\r
+    counter.fetch({cache: true}).done ->\r
       page_status = new Locmare.ListGroupModule.PageStatus(page, page_size, counter.count(), params)\r
-      _this.fetch(options).done ->\r
+      _this.fetch({cache: true}).done ->\r
         #_this.boost(items)\r
         cb(page_status)\r
   \r
index 99b22e6..c9f53eb 100644 (file)
@@ -7,7 +7,7 @@ class Locmare.ProfilerModule.AssociationModule.BelongsTo extends Backbone.View
     pm = @parent_model()\r
     m = new pm({id: @parent_id()})\r
     _this = this\r
-    m.fetch().done ->\r
+    m.fetch({cache: true}).done ->\r
       _this.filer = new Locmare.Filer({\r
         item_name: _this.parent_model().item_name(), \r
         items: [m], \r
index 3cfa6da..80429ef 100644 (file)
@@ -4,6 +4,7 @@ $ ->
     evaluate: /\<\&(.+?)\&\>/g\r
   }\r
   jQuery.timeago.settings.lang = 'ja'\r
+  Backbone.fetchCache.localStorage = false\r
   loaded_manifest = null\r
   loaded_local_manifest = null\r
   $.ajaxSetup({async: false})\r
@@ -13,9 +14,9 @@ $ ->
     loaded_local_manifest = new LocalManifest(data)\r
   )\r
   author = new Pettanr.Author({id: author_id})\r
-  author.fetch({})\r
+  author.fetch({cache: true})\r
   artist = new Pettanr.Artist({id: artist_id})\r
-  artist.fetch({})\r
+  artist.fetch({cache: true})\r
   user = new Pettanr.User({id: author.get('user_id')})\r
   window.operators = new Pettanr.Operator([author, artist, user])\r
   $.ajaxSetup({async: true})\r
index e6986f4..40bf22d 100644 (file)
@@ -27,11 +27,11 @@ class Pettanr.Balloon extends Peta.Element
   \r
   symbol_option: (cb) ->\r
     sb = @speech_balloon()\r
-    sb.fetch().done ->\r
+    sb.fetch({cache: true}).done ->\r
       sbt = sb.speech_balloon_template()\r
-      sbt.fetch().done ->\r
+      sbt.fetch({cache: true}).done ->\r
         sp = sbt.system_picture()\r
-        sp.fetch().done ->\r
+        sp.fetch({cache: true}).done ->\r
           cb(sp.tmb_opt_img_tag())\r
   \r
   initialize: () ->\r
index a49d9f8..d5deea6 100644 (file)
@@ -38,7 +38,7 @@ class Pettanr.GroundPicture extends Peta.Element
   symbol_option: (cb) ->\r
     i = @picture()\r
     _this = this\r
-    i.fetch().done ->\r
+    i.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag(i))\r
   \r
   repeat_text: () ->\r
index 62bfd0c..47ec960 100644 (file)
@@ -19,7 +19,7 @@ class Pettanr.License extends Peta.SystemResource
   \r
   symbol_option: (cb) ->\r
     i = @system_picture()\r
-    i.fetch().done ->\r
+    i.fetch({cache: true}).done ->\r
       cb(i.tmb_opt_img_tag())\r
   \r
   caption_with_group: () ->\r
@@ -41,7 +41,7 @@ class Pettanr.License.Caption extends Backbone.View
     \r
   render: () ->\r
     _this = this\r
-    @license_group.fetch().done ->\r
+    @license_group.fetch({cache: true}).done ->\r
       _this.$el.html(_this.license_group.get('caption') + '/' + _this.license.get('caption'))\r
     this\r
   \r
index 871af07..df61ea1 100644 (file)
@@ -37,7 +37,7 @@ class Pettanr.OriginalPicture extends Peta.Content
   \r
   symbol_option: (cb) ->\r
     _this = this\r
-    this.fetch().done ->\r
+    this.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag())\r
   \r
   revision: () ->\r
@@ -79,7 +79,7 @@ class Pettanr.OriginalPicture.Head extends Backbone.View
   \r
   render: () ->\r
     _this = this\r
-    @pictures.fetch().done ->\r
+    @pictures.fetch({cache: true}).done ->\r
       head = _this.pictures.models[0]\r
       value = if head\r
         head.get('revision')\r
index 1a86e4a..b2dca07 100644 (file)
@@ -52,7 +52,7 @@ class Pettanr.PanelPicture extends Peta.Element
   symbol_option: (cb) ->\r
     i = @picture()\r
     _this = this\r
-    i.fetch().done ->\r
+    i.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag(i))\r
   \r
   initialize: () ->\r
index 405d9b4..cec6aa9 100644 (file)
@@ -51,7 +51,7 @@ class Pettanr.Picture extends Peta.Content
   \r
   symbol_option: (cb) ->\r
     _this = this\r
-    this.fetch().done ->\r
+    this.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag())\r
   \r
   is_enable: () ->\r
index b636dfb..b3f6658 100644 (file)
@@ -48,7 +48,7 @@ class Pettanr.ResourcePicture extends Peta.Content
   \r
   symbol_option: (cb) ->\r
     _this = this\r
-    this.fetch().done ->\r
+    this.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag())\r
   \r
   initialize: () ->\r
index 7109b72..3a131e6 100644 (file)
@@ -23,11 +23,11 @@ class Pettanr.Speech extends Peta.Element
   \r
   symbol_option: (cb) ->\r
     sb = @speech_balloon()\r
-    sb.fetch().done ->\r
+    sb.fetch({cache: true}).done ->\r
       sbt = sb.speech_balloon_template()\r
-      sbt.fetch().done ->\r
+      sbt.fetch({cache: true}).done ->\r
         sp = sbt.system_picture()\r
-        sp.fetch().done ->\r
+        sp.fetch({cache: true}).done ->\r
           cb(sp.tmb_opt_img_tag())\r
   \r
   text_align_text: () ->\r
index 565f695..c10b7b5 100644 (file)
@@ -24,9 +24,9 @@ class Pettanr.SpeechBalloon extends Peta.Element
   \r
   symbol_option: (cb) ->\r
     sbt = @speech_balloon_template()\r
-    sbt.fetch().done ->\r
+    sbt.fetch({cache: true}).done ->\r
       sp = sbt.system_picture()\r
-      sp.fetch().done ->\r
+      sp.fetch({cache: true}).done ->\r
         cb(sp.tmb_opt_img_tag())\r
   \r
   plain_scenario: () ->\r
index 32759bf..9fcc603 100644 (file)
@@ -16,7 +16,7 @@ class Pettanr.SpeechBalloonTemplate extends Peta.Template
   \r
   symbol_option: (cb) ->\r
     i = @system_picture()\r
-    i.fetch().done ->\r
+    i.fetch({cache: true}).done ->\r
       cb(i.tmb_opt_img_tag())\r
   \r
   parsed_settings: () ->\r
index bd5daa6..180e728 100644 (file)
@@ -33,7 +33,7 @@ class Pettanr.SystemPicture extends Peta.SystemResource
   \r
   symbol_option: (cb) ->\r
     _this = this\r
-    this.fetch().done ->\r
+    this.fetch({cache: true}).done ->\r
       cb(_this.tmb_opt_img_tag())\r
   \r
   initialize: () ->\r
index df2ad5e..b36b8b2 100644 (file)
@@ -16,7 +16,7 @@ class Pettanr.WritingFormat extends Peta.Template
   \r
   symbol_option: (cb) ->\r
     i = @system_picture()\r
-    i.fetch().done ->\r
+    i.fetch({cache: true}).done ->\r
       cb(i.tmb_opt_img_tag())\r
   \r
   initialize: () ->\r
index 0dc52b3..0ad5f44 100644 (file)
@@ -96,6 +96,8 @@ class Pettanr
     @distance_of_time_in_words_to_now: (datetime) ->\r
       datetime\r
   \r
+  @cache = {}\r
+  \r
   class Pettanr.FilerCollection extends Backbone.Collection\r
     \r
     initialize: (models, options) ->\r
@@ -143,7 +145,7 @@ class Pettanr
     \r
     show_prof: () ->\r
       _this = this\r
-      @item.fetch().done ->\r
+      @item.fetch({cache: true}).done ->\r
         _this.item.boosts 'post'\r
         profiler = new Locmare.Profiler({\r
           item_name: _this.item.item_name(), \r
@@ -163,7 +165,7 @@ class Pettanr
       @set_model()\r
       @item = new @my_model_class({id: @params['id']})\r
       _this = this\r
-      @item.fetch().done ->\r
+      @item.fetch({cache: true}).done ->\r
         _this.item.boosts 'post'\r
         _this.render_form()\r
     \r
@@ -192,7 +194,7 @@ class Pettanr
       @pager_type = pager_type\r
       @operators = operators\r
       _this = this\r
-      @list_result.fetch({}).done () ->\r
+      @list_result.fetch({cache: true}).done () ->\r
         _this.render()\r
     \r
     render: () ->\r
index 7a2d5e2..dd14345 100644 (file)
@@ -10,7 +10,7 @@ class Pettanr.Views.Balloon.Element extends Backbone.View
   render: () ->\r
     _this = this\r
     system_picture = @element.system_picture()\r
-    system_picture.fetch().done ->\r
+    system_picture.fetch({cache: true}).done ->\r
       attr = {\r
         src: system_picture.r_url(), \r
         alt: _this.element.get('caption')\r
index 568717b..94fc168 100644 (file)
@@ -24,7 +24,7 @@ class Pettanr.Views.GroundColor.Show extends Backbone.View
     })\r
     _this = this\r
     @panel = @item.panel()\r
-    @panel.fetch().done ->\r
+    @panel.fetch({cache: true}).done ->\r
       _this.author = new Pettanr.Views.Show.HeaderAuthor({item: _this.panel})\r
       _this.render()\r
   \r
index e043dc1..80ce802 100644 (file)
@@ -24,7 +24,7 @@ class Pettanr.Views.GroundPicture.Show extends Backbone.View
     })\r
     _this = this\r
     @panel = @item.panel()\r
-    @panel.fetch().done ->\r
+    @panel.fetch({cache: true}).done ->\r
       _this.author = new Pettanr.Views.Show.HeaderAuthor({item: _this.panel})\r
       _this.render()\r
   \r
index 91465de..d72cb69 100644 (file)
@@ -12,7 +12,7 @@ class Pettanr.Views.PanelPicture.Element extends Backbone.View
     this.$el.attr(@attr)\r
     @picture = @element.picture()\r
     _this = this\r
-    @picture.fetch().done ->\r
+    @picture.fetch({cache: true}).done ->\r
       _this.img = new Tag.Img({\r
         attr: _this.opt_img_tag(_this.spot)\r
       })\r
index b9bafd2..86abec9 100644 (file)
@@ -24,7 +24,7 @@ class Pettanr.Views.PanelPicture.Show extends Backbone.View
     })\r
     _this = this\r
     @panel = @item.panel()\r
-    @panel.fetch().done ->\r
+    @panel.fetch({cache: true}).done ->\r
       _this.author = new Pettanr.Views.Show.HeaderAuthor({item: _this.panel})\r
       _this.render()\r
   \r
index aefd1e4..dfac77b 100644 (file)
@@ -4,13 +4,13 @@ class Pettanr.Views.ScrollPanel.Summary extends Backbone.View
     @item = options.item\r
     _this = this\r
     @scroll = @item.scroll()\r
-    @scroll.fetch().done ->\r
+    @scroll.fetch({cache: true}).done ->\r
       _this.scroll_icon = _this.scroll.icon_view(true)\r
       _this.panel = _this.item.panel()\r
-      _this.panel.fetch().done ->\r
+      _this.panel.fetch({cache: true}).done ->\r
         _this.panel_icon = _this.panel.icon_view(true)\r
         _this.author = _this.scroll.author()\r
-        _this.author.fetch().done ->\r
+        _this.author.fetch({cache: true}).done ->\r
           _this.author_name = _this.author.name_view(12)\r
           _this.render()\r
   \r
index 3f531c0..ea5adbe 100644 (file)
@@ -7,7 +7,7 @@ class Pettanr.Views.Scroll.Summary extends Backbone.View
     })\r
     _this = this\r
     @author = @item.author()\r
-    @author.fetch().done ->\r
+    @author.fetch({cache: true}).done ->\r
       _this.author_icon = _this.author.icon_view(true)\r
       _this.author_name = _this.author.name_view(12)\r
       _this.render()\r
index 5591408..d4eaeee 100644 (file)
@@ -46,7 +46,7 @@ class Pettanr.Views.Show.HeaderAuthor extends Backbone.View
     @item = options.item\r
     _this = this\r
     @author = @item.author()\r
-    @author.fetch().done ->\r
+    @author.fetch({cache: true}).done ->\r
       name = _this.author.get('name')\r
       author_url = Pettanr.url(_this.author.table_name(), 'show', {id: _this.author.get('id')})\r
       _this.linked_author =  new Tag.A({\r
index ee2ebb4..e203c4d 100644 (file)
@@ -24,7 +24,7 @@ class Pettanr.Views.SpeechBalloon.Show extends Backbone.View
     })\r
     _this = this\r
     @panel = @item.panel()\r
-    @panel.fetch().done ->\r
+    @panel.fetch({cache: true}).done ->\r
       _this.author = new Pettanr.Views.Show.HeaderAuthor({item: _this.panel})\r
       _this.render()\r
   \r