radiant-fabulator_exhibit-extension 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ === 0.0.1 2010-08-10
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
5
+
data/README.markdown ADDED
@@ -0,0 +1,38 @@
1
+ Fabulator Exhibit Extension
2
+ ===========================
3
+
4
+ This extension acts as the glue tieing together the Fabualtor Radiant extension
5
+ and the Fabulator engine Exhibit extension.
6
+
7
+ Installation
8
+ ------------
9
+
10
+ Installation is done in the usual manner for Radiant extensions.
11
+
12
+ This extension requires Radiant 0.9 or higher as well as the following
13
+ libraries:
14
+
15
+ * ruby-fabulator-exhibit gem
16
+
17
+ == LICENSE:
18
+
19
+ Copyright (c) 2009-2010 Texas A&M University
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining
22
+ a copy of this software and associated documentation files (the
23
+ 'Software'), to deal in the Software without restriction, including
24
+ without limitation the rights to use, copy, modify, merge, publish,
25
+ distribute, sublicense, and/or sell copies of the Software, and to
26
+ permit persons to whom the Software is furnished to do so, subject to
27
+ the following conditions:
28
+
29
+ The above copyright notice and this permission notice shall be
30
+ included in all copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
33
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
35
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
36
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
37
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
38
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,139 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "radiant-fabulator_exhibit-extension"
5
+ gem.summary = %Q{Fabulator Exhibit Extension for Radiant CMS}
6
+ gem.description = %Q{Provides storage management for the Fabulator Exhibit extension for use with the Radiant CMS.}
7
+ gem.email = "jgsmith@tamu.edu"
8
+ gem.homepage = "http://github.com/jgsmith/radiant-fabulator-exhibit"
9
+ gem.authors = ["James Smith"]
10
+ gem.add_dependency('radiant-fabulator-extension', '>= 0.0.3')
11
+ gem.add_dependency('fabulator-exhibit', '>= 0.0.1')
12
+ gem.add_dependency('json', '>= 1.4.3')
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package fabulator_rdf as a gem."
17
+ end
18
+
19
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
20
+ # Check to see if the rspec plugin is installed first and require
21
+ # it if it is. If not, use the gem version.
22
+
23
+ # Determine where the RSpec plugin is by loading the boot
24
+ unless defined? RADIANT_ROOT
25
+ ENV["RAILS_ENV"] = "test"
26
+ case
27
+ when ENV["RADIANT_ENV_FILE"]
28
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
29
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
30
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
31
+ else
32
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
33
+ end
34
+ end
35
+
36
+ require 'rake'
37
+ require 'rake/rdoctask'
38
+ require 'rake/testtask'
39
+
40
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
41
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
42
+ require 'spec/rake/spectask'
43
+ require 'cucumber'
44
+ require 'cucumber/rake/task'
45
+
46
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
47
+ Object.send(:remove_const, :RADIANT_ROOT)
48
+
49
+ extension_root = File.expand_path(File.dirname(__FILE__))
50
+
51
+ task :default => :spec
52
+ task :stats => "spec:statsetup"
53
+
54
+ desc "Run all specs in spec directory"
55
+ Spec::Rake::SpecTask.new(:spec) do |t|
56
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
57
+ t.spec_files = FileList['spec/**/*_spec.rb']
58
+ end
59
+
60
+ task :features => 'spec:integration'
61
+
62
+ namespace :spec do
63
+ desc "Run all specs in spec directory with RCov"
64
+ Spec::Rake::SpecTask.new(:rcov) do |t|
65
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
66
+ t.spec_files = FileList['spec/**/*_spec.rb']
67
+ t.rcov = true
68
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
69
+ end
70
+
71
+ desc "Print Specdoc for all specs"
72
+ Spec::Rake::SpecTask.new(:doc) do |t|
73
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
74
+ t.spec_files = FileList['spec/**/*_spec.rb']
75
+ end
76
+
77
+ [:models, :controllers, :views, :helpers].each do |sub|
78
+ desc "Run the specs under spec/#{sub}"
79
+ Spec::Rake::SpecTask.new(sub) do |t|
80
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
81
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
82
+ end
83
+ end
84
+
85
+ desc "Run the Cucumber features"
86
+ Cucumber::Rake::Task.new(:integration) do |t|
87
+ t.fork = true
88
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
89
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
90
+ t.profile = "default"
91
+ end
92
+
93
+ # Setup specs for stats
94
+ task :statsetup do
95
+ require 'code_statistics'
96
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
97
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
98
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
99
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
100
+ ::CodeStatistics::TEST_TYPES << "Model specs"
101
+ ::CodeStatistics::TEST_TYPES << "View specs"
102
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
103
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
104
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
105
+ end
106
+
107
+ namespace :db do
108
+ namespace :fixtures do
109
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
110
+ task :load => :environment do
111
+ require 'active_record/fixtures'
112
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
113
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
114
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ desc 'Generate documentation for the fabulator_rdf extension.'
122
+ Rake::RDocTask.new(:rdoc) do |rdoc|
123
+ rdoc.rdoc_dir = 'rdoc'
124
+ rdoc.title = 'FabulatorRdfExtension'
125
+ rdoc.options << '--line-numbers' << '--inline-source'
126
+ rdoc.rdoc_files.include('README')
127
+ rdoc.rdoc_files.include('lib/**/*.rb')
128
+ end
129
+
130
+ # For extensions that are in transition
131
+ desc 'Test the fabulator_rdf extension.'
132
+ Rake::TestTask.new(:test) do |t|
133
+ t.libs << 'lib'
134
+ t.pattern = 'test/**/*_test.rb'
135
+ t.verbose = true
136
+ end
137
+
138
+ # Load any custom rakefiles for extension
139
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,21 @@
1
+ module Admin
2
+ module Fabulator
3
+ class ExhibitsController < Admin::ResourceController
4
+ only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
5
+ :when => [:designer, :admin],
6
+ :denied_url => { :controller => 'admin/pages', :action => 'index' },
7
+ :denied_message => 'You must have designer privileges to perform this action.'
8
+
9
+ def model_class
10
+ FabulatorExhibit
11
+ end
12
+
13
+ def show
14
+ respond_to do |format|
15
+ format.xml { super }
16
+ format.html { redirect_to edit_admin_fabulator_exhibits_path(params[:id]) }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ class Api::ExhibitsController < ApplicationController
2
+ skip_before_filter :verify_authenticity_token
3
+
4
+ no_login_required
5
+
6
+ def show
7
+ @exhibit = FabulatorExhibit.find(:first, :conditions => [ "name = ?", params[:id] ])
8
+ respond_to do |format|
9
+ format.json { render :json => @exhibit.data }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class FabulatorExhibit < ActiveRecord::Base
2
+ validates_presence_of :name
3
+ validates_uniqueness_of :name
4
+
5
+ belongs_to :updated_by, :class_name => 'User'
6
+ belongs_to :created_by, :class_name => 'User'
7
+ end
@@ -0,0 +1,28 @@
1
+ - form_for [:admin, @fabulator_exhibit], :html => {:onsubmit_status => onsubmit_status(@fabulator_exhibit)} do |f|
2
+ = f.hidden_field :lock_version
3
+ = render_region :form_top
4
+ .form_area
5
+ - render_region :form do |form|
6
+ - form.edit_title do
7
+ %p.title
8
+ = f.label :name
9
+ = f.text_field :name, :class => 'textbox activate', :maxlength => 100
10
+ - form.edit_description do
11
+ %p.content
12
+ = f.label :description, "Description"
13
+ ~ f.text_area :description, :class => "textarea large", :style => "width: 100%"
14
+ .row
15
+ - form.edit_fn do
16
+ %p.content
17
+ = f.label :description, "Description"
18
+ = f.text_area :description, :class => "textarea large", :style => "width: 100%"
19
+ - render_region :form_bottom do |form_bottom|
20
+ - form_bottom.edit_buttons do
21
+ %p.buttons{:style=>"clear: left"}
22
+ = save_model_button(@fabulator_workflow_def, :label => 'Create Exhibit Database')
23
+ = save_model_and_continue_editing_button(@fabulator_exhibit)
24
+ or
25
+ = link_to 'Cancel', admin_fabulator_exhibits_url
26
+ - form_bottom.edit_timestamp do
27
+ %p.updated_line
28
+ = updated_stamp @fabulator_exhibit
@@ -0,0 +1,9 @@
1
+ - @page_title = @fabulator_exhibit.name + ' Exhibit Database - ' + default_page_title
2
+
3
+ - body_classes << "reversed"
4
+
5
+ - render_region :main do |main|
6
+ - main.edit_header do
7
+ %h1 Edit Exhibit Database Definition
8
+ - main.edit_form do
9
+ = render :partial => 'form'
@@ -0,0 +1,38 @@
1
+ - @page_title = 'Exhibit Databases - ' + default_page_title
2
+
3
+ .outset
4
+ - render_region :top
5
+ %table#exhibits.index
6
+ %thead
7
+ %tr
8
+ - render_region :thead do |thead|
9
+ - thead.title_header do
10
+ %th.filter Exhibit Database
11
+ - thead.size_header do
12
+ %th.size Items
13
+ - thead.modify_header do
14
+ %th.modify Modify
15
+ %tbody
16
+ - if @fabulator_exhibits.any?
17
+ - @fabulator_exhibits.each do |exhibit|
18
+ %tr.node.level_1
19
+ - render_region :tbody do |tbody|
20
+ - tbody.title_cell do
21
+ %td.snippet
22
+ = image('snippet', :alt => '')
23
+ %span= link_to exhibit.name, edit_admin_fabulator_exhibit_url(exhibit)
24
+ - tbody.size_cell do
25
+ %td.size
26
+ %span= exhibit.items_count
27
+ - tbody.modify_cell do
28
+ %td.remove
29
+ = link_to image('remove', :alt => 'Remove Exhibit Database'), remove_admin_fabulator_exhibit_url(exhibit)
30
+ - else
31
+ %tr
32
+ %td.note{:colspan => admin.fabulator_exhibit.index.tbody.length} No Exhibit Databases
33
+
34
+ - render_region :bottom do |bottom|
35
+ - bottom.new_button do
36
+ #actions
37
+ %ul
38
+ %li= link_to "New Exhibit Database", { :controller => 'admin/fabulator/exhibits', :action => 'new' }
@@ -0,0 +1,7 @@
1
+ - body_classes << "reversed"
2
+
3
+ - render_region :main do |main|
4
+ - main.edit_header do
5
+ %h1 New Exhibit Database
6
+ - main.edit_form do
7
+ = render :partial => 'form'
@@ -0,0 +1,19 @@
1
+ %h1 Remove Exhibit Database
2
+
3
+ %p
4
+ Are you sure you want to
5
+ %strong.warning permanently remove
6
+ the following exhibit database?
7
+
8
+ %table.index#workflows
9
+ %tbody
10
+ %tr.node.level_1
11
+ %td.workflow
12
+ = image('snippet', :alt => "")
13
+ %span.title= @fabulator_exhibit.name
14
+
15
+ - form_for [:admin, @fabulator_exhibit], :html => {:method => :delete, :onsubmit_status=>"Removing exhibit database&#8230;"} do
16
+ %p.buttons
17
+ %input.button{:type=>"submit", :value=>"Delete Exhibit Database"}/
18
+ or
19
+ = link_to 'Cancel', admin_fabulator_exhibits_url
data/config/routes.rb ADDED
@@ -0,0 +1,10 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.namespace 'admin' do |admin|
3
+ admin.namespace 'fabulator', :member => { :remove => :get } do |fab|
4
+ fab.resources :exhibits
5
+ end
6
+ end
7
+ map.namespace 'api' do |api|
8
+ api.resources :exhibits
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ class CreateFabulatorExhibitTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :fabulator_exhibits do |t|
4
+ t.string :name, :null => false
5
+ t.text :description
6
+ t.integer :lock_version, :default => 0
7
+ t.integer :items_count, :default => 0
8
+ t.text :data
9
+ t.references :updated_by
10
+ t.references :created_by
11
+ t.timestamps
12
+ end
13
+ end
14
+
15
+ def self.down
16
+ drop_table :fabulator_exhibits
17
+ end
18
+ end
19
+
@@ -0,0 +1,78 @@
1
+ require 'fabulator/exhibit'
2
+ require 'json'
3
+
4
+ class FabulatorExhibitExtension < Radiant::Extension
5
+ version "1.0"
6
+ description "Exhibit extension to the Fabulator extension"
7
+ url "http://github.com/jgsmith/radiant-fabulator-exhibit"
8
+
9
+ class MissingRequirement < StandardError; end
10
+
11
+ extension_config do |config|
12
+ config.gem 'radiant-fabulator-extension'
13
+ config.gem 'fabulator-exhibit'
14
+ end
15
+
16
+ def activate
17
+ #raise FabulatorExhibitExtension::MissingRequirement.new('FabulatorExtension must be installed and loaded first.') unless defined?(FabulatorExtension)
18
+
19
+ tab 'Fabulator' do
20
+ add_item("Exhibit Databases", "/admin/fabulator/exhibits")
21
+ end
22
+
23
+ Radiant::AdminUI.class_eval do
24
+ attr_accessor :exhibits
25
+ alias_method :fabulator_exhibit, :exhibits
26
+ end
27
+ admin.exhibits = load_default_fabulator_exhibit_regions
28
+
29
+ Fabulator::Exhibit::Actions::Lib.class_eval do
30
+ def self.fetch_database(nom)
31
+ db = FabulatorExhibit.find(:first, :conditions => [ 'name = ?', nom ])
32
+ if db.nil?
33
+ return { :items => [], :types => {}, :properties => {} }
34
+ else
35
+ data = (JSON.parse(db.data) rescue { 'items' => [], 'types' => {}, 'properties' => {} })
36
+ ret = { :items => { }, :types => data['types'], :properties => data['properties'] }
37
+ ret[:properties] = { } if ret[:properties].nil?
38
+ ret[:types] = { } if ret[:types].nil?
39
+ data['items'].each do |i|
40
+ ret[:items][i['id']] = i
41
+ end
42
+ return ret
43
+ end
44
+ end
45
+
46
+ def self.store_database(nom, data)
47
+ db = FabulatorExhibit.find(:first, :conditions => [ 'name = ?', nom ])
48
+ if db.nil?
49
+ raise "The Exhibit database #{nom} does not exist."
50
+ end
51
+ to_save = { :items => data[:items].values, :properties => data[:properties], :types => data[:types] }
52
+ db.data = to_save.to_json
53
+ db.items_count = to_save[:items].size
54
+ db.save
55
+ end
56
+ end
57
+ end
58
+
59
+ def deactivate
60
+ end
61
+
62
+ def load_default_fabulator_exhibit_regions
63
+ returning OpenStruct.new do |exhibit|
64
+ exhibit.edit = Radiant::AdminUI::RegionSet.new do |edit|
65
+ edit.main.concat %w{edit_header edit_form}
66
+ edit.form.concat %w{edit_title edit_description}
67
+ edit.form_bottom.concat %w{edit_buttons edit_timestamp}
68
+ end
69
+ exhibit.index = Radiant::AdminUI::RegionSet.new do |index|
70
+ index.top.concat %w{help_text}
71
+ index.thead.concat %w{title_header size_header modify_header}
72
+ index.tbody.concat %w{title_cell size_cell modify_cell}
73
+ index.bottom.concat %w{new_button}
74
+ end
75
+ exhibit.new = exhibit.edit
76
+ end
77
+ end
78
+ end
File without changes
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-fabulator_exhibit-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - James Smith
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-08 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: radiant-fabulator-extension
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 29
30
+ segments:
31
+ - 0
32
+ - 0
33
+ - 1
34
+ version: 0.0.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: fabulator-exhibit
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 29
46
+ segments:
47
+ - 0
48
+ - 0
49
+ - 1
50
+ version: 0.0.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Provides storage management for the Fabulator Exhibit extension for use with the Radiant CMS.
54
+ email: jgsmith@tamu.edu
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.markdown
61
+ files:
62
+ - History.txt
63
+ - README.markdown
64
+ - Rakefile
65
+ - VERSION
66
+ - app/controllers/admin/fabulator/exhibits_controller.rb
67
+ - app/controllers/api/exhibits_controller.rb
68
+ - app/models/fabulator_exhibit.rb
69
+ - app/views/admin/fabulator/exhibits/_form.html.haml
70
+ - app/views/admin/fabulator/exhibits/edit.html.haml
71
+ - app/views/admin/fabulator/exhibits/index.html.haml
72
+ - app/views/admin/fabulator/exhibits/new.html.haml
73
+ - app/views/admin/fabulator/exhibits/remove.html.haml
74
+ - config/routes.rb
75
+ - db/migrate/001_create_fabulator_exhibit_tables.rb
76
+ - fabulator_exhibit_extension.rb
77
+ - lib/radiant-fabulator_exhibit-extension.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/jgsmith/radiant-fabulator-exhibit
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options:
84
+ - --charset=UTF-8
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project:
108
+ rubygems_version: 1.3.7
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: Fabulator Exhibit Extension for Radiant CMS
112
+ test_files: []
113
+