radiant-fabulator_exhibit-extension 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.5 2010-11-06
2
+ * 1 major enhancement
3
+ * Progress bar while loading items
4
+
1
5
  === 0.0.4 2010-11-06
2
6
  * 1 major enhancement
3
7
  * Exhbit databases are now more than just blobs of text. Run the migration
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -6,7 +6,7 @@ class Api::ExhibitsController < ApplicationController
6
6
  def show
7
7
  @exhibit = FabulatorExhibit.find(:first, :conditions => [ "name = ?", params[:id] ])
8
8
  respond_to do |format|
9
- format.json { render :json => @exhibit.data }
9
+ format.json { render :json => @exhibit.database.to_json }
10
10
  end
11
11
  end
12
12
  end
@@ -9,10 +9,6 @@ class FabulatorExhibit < ActiveRecord::Base
9
9
  belongs_to :updated_by, :class_name => 'User'
10
10
  belongs_to :created_by, :class_name => 'User'
11
11
 
12
- def data
13
- self.database.to_json
14
- end
15
-
16
12
  def database
17
13
  FabulatorExhibitExtension::Database.new(self)
18
14
  end
@@ -2,7 +2,5 @@ class FabulatorExhibitProperty < ActiveRecord::Base
2
2
  validates_presence_of :name
3
3
  validates_uniqueness_of :name, :scope => [ :fabulator_exhibit_id ]
4
4
 
5
- before_save :freeze_data
6
-
7
5
  belongs_to :fabulator_exhibit
8
6
  end
@@ -2,7 +2,5 @@ class FabulatorExhibitType < ActiveRecord::Base
2
2
  validates_presence_of :name
3
3
  validates_uniqueness_of :name, :scope => [ :fabulator_exhibit_id ]
4
4
 
5
- before_save :freeze_data
6
-
7
5
  belongs_to :fabulator_exhibit
8
6
  end
@@ -27,30 +27,36 @@ class CreateFabulatorExhibitContentTables < ActiveRecord::Migration
27
27
  FabulatorExhibit.find(:all).each do |db|
28
28
  data = (JSON.parse(db.data) rescue { 'items' => [], 'types' => {}, 'properties' => {} })
29
29
  data['types'].each_pair do |k,t|
30
- t_ob = FabulatorExhibitType.create({
31
- :fabulator_exhibit_id => db.id,
32
- :name => k,
33
- :data => t.to_json
34
- })
35
- t_ob.save!
30
+ if !k.nil? && k != ""
31
+ t_ob = FabulatorExhibitType.create({
32
+ :fabulator_exhibit_id => db.id,
33
+ :name => k,
34
+ :data => t.to_json
35
+ })
36
+ t_ob.save!
37
+ end
36
38
  end
37
39
 
38
40
  data['properties'].each_pair do |k,p|
39
- p_ob = FabulatorExhibitProperty.create({
40
- :fabulator_exhibit_id => db.id,
41
- :name => k,
42
- :data => p.to_json
43
- })
44
- p_ob.save!
41
+ if !k.nil? && k != ""
42
+ p_ob = FabulatorExhibitProperty.create({
43
+ :fabulator_exhibit_id => db.id,
44
+ :name => k,
45
+ :data => p.to_json
46
+ })
47
+ p_ob.save!
48
+ end
45
49
  end
46
50
 
47
51
  data['items'].each do |i|
48
- i_ob = FabulatorExhibitItem.create({
49
- :fabulator_exhibit_id => db.id,
50
- :uuid => i['id'],
51
- :data => i.to_json
52
- });
53
- i_ob.save!
52
+ if !i['id'].nil? && i['id'] != ""
53
+ i_ob = FabulatorExhibitItem.create({
54
+ :fabulator_exhibit_id => db.id,
55
+ :uuid => i['id'],
56
+ :data => i.to_json
57
+ });
58
+ i_ob.save!
59
+ end
54
60
  end
55
61
  end
56
62
  end
@@ -2,7 +2,7 @@ require 'fabulator/exhibit'
2
2
  require 'json'
3
3
 
4
4
  class FabulatorExhibitExtension < Radiant::Extension
5
- version "0.0.4"
5
+ version "0.0.5"
6
6
  description "Exhibit extension to the Fabulator extension"
7
7
  url "http://github.com/jgsmith/radiant-fabulator-exhibit"
8
8
 
@@ -615,7 +615,7 @@ Fabulator.namespace('Exhibit');
615
615
  };
616
616
 
617
617
  that.loadItems = function(items, baseURI) {
618
- var spo, ops, indexTriple, i, entry, n;
618
+ var spo, ops, indexTriple, i, entry, n, progress, percent, old_percent;
619
619
 
620
620
  var indexPut = function(index, x, y, z) {
621
621
  var hash = index[x],
@@ -642,6 +642,18 @@ Fabulator.namespace('Exhibit');
642
642
 
643
643
 
644
644
  that.events.onBeforeLoadingItems.fire(that);
645
+ $("<div id='progress-items-" + options.source + "'>" +
646
+ "<div class='flc-progress progress-pop-up exhibit-progress-pop-up'><h3>Loading " + items.length + " Item" + (items.length == 1 ? "" : "s") + "</h3>" +
647
+ "<div class='flc-progress-bar progress-bar'>" +
648
+ "<div class='flc-progress-indicator progress-indicator'></div>" +
649
+ "</div>" +
650
+ "<p class='flc-progress-label progress-label'>0% Complete</p>" +
651
+ "</div></div>").appendTo($("html > body"));
652
+
653
+ progress = fluid.progress("#progress-items-" + options.source);
654
+ progress.show();
655
+ old_percent = 0;
656
+
645
657
  try {
646
658
  baseURI = canonicalBaseURI(baseURI);
647
659
 
@@ -651,6 +663,11 @@ Fabulator.namespace('Exhibit');
651
663
  };
652
664
 
653
665
  for(i = 0, n = items.length; i < n; i++) {
666
+ percent = (i * 100 / n);
667
+ if( percent > old_percent ) {
668
+ old_percent = percent;
669
+ progress.update(percent, percent + "% Complete");
670
+ }
654
671
  entry = items[i];
655
672
  if( typeof(entry) == "object" ) {
656
673
  that.loadItem(entry, indexTriple, baseURI);
@@ -661,6 +678,8 @@ Fabulator.namespace('Exhibit');
661
678
  catch(e) {
662
679
  Exhibit.debug("loadItems failed: ", e);
663
680
  }
681
+ progress.update(100, "100% Complete");
682
+ progress.hide();
664
683
  };
665
684
 
666
685
  that.loadItem = function(item, indexFn, baseURI) {
@@ -108,3 +108,9 @@
108
108
  display: block;
109
109
  text-align: center;
110
110
  }
111
+
112
+ .exhibit-progress-pop-up {
113
+ position: absolute;
114
+ right: 40%;
115
+ top: 40%;
116
+ }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-fabulator_exhibit-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith